﻿function $(str){return document.getElementById(str);}

function initHotel(){
	
	var newOption;
	for(var i=$("HotelID").options.length-1;i>=0;i--)
		$("HotelID").remove(i);

		var ConPerNum = document.getElementById("HotelID"); 
		var Context = document.createElement("option"); 

		//Contextoptions.add( new Option(ii,ii)
		ConPerNum.options[ConPerNum.options.length]=new Option("所有酒店","");

}

function setHotel(arr,para){
	newOption = document.createElement("option");
	newOption.text = arr[para].split("|")[1];
	newOption.value = arr[para].split("|")[0];
	$("HotelID").options[$("HotelID").options.length]=new Option(newOption.text,newOption.value);
	//$("HotelID").add(newOption);
}

function ChgHotel(str,paravar){
	var v_array = new Array();

	initHotel();

	var values = $("values").value;
	v_array = values.split(",");

	if(paravar == 'City'){
	  if(str != ''){
		for(var i = 0;i < v_array.length;i++){
			if(str==v_array[i].split("|")[3])
				setHotel(v_array,i);
		}
	  }
	}
}

function setCityID(id){
	if(id.value==""){
		alert('请选择城市！');
		$("CityID1").focus();
		return false
	}
	else
	{
		$("CityID").value = id.value;
		$("City").value = ($("CityID1").options[$("CityID1").selectedIndex].text).split(' ')[0];
		ChgHotel($("CityID").value,'City');
	}
}

//检测列表框元素重复
function chkDup(item){
	for ( i=0; i<$('BrandID').options.length;i++ ){
		//alert( item + " - " + list.options[i].value );
		if(item == $('BrandID').options[i].value ){
			return true;
		}
	}
	return false;
}