var hot_city_check = 0;
var hot_disp_rooms = 8;

function process_hotel_form()
{
	return true;
}

function custom_hotel_loc()
{
	if (hot_city_check)
	{
		fetch_object('hot_city_0').checked = true;
		fetch_object('hot_city_' + hot_city_check).checked = false;
		hot_city_check = 0;
	}
}

function hotel_location(which, region, country)
{
	hot_city_check = which;

	if (region + country == '')
	{
		fetch_object('hot_city').focus();
	}
	else
	{
		fetch_object('hot_city').value = fetch_object('hot_address').value = fetch_object('hot_postal').value = '';
		fetch_object('hot_country').value = country;
		var regiond = fetch_object('hot_region');
		
		for (var x = 0; x < regiond.options.length; x++)
		{
			if (regiond.options[x].value == region)
			{
				regiond.selectedIndex = x;
				break;	
			}
		}
	}
}

function build_hot_rooms()
{
	var section = fetch_object('hot_people').style;
	var rooms = fetch_object('hot_rooms').value;

	if (rooms < 9)
	{
		section.display = 'block';

		while (hot_disp_rooms > rooms)
		{
			fetch_object('hot_room_' + (--hot_disp_rooms)).style.display = 'none';
		}
		while (hot_disp_rooms < rooms)
		{
			fetch_object('hot_room_' + (hot_disp_rooms++)).style.display = ( is_ie ? 'block' : 'table-row' );
		}
	}
	else
	{
		section.display = 'none';
	}
}

function amenity_useall()
{
	var amenities = fetch_tags(fetch_object('collapseobj_hotel_amenities'), 'input');

	if (amenities[0].checked)
	{
		for (var x = 1; x <= 9; x++)
		{
			amenities[x].checked = false;
		}
	}
	else
	{
		amenities[0].checked = true;
	}
}

function amenity_select(which)
{
	var last = 0;
	var checked = 0;
	var amenities = fetch_tags(fetch_object('collapseobj_hotel_amenities'), 'input');

	for (var x = 1; x <= 9; x++)
	{
		if (amenities[x].checked)
		{
			amenities[0].checked = false;
			checked++;
			last = x;
		}
	}
	if (checked == 0)
	{
		amenities[0].checked = true;
	}
	if (checked > 3)
	{
		fetch_object('hot_amen_' + which).checked = false;
		alert('Please select only three amenities.');
	}
}

function init_hotel_form()
{
	var temp = fetch_object('collapseobj_hotel_amenities');

	if (temp)
	{
		temp.style.display = 'none';
	}

	temp = fetch_object('collapseobj_hotel_address');

	if (temp)
	{
		temp.style.display = 'none';
	}

	temp = fetch_object('hot_people');

	if (temp)
	{
		temp.style.display = 'none';
	}

	var usedate = new Date();
	var datetime = new Date();
	var thecookie = ( fetch_cookie('hotel_form') ? fetch_cookie('hotel_form').split('|') : new Array('', '', '', '', '', build_timestamp(datetime.getMonth(), datetime.getDate(), 7), 7, 1) );

	fetch_object('hot_city').value = thecookie[0];
	fetch_object('hot_address').value = thecookie[1];
	
	temp = fetch_object('hot_region');
	
	for (var i = 0; i < temp.options.length; i++)
	{
		if (temp.options[i].value == thecookie[2])
		{
			temp.options[i].selected = true;
			break;
		}
	}

	fetch_object('hot_country').value = thecookie[3];
	fetch_object('hot_postal').value = thecookie[4];
	datetime.setTime(thecookie[5] * 1000);

	if (datetime > usedate)
	{
		usedate = datetime;
	}

	fetch_object('hot_check_month').selectedIndex = usedate.getMonth();
	build_drop_days('hot_check');
	fetch_object('hot_check_day').selectedIndex = usedate.getDate() - 1;
		
	fetch_object('hot_nights').selectedIndex = thecookie[6] - 1;
	fetch_object('hot_rooms').selectedIndex = thecookie[7] - 1;
	build_hot_rooms();	
}
