function ClientUserInfo(accountObjName,verifyObjName,checkObjName) {
	try {
		this.accountObj = document.getElementsByName(accountObjName)[0];
		this.verifyObj = document.getElementsByName(verifyObjName)[0];
		this.checkObj = document.getElementsByName(checkObjName)[0];
	} catch (e) {
	}
	
	this.expireDay = 1;
	this.cookieId = "USERINFO";
}

ClientUserInfo.prototype.restore = function() {
	if (this.accountObj.value == "") return;
	var info = this.getUserInfo();
	if (info == null) return;
	if (this.accountObj.value == info[0]) {
		this.verifyObj.value = info[1];
		this.checkObj.checked = true;
	}
}

ClientUserInfo.prototype.getUserInfo = function() {
	var c = this.getUserInfoCookie();
	if (c == null) return null;
	return c.split("#"); 
}

ClientUserInfo.prototype.getUserInfoCookie = function() {
	var arr = document.cookie.match(new RegExp("(^| )"+this.cookieId+"=([^;]*)(;|$)"));
     if(arr != null) 
     	return unescape(arr[2]); 
     return null;
}
	
ClientUserInfo.prototype.saveInfo = function() {
	if (this.accountObj.value == "") return;
	var info = this.getUserInfo();
	if (this.checkObj.checked) {
		if (this.verifyObj.value != "") {
			if (info != null) {
					if (info[0] == this.accountObj.value && info[1] == this.verifyObj.value) return;
			}
			this.createCookie(this.accountObj.value + "#" + this.verifyObj.value,this.expireDay);
		}
	} else {
		if (info != null && info[0] == this.accountObj.value) {
			this.deleteInfo();
		}
	}
}

ClientUserInfo.prototype.deleteInfo = function() {	
    var info = this.getUserInfoCookie();
    if (info!=null) this.createCookie("",-1);
}

ClientUserInfo.prototype.createCookie = function(value,exp) {
	var now = new Date();
	now.setTime(now.getTime()+(exp*24*60*60*1000));
	var str = this.cookieId + "="+ escape(value) +";expires=" + now.toGMTString();
	str = str + ";path=/";
	document.cookie = str;
}


