﻿

var xmlhttprequest=null;
var url;
var num=-1;
var strReturn;
    function  UsersExists()
    {
        var LoginName =  document.getElementById("TxtLogin").value;
         var item = document.getElementById("infoCount").innerText;
        if(LoginName!="" )
        {
            if(LoginName.length>=6 && LoginName.length<=20)
            {
                url="UsersExist.aspx?LoginName="+LoginName+"&Time="+new Date();
                getAllLayersName();
               
                if(strReturn=="0")
                {
                   if(item==undefined)
                   {
                        document.getElementById("infoCount").innerContent="<font style=\"color:red;font-weight:bold\">该用户名以存在</font>";
                   }else
                   {
                         document.getElementById("infoCount").innerHTML ="<font style=\"color:red;font-weight:bold\">该用户名以存在</font>";
                   }
                }
                else
                {
                   if(item==undefined)
                   {
                        document.getElementById("infoCount").innerContent="<font style=\"color:#00FF00;font-weight:bold\">用户名可以使用</font>";
                   }
                   else
                   {
                       document.getElementById("infoCount").innerHTML="<font style=\"color:#00FF00;font-weight:bold\">用户名可以使用</font>";
                   }
                } 
                  document.getElementById("TxtIsExists").value=strReturn;
            }else{ 
                 if(item==undefined)
                 {
                    document.getElementById("infoCount").innerContent="<font style=\"color:red;font-weight:bold\">用户名只能在6-20个字符.</font>"; 
                    document.getElementById("TxtIsExists").value="0";
                 }else{  document.getElementById("infoCount").innerHTML="<font style=\"color:red;font-weight:bold\">用户名只能在6-20个字符.</font>";
                 document.getElementById("TxtIsExists").value="0"; }
                } 
        }
        else
        { 
               if(item==undefined)
               {
                    document.getElementById("infoCount").innerContent="<font style=\"color:red;font-weight:bold\">用户名不能为空</font>";
               }
               else
               {
                   document.getElementById("infoCount").innerHTML="<font style=\"color:red;font-weight:bold\">用户名不能为空</font>";
               }
        }
    }
    function AddRepositoryLookCount(linkUrl)
    {
        url=linkUrl;
        getAllLayersName();
    }

    function getOs()  //判断浏览器类型
{  
   var OsObject = "";  
   if(navigator.userAgent.indexOf("MSIE")>0) {  
        return "MSIE";       //IE浏览器
   }
   if(isFirefox=navigator.userAgent.indexOf("Firefox")>0){  
        return "Firefox";     //Firefox浏览器
   }
   if(isSafari=navigator.userAgent.indexOf("Safari")>0) {  
        return "Safari";      //Safan浏览器
   }
   if(isCamino=navigator.userAgent.indexOf("Camino")>0){  
        return "Camino";   //Camino浏览器
   }
   if(isMozilla=navigator.userAgent.indexOf("Gecko/")>0){  
        return "Gecko";    //Gecko浏览器
   }  
} 


 function getAllLayersName()
{
    
    if (null==xmlhttprequest)
    {
//         xmlhttprequest =new ActiveXObject("Microsoft.XMLHTTP");
            if   (window.ActiveXObject)   //IE浏览器   
         {                   
             xmlhttprequest   =   new   ActiveXObject("Microsoft.XMLHTTP");           
         }             
        else   if   (window.XMLHttpRequest)   //非IE浏览器   
        {                 
            xmlhttprequest   =   new   XMLHttpRequest();           
         }   
       
//使用AjaxMap中的_GetXmlHttpRequest方法来初始化xmlhttprequest对象。
    }
    
    //在FF下，第一次执行完onreadystatechange后，继续执行到send，但后面就不会再回头执行onreadystatechange,一直傻傻的走下去。
       
   
     xmlhttprequest.open("GET",url,false);//向layer.ashx发送参数
    xmlhttprequest.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
    var btype=getOs();
   xmlhttprequest.onreadystatechange = (btype!="Firefox")?(GetReturn):(GetReturn());//是火狐的话 则方法要括号
    xmlhttprequest.send(null);
    xmlhttprequest.onreadystatechange = (btype!="Firefox")?(GetReturn):(GetReturn());//再调用一次
}

function GetReturn()
{ 

    var readyState=xmlhttprequest.readyState;
        if (readyState==4)//判断对象状态，4为完成
        {
             var status=xmlhttprequest.status;
                if(status==200)//信息已经返回开始处理信息
                {
                    var strLayersName= xmlhttprequest.responseText;//得到返回的字符串
                    
                    if(strLayersName!= null)
                    {
                        strReturn=strLayersName;
                    }
                }
                else
                {
                   
                }
             // xmlhttprequest = null; 如果这里设置了null 则IE 不支持了
        }      
}


