//检索页面初始化
/*function win_search_load()
{
	//清空省份列表
	clearSelect(document.forms[0].listProvinceName);
	//清空城市列表
    clearSelect(document.forms[0].listCityName);
	//省份，城市列表补白
	addOption(document.forms[0].listProvinceName, DEFAULT_PROVINCE, "-1");
	addOption(document.forms[0].listCityName, DEFAULT_CITY, "-1");
	//添加省份列表
	for(i = 0; i < ProvinceList.length; i++)
	{
      	var text  = ProvinceList[i].name;
      	var value = ProvinceList[i].id;
      	addOption(document.forms[0].listProvinceName, text, value);
    }
}
*/
//快捷城市列表单击
function rad_city_click()
{
	//重置省份，城市列表
	//document.forms[0].listProvinceName.selectedIndex = 0;
	//清空城市列表
   // clearSelect(document.forms[0].listCityName);
	//addOption(document.forms[0].listCityName, DEFAULT_CITY, "-1");
	//清空其他城市
	//var name = document.forms[0].txtCityName.value;
	var name = document.forms[0].txt_CityName.value;
	
	if(name.trim() != DEFAULT_CITY_NAME)
	{
		document.forms[0].txt_CityName.value = DEFAULT_CITY_NAME;
		document.forms[0].txtCityName.value = "";
	}
}

//添加城市
function add_city()
{
	//取得当前省份ID
	var provId = document.forms[0].listProvinceName.value;
    //初始化城市
    clearSelect(document.forms[0].listCityName);
    addOption(document.forms[0].listCityName, DEFAULT_CITY, "-1");
    
    if(provId != -1)
    {
		for(var i = 0; i < CityList.length; i++)
		{			
			if(CityList[i].id1 == provId)
			{
				addOption(document.forms[0].listCityName,CityList[i].name1,CityList[i].id2);	
			}		
		}
	}
	document.forms[0].listCityName.options[0].selected = true;
}

//选择省份
function list_province_change()
{
	//清空其他城市
	//var name = document.forms[0].txtCityName.value;
	//if(name.trim() != DEFAULT_CITY_NAME)
	//{
	//	document.forms[0].txtCityName.value = DEFAULT_CITY_NAME;
	//}
	var name = document.forms[0].txt_CityName.value;
	
	if(name.trim() != DEFAULT_CITY_NAME)
	{
		document.forms[0].txt_CityName.value = DEFAULT_CITY_NAME;
		document.forms[0].txtCityName.value = "";
	}
	
	//重置快捷城市
	var index = getRadioSelectedIndex(document.forms[0].radCityName);
	if( index != -1)
	{
		document.forms[0].radCityName[index].checked = false;
	}
	//添加城市
	add_city();
}

//选择城市
function list_city_change()
{
	//清空其他城市
	//var name = document.forms[0].txtCityName.value;
	//if(name.trim() != DEFAULT_CITY_NAME)
	//{
	//	document.forms[0].txtCityName.value = DEFAULT_CITY_NAME;
	//}
	var name = document.forms[0].txt_CityName.value;
	
	if(name.trim() != DEFAULT_CITY_NAME)
	{
		document.forms[0].txt_CityName.value = DEFAULT_CITY_NAME;
		document.forms[0].txtCityName.value = "";
	}
	
	//重置快捷城市
	var index = getRadioSelectedIndex(document.forms[0].radCityName);
	if( index != -1)
	{
		document.forms[0].radCityName[index].checked = false;
	}
}

