function login_form_init(){
	var form_163 = document.getElementById("loginform");
	var account=document.getElementById("account_name");
	var password=document.getElementById("password");
	var rem = document.getElementById("remUsername");
	if(!form_163){
		alert("\u627e\u4e0d\u5230id\u4e3aloginform\u7684\u767b\u5f55\u8868\u5355");
	}else{
		form_163.onsubmit=checkSubmit;
	}
	var cookie = document.cookie;
	var arr = cookie.split(";");
	for(var i=0;i<arr.length;i++){
		var items = arr[i].split("=");
		if(items[0].replace(" ","")=="qiye_account"){
			var val = items[1];
			if(val && val.length>0){
				account.value=val;
				rem.checked="checked";
			}
			break;
		}		
	}
}
if(window.attachEvent){
	window.attachEvent("onload",login_form_init);
}else if(window.addEventListener){
	window.addEventListener("load",login_form_init,false);
}else{
	window.onload = login_form_init();
}
function checkSubmit(){
	var account=document.getElementById("account_name");
	var password=document.getElementById("password");
	var rem = document.getElementById("remUsername");
	var secure = document.getElementById("secure");
	if(!account || account.value==""){
		alert("\u5e10\u53f7\u540d\u4e0d\u80fd\u4e3a\u7a7a");
		return false;
	}
	if(!password || password.value==""){
		alert("\u5bc6\u7801\u4e0d\u80fd\u4e3a\u7a7a");
		return false;
	}
	var host=location.hostname;
	if(rem && rem.checked){
		var exp  = new Date();    
   		var account_value=account.value;
   		exp.setTime(exp.getTime() + 86400 * 365 * 10);
		document.cookie="qiye_account="+account_value+";domain="+host+";path=/;expires="+exp.toGMTString();
	}else{
		var exp  = new Date();    
		exp.setTime(exp.getTime()-1);
		document.cookie="qiye_account=;domain="+host+";path=/;expires="+exp.toGMTString();
	}
	var url = "http://entry.qiye.163.com/domain/domainEntLoginEn";
	if(secure && secure.checked){
		url = "https://entry.qiye.163.com/domain/domainEntLoginEn";
	}
	var item = document.createElement("input");
	item.type="hidden";
	item.name="domain";
	item.value="5912176cf64fc3bd4e0fc79433986bc3";
	this.appendChild(item);
	this.action=url;
	this.method="post";
	return true;
}
