$ = function(obj){return document.getElementById(obj);}

function Show(obj)
{
    obj.style.display = "";
}
function NotShow(obj)
{
    obj.style.display = "none";
}
function CheckData()
{
	if($("txtAccount").value==""){
		alert("邮箱名不能为空！");
		return false;
	}                      

	if($("txtPassword").value=="") {
		alert("密码不能为空！");
		return false;
	}
	if(!$("chkjz").checked)
	{
		if($("txtCheckCode").value=="") {
			alert("验证码不能为空！");
			return false;
		}  
	}
	
	return true;
}
function SubmitData()
{
	if(!CheckData()){
		return false;
	}
	SetCookie("loginname",$("txtAccount").value);
	if($("chkjz").checked)
	{
		//alert($("txtPassword").value);
		SetCookie("loginpwd",$("txtPassword").value)
		$("txtCheckCode").name="code"
	}
	
	$("submitForm").submit();
	return false;
}
function chkFunction(obj)
{
	if(obj.checked)
	{
		
	}
	else
	{
		delCookie("loginpwd")
		$("txtPassword").value="";
		$("trcheckcode").style.display = "block";
		$("txtCheckCode").name="CheckCode"
	}
}


window.onload = function()
{

	if(getCookie("loginname")!=null){
		if($("txtAccount")!=null)
		$("txtAccount").value = getCookie("loginname");
	}
	//alert(getCookie("loginpwd"))
	if(getCookie("loginpwd")!=null){
		if($("txtPassword")!=null)
		{
			$("chkjz").checked=true;
			$("trcheckcode").style.display = "none";
			$("txtPassword").value = getCookie("loginpwd");
			//alert(getCookie("loginpwd"))
		}
	}
}

//**********************************
//js操作cookies
//
//**********************************


function SetCookie(name,value)//两个参数，一个是cookie的名子，一个是值
{
    var Days = 7; //此 cookie 将被保存 7 天
    var exp = new Date();    //new Date("December 31, 9998");
    exp.setTime(exp.getTime() + Days*24*60*60*1000);
    document.cookie = name + "="+ escape (value) + ";expires=" + exp.toGMTString();
	//alert('ccc')
}
function getCookie(name)//取cookies函数        
{
    var arr = document.cookie.match(new RegExp("(^| )"+name+"=([^;]*)(;|$)"));
	//alert(arr[2]);
     if(arr != null) return unescape(arr[2]); return null;

}
function delCookie(name)//删除cookie
{
    var exp = new Date();
    exp.setTime(exp.getTime() - 1);
    var cval=getCookie(name);
    if(cval!=null) document.cookie= name + "="+cval+";expires="+exp.toGMTString();
}




  document.onkeydown = function(event)
    {
		
        event = event || window.event;   
        var e = event.keyCode || event.which
		
        if(e==13)
        {
            $("login").click();
            return false;
        }
    }