//其他城市
function txt_city_focus()
{
	//if(document.forms[0].txtCityName.value == DEFAULT_CITY_NAME)
	//{
	//	document.forms[0].txtCityName.value = "";
	//}
	if(document.forms[0].txt_CityName.value == DEFAULT_CITY_NAME)
	{
		document.forms[0].txtCityName.value = "";
	}
	//重置省份，城市列表
	//document.forms[0].listProvinceName.selectedIndex = 0;
	//清空城市列表
   // clearSelect(document.forms[0].listCityName);
   // addOption(document.forms[0].listCityName, DEFAULT_CITY, "-1");
	//重置快捷城市
	var index = getRadioSelectedIndex(document.forms[0].radCityName);
	if( index != -1)
	{
		document.forms[0].radCityName[index].checked = false;
	}
}

function txt_city_blur()
{
	//var name = document.forms[0].txtCityName.value;
	var name = document.forms[0].txt_CityName.value;
	if(name.trim() == '' || name == DEFAULT_CITY_NAME)
	{
		document.forms[0].txt_CityName.value = DEFAULT_CITY_NAME;
		document.forms[0].txtCityName.value = "";
		document.forms[0].radCityName[0].checked = true;
	}
}

//入住日期的回调函数
function callback_date(date)
{
	document.forms[0].txtInDate.value = date;
	if(document.forms[0].txtOutDate.value.length == 0)
	{
		showCalendar('txtOutDate',false,'txtOutDate','txtInDate');
	}
}
//入住日期的回调函数—2
function callback_date_hotel(date)
{
	document.forms[0].hotelInDate.value = date;
	if(document.forms[0].hotelOutDate.value.length == 0)
	{
		showCalendar('hotelOutDate',false,'hotelOutDate','hotelInDate');
	}
}
function do_search_submit()
{
	//check
	document.forms[0].hidCityName.value = "";
	
	//var tCity = "" + document.forms[0].txtCityName.value;
	var tCity = "" + document.forms[0].txt_CityName.value;
	var nIndex = getRadioSelectedIndex(document.forms[0].radCityName);
	if( nIndex != -1)
	{
		document.forms[0].hidCityName.value = document.forms[0].radCityName[nIndex].value;
	}
	/*else if(document.forms[0].listCityName.selectedIndex > 0)
	{
		document.forms[0].hidCityName.value = document.forms[0].listCityName[document.forms[0].listCityName.selectedIndex].text;
	}*/
	else if( tCity.trim() != "" && tCity.trim() != DEFAULT_CITY_NAME)
	{
		document.forms[0].hidCityName.value = tCity.trim();
	}
	else
	{
		alert(NON_CITY);
		document.forms[0].txtCityName.focus();
		return;
	}
	
	sDate = document.forms[0].txtInDate.value;
	if(sDate.trim() == "")
	{
		alert(NON_INDATE);
		document.forms[0].txtInDate.focus();
		return;
	}
	
	if(!isDate(sDate))
	{
		alert(ERROR_IDDATE);
		document.forms[0].txtInDate.focus();
		return;
	}
	
	if(compareDate(sDate,document.forms[0].hidNowDate.value) < 0)
	{
		alert(INVALID_INDATE + document.forms[0].hidNowDate.value + "。");
		document.forms[0].txtInDate.focus();
		return;
	}
	
	if(compareDate(sDate,document.forms[0].hidLastDate.value) >= 0)
	{
		alert("本系统不支持" + document.forms[0].hidLastDate.value +"日之后的预订，\n如需预订请致电(010)85118522！");
		document.forms[0].txtInDate.focus();
		return;
	}
	
	sDate = document.forms[0].txtOutDate.value;
	if(sDate.trim() == "")
	{
		alert(NON_OUTDATE);
		document.forms[0].txtOutDate.focus();
		return;
	}
	
	if(!isDate(sDate))
	{
		alert(ERROR_OUTDATE);
		document.forms[0].txtOutDate.focus();
		return;
	}
	
	if(compareDate(sDate,document.forms[0].txtInDate.value) <= 0)
	{
		alert(INVALID_OUTDATE_1 + document.forms[0].txtInDate.value + "。");
		document.forms[0].txtOutDate.focus();
		return;
	}
	
	if(compareDate(sDate,document.forms[0].hidLastDate.value) > 0)
	{
		alert("本系统不支持" + document.forms[0].hidLastDate.value +"日之后的预订，\n如需预订请致电(010)85118522！");
		document.forms[0].txtOutDate.focus();
		return;
	}
	
	if(compareDate(sDate,document.forms[0].txtInDate.value) > 20*24*60*60*1000)
	{
		alert(INVALID_DATE);
		document.forms[0].txtOutDate.focus();
		return;
	}
	
	document.forms[0].hidInDate.value = "";
	document.forms[0].hidOutDate.value = "";
	document.forms[0].hidHotelName.value = "";
	document.forms[0].hidHotelLevel.value = "";
	document.forms[0].hidHotelPrice.value = "";
	
	document.forms[0].hidInDate.value    = document.forms[0].txtInDate.value;
	document.forms[0].hidOutDate.value   = document.forms[0].txtOutDate.value;
	document.forms[0].hidHotelName.value = document.forms[0].txtHotelName.value;
	
	//document.forms[0].hidRoomNum.value = document.forms[0].roomNum.value;
	//document.forms[0].hidPeopelNum.value = document.forms[0].peopleNum.value;
	
	var hotellevel = "";
	
	/*if(document.forms[0].chkStar0.checked)
		hotellevel = "1";
	else 
		hotellevel = "0";
	
	if(document.forms[0].chkStar1.checked)
		hotellevel = hotellevel + "1";
	else
		hotellevel = hotellevel + "0";
	
	if(document.forms[0].chkStar2.checked)
		hotellevel = hotellevel + "1";
	else
		hotellevel = hotellevel + "0";
	
	if(document.forms[0].chkStar3.checked)
		hotellevel = hotellevel + "1";
	else
		hotellevel = hotellevel + "0";
	
	if(document.forms[0].chkStar4.checked)
		hotellevel = hotellevel + "1";
	else
		hotellevel = hotellevel + "0";
	
	if(document.forms[0].chkStar5.checked)
		hotellevel = hotellevel + "1";
	else
		hotellevel = hotellevel + "0";*/
	var starLevel = document.forms[0].chkStar3.value;
    if(starLevel==""){
    	hotellevel="111111";
    }else if(starLevel=="0"){
    	hotellevel="100000";
    }else if(starLevel=="1"){
    	hotellevel="010000";
    }else if(starLevel=="2"){
    	hotellevel="001000";
    }else if(starLevel=="3"){
    	hotellevel="000100";
    }else if(starLevel=="4"){
    	hotellevel="000010";
    }else if(starLevel=="5"){
    	hotellevel="000001";
    }
	document.forms[0].hidHotelLevel.value = hotellevel;
	document.forms[0].hotelLevelUse.value = starLevel;
	
	var price = "";
	
	/*if(document.forms[0].chkPrice0.checked)
		price = "1";
	else
		price = "0";
	
	if(document.forms[0].chkPrice1.checked)
		price = price + "1";
	else
		price = price + "0";
	
	if(document.forms[0].chkPrice2.checked)
		price = price + "1";
	else
		price = price + "0";
	
	if(document.forms[0].chkPrice3.checked)
		price = price + "1";
	else
		price = price + "0";
	
	if(document.forms[0].chkPrice4.checked)
		price = price + "1";
	else
		price = price + "0";*/
	var tempPrice = document.forms[0].chkPrice0.value;
	if(tempPrice==""){
		price = "11111";
	}else if(tempPrice=="0"){
		price = "10000";
	}else if(tempPrice=="1"){
		price = "01000";
	}else if(tempPrice=="2"){
		price = "00100";
	}else if(tempPrice=="3"){
		price = "00010";
	}else if(tempPrice=="4"){
		price = "00001";
	}
	
	document.forms[0].hidHotelPrice.value = price;
	document.forms[0].hotelPriceUse.value = tempPrice;
	
	document.forms[0].action = "/citsonlineWeb/switchdo.do?prefix=/hotel&page=/hotelSearchResultC.do"; 
	document.forms[0].submit();
}

