var d = new Date();

function changedate()
{
	var thisDate = new String;
	var dateElem;
	
	thisDate = document.bookingStage1.checkindate.value;
	
	dateElem = thisDate.split("/");
	
	setDateDropdown(dateElem[0], dateElem[1], dateElem[2])
}

function setDateDropdown(day, month, year)
{
	document.bookingStage1.day.options[(day - 1)].selected = true;
	document.bookingStage1.month.options[(month - 1)].selected = true;
	document.bookingStage1.year.options[(year - 2005)].selected = true;
}

function setDate(dayDate, monthDate, yearDate)
{
	document.bookingStage1.checkindate.value = dayDate + "-" + literalMonth(monthDate) + "-" + yearDate;
}

function literalMonth(month)
{
	var shortMonth = new String();
	var numericMonth = new Number();

	numericMonth = month;

	if (numericMonth == 1) {shortMonth = "Jan"}
	if (numericMonth == 2) {shortMonth = "Feb"}
	if (numericMonth == 3) {shortMonth = "Mar"}
	if (numericMonth == 4) {shortMonth = "Apr"}
	if (numericMonth == 5) {shortMonth = "May"}
	if (numericMonth == 6) {shortMonth = "Jun"}
	if (numericMonth == 7) {shortMonth = "Jul"}
	if (numericMonth == 8) {shortMonth = "Aug"}
	if (numericMonth == 9) {shortMonth = "Sep"}
	if (numericMonth == 10) {shortMonth = "Oct"}
	if (numericMonth == 11) {shortMonth = "Nov"}
	if (numericMonth == 12) {shortMonth = "Dec"}

	return shortMonth;
}

function setGeographicDropdown(destination_id, attraction_id)
{
	var i;
	
	if (destination_id != "des_0")
	{
		for (i = 0; i < document.bookingStage1.destination_id.length; i++)
		{
			if (document.bookingStage1.destination_id[i].value == destination_id)
			{
				document.bookingStage1.destination_id[i].selected = true;
			}
		}
		fillRes(document.bookingStage1.destination_id);
		for (i = 0; i < document.bookingStage1.attraction_id.length; i++)
		{
			if (document.bookingStage1.attraction_id[i].value == attraction_id)
			{
				document.bookingStage1.attraction_id[i].selected = true;
			}
		}
	}
}

function checkForm(thisForm)
{
		
	if (isDate(thisForm.day.value, thisForm.month.value, thisForm.year.value) == false)
	{
		alert ("The date entered ("+thisForm.day.value+"/"+thisForm.month.value+"/"+thisForm.year.value+") is invalid. Please select a new date and press the 'Search' button.");
		
		return false;
	}
	
	var chosenDate = thisForm.day.value+" "+literalMonth(thisForm.month.value)+" "+thisForm.year.value;
	var date = new Date(chosenDate);
	var now = new Date();
	var diff = date.getTime() - now.getTime();
	var days = Math.floor(diff / (1000 * 60 * 60 * 24));
	if (days < 0) {
		alert("Please choose a date in the future");
		return false;
	}
	
	if (days < 3) {
		alert("The date you have selected is within three days, please phone us on 0870 705 5000");
		return false;
	}

{
    if (thisForm.destination_id.value == "des_0")
	{
       alert("Please select your destination.");
	   return false;
	}    
	
}  
	return true;
}