Event.observe(window, 'load', function() {

	var d = new Date();

	var curr_month = d.getMonth()+1;
	var curr_year = d.getFullYear();

	 Calendar.setup({
		 dateField : 'arrive_date',
		 triggerElement : 'calendarOpen_arrive',
		 setMinMonth: curr_month,
		 setMinYear: curr_year,
		 otherFieldToSet:'return_date',
		 checkType:'higher'
		 }),
	 Calendar.setup({
		 dateField : 'return_date',
		 triggerElement : 'calendarOpen_return',
		 setMinMonth: curr_month,
		 setMinYear: curr_year,
		 otherFieldToSet:'arrive_date',
		 checkType:'lower'
		 })

	new Autocomplete('query', {
		serviceUrl:'/hotels/autocomplete.php',
		minChars:2,
		maxHeight:212,
		width:212,
		onSelect: function(value, data){
			$('city_code').value = data;
		}
	  });
});

function activeRoom() {

	var n_room = $('room_count').value;
	if(n_room==1) {
		$('div_room_2').style.display='none';
		$('div_room_3').style.display='none';
	}
	else if(n_room==2) {
		$('div_room_2').style.display='';
		$('div_room_3').style.display='none';
	}
	else if(n_room==3) {
		$('div_room_2').style.display='';
		$('div_room_3').style.display='';
	}
}

function activeChild(room) {

	var n_child = $('child_count_'+room).value;
	if(n_child==1) {
		$('title_child_'+room).style.display='';
		$('child_count_'+room+'_1').style.display='';
	}
	else if(n_child==2) {
		$('title_child_'+room).style.display='';
		$('child_count_'+room+'_1').style.display='';
	}
	else if(n_child==3) {
		$('title_child_'+room).style.display='';
		$('child_count_'+room+'_1').style.display='';
	}
	else
	{
		$('child_count_'+room+'_1').style.display='none';
		$('title_child_'+room).style.display='none';
	}
}

function checkRoomType(room) {

	var room_type = $F('room_'+room);

	if(room_type!='DBL' & room_type!='TWN') {
		$('child_count_'+room+'_1').disabled=true;
		$('child_count_'+room).disabled=true;
	}
	else {
		$('child_count_'+room+'_1').disabled=false;
		$('child_count_'+room).disabled=false;
	}

	if(room_type=='SGL') {
		$('cot_count_'+room).disabled=true;
	}
	else {
		$('cot_count_'+room).disabled=false;
	}
}

function sendHotelForm() {

	$('frm_hotel').submit();
}