function list_zone_change()
{
	var zoneType = document.forms[0].listZoneType.value;
	
    //初始化区域
    clearSelect(document.forms[0].listZone);
    var defaultZone = "";
    if(zoneType == "2")
    {
    	defaultZone = DEFAULT_SHOP_AREA;
    }
    else if(zoneType == "3")
    {
    	defaultZone = DEFAULT_TRAFFIC_AREA;
    }
    else if(zoneType == "4")
    {
    	defaultZone = DEFAULT_TOUR_AREA;
    }
    else
    {
    	defaultZone = DEFAULT_AREA;
    }
    addOption(document.forms[0].listZone, defaultZone, "-1");
    
    if(zoneType == "2")
    {
		for(var i = 0; i < ShopAreaList.length; i++)
		{
			addOption(document.forms[0].listZone,ShopAreaList[i].name,ShopAreaList[i].id);
		}
	}
	else if(zoneType == "3")
	{
		for(var i = 0; i < TrafficAreaList.length; i++)
		{
			addOption(document.forms[0].listZone,TrafficAreaList[i].name,TrafficAreaList[i].id);
		}
	}
	else if(zoneType == "4")
	{
		for(var i = 0; i < TourAreaList.length; i++)
		{
			addOption(document.forms[0].listZone,TourAreaList[i].name,TourAreaList[i].id);
		}
	}
	else
	{
		for(var i = 0; i < AreaList.length; i++)
		{
			addOption(document.forms[0].listZone,AreaList[i].name,AreaList[i].id);
		}
	}
	document.forms[0].listZone.options[0].selected = true;
}

