﻿// JScript 文件

var Continent;  //洲下拉列表对象
var Country;    //国家下拉列表对象
var City;       //城市下拉列表对象
var IsBuildCity=0;  //是否要生成城市下拉列表（0不要，1要）

/// <summary>
/// 初始化洲国家城市下拉列表
/// </summary>
/// <param name="ddlContinentID">洲下拉列表ID</param>
/// <param name="ddlCountryID">国家下拉列表ID</param>
/// <param name="ddlCityID">国家下拉列表ID</param>
function CCCInitialize(ddlContinentID,ddlCountryID,ddlCityID)
{
    Continent=document.getElementById(ddlContinentID);
    Country=document.getElementById(ddlCountryID);
    City=document.getElementById(ddlCityID);
    CountryCodeResult(ddlContinentID,ddlCountryID,1);//根据洲生成相应的国家下拉列表
    CityCodeResult(ddlCountryID,ddlCityID);//根据国家生成相应的城市下拉列表
}
//------------------------------------------------------------------------------------------
/// <summary>
/// 初始化洲国家下拉列表
/// </summary>
/// <param name="ddlContinentID">洲下拉列表ID</param>
/// <param name="ddlCountryID">国家下拉列表ID</param>
/// <param name="ddlCityID">国家下拉列表ID</param>
function CCInitialize(ddlContinentID,ddlCountryID)
{
    Continent=document.getElementById(ddlContinentID);
    Country=document.getElementById(ddlCountryID);
    CountryCodeResult(ddlContinentID,ddlCountryID,0);//根据洲生成相应的国家下拉列表
}
//------------------------------------------------------------------------------------------
/// <summary>
/// 根据洲生成相应的国家下拉列表
/// </summary>
/// <param name="ddlContinentID">洲下拉列表ID</param>
/// <param name="ddlCountryID">国家下拉列表ID</param>
/// <param name="IsGetCity">是否要生成城市下拉列表（0不要，1要）</param>
/// <returns>重新生成后的国家下拉列表控件</returns>
function CountryCodeResult(ddlContinentID,ddlCountryID,ddlCityID,IsCreateCity)
{ 
    Continent=document.getElementById(ddlContinentID);
    Country=document.getElementById(ddlCountryID);
    City=document.getElementById(ddlCityID);
    IsBuildCity=IsCreateCity;
    AjaxTest.AjaxMethod.GetCountryCodeList2(Continent.value,get_CountryCode_Result_CallBack);
}

