﻿var TagPrefix="ctl00_PageContent_SearchBlock_";

//通用函数 
function $(id)
{
    return document.getElementById(id);
}

//获取城市
function CityResult(prefix)
{
    TagPrefix=prefix;
    $(TagPrefix+"CityList").length=0;
    $(TagPrefix+"InnList").length=0;
    $(TagPrefix+"CityList").style.display="none";
    $(TagPrefix+"InnList").style.display="none";
    var DicEntity=$(TagPrefix+"DicEntityList");
    AjaxService.GetCityListByID(DicEntity.value,get_City_Result_CallBack);
}

function get_City_Result_CallBack(response)
{
   
    if (response.value != null)
    { 
        var table = response.value;
        if(table != null)
        {
             $(TagPrefix+"CityList").options.add(new Option("请选择","0"));
             for(var i=0; i<table.Rows.length; i++)
             {
                 var name=table.Rows[i].Note;
                 var id=table.Rows[i].CID;
                 document.all(TagPrefix+"CityList").options.add(new Option(name,id));
                 
             }
             if(table.Rows.length > 0)
             {
                $(TagPrefix+"CityList").style.display="";
                $(TagPrefix+"InnList").style.display="none";
             }
             else
             {
                $(TagPrefix+"CityList").style.display="none";
                InnListBind($(TagPrefix+"DicEntityList").value)
             }
        }
        else
        {
            //alert("asd");
        }
    } 
    else
    {
         //当省级是直辖市的时候
         $(TagPrefix+"CityList").style.display="none";
         $(TagPrefix+"CityList").value="0";
    }
return
}


function InnListBind(CityID)
{
   $(TagPrefix+"InnList").length=0;
   $(TagPrefix+"InnList").style.display="none";
   var Tables = AjaxService.GetInnList(CityID).value;
   if (Tables != null)
    {
        $(TagPrefix+"InnList").options.add(new Option("请选择","0"));
        for(var i=0; i<Tables.Rows.length; i++)
        {
            var name=Tables.Rows[i].InnName;
            var id=Tables.Rows[i].CID;
            
            $(TagPrefix+"InnList").options.add(new Option(name,id));
        }
        
        if(Tables.Rows.length==0)
        {
             $(TagPrefix+"InnList").style.display="none";
        }
        else
        {
            $(TagPrefix+"InnList").style.display="";
        }
    }
    else
    {
        //alert(CityID);
    }
    return    
}