function do_research_submit()
{
	window.location.href = "/citsonlineWeb/switchdo.do?prefix=/hotel&page=/hotelSearchC.do"; 
}

function do_consearch_submit()
{	
	var cityID = document.forms[0].hotelCityID.value;
	
	if (cityID.trim()== "") {
		alert(NON_CITY);
		document.forms[0].hotel_CityID.focus();
		return;
	}
	document.forms[0].hidCityName.value = document.forms[0].hotel_CityID.value;
	
	sDate = document.forms[0].txtInDate.value;
	if(sDate.trim() == "")
	{
		alert(NON_INDATE);
		document.forms[0].txtInDate.focus();
		return;
	}
	
	if(!isDate(sDate))
	{
		alert(ERROR_IDDATE);
		document.forms[0].txtInDate.focus();
		return;
	}
	
	if(compareDate(sDate,document.forms[0].hidNowDate.value) < 0)
	{
		alert(INVALID_INDATE + document.forms[0].hidNowDate.value + "。");
		document.forms[0].txtInDate.focus();
		return;
	}
	
	if(compareDate(sDate,document.forms[0].hidLastDate.value) >= 0)
	{
		alert("本系统不支持" + document.forms[0].hidLastDate.value +"日之后的预订，\n如需预订请致电(010)85118522！");
		document.forms[0].txtInDate.focus();
		return;
	}
	
	sDate = document.forms[0].txtOutDate.value;
	if(sDate.trim() == "")
	{
		alert(NON_OUTDATE);
		document.forms[0].txtOutDate.focus();
		return;
	}
	
	if(!isDate(sDate))
	{
		alert(ERROR_OUTDATE);
		document.forms[0].txtOutDate.focus();
		return;
	}
	
	if(compareDate(sDate,document.forms[0].txtInDate.value) <= 0)
	{
		alert(INVALID_OUTDATE_1 + document.forms[0].txtInDate.value + "。");
		document.forms[0].txtOutDate.focus();
		return;
	}
	
	if(compareDate(sDate,document.forms[0].hidLastDate.value) > 0)
	{
		alert("本系统不支持" + document.forms[0].hidLastDate.value +"日之后的预订，\n如需预订请致电(010)85118522！");
		document.forms[0].txtOutDate.focus();
		return;
	}
	
	if(compareDate(sDate,document.forms[0].txtInDate.value) > 20*24*60*60*1000)
	{
		alert(INVALID_DATE);
		document.forms[0].txtOutDate.focus();
		return;
	}
	
	document.forms[0].hidInDate.value = "";
	document.forms[0].hidOutDate.value = "";
	document.forms[0].hidHotelName.value = "";
	document.forms[0].hidHotelLevel.value = "";
	document.forms[0].hidHotelPrice.value = "";
	document.forms[0].hidZoneType.value    = "";
	document.forms[0].hidZone.value        = "";
	document.forms[0].hidOrderBy.value     = "";
	
	document.forms[0].hidInDate.value = document.forms[0].txtInDate.value;
	document.forms[0].hidOutDate.value = document.forms[0].txtOutDate.value;
	document.forms[0].hidHotelName.value = document.forms[0].txtHotelName.value;
	
	var index = document.forms[0].listHotelLevel.value;
	var hotellevel = "";
	if(index==""){
		hotellevel = "111111";
	}else{
		for(var i = 0; i <=5; i++){
			if( index == i)
			{
				hotellevel = hotellevel + "1";
			}
			else
			{
				hotellevel = hotellevel + "0";
			}
		}
	}
	document.forms[0].hidHotelLevel.value = hotellevel;
	document.forms[0].hotelLevelUse.value = index;
	
	var index = document.forms[0].listHotelPrice.value;
	var hotelprice = "";
	if(index==""){
		hotelprice = "11111";
	}else{
		for(var i = 0; i <= 4; i++){
			if( index == i )
			{
				hotelprice = hotelprice + "1";
			}
			else
			{
				hotelprice = hotelprice + "0";
			}
		}
	}
	
	document.forms[0].hidHotelPrice.value = hotelprice;
	document.forms[0].hotelPriceUse.value = index;
	
	///新加的酒店位置==以前是商业区或行政区的一个，现在可以是两个同时
	document.forms[0].hidZoneType.value = "1";//document.forms[0].listZoneType.options[document.forms[0].listZoneType.selectedIndex].value;
	document.forms[0].hidZone.value     = document.forms[0].district.options[document.forms[0].district.selectedIndex].value;
	
	document.forms[0].hidShopAreaType.value = "2";//document.forms[0].listZoneType.options[document.forms[0].listZoneType.selectedIndex].value;
	document.forms[0].hidShopArea.value     = document.forms[0].sowntown.options[document.forms[0].sowntown.selectedIndex].value;
	
	
	
	document.forms[0].action = "/citsonlineWeb/switchdo.do?prefix=/hotel&page=/hotelSearchResultC.do"; 
	document.forms[0].submit();
}
/*
function do_zonesearch_submit()
{
	if(document.forms[0].listZone.selectedIndex < 1)
	{
		switch(document.forms[0].listZoneType.selectedIndex)
		{
			case 0:
				alert(NON_AREA);
			    return;
			case 1:
				alert(NON_SHOP_AREA);
			    return;
			case 2:
				alert(NON_TRAFFIC_AREA);
			    return;
			case 3:
				alert(NON_TOUR_AREA);
				return;
		}
	}
	document.forms[0].hidOrderBy.value      = "";
	document.forms[0].hidZoneType.value = document.forms[0].listZoneType.options[document.forms[0].listZoneType.selectedIndex].value;
	document.forms[0].hidZone.value     = document.forms[0].listZone.options[document.forms[0].listZone.selectedIndex].value;
	document.forms[0].action = "switchdo.do?prefix=/hotel&page=/hotelSearchResultC.do"; 
	document.forms[0].submit();
}
*/
function rad_orderby_click()
{
	document.forms[0].hidOrderBy.value  = getRadioValue(document.forms[0].radOrderBy);
	document.forms[0].action = "/citsonlineWeb/switchdo.do?prefix=/hotel&page=/hotelSearchResultC.do"; 
	document.forms[0].submit();
}

