﻿function pageOnload()
{  
    initControl($("errorType").value);
}
function loginValidate(obj)
{  
    if(!chkMailFormat($("txtAccount").value.Trim()))
    {
        $("errorTime").value=(parseInt( $("errorTime").value,10) + 1) + "";                                     
        $("errorType").value="1";     
        return;
    } 
    if(Trim($("txtPassword").value).length == 0)
    {
        $("errorTime").value=(parseInt( $("errorTime").value,10) + 1) + "";                       
        $("errorType").value="2";
        return;
    }
    if($("txtValidate") && Trim($("txtValidate").value).length==0)
    {           
       $("errorType").value="3";
        return;
    }  
     clearMessage();       
     $("errorType").value="0";      
}

function initControl(type)
{
    if(type=="1")
    {
        showMessage("请输入正确的账号，账号为您的企业邮箱地址");
        $("txtAccount").focus();
        $("txtAccount").select();      
    }
    else if(type=="2")
    {
        showMessage("请输入正确的密码");           
        $("txtPassword").focus();
            
    }
    else if(type=="3")
    { 
        showMessage("请输入正确的验证码");           
        $("txtPassword").focus();                            
    }
   else if(type=="4")
   {
        showMessage("服务器繁忙,请稍后再试");
       $("txtPassword").focus();      
   } 
   else if(type=="5")
   {
        showMessage("对不起，企业邮箱服务已暂停，请联系管理员");
       $("txtPassword").focus();      
   } 
   else if(type=="6")
   {
        showMessage("该用户邮箱已暂停服务");
        $("txtAccount").focus();
        $("txtAccount").select();   
   }
   else if(type=="7")
   {
        showMessage("该用户邮箱不存在");
        $("txtAccount").focus();
        $("txtAccount").select();   
   }   
    else if(type=="8")
   {
        showMessage("对不起，登录已超时");
        $("txtAccount").focus();
        $("txtAccount").select();   
   }   
    else
    {
        clearMessage();
    }     
    $("txtPassword").value="";
    if($("txtValidate"))
    {
        $("txtValidate").value=""; 
    }
}

function showMessage(str)
{
    $("errorMsg").innerHTML=str;
    $("errorMsg").style.display = "block";
}

function clearMessage()
{
    $("errorMsg").innerHTML="";
    $("errorMsg").style.display="none";     
}

function refreshCc(url) 
{
	var ccImg = $("checkCodeImg");
	var ccImgSrc = "";
	if (ccImg) 
	{
		nowTime = new Date();
		ccImgSrc = url+"&cms=" + nowTime.getTime();
		ccImg.src = ccImgSrc;
	}
}
