﻿// JScript 文件
var httpRq;
//创建XMLHttpRequest对象
function createXMLHttpRequest()
{
    var o=new Array("Microsoft.XMLHTTP","Msxml2.XMLHTTP.5.0","Msxml2.XMLHTTP.4.0","Msxml2.XMLHTTP.3.0","Msxml2.XMLHTTP");
    var xmlHttp; 
    if(window.ActiveXObject)
    {
        for(var i=0;i<o.length;i++)
        {
            try
            {
                xmlHttp = new ActiveXObject(o[i]);
                return xmlHttp;
            }
            catch(b)
            {}
        }
    }
    else if(window.XMLHttpRequest)
    {
        xmlHttp = new XMLHttpRequest();
        return xmlHttp;
    }
    return null;
}

//创建请求所要的XML
function Request(type,object)
{
    var xml = "";
    var value = "";
    
    var value = object.value;
    
    var xml = "<Request><Type>" + type + "</Type><" + type + ">" + value + "</" + type + "></Request>";
    
    doPost(xml);
}

//分页创建请求所要的XML
function RequestSearch(type,keywords,shcontinent,shcountry,shprovinces,shcity,shdistrict,page)
{
    var xml = "";
    var value = "";
    //var value = keywords;
    
    var xml = "<RequestSearch><Type>" + type + "</Type><KeyWords>" + keywords + "</KeyWords><Continent>" + shcontinent + "</Continent><Country>" + shcountry + "</Country><Provinces>" + shprovinces + "</Provinces><City>" + shcity + "</City><District>" + shdistrict + "</District><Page>" + page + "</Page></RequestSearch>";
 
    doPost2(xml);
}

function doPost2(str)
{
    var xmlHttp = createXMLHttpRequest();
    if(xmlHttp==null)
    {
        return;
    }
 
    var url ="PageSearch.aspx";
    xmlHttp.open("POST",url,true);
    xmlHttp.onreadystatechange = handleStateChange;
    //xmlHttp.setRequestHeader("Content-Type","utf-8;");
    xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded;");
    httpRq=xmlHttp;
    xmlHttp.send(str);
}

function doPost(str)
{
    var xmlHttp = createXMLHttpRequest();
    if(xmlHttp==null)
    {
        return;
    }
 
    var url ="AreaBind.aspx";
    xmlHttp.open("POST",url,true);
    xmlHttp.onreadystatechange = handleStateChange;
    //xmlHttp.setRequestHeader("Content-Type","utf-8;");
    xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded;");
    httpRq=xmlHttp;
    xmlHttp.send(str);
}