function hotel_map(picture,name)
{
	if(picture == "" || name == "")
	{
		return;
	}
	var action = "hotel/b2c/hotelMap.jsp?pname=" + picture + "&hname=" + name;
	window.open(action,null,'width=550,height=500,scrollbars=yes,resizable=yes');
}

function page_scroll(pageno)
{
	document.forms[0].action = "/citsonlineWeb/switchdo.do?prefix=/hotel&page=/hotelSearchResultC.do?PageNo=" + pageno; 
	document.forms[0].submit();
}

function list_pageno_change()
{
	var index = document.forms[0].listPageNo.selectedIndex;
	var value = document.forms[0].listPageNo.options[index].value;
	document.forms[0].action = "/citsonlineWeb/switchdo.do?prefix=/hotel&page=/hotelSearchResultC.do?PageNo=" + value; 
	document.forms[0].submit();
}

function hotelRoomInfo(hotelid,hotelShop)
{
	var para = "HotelID=" + hotelid + "&InDate=" + document.forms[0].hidInDate.value+"&OutDate="+document.forms[0].hidOutDate.value+"&Shop="+hotelShop;
	var url  = "/citsonlineWeb/switchdo.do?prefix=/hotel&page=/hotelRoomInfoC.do?" + para; 
	window.open(url,"roominfo",'width=710,height=380,location=no,toolbar=yes,scrollbars=yes,resizable=yes');
}

