var d = new Date();

function changedate()
{
	var thisDate = new String;
	var dateElem;
	thisDate = document.tick1.bdate.value;
	dateElem = thisDate.split("/");
	setDateDropdown(dateElem[0], dateElem[1], dateElem[2])
}

function setDateDropdown(day, month, year)
{
	document.tick1.day.options[(day - 1)].selected = true;
	document.tick1.month.options[(month - 1)].selected = true;
	document.tick1.year.options[(year - 2005)].selected = true;
}

function CheckEndDate(dayDate, monthDate, yearDate, FormName)
{
	var form = eval("document." + FormName);
	//alert(form.bdate.value);
	form.bdate.value=dayDate + "-" + literalMonth(monthDate, form) + "-" + yearDate;
		if (FormName="terra_mitica_offer")
		{
			if (monthDate>=7)
			{
				alert ("The ticket offer you have selected is not valid after 30 June 2005");
				return false;
			}
		}
		return true;
	
}

function setDate(dayDate, monthDate, yearDate, FormName)
{
	var form = eval("document." + FormName);
	form.bdate.value=dayDate + "-" + literalMonth(monthDate, form) + "-" + yearDate;
}

function literalMonth(month, form)
{
	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.tick1.destination_id.length; i++)
		{
			if (document.tick1.destination_id[i].value == destination_id)
			{
				document.tick1.destination_id[i].selected = true;
			}
		}
		fillRes(document.tick1.destination_id);
		for (i = 0; i < document.tick1.attraction_id.length; i++)
		{
			if (document.tick1.attraction_id[i].value == attraction_id)
			{
				document.tick1.attraction_id[i].selected = true;
			}
		}
	}
}

function checkForm(thisForm)
{
	
//new

if	(thisForm.ticketbookA_0.value==0 && thisForm.ticketbookC_0.value==0)
{
	alert("You did not enter the number of tickets you require");
	return false;
}

if (thisForm.cont.value=='N')
{
	alert("The date you are trying to book is not available for this attraction");
	return false;
}
	
	//end
		
	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 < 5)
	{
		alert("The date you have selected is within five days, please phone us on 0870 705 5000");
		return false;
	}
	{
   
	
	}  
	return true;
}

