﻿var loginDiv;
function changeLoginDiv(f)
{
    if(f==0){clearLoginDiv();showDiv();}
    else{loginDiv=setTimeout('hiddenDiv()',1000);}
}
function clearLoginDiv(){clearTimeout(loginDiv);}
function showDiv(){document.getElementById("div_login").style.display="block";}
function hiddenDiv(){document.getElementById("div_login").style.display="none";document.getElementById("msgDiv").innerHTML="";document.getElementById("ctl00_ContentPlaceHolder1_MyRightList_user").value="";document.getElementById("ctl00_ContentPlaceHolder1_MyRightList_pwd").value="";document.getElementById("ctl00_ContentPlaceHolder1_MyRightList_yzCode").value="";}

var loginDiv1;
function changeLoginDiv1(f)
{
    if(f==0){clearLoginDiv1();showDiv1();}
    else{loginDiv1=setTimeout('hiddenDiv1()',1000);}
}
function clearLoginDiv1(){clearTimeout(loginDiv1);}
function showDiv1(){document.getElementById("div_login1").style.display="block";}
function hiddenDiv1(){document.getElementById("div_login1").style.display="none";}

function ggour(url)
{
    window.open(url);
    return false;
}

var req; //定义变量，用来创建xmlhttprequest对象
        function ULogin() // 创建xmlhttprequest,ajax开始
        {
            //alert("ULogin()");
            var url="TestRightList.aspx?username="+document.getElementById("ctl00_ContentPlaceHolder1_MyRightList_user").value+"&pwd="+document.getElementById("ctl00_ContentPlaceHolder1_MyRightList_pwd").value+"&yzCode="+document.getElementById("ctl00_ContentPlaceHolder1_MyRightList_yzCode").value; //要请求的服务端地址
            //var url="HandlerRightList.ashx";
            //alert(url);
            if(window.XMLHttpRequest) //非IE浏览器及IE7(7.0及以上版本)，用xmlhttprequest对象创建
            {
                req=new XMLHttpRequest();
            }
            else if(window.ActiveXObject) //IE(6.0及以下版本)浏览器用activexobject对象创建,如果用户浏览器禁用了ActiveX,可能会失败.
            {
                req=new ActiveXObject("Microsoft.XMLHttp");
            }
            
            if(req) //成功创建xmlhttprequest
            {
                req.open("GET",url,true); //与服务端建立连接(请求方式post或get，地址,true表示异步)
                req.onreadystatechange = callback; //指定回调函数
                req.send(url); //发送请求
            }
        }
        
        function callback() //回调函数，对服务端的响应处理，监视response状态
        {
            if(req.readyState==4) //请求状态为4表示成功
            {
                if(req.status==200) //http状态200表示OK
                {
                    alert("服务端返回状态" + req.status);
                    Dispaly(); //所有状态成功，执行此函数，显示数据
                }
                else //http返回状态失败
                {
                    alert("服务端返回状态" + req.status);
                }
            }
//            else //请求状态还没有成功，页面等待
//            {
//                document .getElementById ("myTime").innerHTML ="数据加载中";
//            }
        }
        
        function Dispaly() //接受服务端返回的数据，对其进行显示
        {
        
            var result =req.responseText;
            var msg=document.getElementById("msgDiv");
            switch (result)
            {
                case "1":
                    msg.innerHTML="登录有误!";
                    break;
                case "2":
                    msg.innerHTML="账户名或密码有误!";
                    break;
                case "3":
                    msg.innerHTML="验证码错误!";
                    break;
                case "4":
                    msg.innerHTML="请输入验证码!";
                    break;
                default:
                    msg.innerHTML=result;
                    break;
            }
        }