function hotelInfo(hotelid)
{	
	document.forms[0].hidHotelID.value = hotelid;
	
	document.forms[0].action = "/citsonlineWeb/switchdo.do?prefix=/hotel&page=/hotelInfoC.do"; 
	document.forms[0].submit();
}

function do_preorder(hotelid,roomid,paytype)
{
	document.forms[0].hidHotelID.value = hotelid;
	document.forms[0].hidRoomID.value  = roomid;
	document.forms[0].hidPayType.value = paytype;
	document.forms[0].action = "/citsonlineWeb/switchdo.do?prefix=/hotel&page=/hotelOrderC.do";
	document.forms[0].submit();
}

function pop_zancun(hotelid)
{
	var url  = "/citsonlineWeb/switchdo.do?prefix=/hotel&page=/hotelSaveC.do?hidHotelID=" + hotelid;
	window.open(url,null,'width=450,height=200,location=no,toolbar=yes,scrollbars=yes,resizable=yes');
}

function inputdate_submit()
{
	sDate = document.forms[0].hotelInDate.value;
	if(sDate.trim() == "")
	{
		alert(NON_INDATE);
		document.forms[0].hotelInDate.focus();
		return;
	}
	
	if(!isDate(sDate))
	{
		alert(ERROR_IDDATE);
		document.forms[0].hotelInDate.focus();
		return;
	}
	
	if(compareDate(sDate,document.forms[0].hidNowDate.value) < 0)
	{
		alert(INVALID_INDATE + document.forms[0].hidNowDate.value + "。");
		document.forms[0].hotelInDate.focus();
		return;
	}
	
	if(compareDate(sDate,document.forms[0].hidLastDate.value) >= 0)
	{
		alert("本系统不支持" + document.forms[0].hidLastDate.value +"日之后的预订，\n如需预订请致电(010)85118522！");
		document.forms[0].hotelInDate.focus();
		return;
	}
	
	sDate = document.forms[0].hotelOutDate.value;
	if(sDate.trim() == "")
	{
		alert(NON_OUTDATE);
		document.forms[0].hotelOutDate.focus();
		return;
	}
	
	if(!isDate(sDate))
	{
		alert(ERROR_OUTDATE);
		document.forms[0].hotelOutDate.focus();
		return;
	}
	
	if(compareDate(sDate,document.forms[0].hotelInDate.value) <= 0)
	{
		alert(INVALID_OUTDATE_1 + document.forms[0].hotelInDate.value +  "。");
		document.forms[0].hotelOutDate.focus();
		return;
	}
	
	if(compareDate(sDate,document.forms[0].hidLastDate.value) > 0)
	{
		alert("本系统不支持" + document.forms[0].hidLastDate.value +"日之后的预订，\n如需预订请致电(010)85118522！");
		document.forms[0].hotelOutDate.focus();
		return;
	}
	
	if(compareDate(sDate,document.forms[0].hotelInDate.value) > 20*24*60*60*1000)
	{
		alert(INVALID_DATE);
		document.forms[0].hotelOutDate.focus();
		return;
	}
	
	document.forms[0].hidInDate.value = document.forms[0].hotelInDate.value;
	document.forms[0].hidOutDate.value = document.forms[0].hotelOutDate.value;
	document.forms[0].action = "/citsonlineWeb/switchdo.do?prefix=/hotel&page=/hotelInfoC.do";
	document.forms[0].submit();
}

