function validateSearchForm()
{
if (!isValidDate(document.forms[searchFormName].startDate.value))
	{
		alert('Please enter a valid departure date');
		return false;
	}
	var flightType;
	for (i=0; i < document.forms[searchFormName].flightType.length; i++)
	{
		if (document.forms[searchFormName].flightType[i].checked)
		{
			flightType = document.forms[searchFormName].flightType[i].value;
		}
	}
	if (flightType != 'oneway' && !isValidDate(document.forms[searchFormName].endDate.value))
	{
		alert('Please enter a valid return date');
		return false;
	}
	if (document.forms[searchFormName].startCity.value == '' || document.forms[searchFormName].endCity.value == '')
	{
		alert('Please choose your departure and destination.');
		return false;
	}
	if (document.forms[searchFormName].startCity.value == document.forms[searchFormName].endCity.value)
	{
		alert('Departure and arrival cities are the same. Please change your cities.');
		return false;
	}
	showLargeWait('altLargeWait');
	hideDropDowns('flights');
	document.searchForm.endCity.style.visibility='hidden'; 
	document.searchForm.startCity.style.visibility='hidden';
	window.open("process.html","window_flightsearch","toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes");
	document.searchForm.target = 'window_flightsearch';
	return true;
}
function validateSearchFormToNewWindow(){
	if (!isValidDate(document.forms[searchFormName].startDate.value))
	{
		alert('Please enter a valid departure date');
		return false;
	}
	var flightType;
	var today = new Date();
	var todayFormat = today.getDate()+"/"+eval(today.getMonth()+1) + "/" +today.getFullYear();
	flightType = document.forms[searchFormName].flightType.value;
	if (flightType != 'oneway' && !isValidDate(document.forms[searchFormName].endDate.value))
	{
		alert('Please enter a valid return date');
		return false;
	}
	if (document.forms[searchFormName].startCity.value == '' || document.forms[searchFormName].endCity.value == '')
	{
		alert('Please choose your departure and destination.');
		return false;
	}
	if (document.forms[searchFormName].startCity.value == document.forms[searchFormName].endCity.value)
	{
		alert('Departure and arrival cities are the same. Please change your cities.');
		return false;
	}
if (dateDiff(todayFormat , document.forms[searchFormName].startDate.value) < 0){
		alert('Departure date has to be greater than today.');
		return false;
	}
if (flightType != 'oneway' && dateDiff(document.forms[searchFormName].startDate.value, document.forms[searchFormName].endDate.value) < 0){
		alert('Departure date cannot be greater than the return date.');
		return false;
	}
	if (dateDiff(document.forms[searchFormName].startDate.value, document.forms[searchFormName].endDate.value) < 0){
		alert('Departure date cannot be greater than the return date.');
		return false;
	}
	if (flightType != 'oneway' && !dateCheck(document.forms[searchFormName].endDate.value)){
		alert('Travel dates should be within the next 11 months.');
		return false;
	}
if (flightType == 'oneway' && !dateCheck(document.forms[searchFormName].startDate.value)){
		alert('Travel dates should start within the next 11 months.');
		return false;
	}
<!-- Added by MD on 8/12 -->
/**
if ((document.forms[searchFormName].endCity.value == 'ADL' || document.forms[searchFormName].endCity.value == 'BNE' ||
				 document.forms[searchFormName].endCity.value == 'CNS' || document.forms[searchFormName].endCity.value == 'MEL' ||
				 document.forms[searchFormName].endCity.value == 'PER' || document.forms[searchFormName].endCity.value == 'SYD') 
				&&
				(document.forms[searchFormName].startCity.value != 'AKL' && document.forms[searchFormName].startCity.value != 'WLG' &&
				 document.forms[searchFormName].startCity.value != 'CHC'))
		{		
			alert('Flights to Australia are only available from Auckland, Wellington or Christchurch. Please search again.');
			return false;
		}
**/
<!-- End Addition -->
<!-- added on 1st Nov by MD -->
	varAdults = 0;
	varChildren = 0;
	varInfants = 0;
	varAdults = parseInt(document.forms[searchFormName].elements['numAdults'].value);
	varChildren = parseInt(document.forms[searchFormName].elements['numChildren'].value);
	varInfants = parseInt(document.forms[searchFormName].elements['numInfants'].value);
	if (!ValidateNotExceedTen(varAdults,varChildren,varInfants)){
		alert("Total Number of Passengers cannot exceed 10. For group booking please call 0800 FLIGHTS.");
		return false;
	}
	
	if (!ValidateChildrenLessThanAdults(varAdults,varChildren)){
		alert("The number of children cannot exceed 2 per adult.");
		return false;
	}
	
<!-- End Addition -->
/*	oFlightWin = window.open("process.html","window_flightsearch","toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes");
	document.forms[searchFormName].target = 'window_flightsearch';*/
	//showLargeWait('altLargeWait');
	//hideDropDowns('flights');
	//document.searchForm.endCity.style.visibility='hidden'; 
	//document.searchForm.startCity.style.visibility='hidden'; 
	return true;
}
var oFlightWin = null;
function PostForm(){
	if(oFlightWin){
		oFlightWin.focus();
	}
	document.forms[searchFormName].submit();
}
<!-- added on 1st Nov by MD -->
	function ValidateNotExceedTen(varAdults,varChildren,varInfants){
		varTotal = 0;
		varTotal = parseInt(varAdults) + parseInt(varChildren) + parseInt(varInfants);
		if (varTotal > 10){
			return false;
		}
		return true;
	}
	
	function ValidateChildrenLessThanAdults(varAdults,varChildren){
		varTot = parseInt(varAdults * 2);
		varChildren = parseInt(varChildren);
		if (varChildren > varTot){
			return false;
		}
		return true;
	}
	
