﻿// zhangjian
var $ = function(i){ return document.getElementById(i); }
function showCity()
{
    getDATA1($("ddl1").value,"ddl2",1);
}
function showArea()
{
    getDATA1($("ddl2").value,"ddl3",2);
}
var xmlHttp;
var oDoc;
function createXMLHttpRequest()
{
    if(window.ActiveXObject)
    {
        xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
    else if(window.XMLHttpRequest)
    {
        xmlHttp=new XMLHttpRequest();
    }
    return xmlHttp;
}
function creatoDoc()
{
    try
    {
        oDoc=new ActiveXObject("Msxml2.DOMDocument.4.0"); 
    }
    catch(e){}
    try
    {
        oDoc = document.implementation.createDocument("", "", null); 
　　    oDoc.async = false;
    }
    catch(e){}
    return oDoc;
}
function getDATA1(objid,strobj,strac)
{
    createXMLHttpRequest();
    xmlHttp.open("GET","/inc/selectStr.aspx?id="+objid+"&action="+strac+"",true);
    xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
    xmlHttp.onreadystatechange= function () { handleStateChange1(xmlHttp,strobj); } ;
    xmlHttp.send(null);
}
function handleStateChange1(xmlHttp,strobj)
{
    if(xmlHttp.readyState==4)
    {
        if(xmlHttp.status==200)
        {           
	    for (i = $("ddl3").length; i >= 0; i--){ 
                  $("ddl3").options.remove(i); 
            }
            creatoDoc();
            oDoc.loadXML(xmlHttp.responseText); 
            items1 = oDoc.selectNodes("//INFOTYPE/Table/id"); 
            items2 = oDoc.selectNodes("//INFOTYPE/Table/title"); 
            var itemsLength=items1.length; 
            if(itemsLength==0)
            {
                var newOption = document.createElement("OPTION"); 
                newOption.text="请选择"; 
                newOption.value="0"; 
                $(strobj).options.add(newOption);
            }
            else
            {
                  var newOption1 = document.createElement("OPTION"); 
                  newOption1.text="请选择"; 
                  newOption1.value="0"; 
                  $(strobj).options.add(newOption1);
                  for(i=0;i<=itemsLength;i++) 
                  {  
                    try
                    {
                    //alert("1");
                    var newOption = document.createElement("OPTION"); 
                    newOption.value=items1[i].text;
                    newOption.text=items2[i].text; 
                    $(strobj).options.add(newOption); 
                    }
                    catch(e){}
                  }
             }
             showLst("/inc/resLst.aspx?nID="+ $("ddl1").value +"&fID="+ $("ddl2").value +"&cID="+ $("ddl3").value +"&page=1","sLst");
        }
        else
        {
            $(strobj).innerHTML="错误";
        }
    }
    else
    {
        $(strobj).innerHTML="";
    }
}
function showLst(a,strObj)
{
    //alert("fd");
    createXMLHttpRequest();
    xmlHttp.open("GET",a,true);
    xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
    xmlHttp.onreadystatechange= function () { handleStateChange2(xmlHttp,strObj); } ;
    xmlHttp.send(null);
}
function handleStateChange2(xmlHttp,strobj)
{
    if(xmlHttp.readyState==4)
    {
        if(xmlHttp.status==200)
        {
            $(strobj).innerHTML = xmlHttp.responseText;
         }
        else
        {
            $(strobj).innerHTML = "错误";
        }
    }
    else
    {
        $(strobj).innerHTML = "正在加载";
    }
}
function showPage(p)
{
    showLst("/inc/resLst.aspx?nID="+ $("ddl1").value +"&fID="+ $("ddl2").value +"&cID="+ $("ddl3").value +"&page="+ p +"","sLst");
}