function hotelsubmit()
{
	//check
	document.forms[0].hidCityName.value = "";
	
	var tCity = "" + document.forms[0].txtCityName.value;
	if( tCity.trim() != "")
	{
		document.forms[0].hidCityName.value = tCity.trim();
	}
	else
	{
		alert(NON_CITY);
		document.forms[0].txtCityName.focus();
		return;
	}
	
	sDate = document.forms[0].txtInDate.value;
	if(sDate.trim() == "")
	{
		alert(NON_INDATE);
		document.forms[0].txtInDate.focus();
		return;
	}
	
	if(!isDate(sDate))
	{
		alert(ERROR_IDDATE);
		document.forms[0].txtInDate.focus();
		return;
	}
	
	if(compareDate(sDate,document.forms[0].hidNowDate.value) < 0)
	{
		alert(INVALID_INDATE + document.forms[0].hidNowDate.value + "。");
		document.forms[0].txtInDate.focus();
		return;
	}
	
	if(compareDate(sDate,document.forms[0].hidLastDate.value) >= 0)
	{
		alert("本系统不支持" + document.forms[0].hidLastDate.value +"日之后的预订，\n如需预订请致电(010)85118522！");
		document.forms[0].txtInDate.focus();
		return;
	}
	
	sDate = document.forms[0].txtOutDate.value;
	if(sDate.trim() == "")
	{
		alert(NON_OUTDATE);
		document.forms[0].txtOutDate.focus();
		return;
	}
	
	if(!isDate(sDate))
	{
		alert(ERROR_OUTDATE);
		document.forms[0].txtOutDate.focus();
		return;
	}
	
	if(compareDate(sDate,document.forms[0].txtInDate.value) <= 0)
	{
		alert(INVALID_OUTDATE_1 + document.forms[0].txtInDate.value + "。");
		document.forms[0].txtOutDate.focus();
		return;
	}
	
	if(compareDate(sDate,document.forms[0].hidLastDate.value) > 0)
	{
		alert("本系统不支持" + document.forms[0].hidLastDate.value +"日之后的预订，\n如需预订请致电010-85227698！");
		document.forms[0].txtOutDate.focus();
		return;
	}
	
	if(compareDate(sDate,document.forms[0].txtInDate.value) > 20*24*60*60*1000)
	{
		alert(INVALID_DATE);
		document.forms[0].txtOutDate.focus();
		return;
	}
	
	document.forms[0].hidInDate.value = "";
	document.forms[0].hidOutDate.value = "";
	document.forms[0].hidHotelName.value = "";
	document.forms[0].hidHotelLevel.value = "";
	document.forms[0].hidHotelPrice.value = "";
	
	document.forms[0].hidInDate.value    = document.forms[0].txtInDate.value;
	document.forms[0].hidOutDate.value   = document.forms[0].txtOutDate.value;
	document.forms[0].hidHotelName.value = document.forms[0].txtHotelName.value;
	
	var index = document.forms[0].listHotelLevel.selectedIndex;
	var hotellevel = "";
	for(var i = 1; i <= 6; i++)
	{
		if( index == i)
		{
			hotellevel = hotellevel + "1";
		}
		else
		{
			hotellevel = hotellevel + "0";
		}
	}
	document.forms[0].hidHotelLevel.value = hotellevel;
	
	var index = document.forms[0].listHotelPrice.selectedIndex;
	var hotelprice = "";
	for(var i = 1; i <= 5; i++)
	{
		if( index == i )
		{
			hotelprice = hotelprice + "1";
		}
		else
		{
			hotelprice = hotelprice + "0";
		}
	}
	document.forms[0].hidHotelPrice.value = hotelprice;
	document.forms[0].action = "/citsonlineWeb/switchdo.do?prefix=/hotel&page=/hotelSearchResultC.do"; 
	document.forms[0].submit();
}