function ChangePro(proid,cityid)
{
    //alert(document.getElementById("SelectPro").selectedIndex);
    var pro=document.getElementById(proid).options[document.getElementById(proid).selectedIndex].value;
    if(pro=="-1")
    {
        return;
    }
    else
    {
        flag=1;
        url="Province.aspx?ProID="+pro+"&time"+new Date();
        getAllLayersName();
        var cityArray=strReturn.split('|');//这里strReturn 是接受的到得数据 格式是：1=上海|2=北京|3=重庆 这样是的格式
        var oOption=null;
        document.getElementById(cityid).options.length=1;
         for(var i=0;i<cityArray.length;i++)
         {
            if(cityArray[i]!="")
            {
                var valuetext=cityArray[i].split('=');                
                oOption = new Option(valuetext[1],valuetext[0]);
                document.getElementById(cityid).options.add(oOption);
            }
        }
    }
}


function ChangeCity(proid,cityid)
{
    //alert(document.getElementById("SelectPro").selectedIndex);
    var pro=document.getElementById(proid).options[document.getElementById(proid).selectedIndex].value;
    if(pro=="-1")
    {
        return;
    }
    else
    {
        flag=1;
        url="Province.aspx?CityId="+pro+"&time"+new Date();
        getAllLayersName();
        var cityArray=strReturn.split('|');//这里strReturn 是接受的到得数据 格式是：1=上海|2=北京|3=重庆 这样是的格式
        var oOption=null;
        document.getElementById(cityid).options.length=1;
         for(var i=0;i<cityArray.length;i++)
         {
            if(cityArray[i]!="")
            {
                var valuetext=cityArray[i].split('=');                
                oOption = new Option(valuetext[1],valuetext[0]);
                document.getElementById(cityid).options.add(oOption);
            }
        }
    }
}

function ChangeKind(proid,cityid)
{
    //alert(document.getElementById("SelectPro").selectedIndex);
    var pro=document.getElementById(proid).options[document.getElementById(proid).selectedIndex].value;
    if(pro=="-1")
    {
        return;
    }
    else
    {
        flag=1;
        url="Province.aspx?KindId="+pro+"&time"+new Date();
        getAllLayersName();
        var cityArray=strReturn.split('|');//这里strReturn 是接受的到得数据 格式是：1=上海|2=北京|3=重庆 这样是的格式
        var oOption=null;
        document.getElementById(cityid).options.length=1;
         for(var i=0;i<cityArray.length;i++)
         {
            if(cityArray[i]!="")
            {
                var valuetext=cityArray[i].split('=');                
                oOption = new Option(valuetext[1],valuetext[0]);
                document.getElementById(cityid).options.add(oOption);
            }
        }
    }
}
function ChangeProductsCatalog(proid,cityid)
{
    //alert(document.getElementById("SelectPro").selectedIndex);
    var pro=document.getElementById(proid).options[document.getElementById(proid).selectedIndex].value;
    if(pro=="-1")
    {
        return;
    }
    else
    {
        flag=1;
        url="Province.aspx?ProductsCataLog="+pro+"&time"+new Date();
        getAllLayersName();
        var cityArray=strReturn.split('|');//这里strReturn 是接受的到得数据 格式是：1=上海|2=北京|3=重庆 这样是的格式
        var oOption=null;
        document.getElementById(cityid).options.length=1;
         for(var i=0;i<cityArray.length;i++)
         {
            if(cityArray[i]!="")
            {
                var valuetext=cityArray[i].split('=');                
                oOption = new Option(valuetext[1],valuetext[0]);
                document.getElementById(cityid).options.add(oOption);
            }
        }
    }
}

function ChangeProDefault(proid,cityid)
{
    //alert(document.getElementById("SelectPro").selectedIndex);
    var pro=document.getElementById(proid).options[document.getElementById(proid).selectedIndex].value;
    if(pro=="-1")
    {
        return;
    }
    else
    {
        flag=1;
        url="web/Province.aspx?ProID="+pro+"&time"+new Date();
        getAllLayersName();
        var cityArray=strReturn.split('|');//这里strReturn 是接受的到得数据 格式是：1=上海|2=北京|3=重庆 这样是的格式
        var oOption=null;
        document.getElementById(cityid).options.length=1;
         for(var i=0;i<cityArray.length;i++)
         {
            if(cityArray[i]!="")
            {
                var valuetext=cityArray[i].split('=');                
                oOption = new Option(valuetext[1],valuetext[0]);
                document.getElementById(cityid).options.add(oOption);
            }
        }
    }
}
