/*
	this is for the booking calendar page
	/bookings/
*/
 function CheckBookingDate(theform,thefield,themessage)
{
	var theday_field_name=thefield+"_day";
	var themonth_field_name=thefield+"_month";
	var theyear_field_name=thefield+"_year";
	var theday=0;
	var themonth=0;
	var theyear=0;
	var day_is_booked=0;
	
	//get the parts of the day we are checking for 
	theday=theform[theday_field_name][theform[theday_field_name].selectedIndex].value;
	themonth=theform[themonth_field_name][theform[themonth_field_name].selectedIndex].value;
	theyear=theform[theyear_field_name][theform[theyear_field_name].selectedIndex].value;
	
	day_is_booked=CheckBookingYear(theform,theyear,themonth,theday);
	
	if (day_is_booked)
	{
		alert("We're sorry, your selection for " + themessage + " is currently booked, please select another date.");
		theform[theday_field_name][0].focus();
		return false;
	}
	
	return true;
}


function CheckBookingYear(theform,theyear,themonth,theday)
{
	var temp_string="month"+"_"+theyear+"_"+themonth;
	var the_month_list=theform[temp_string].value.split(",");
	var day_is_booked=false;
	
	//loop over the month list, checking to see if we have a match on the day
	for (var i=0;i<the_month_list.length;i++)
	{
		if (the_month_list[i]==theday)
		{
			day_is_booked=true;
			break;
		}
	}

	return day_is_booked;
}