function handleStateChange()
{
    if(httpRq.readyState == 4)
    {
//        if(httpRq.status == 500)
//        {
//            alert("未知错误！");
//        }
        if(httpRq.status == 200)
        {
            parseResults();
        }
        else
        {
            alert("未知错误！");
        }
    }
 }
 
 function parseResults()
 {
    var xml = httpRq.responseXML;
    if(xml!=null)
    {
        var type = xml.getElementsByTagName("Type").item(0).firstChild.nodeValue;
        switch (type)
        {
            case "country":          
                var itemList = xml.getElementsByTagName(type);
                var sel =  document.getElementById("sltCountry");
                sel.options.length = 1;
                sel.selectedIndex=0;
               
                document.getElementById("sltDistrict").options.length = 1;
                document.getElementById("sltDistrict").selectedIndex=0;
                document.getElementById("sltProvinces").options.length = 1;
                document.getElementById("sltProvinces").selectedIndex=0;
                document.getElementById("sltCity").options.length = 1;
                document.getElementById("sltCity").selectedIndex=0;
               
                for(var i=0;i<itemList.length;i++)
                {   
                    var item = itemList.item(i);
                    var name = item.getElementsByTagName("name").item(0).firstChild.nodeValue;
                    var value =  item.getElementsByTagName("value").item(0).firstChild.nodeValue;
                    var option = document.createElement("OPTION");
                    option.text=unescape(name);
                    option.value=value;                    
                    sel.options.add(option);                    
                }                
                break;
            case "provinces":
                var itemList = xml.getElementsByTagName(type);
                var sel =  document.getElementById("sltProvinces");
                sel.options.length = 1;
                sel.selectedIndex=0;
               
                document.getElementById("sltDistrict").options.length = 1;
                document.getElementById("sltDistrict").selectedIndex=0;
                document.getElementById("sltCity").options.length = 1;
                document.getElementById("sltCity").selectedIndex=0;
                
                for(var i=0;i<itemList.length;i++)
                {
                    var item = itemList.item(i);
                    var name = item.getElementsByTagName("name").item(0).firstChild.nodeValue;
                    var value =  item.getElementsByTagName("value").item(0).firstChild.nodeValue;                    
                    var option = document.createElement("OPTION");
                    option.text=unescape(name);
                    option.value=value;
                    sel.options.add(option);
                }
                break;
            case "city":
                var itemList = xml.getElementsByTagName(type);
                var sel =  document.getElementById("sltCity");
                sel.options.length = 1;
                sel.selectedIndex=0;
                
                document.getElementById("sltDistrict").options.length = 1;
                document.getElementById("sltDistrict").selectedIndex=0;
              
                for(var i=0;i<itemList.length;i++)
                {
                    var item = itemList.item(i);
                    var name = item.getElementsByTagName("name").item(0).firstChild.nodeValue;
                    var value =  item.getElementsByTagName("value").item(0).firstChild.nodeValue;
                    var option = document.createElement("OPTION");
                    option.text=unescape(name);
                    option.value=value;
                    sel.options.add(option);
                }
                break;
            case "district":
                var itemList = xml.getElementsByTagName(type);
                var sel =  document.getElementById("sltDistrict");
                sel.options.length = 1;
                sel.selectedIndex=0;
                for(var i=0;i<itemList.length;i++)
                {
                    var item = itemList.item(i);
                    var name = item.getElementsByTagName("name").item(0).firstChild.nodeValue;
                    var value =  item.getElementsByTagName("value").item(0).firstChild.nodeValue;
                    var option = document.createElement("OPTION");
                    option.text=unescape(name);
                    option.value=value;
                    sel.options.add(option);
                }
                break;
            case "1":
                var itemList = xml.getElementsByTagName("coop");
                var str="<table align=\"left\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"70%\">";    
                for(var i=0;i<itemList.length;i++)
                {                         
                    var item = itemList.item(i);                         
                    var cooid=item.getElementsByTagName("cooid").item(0).firstChild.nodeValue;     
                    var cooname = unescape(item.getElementsByTagName("cooname").item(0).firstChild.nodeValue);
                    var coomsg = unescape(item.getElementsByTagName("coomsg").item(0).firstChild.nodeValue);
                    var coohttp = unescape(item.getElementsByTagName("coohttp").item(0).firstChild.nodeValue);
                    
                    str += "<tr><td>";
                    
                    str += "<table align=\"left\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\">";
                    str += "<tr>";
                    str += "<td><a href=\"" + coohttp + "\" target=\"_blank\"><font size=\"4\" color=\"#261CDC\" style=\"text-decoration:underline;\">" + cooname + "</font></a></td>";
                    str += "</tr>";
                    str += "<tr>";
                    str += "<td style=\"word-wrap:break-word;word-break:break-all;\" class=\"HotelNews\">" + coomsg + "</td>";
                    str += "</tr>";
                    str += "<tr>";
                    str += "<td><a href=\"" + coohttp + "\" target=\"_blank\"><font color=\"#008000\">" + coohttp + "</font></a>-<font color=\"#666666\">玛雅在线</font></td>";
                    str += "</tr>";
                    str += "</table>";
                    
                    str += "</td></tr>";
                    str += "<tr><td height=\"20\"></td></tr>"; 
                }
                str += "</table>";
                var divNew = document.getElementById("DivSearch");
                //divNew.innerHTML="";
                divNew.innerHTML=str;
                break;
            case "2":
                var itemList = xml.getElementsByTagName("coop");
                var str="<table align=\"left\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"70%\">";    
                for(var i=0;i<itemList.length;i++)
                {                         
                    var item = itemList.item(i);                         
                    var cooid=item.getElementsByTagName("cooid").item(0).firstChild.nodeValue;     
                    var cooname = unescape(item.getElementsByTagName("cooname").item(0).firstChild.nodeValue);
                    var coomsg = unescape(item.getElementsByTagName("coomsg").item(0).firstChild.nodeValue);
                    var coohttp = unescape(item.getElementsByTagName("coohttp").item(0).firstChild.nodeValue);
                    
                    str += "<tr><td>";
                    
                    str += "<table align=\"left\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\">";
                    str += "<tr>";
                    str += "<td><a href=\"" + coohttp + "\" target=\"_blank\"><font size=\"4\" color=\"#261CDC\" style=\"text-decoration:underline;\">" + cooname + "</font></a></td>";
                    str += "</tr>";
                    str += "<tr>";
                    str += "<td style=\"word-wrap:break-word;word-break:break-all;\" class=\"HotelNews\">" + coomsg + "</td>";
                    str += "</tr>";
                    str += "<tr>";
                    str += "<td><a href=\"" + coohttp + "\" target=\"_blank\"><font color=\"#008000\">" + coohttp + "</font></a>-<font color=\"#666666\">玛雅在线</font></td>";
                    str += "</tr>";
                    str += "</table>";
                    
                    str += "</td></tr>";
                    str += "<tr><td height=\"20\"></td></tr>"; 
                }
                str += "</table>";
                var divNew = document.getElementById("DivSearch");
                //divNew.innerHTML="";
                divNew.innerHTML=str;
                break;
            case "3":
                var itemList = xml.getElementsByTagName("coop");
                var str="<table align=\"left\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"70%\">";    
                for(var i=0;i<itemList.length;i++)
                {                         
                    var item = itemList.item(i);                         
                    var cooid=item.getElementsByTagName("cooid").item(0).firstChild.nodeValue;     
                    var cooname = unescape(item.getElementsByTagName("cooname").item(0).firstChild.nodeValue);
                    var coomsg = unescape(item.getElementsByTagName("coomsg").item(0).firstChild.nodeValue);
                    var coohttp = unescape(item.getElementsByTagName("coohttp").item(0).firstChild.nodeValue);
                    
                    str += "<tr><td>";
                    
                    str += "<table align=\"left\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\">";
                    str += "<tr>";
                    str += "<td><a href=\"" + coohttp + "\" target=\"_blank\"><font size=\"4\" color=\"#261CDC\" style=\"text-decoration:underline;\">" + cooname + "</font></a></td>";
                    str += "</tr>";
                    str += "<tr>";
                    str += "<td style=\"word-wrap:break-word;word-break:break-all;\" class=\"HotelNews\">" + coomsg + "</td>";
                    str += "</tr>";
                    str += "<tr>";
                    str += "<td><a href=\"" + coohttp + "\" target=\"_blank\"><font color=\"#008000\">" + coohttp + "</font></a>-<font color=\"#666666\">玛雅在线</font></td>";
                    str += "</tr>";
                    str += "</table>";
                    
                    str += "</td></tr>";
                    str += "<tr><td height=\"20\"></td></tr>"; 
                }
                str += "</table>";
                var divNew = document.getElementById("DivSearch");
                //divNew.innerHTML="";
                divNew.innerHTML=str;
                break;
            case "4":
                var itemList = xml.getElementsByTagName("coop");
                var str="<table align=\"left\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"70%\">";    
                for(var i=0;i<itemList.length;i++)
                {                         
                    var item = itemList.item(i);                         
                    var cooid=item.getElementsByTagName("cooid").item(0).firstChild.nodeValue;     
                    var cooname = unescape(item.getElementsByTagName("cooname").item(0).firstChild.nodeValue);
                    var coomsg = unescape(item.getElementsByTagName("coomsg").item(0).firstChild.nodeValue);
                    var coohttp = unescape(item.getElementsByTagName("coohttp").item(0).firstChild.nodeValue);
                    
                    str += "<tr><td>";
                    
                    str += "<table align=\"left\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\">";
                    str += "<tr>";
                    str += "<td><a href=\"" + coohttp + "\" target=\"_blank\"><font size=\"4\" color=\"#261CDC\" style=\"text-decoration:underline;\">" + cooname + "</font></a></td>";
                    str += "</tr>";
                    str += "<tr>";
                    str += "<td style=\"word-wrap:break-word;word-break:break-all;\" class=\"HotelNews\">" + coomsg + "</td>";
                    str += "</tr>";
                    str += "<tr>";
                    str += "<td><a href=\"" + coohttp + "\" target=\"_blank\"><font color=\"#008000\">" + coohttp + "</font></a>-<font color=\"#666666\">玛雅在线</font></td>";
                    str += "</tr>";
                    str += "</table>";
                    
                    str += "</td></tr>";
                    str += "<tr><td height=\"20\"></td></tr>"; 
                }
                str += "</table>";
                var divNew = document.getElementById("DivSearch");
                //divNew.innerHTML="";
                divNew.innerHTML=str;
                break;
            case "5":
                var itemList = xml.getElementsByTagName("coop");
                var str="<table align=\"left\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"70%\">";    
                for(var i=0;i<itemList.length;i++)
                {                         
                    var item = itemList.item(i);                         
                    var cooid=item.getElementsByTagName("cooid").item(0).firstChild.nodeValue;     
                    var cooname = unescape(item.getElementsByTagName("cooname").item(0).firstChild.nodeValue);
                    var coomsg = unescape(item.getElementsByTagName("coomsg").item(0).firstChild.nodeValue);
                    var coohttp = unescape(item.getElementsByTagName("coohttp").item(0).firstChild.nodeValue);
                    
                    str += "<tr><td>";
                    
                    str += "<table align=\"left\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\">";
                    str += "<tr>";
                    str += "<td><a href=\"" + coohttp + "\" target=\"_blank\"><font size=\"4\" color=\"#261CDC\" style=\"text-decoration:underline;\">" + cooname + "</font></a></td>";
                    str += "</tr>";
                    str += "<tr>";
                    str += "<td style=\"word-wrap:break-word;word-break:break-all;\" class=\"HotelNews\">" + coomsg + "</td>";
                    str += "</tr>";
                    str += "<tr>";
                    str += "<td><a href=\"" + coohttp + "\" target=\"_blank\"><font color=\"#008000\">" + coohttp + "</font></a>-<font color=\"#666666\">玛雅在线</font></td>";
                    str += "</tr>";
                    str += "</table>";
                    
                    str += "</td></tr>";
                    str += "<tr><td height=\"20\"></td></tr>"; 
                }
                str += "</table>";
                var divNew = document.getElementById("DivSearch");
                //divNew.innerHTML="";
                divNew.innerHTML=str;
                break;
            case "6":
                var itemList = xml.getElementsByTagName("coop");
                var str="<table align=\"left\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"70%\">";    
                for(var i=0;i<itemList.length;i++)
                {                         
                    var item = itemList.item(i);                         
                    var cooid=item.getElementsByTagName("cooid").item(0).firstChild.nodeValue;     
                    var cooname = unescape(item.getElementsByTagName("cooname").item(0).firstChild.nodeValue);
                    var coomsg = unescape(item.getElementsByTagName("coomsg").item(0).firstChild.nodeValue);
                    var coohttp = unescape(item.getElementsByTagName("coohttp").item(0).firstChild.nodeValue);
                    
                    str += "<tr><td>";
                    
                    str += "<table align=\"left\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\">";
                    str += "<tr>";
                    str += "<td><a href=\"" + coohttp + "\" target=\"_blank\"><font size=\"4\" color=\"#261CDC\" style=\"text-decoration:underline;\">" + cooname + "</font></a></td>";
                    str += "</tr>";
                    str += "<tr>";
                    str += "<td style=\"word-wrap:break-word;word-break:break-all;\" class=\"HotelNews\">" + coomsg + "</td>";
                    str += "</tr>";
                    str += "<tr>";
                    str += "<td><a href=\"" + coohttp + "\" target=\"_blank\"><font color=\"#008000\">" + coohttp + "</font></a>-<font color=\"#666666\">玛雅在线</font></td>";
                    str += "</tr>";
                    str += "</table>";
                    
                    str += "</td></tr>";
                    str += "<tr><td height=\"20\"></td></tr>"; 
                }
                str += "</table>";
                var divNew = document.getElementById("DivSearch");
                //divNew.innerHTML="";
                divNew.innerHTML=str;
                break;
            case "7":
                var itemList = xml.getElementsByTagName("coop");
                var str="<table align=\"left\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"70%\">";    
                for(var i=0;i<itemList.length;i++)
                {                         
                    var item = itemList.item(i);                         
                    var cooid=item.getElementsByTagName("cooid").item(0).firstChild.nodeValue;     
                    var cooname = unescape(item.getElementsByTagName("cooname").item(0).firstChild.nodeValue);
                    var coomsg = unescape(item.getElementsByTagName("coomsg").item(0).firstChild.nodeValue);
                    var coohttp = unescape(item.getElementsByTagName("coohttp").item(0).firstChild.nodeValue);
                    
                    str += "<tr><td>";
                    
                    str += "<table align=\"left\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\">";
                    str += "<tr>";
                    str += "<td><a href=\"" + coohttp + "\" target=\"_blank\"><font size=\"4\" color=\"#261CDC\" style=\"text-decoration:underline;\">" + cooname + "</font></a></td>";
                    str += "</tr>";
                    str += "<tr>";
                    str += "<td style=\"word-wrap:break-word;word-break:break-all;\" class=\"HotelNews\">" + coomsg + "</td>";
                    str += "</tr>";
                    str += "<tr>";
                    str += "<td><a href=\"" + coohttp + "\" target=\"_blank\"><font color=\"#008000\">" + coohttp + "</font></a>-<font color=\"#666666\">玛雅在线</font></td>";
                    str += "</tr>";
                    str += "</table>";
                    
                    str += "</td></tr>";
                    str += "<tr><td height=\"20\"></td></tr>"; 
                }
                str += "</table>";
                var divNew = document.getElementById("DivSearch");
                //divNew.innerHTML="";
                divNew.innerHTML=str;
                break;
            case "8":
                var itemList = xml.getElementsByTagName("coop");
                var str="<table align=\"left\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"70%\">";    
                for(var i=0;i<itemList.length;i++)
                {                         
                    var item = itemList.item(i);                         
                    var cooid=item.getElementsByTagName("cooid").item(0).firstChild.nodeValue;     
                    var cooname = unescape(item.getElementsByTagName("cooname").item(0).firstChild.nodeValue);
                    var coomsg = unescape(item.getElementsByTagName("coomsg").item(0).firstChild.nodeValue);
                    var coohttp = unescape(item.getElementsByTagName("coohttp").item(0).firstChild.nodeValue);
                    
                    str += "<tr><td>";
                    
                    str += "<table align=\"left\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\">";
                    str += "<tr>";
                    str += "<td><a href=\"" + coohttp + "\" target=\"_blank\"><font size=\"4\" color=\"#261CDC\" style=\"text-decoration:underline;\">" + cooname + "</font></a></td>";
                    str += "</tr>";
                    str += "<tr>";
                    str += "<td style=\"word-wrap:break-word;word-break:break-all;\" class=\"HotelNews\">" + coomsg + "</td>";
                    str += "</tr>";
                    str += "<tr>";
                    str += "<td><a href=\"" + coohttp + "\" target=\"_blank\"><font color=\"#008000\">" + coohttp + "</font></a>-<font color=\"#666666\">玛雅在线</font></td>";
                    str += "</tr>";
                    str += "</table>";
                    
                    str += "</td></tr>";
                    str += "<tr><td height=\"20\"></td></tr>"; 
                }
                str += "</table>";
                var divNew = document.getElementById("DivSearch");
                //divNew.innerHTML="";
                divNew.innerHTML=str;
                break;
        }
    }
 }
