﻿ 
var xmlhttp;

 
function createXmlrequest()
{
    /*@cc_on
    @if (@_jscript_version >= 5)

    try {
        xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
    }
    catch (e) {
        try {
            xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
        }
        catch (E) {
            xmlhttp = false;
        }
    }

    @else

    xmlhttp = false;

    @end @*/

    if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
        try {
            xmlhttp = new XMLHttpRequest();
        } catch (e) {
            xmlhttp = false;
        }
    }

}

 
function staffLog()
{
    var name=document.getElementById("u_name").value;
    var pass=document.getElementById("p_word").value;
    if(name==""||pass=="")
    {
        alert("not null!");
    }
    else
    {
        createXmlrequest();
        
        var xmlStr = "<loginfo><logname>"+escape(name)+"</logname><logpass>"+escape(pass)+"</logpass></loginfo>";
        var url="../ashx/stafflog.ashx";
        xmlhttp.open("POST",url,true);
        xmlhttp.setRequestHeader("Content-Type", "text/xml");
        xmlhttp.onreadystatechange = stafflog;
        xmlhttp.send(xmlStr);
    }
}

 
function stafflog()
{
    if(xmlhttp.readyState==4)
    { 
        if(xmlhttp.status==200)
        {
            var result=xmlhttp.responseText;
            
            if(result=="error message!")
            {
                alert(result);
            }   
            else
            {
                var time=document.getElementById("cookies");
                
                var date=new Date();
                
                date.setTime(date.getTime() + 1800*1000);
                
                var name=document.getElementById("u_name").value;
      
            
                if(getCookie(name)!=null)
                {
                alert("you had login");
                
                }
                else
                {
                 
                 document.cookie= "uname="+name+";   expires= "+   date.toGMTString()+ "; ";
                 document.getElementById("warbuy").style.display="block";
                 document.getElementById("warbuyMLcontent2").style.display="none";
                 document.getElementById("uname").innerHTML=name;
                  document.getElementById("u_name").value="";
    document.getElementById("p_word").value="";
                alert(result);
                }
                 
                
            }
        }
    }
}
 
function getCookie(nm)
{
         var strCookie=document.cookie;
              var arrCookie=strCookie.split("; ");
              var user;
              for(var i=0;i<arrCookie.length;i++)
              {
                 var arr=arrCookie[i].split("=");
                 //找到名称为userId的cookie，并返回它的值
                 if("uname"==arr[0]&nm==arr[1])
                 {
                  return user=arr[1];
                  break;
                 }
              }
}
function getcook()
{
         var strCookie=document.cookie;
              var arrCookie=strCookie.split("; ");
              var user;
              for(var i=0;i<arrCookie.length;i++)
              {
                 var arr=arrCookie[i].split("=");
                 
                 if("uname"==arr[0])
                 {
                         document.getElementById("uname").innerHTML=arr[1];
                         document.getElementById("warbuy").style.display="block";
                         document.getElementById("warbuyMLcontent2").style.display="none";
                         break;
                 }
              }
              count1()
              countrylist1()
}

function delCookie()
{
    var date = new Date();
    date.setTime(date.getTime() - 100000);
    var u=document.getElementById("uname").innerHTML;
    document.cookie = "uname = "+u+ ";  expires=" + date.toGMTString();
    document.getElementById("warbuy").style.display="none";
    document.getElementById("warbuyMLcontent2").style.display="block";
    
}

var xhr
     function createXHR() { 
     
          try {
            xhr = new XMLHttpRequest();
        } 
        catch (trymicrosoft) 
        {
            try 
            {
              xhr = new ActiveXObject("Msxml2.XMLHTTP");
            } 
            catch (othermircosoft) {
              try 
              {
                xhr = new ActiveXObject("Microsoft.XMLHTTP");
              } 
              catch (failed) 
              {
                xhr = false;
              }
            }
        }
  if (!xhr)
    alert("Error initializing XMLHttpRequest!");
    }  
function count1()
{
   
            var webFileUrl = "../count.aspx?cur="+escape(document.referrer);
            var result = "";
            createXHR();
            xhr.onreadystatechange =ct1;
            xhr.open("GET", webFileUrl,true);
            xhr.send(null);
}
 function ct1()
 {
  if(xhr.readyState == 4)
        { 
               
                if(xhr.status == 200)
                {
             
                }
        }       
 }
 
 
 
 
 
 
 
var countryhttp1;
 
function createCountry()
{
    /*@cc_on
    @if (@_jscript_version >= 5)

    try {
        countryhttp1 = new ActiveXObject("Msxml2.XMLHTTP");
    }
    catch (e) {
        try {
            countryhttp1 = new ActiveXObject("Microsoft.XMLHTTP");
        }
        catch (E) {
            countryhttp1 = false;
        }
    }

    @else

    countryhttp1 = false;

    @end @*/

    if (!countryhttp1 && typeof countryhttp == 'undefined') {
        try {
            countryhttp1= new XMLHttpRequest();
        } catch (e) {
            countryhttp1 = false;
        }
    }

}

function countrylist1()
{
   
            var webFileUrl = "../ashx/packageList.ashx?country=country"
           
            createCountry();
          
            countryhttp1.open("GET", webFileUrl,true);
            countryhttp1.setRequestHeader("Content-Type", "text/xml");
            countryhttp1.onreadystatechange =countrybind1;
            countryhttp1.send("");
}
 function countrybind1()
 {
  
  if(countryhttp1.readyState == 4)
        { 
              
                if(countryhttp1.status == 200)
                {
                         var xmlDoc=countryhttp1.responseXML;
                         var ddl=document.getElementById("country");
                        // var ddl1=document.getElementById("country1");
                        var x=xmlDoc.getElementsByTagName("Table");
                   
                   /*    if(ddl1)
                       {
                         for(var i=0; i<x.length;i++)
                        {
                                  var country = x[i].getElementsByTagName("CountryName")[0].childNodes[0].nodeValue;
                                 var   option = document.createElement("option");
                                option.appendChild(document.createTextNode(country));
                                option.value=country;
                              
                               
                                
                                ddl1.appendChild(option);
                               
                    
                        }
                        }*/
                        if(ddl)
                        {
                         for(var i=0; i<x.length;i++)
                        {
                                  var country = x[i].getElementsByTagName("CountryName")[0].childNodes[0].nodeValue;
                                 var   option = document.createElement("option");
                                option.appendChild(document.createTextNode(country));
                                option.value=country;
                                ddl.appendChild(option);
                        }
                        }
                        
                }
        }       
 }


 

  
