// Multi Hotel Quickbook Code
// (c) 2006 Avvio.com
// Author: Stefan Wendt
// XHTML verified
function getSingleHotel()
{
	hotel=document.forms["hotel_selector"].elements["hotel"].value;

	if ( hotel == "na" )
	{
		document.getElementById('hotel_selector_box').style.background='#FFAAAA';
		alert("Please select a hotel first.");
		return(false);
	}
	if ( ( hotel == "All Festival Hotels" ) )
	{
		document.getElementById('hotel_selector_box').style.background='#FFAAAA';
		alert("This option is only available for specific hotels. Do not select a group, please select a hotel!");
		return(false);
	}
	return(hotel);
}
function getHotel()
{
	hotel=document.forms["hotel_selector"].elements["hotel"].value;

	if ( hotel == "na" )
	{
		document.getElementById('hotel_selector_box').style.background='#FFAAAA';
		alert("Please select a hotel or a group first.");
		return(false);
	}
	
	return(hotel);
}
function submitQuickBook()
{
	hotel=getHotel();
	if ( hotel == false ) return false;

	if ( ( hotel == "All Festival Hotels" ) || ( hotel == "All Central Hotels" ) )
	{
		document.forms["quickbook_portal"].elements["ci_day"].value=document.forms["quickbook"].elements["ci_day"].value;
		document.forms["quickbook_portal"].elements["ci_ym"].value=document.forms["quickbook"].elements["ci_ym"].value;
		document.forms["quickbook_portal"].elements["nights"].value=document.forms["quickbook"].elements["nights"].value;
		document.forms["quickbook_portal"].elements["location"].value=hotel;
		document.forms["quickbook_portal"].elements["location_manual"].value=hotel;
		document.forms["quickbook_portal"].submit();
	} else
	{	
		document.forms["quickbook"].elements["hotel"].value=hotel;
		document.forms["quickbook"].submit();
	}
}
function submitPromotion()
{
	hotel=getSingleHotel();
	if ( hotel == false ) return false;
	
	document.forms["promotion"].elements["hotel"].value=hotel;
	document.forms["promotion"].submit();
}
function submitLogin()
{
	hotel=getSingleHotel();
	if ( hotel == false ) return false;
	
	document.forms["login"].elements["hotel"].value=hotel;
	document.forms["login"].submit();
}

function buildYears() {
	var select_month=new Array("Null", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec");
	var datenow=new Date();
	var month=datenow.getMonth()+1;
	var year=datenow.getFullYear();
	for(var i=1; i<=13; i++)
	{
		document.write("<option value='" + year + "-" + month + "'>" + select_month[month] + "-" + year + "</option>");
		if ( month >= 12 )
		{
			year++;
					month=1;
		} else
		{
			month++;
		}
	}

}

function setFormVals() {
	var datenow=new Date();
	var day=datenow.getDate();
	var month=datenow.getMonth()+1;         // starts at 0->jan
	var year=datenow.getFullYear();
	document.forms["quickbook"].elements["ci_day"].value=day;
	document.forms["quickbook"].elements["ci_ym"].value=year+"-"+month;
	document.forms["quickbook"].elements["nights"].value=2;
}