function get_CountryCode_Result_CallBack(response)
{
    if (response.value != null)
    {                    
        document.all(Country.id).length=0;
        var ds = response.value;
        if(ds != null && typeof(ds) == "object" && ds.Tables != null)
        {
            document.all(Country.id).options.add(new Option('正在加载 ...','Qxz'));
            document.all(Country.id).disabled=true;
            document.all(Country.id).length=0;
            document.all(Country.id).options.add(new Option('全部','Qxz'));
            for(var i=0; i<ds.Tables[0].Rows.length; i++)
            {
                var name=ds.Tables[0].Rows[i].Name;
                var id=ds.Tables[0].Rows[i].Code;
                //document.all("ddlStartCountryID").options.add(new Option(name,id));
                document.all(Country.id).options.add(new Option(name,id));
            }
            document.all(Country.id).disabled=false;
        }
        if (IsBuildCity==1)
        {
            CityCodeResult(Country.id,City.id) 
//            alert(IsBuildCity+'|'+Continent.id+'|'+Country.id+'|'+City.id);
        }
    } 
    return
}
//------------------------------------------------------------------------------------------
/// <summary>
/// 根据国家生成相应的城市下拉列表
/// </summary>
/// <param name="ddlCountryID">国家下拉列表ID</param>
/// <param name="ddlCityID">城市下拉列表ID</param>
/// <returns>重新生成后的城市下拉列表控件</returns>
function CityCodeResult(ddlCountryID,ddlCityID) 
{
    Country=document.getElementById(ddlCountryID);
    City=document.getElementById(ddlCityID);
    AjaxTest.AjaxMethod.GetCityCodeList2(Country.value,get_CityCode_Result_CallBack);
}
function get_CityCode_Result_CallBack(response)
{
    if (response.value != null)
    {                    
        document.all(City.id).length=0;
        var ds = response.value;
        if(ds != null && typeof(ds) == "object" && ds.Tables != null)
        {
            document.all(City.id).options.add(new Option('正在加载 ...','Qxz'));
            document.all(City.id).disabled=true;
            document.all(City.id).length=0;
            document.all(City.id).options.add(new Option('全部','Qxz'));  
            for(var i=0; i<ds.Tables[0].Rows.length; i++)
            {
                var name=ds.Tables[0].Rows[i].Name;
                var id=ds.Tables[0].Rows[i].Code;
                //document.all("ddlStartCityID").options.add(new Option(name,id));
                document.all(City.id).options.add(new Option(name,id));
            }
            document.all(City.id).disabled=false;          
        }
    }
    return
}
//------------------------------------------------------------------------------------------
/// <summary>
/// 获取下拉列表选定项的值或文本
/// </summary>
/// <param name="DropDownListID">下拉列表控件的ID</param>
/// <param name="GetType">取值的类型（Value，Text）</param>
/// <returns>返回相应的值</returns>
function GetDropDownListData(DropDownListID,GetType)
{
    var DropDownList=document.getElementById(DropDownListID);
    var DropDownListIndex = DropDownList.selectedIndex;
    var DropDownListValue = DropDownList.options[DropDownListIndex].value;
    var DropDownListText  = DropDownList.options[DropDownListIndex].text;
    switch(GetType.toLowerCase())
    {
        case "value" :
            return DropDownListValue;
            break;
        case "text" :
            return DropDownListText;
            break;
    }
}
//跳转到机票查询结果页面
function QtTicketSearch(URL,cWhitherContinentID,cWhitherCountryID,cWhitherCityID)
{
    var WhitherContinentID = document.getElementById(cWhitherContinentID);
    var WhitherCountryID = document.getElementById(cWhitherCountryID);
    var WhitherCityID = document.getElementById(cWhitherCityID);
//    alert(URL+"?WhitherContinentID="+escape(WhitherContinentID.value)+"&WhitherCountryID="+escape(WhitherCountryID.value)+"&WhitherCityID="+escape(WhitherCityID.value));
	window.location=URL+"?WhitherContinentID="+escape(WhitherContinentID.value)+"&WhitherCountryID="+escape(WhitherCountryID.value)+"&WhitherCityID="+escape(WhitherCityID.value);
}
//跳转到酒店查询结果页面
//function QtHotelSearch(URL,cGjz,cCityID,cLevel,cHouseName,cPrice)
//{
//    var Gjz = document.getElementById(cGjz);
//    var CityID = document.getElementById(cCityID);
//    var Level = document.getElementById(cLevel);
//    var HouseName = document.getElementById(cHouseName);
//    var Price = document.getElementById(cPrice);
//	window.location=URL+"?cityid="+escape(CityID.value)+"&level="+escape(Level.value)+"&housename="+escape(HouseName.value)+"&price="+escape(Price.value)+"&gjz="+escape(Gjz.value);
//}
function QtHotelSearch(URL,Page,cGjz,cCityID,cLevel,cHouseName,cPrice)
{
    var Gjz = document.getElementById(cGjz);
    var CityID = document.getElementById(cCityID);
    var Level = document.getElementById(cLevel);
    var HouseName = document.getElementById(cHouseName);
    var Price = document.getElementById(cPrice);
	window.location=URL+"?page="+Page+"&cityid="+escape(CityID.value)+"&level="+escape(Level.value)+"&housename="+escape(HouseName.value)+"&price="+escape(Price.value)+"&gjz="+escape(Gjz.value);
}
