﻿// JScript 文件
//------------------------------------------------------------------------------
//By J.C
function loginValidate_JC_1(n, p,type){
    function parseXML(){
        var rootNode = xmlhttp.responseXML.documentElement;
        var code = rootNode.getElementsByTagName("returnCode")[0].firstChild.data;
        switch(code)
        {

            case "1" :
                if(type=="list")
                {
                    window.location=window.location.href.replace("ListByNoLogin","List");
                }else if(type=="compare")
                {
                     window.location=window.location.href.replace("CompareByNoLogin","CompareByLogin");
                }else if(type=="buy")
                {
                    var id=document.getElementById("hdId").value;
                    f_buy(id);
                }else if(type=="shouc")
                {
                    var id=document.getElementById("hdId").value;
                    f_ShouC(id);
                    f_close();
                }
                else window.location='/light/Default.shtml';
                break;
            case "99":
                window.location='http://user.ju51.com/usercenter/index.aspx';
                break;
            case "-2" :
                window.alert("[异常] " + rootNode.getElementsByTagName("returnMsg")[0].firstChild.data);
                break;
            case "0" :
                window.alert("[提醒] " + rootNode.getElementsByTagName("returnMsg")[0].firstChild.data);
                break;
            case "-1" :
                window.alert("[警告] " + rootNode.getElementsByTagName("returnMsg")[0].firstChild.data);
                break;  
            case "-3":
                window.alert("[提醒] " + rootNode.getElementsByTagName("returnMsg")[0].firstChild.data);
                break;
            default :
                break;
        }
    }
    
    function startDo(){
       if(xmlhttp.readyState==4)
         {
           if(xmlhttp.status==200)
           {
                //divLoad.style.display = "none";
                //displayObj.style.display = "block";
                parseXML();
           }else{
           }
         }else{
            //divLoad.style.display = "block";
            //displayObj.style.display = "none";
         }
    }
    
    var xmlhttp;
    if(window.ActiveXObject)
    {
       xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
    else if(window.XMLHttpRequest)
    {
       xmlhttp=new XMLHttpRequest();
    }
    
    xmlhttp.onreadystatechange = startDo;
    xmlhttp.open("GET","/AjaxService/PortalMemberUserServiceService.aspx?operation=login&name=" + n + "&pwd=" + p + "&time=" + new Date().getTime(),true);
    xmlhttp.send(null);
    
}

//------------------------------------------------------------------------------
//By zqz
function goToLogin_1(type){
 var uname = window.document.getElementById("name").value;
 var upwd = window.document.getElementById("pwd").value;
 
 if(uname == ""){
    window.alert("用户名不能为空!");
    return;
 }
 if(upwd == ""){
    window.alert("密码不能为空!");
    return;
 }
   
  loginValidate_JC_1(escape(uname), escape(upwd),type);
}

