function checkKey()
	{
	var keycode;
	if (window.event)
		{
		keycode = window.event.keyCode;
		}
	
	if (keycode == 13)
	   {
	   formCheck();
	   }
	}
	
function CheckDates(ArrivalYear,ArrivalMonth)
	{
	// set current selected day in temp variable
	var currentDay = document.SearchForm.dateArrival_Day.selectedIndex;
	// Clear dateArrival_Day select menu
	for (i = document.SearchForm.dateArrival_Day.length; i >= 0; i--)
		{
		document.SearchForm.dateArrival_Day.options[i] = null;
		}
	// Re-populate dateArrival_Day select menu
	DayOption = new Option('--',0,false,false);
	document.SearchForm.dateArrival_Day.options[0] = DayOption;
	if(ArrivalMonth==2)
		{
		if(isLeapYear(ArrivalYear))
			{
			for ( s = 30, d = 1; d<s; d++ )// 0-28, needs to translate to 1-29
				{
				DayOption = new Option(d,d,false,false);
				document.SearchForm.dateArrival_Day.options[d] = DayOption;
				}
			}
		else
			{
			for ( s = 29, d = 1; d<s; d++ )// 0-27, needs to translate to 1-28
				{
				DayOption = new Option(d,d,false,false);
				document.SearchForm.dateArrival_Day.options[d] = DayOption;
				}
			}
		}
	else
		{						
		if(ArrivalMonth==4 || ArrivalMonth==6 || ArrivalMonth==9 || ArrivalMonth==11)
			{
			for ( s = 31, d = 1; d<s; d++ )//0-29, needs to translate to 1-30
				{
				DayOption = new Option(d,d,false,false);
				document.SearchForm.dateArrival_Day.options[d] = DayOption;
				}			
			}			
		else
			{
			for ( s = 32, d = 1; d<s; d++ )
				{
				DayOption = new Option(d,d,false,false);
				document.SearchForm.dateArrival_Day.options[d] = DayOption;
				}
			}
		}
		// reset previously selected day
		if (currentDay<document.SearchForm.dateArrival_Day.options.length)
		{
			document.SearchForm.dateArrival_Day.selectedIndex=currentDay;
		}
	}
	
function determineLeapYear(year)
	{
	yearSelected = year;
	theseAreLeapYears = new Array("2008","2012","2016","2020","2024","2028");
	theseAreLeapYearsLength = 6;
	bitLeapYear = 0;
	for (j = 0; j<theseAreLeapYearsLength; j++)
		{
		if(yearSelected == theseAreLeapYears[j])
			{
			bitLeapYear = bitLeapYear+1;
			}
		}
	}
	
function isLeapYear(year) {
	return (year % 4 == 0)
}

function MonthsArray()
	{
	for(i=0; i<MonthsArray.arguments.length; i++)
		{
		this[i] = MonthsArray.arguments[i];
		}
	}
	
function propRating()
	{
		var stars = '';
		for (i=0;i< document.SearchForm.PropertyRating.length;i++)
		{
				if (document.SearchForm.PropertyRating[i].checked)
					stars = stars + document.SearchForm.PropertyRating[i].value + ',';
		}
		return stars;
	}

function formCheck()
	{
	var error = 0;
	var errMSG = "";
	
	/*
	if(!document.formTampered&&document.SearchForm.Destination.value.length>0) {
		location.href="/en/search/destination/"+document.SearchForm.Destination.value.replace(/[^\w\d]+/ig, "_")+"/";
		return false;
	}
	*/
	
	if (document.SearchForm.Destination.value == ""&&document.SearchForm.PropertyName.value == "")
		{
		error = 1; errMSG = errMSG + "\n" + errorMsgDestination;
		}
	//if (document.SearchForm.Destination.value.length > 0 && document.SearchForm.Destination.value.length < 4)
	//	{
	//	error = 1; errMSG = errMSG + "\n#Application.obj.Language.Show(Lang=Session.Language,Page=variables.thisPageName,Element='JS_DestLengthErrorMsg')#";
	//	}
	if (document.SearchForm.PropertyName.value.length > 0 && document.SearchForm.PropertyName.value.length < 3)
		{
		error = 1; errMSG = errMSG + "\n" + errorMsgProperty;
		}
	// check arrival date
	
	
	if ( (document.SearchForm.dateArrival_Year.options[document.SearchForm.dateArrival_Year.selectedIndex].value!='')  || (document.SearchForm.dateArrival_Day.options[document.SearchForm.dateArrival_Day.selectedIndex].value!='') )
		{
		if(document.SearchForm.dateArrival_Year.options[document.SearchForm.dateArrival_Year.selectedIndex].value=='')
			{
			error = 1; errMSG = errMSG + "\n" + "Incomplete details please check date.";
			}
		else if(document.SearchForm.dateArrival_Day.options[document.SearchForm.dateArrival_Day.selectedIndex].value=='0' && document.SearchForm.dateArrival_Year.options[document.SearchForm.dateArrival_Year.selectedIndex].value!='')
			{
			error = 1; errMSG = errMSG + "\n" + "Incomplete details please check date.";
			}
		var nowDateTime=new Date();
		var nowDate = new Date(nowDateTime.getYear(),nowDateTime.getMonth(),nowDateTime.getDate());
		var arrDate=new Date("20"+document.SearchForm.dateArrival_Year.value.split("_")[1],document.SearchForm.dateArrival_Year.value.split("_")[0]-1,document.SearchForm.dateArrival_Day.value);
		if (arrDate<nowDate)
			{
			error = 1; errMSG = errMSG + "\n" + errorMsgDate;
			}
		}
		
	//if errors send up alert
	if(error == 1 && errMSG != "")
		{
		alert(errMSG);
		}
	else
		{
		document.SearchForm.submit();
		}
	
	}
