// ¶óÀÌºêÆû Å¬·¡½º
var LIVEFORM = function() {
	this.is_member = false;
	this.is_form = new String();
	this.is_locale = new String();
	this.sb_selects = new Object();
	this.sb_embeds = new Object();
	this.sb_objects = new Object();
	this.other_url	= '';
	this.other_go	= '';
}
// ºí¶óÀÎµå
LIVEFORM.prototype.LiveScreenBlind = function(mode) {
	if(mode===true) {
		var _height = parseInt(document.body.clientHeight,10);
		if(parseInt(document.body.scrollHeight,10)>_height) _height = parseInt(document.body.scrollHeight,10);
		$('LiveScreenBlind').style.height = _height + "px";
		$('LiveScreenBlind').style.marginTop = "-" + parseInt(document.body.scrollTop,10) + "px";
		this.changeDisplay("LiveScreenBlind", true);
		// SELECT/EMBED/OBJECT °´Ã¼ ¼û±â±â
		this.sb_selects = document.getElementsByTagName("select");
		this.sb_embeds = document.getElementsByTagName("embed");
		this.sb_objects = document.getElementsByTagName("object");
		for(var i=0; i<this.sb_selects.length; i++) this.sb_selects[i].style.visibility = "hidden";
		for(var i=0; i<this.sb_embeds.length; i++) this.sb_embeds[i].style.visibility = "hidden";
		for(var i=0; i<this.sb_objects.length; i++) this.sb_objects[i].style.visibility = "hidden";
	}
	else {
		this.changeDisplay("LiveScreenBlind", false);
		for(var i=0; i<this.sb_selects.length; i++) this.sb_selects[i].style.visibility = "visible";
		for(var i=0; i<this.sb_embeds.length; i++) this.sb_embeds[i].style.visibility = "visible";
		for(var i=0; i<this.sb_objects.length; i++) this.sb_objects[i].style.visibility = "visible";
	}
}
// ·Î±×ÀÎ Ã¼Å©
LIVEFORM.prototype.checkLogin = function() {
	return this.is_member;
}
// ÆûÃ¼Å©
LIVEFORM.prototype.validateForm = function(el) {
	var classObj = this;
	if(!validate(el)) return false;
	this.is_form = el.name; //È¸¿ø°¡ÀÔÃ³¸®½Ã ¿À·ù ¹ß»ýÀ¸·Î ¤Ñ¤Ñ;
	this.multiProcess();
	return true;
}
// ÇÁ·Î¼¼½º - ·Î±×ÀÎ Ã³¸®
LIVEFORM.prototype.multiProcess = function() {
	if(this.is_form=='') return false;
	//alert(this.other_url);
	document.forms[this.is_form].action = domain+"LiveForm/LiveFormMultiProcess.html?mode="+this.is_form+"&uri="+encodeURIComponent(this.is_locale)+"&domains="+document.domain+"&other_url="+encodeURIComponent(this.other_url)+"&other_go="+this.other_go;
}
// ÆäÀÌÁö ÀüÈ¯
LIVEFORM.prototype.changePage = function(uri) {
	if(!this.checkLogin()) {
		this.is_locale = uri;
		this.changeForm("LiveFormLogin"); // ·Î±×ÀÎ Æû ·Îµå
	}
	else {
		if(uri.indexOf("javascript")==-1) document.location.href=uri; // ¸µÅ© ÀÌµ¿
		else eval(uri.replace(/javascript:/g, '')); // ÀÚ½º ½ÇÇà
	}
	return void(0);
}
// Æû º¯°æ
LIVEFORM.prototype.changeForm = function(el) {
	this.LiveScreenBlind(true);
	// ·Î±×ÀÎÆû È°¼ºÈ­
	if(el=="LiveFormLogin") this.changeDisplay("LiveFormLoginDiv", true);
}
// ·¹ÀÌ¾î º¯°æ
LIVEFORM.prototype.changeDisplay = function(el, val) {
	if(val===true||val===false) {
		var obj = $(el);
		obj.style.display = val ? "block" : "none";
		if(val===false) return;

		// ÆäÀÌÁö Áß¾Ó¿¡ ¶ç¿ì±â
		obj.style.top = (obj.offsetHeight>document.body.clientHeight) ? document.body.scrollTop : document.body.scrollTop+(document.body.clientHeight-obj.offsetHeight)/2 + "px";
		obj.style.left = (obj.offsetWidth>document.body.clientWidth) ? document.body.scrollLeft : document.body.scrollLeft+(document.body.clientWidth-obj.offsetWidth)/2 + "px";
		// Æû ÃÊ±âÈ­
		if(in_array(el, new Array("LiveFormLoginDiv","employ_detail_span"))) {
			//var frm = document.forms[el.replace(/Div/g, "Frm")];
			//frm.reset(); frm.id.focus();
		}
	}
	else {
		var _val = $(el).style.display;
		$(el).style.display = (_val=="none") ? "block" : "none";
		this.LiveScreenBlind(false);
	}
}
// ÀÌº¥Æ® ÀüÈ¯
LIVEFORM.prototype.initializeForm = function() {
	var Atags = document.getElementsByTagName("A");
	for(var i=0; i<Atags.length; i++) {
		if(Atags[i].getAttribute("OTHER_URL")!=null)		this.other_url	= (Atags[i].getAttribute("OTHER_URL")) ? Atags[i].getAttribute("OTHER_URL") : "";
		if(Atags[i].getAttribute("OTHER_GO")!=null)		this.other_go	= (Atags[i].getAttribute("OTHER_GO")) ? Atags[i].getAttribute("OTHER_GO") : "";
		if(Atags[i].getAttribute("CHECKLOGIN")!=null)	Atags[i].href = "javascript:LiveForm.changePage(\""+Atags[i].href+"\");";
	}
}

var LiveForm = new LIVEFORM;