<!-- End Addition -->
function validateReview()
{
	if (!document.forms[searchFormName].reviewAgree.checked)
	{
		alert('You must agree to the terms and conditions to continue');
		return false;
	}
	showLargeWait('altLargeWait');
	return true;
}
function validateBooking()
{
	var i=1;
	var invalidNames = "";
	
	while (document.forms[searchFormName].elements['paxAdult' + i + 'FirstName'])
	{
		if (!isValidName(document.forms[searchFormName].elements['paxAdult' + i + 'FirstName'].value)
		|| !isValidName(document.forms[searchFormName].elements['paxAdult' + i + 'Surname'].value))
		{
			invalidNames += "Adult " + i + "\n";
		}
		i++;
	}
	
	i=1;
	while (document.forms[searchFormName].elements['paxChild' + i + 'FirstName'])
	{
		if (!isValidName(document.forms[searchFormName].elements['paxChild' + i + 'FirstName'].value)
		|| !isValidName(document.forms[searchFormName].elements['paxChild' + i + 'Surname'].value))
		{
			invalidNames += "Child " + i + "\n";
		}
		i++;
	}
	
	i=1;
	while (document.forms[searchFormName].elements['paxInfant' + i + 'FirstName'])
	{
		if (!isValidName(document.forms[searchFormName].elements['paxInfant' + i + 'FirstName'].value)
		|| !isValidName(document.forms[searchFormName].elements['paxInfant' + i + 'Surname'].value))
		{
			invalidNames += "Infant " + i + "\n";
		}
		i++;
	}
	
	if (invalidNames.length > 0)
	{
		alert('The following passengers have invalid names:\n\n' + invalidNames);
		return false;
	}
	
	showLargeWait('altLargeWait');
	return true;
}
function validatedetailsFormFcl()
{
	if (!validateVehicleDetails())
	{
		return false;
	}
	
	if (document.forms[searchFormName].agree) {
		if (!document.forms[searchFormName].agree.checked) {
			alert(document.forms[searchFormName].termsAgreeErr.value);
			document.forms[searchFormName].agree.focus();
			return false;
		}
	}
	
	showLargeWait("altLargeWait");
	document.forms[searchFormName].submit();
}
function validatePayment()
{
	if (!isValidName(document.forms[searchFormName].contactFirstName.value)
	|| !isValidName(document.forms[searchFormName].contactSurname.value))
	{
		alert('Please enter a valid contact name');
		return false;
	}
	
	if (!checkEmail(document.forms[searchFormName].contactEmail.value))
	{
		alert('Please enter a valid email address for the booking contact');
		return false;
	}
	
	if (!isValidName(document.forms[searchFormName].cardHolderName.value))
	{
		alert('Please enter a valid card holder name');
		return false;
	}
	
	var cardRE = /[\d\s]+/;
	var cardNum = document.forms[searchFormName].cardNumber.value;
	var match = "" + cardNum.match(cardRE);
	if (match != cardNum) 
	{
		alert('Please enter a valid credit card number');
		return false;
	}
	
	if (!document.forms[searchFormName].readConditions.checked)
	{
		alert('You must agree to the booking conditions to continue');
		return false;
	}
	
	showLargeWait('altLargeWait');
	return true;
}
function validateRegister()
{
	if (isBlank('email'))
	{
		alert('Please enter a valid email address');
		return false;
	}
	if (isBlank('emailConfirmation'))
	{
		alert('Please enter a valid email confirmation address');
		return false;
	}
	if (isBlank('password'))
	{
		alert('Please enter a valid password');
		return false;
	}
	if (isBlank('passwordConfirmation'))
	{
		alert('Please enter a valid password confirmation');
		return false;
	}
	if (isBlank('firstName'))
	{
		alert('Please enter a valid first name');
		return false;
	}
	if (isBlank('surname'))
	{
		alert('Please enter a valid last name');
		return false;
	}
	if (!isBlank('phoneNumber') && isBlank('phoneAreaCode'))
	{
		alert('Please enter a valid area code');
		return false;
	}
	if (isBlank('phoneNumber') && isBlank('mobileNumber'))
	{
		alert('Please enter a valid phone number or mobile number');
		return false;
	}
	if (document.forms[searchFormName].termsConditionsAgree.checked == false)
	{
		alert('You must agree to the privacy policy and terms and conditions to continue');
		return false;
	}
	
	return true;
}
function setDepartureCookie(cityCode)
{
	document.cookie = "departureCity=" + escape(cityCode) + ";";
	window.opener.location.href = window.opener.location.pathname;
	window.close();
}

