﻿// 网上办事快速通道 相关ajax 操作

//下拉选择
function Sel(value,flag)
{
    var date = new Date();
    var time = date.getTime();
    var http  = new HTTPRequest();
    http.open("GET","WSBS.ashx?Id="+ value +"&flag="+ flag +"&time=" + time ,true);
    http.onreadystatechange = function()
    {
        WSBS_HttpResponse(http,flag);
    }
    http.send(null); 
}
function WSBS_HttpResponse(http,flag)
{
    if(http.readyState == 4)
    {
        if(http.Status == 200)
        {
            var str = http.responseText;
            if(flag == "zt")
            {
                FillZT(str)
            }
            else if(flag == "wy")
            {
               FillWY(str)
            }
        }
    }
}

//状态下拉表填充
function FillZT(str)
{
    var ZTAry = str.split('@');

    document.all.SelZT.options.length = 0;
    
    if(str!="")
    {
        if(ZTAry.length == 1)
        {
            var content = ZTAry[0].split('|');
            var text = content[0];
            var value  =  content[1];
            document.all.SelZT.options.add(new Option(text,value));//添加列表项
        }
        else
        {
            for(var i = 0;i< ZTAry.length;i++)
            {
                var content = ZTAry[i].split('|');
                var text = content[0];
                var value  =  content[1];
                document.all.SelZT.options.add(new Option(text,value));//添加列表项
            }
        }
        var ztId = document.all.SelZT.value
        Sel(ztId,"wy")
    }
    else
    {
        document.all.SelZT.options.add(new Option("--选择--","0"))
        document.all.SelWY.options.length = 0;
        document.all.SelWY.options.add(new Option("--选择--","0"))
    }   
}
//我要状态表填充
function FillWY(str)
{
    var WYAry = str.split('@');
    
    document.all.SelWY.options.length = 0;
    
    if(str!="")
    {
        if(WYAry.length == 1)
        {
            var content = WYAry[0].split('|');
            var text = content[0];
            var value  =  content[1];
            document.all.SelWY.options.add(new Option(text,value));//添加列表项
        }
        else
        {
            for(var i = 0;i< WYAry.length;i++)
            {
                var content = WYAry[i].split('|');
                var text = content[0];
                var value  =  content[1];
                document.all.SelWY.options.add(new Option(text,value));//添加列表项
            }
        }
        
    }
    else
    {
        document.all.SelWY.options.add(new Option("--选择--","0"))
    }   
}

function Check(ws,zt,wy)
{
    ws_value = document.getElementById(ws).value;
    zt_value = document.getElementById(zt).value;
    wy_value = document.getElementById(wy).value;
    if(ws_value == "0" || zt_value == "0" || wy_value == "0" || ws_value == "" || zt_value == "" || wy_value == ""  )
    {
        alert("请选择具体条件进行搜索。");
        return false;
    }
    else
    {
       return true; 
    }
    
   
}