function hotel_bbs(hotelid)
{
	var url  = "/citsonlineWeb/switchdo.do?prefix=/hotel&page=/hotelBBSC.do?hidHotelID=" + hotelid;
	window.location.href = url;
}
////////////////////////新增城市行政区商业区联动///start/////////////////////////
/* send the request to server */
function setDistrictAndSowntown() {

	var cityID = document.getElementById("hotelCityID").value;
	if (document.getElementById("hotel_CityID").value == "") {
		cityID = "";
	}
	//TODO
	var url = "/citsonlineWeb/switchdo.do?prefix=/hotel&page=/hotelCantonAndShop.do?actionType=queryDistrictAndSowntown&cityID="
			+ cityID;

	var req = createXMLHttpRequest1();
	req.onreadystatechange = responseAjax(req);
	req.open("post", url, true);
	req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	req.send(null);
}
/* get the XXMLHttpRequest(by different browser) */
function createXMLHttpRequest1() {
	var xmlreq = false;

	if (window.XMLHttpRequest) {
		// Mozilla browser
		xmlreq = new XMLHttpRequest();
	} else if (window.ActiveXObject) {
		// IE browser
		try {
			xmlreq = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e1) {
			try {
				xmlreq = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e2) {
				alert("The vision of your browser is too old!");
			}
		}
	}
	return xmlreq;
}
function responseAjax(req) {
	return function() {
		if (req.readyState == 4) {
			if (req.status == 200) {
				var root = req.responseXML.getElementsByTagName("root")[0];
				setDistrictSelect(root);
				setSowntownSelect(root);
			}
		}
	}
}
function setDistrictSelect(root) {
	var selDistirct = document.getElementById("district");
	removeElement(selDistirct);
	var districts = root.getElementsByTagName("districts")[0];
	var district = districts.getElementsByTagName("district");
	for (var i = 0; i < district.length; i++) {
		var id = district[i].getAttribute("id");
		var name = district[i].getAttribute("name");
		var option = new Option(name, id);
		selDistirct.add(option);
	}
}
function setSowntownSelect(root) {
	var selSowntown = document.getElementById("sowntown");
	removeElement(selSowntown);
	var sowntowns = root.getElementsByTagName("sowntowns")[0];
	var sowntown = sowntowns.getElementsByTagName("sowntown");
	for (var i = 0; i < sowntown.length; i++) {
		var id = sowntown[i].getAttribute("id");
		var name = sowntown[i].getAttribute("name");
		var option = new Option(name, id);
		selSowntown.add(option);
	}
}
function removeElement(element) {
	var lenObj = element.options.length;
	for (var i = lenObj - 1; i > 0; i--) {
		element.removeChild(element.options[i]);
	}
}
////////////////////////新增城市行政区商业区联动///start/////////////////////////
