var LeftLoginForm = {
	PreLogin: function(frm){
		if (ChkForm(frm.userId, '', '아이디는', 4, 16) != true ) {
			return false;
		} else if (ChkForm(frm.password, '', '패스워드', 4, 16) != true ) {
			return false;
		} else {
			if (frm.idSave.checked){
				this.saveLogin(frm.userId.value);
			} else {
				this.saveLogin("");
			}
		}
		return true;
	},

	getCookie: function(key){
    	var cook = document.cookie + ";";
	    var idx =  cook.indexOf(key, 0);
	    var val = "";
	    if(idx != -1) {
			cook = cook.substring(idx, cook.length);
			begin = cook.indexOf("=", 0) + 1;
			end = cook.indexOf(";", begin);
			val = unescape( cook.substring(begin, end) );
		}
		return val;
	},
	
	setCookie:function (name, value, expiredays) {
		var today = new Date();
		today.setDate( today.getDate() + expiredays );
		document.cookie = name + "=" + escape( value ) + "; path=/; expires=" + today.toGMTString() + ";"
	},

	getLogin:function () {
		var form = document.leftLoginForm;
		var id = this.getCookie("CuserId");
	
		if(id != "") {
			form.userId.value = id;
			form.saveId.checked = true;
		}
	},

	saveLogin:function (id){
		if(id != ""){
    		this.setCookie("CuserId", id, 7);
		} else {
			this.setCookie("CuserId", id, -1);
		}
	},

	focusId:function(obj) {
		obj.style.backgroundImage='';
	},

	blurId:function(obj) {
		if (obj.value.length == 0)
		{
			obj.style.backgroundImage = 'url(/image/common/loginbox_id.gif)';
		}
	},

	focusPwd:function(obj) {
		obj.style.backgroundImage='';
	},

	blurPwd:function(obj) {
		if (obj.value.length == 0)
		{
			obj.style.backgroundImage = 'url(/image/common/loginbox_pw.gif)';
		}
	},
	
	init:function(){
		if ($('leftLoginForm').style.display == 'none') return;
		
		var frm = document.leftLoginForm;
		if (this.getCookie("CuserId") != "" ) {
			frm.userId.value = this.getCookie("CuserId");
			frm.idSave.checked = true;
		} else {

		}
		
		if (frm.userId.value.length == 0)
		{
			frm.userId.style.backgroundImage = 'url(/image/common/loginbox_id.gif)';
		}

		if (frm.password.value.length == 0)
		{
			frm.password.style.backgroundImage = 'url(/image/common/loginbox_pw.gif)';
		}
	}
}