function validateform(max,adults,children) {
//PASS THROUGH BOXES
//var max=maxp;
	var success = true, tempString = '';
	var fieldprefix = '', offset = 0;
	for (i = 0; i < max; i++) {
		offset = i;
		if (adults > 0) { 
			if (i > (adults - 1)) { 
				fieldprefix = 'Child_';
				offset = (i - adults);
			}
		}
		
		var fieldpass=(i*6)+0;

		// "Title" field - empty value
		if (success) { eval("if(document.mailform."+fieldprefix+"Title_"+(offset+1)+".value == '') { alert('You must select a title for all passengers.'); document.mailform."+fieldprefix+"Title_"+(offset+1)+".focus(); success = false; } "); }

		// "First Name" field - empty value
		if (success) { eval("if(document.mailform."+fieldprefix+"FirstName_"+(offset+1)+".value == '') { alert('You must select a first name for all passengers.'); document.mailform."+fieldprefix+"FirstName_"+(offset+1)+".focus(); success = false; } "); }
		// "First Name" field - short value
		if (success) { eval("if(document.mailform."+fieldprefix+"FirstName_"+(offset+1)+".value.length < 2) { alert('You must enter a full first name for all passengers.'); document.mailform."+fieldprefix+"FirstName_"+(offset+1)+".focus(); success = false; } "); }
		// replace rogue characters
		if (success) {
			eval("tempString = document.mailform."+fieldprefix+"FirstName_"+(offset+1)+".value;");
			eval("document.mailform."+fieldprefix+"FirstName_"+(offset+1)+".value = tempString.replace(/[\.,@~+=*&]/g,'');");
			//eval("tempString = document.mailform.FirstName_"+(i+1)+".value;");
			//eval("document.mailform.FirstName_"+(i+1)+".value = tempString.replace(/\-/g,'');");
		}
	
		// "Surname" field - empty value
		if (success) { eval("if(document.mailform."+fieldprefix+"Surname_"+(offset+1)+".value == '') { alert('You must select a surname for all passengers.'); document.mailform."+fieldprefix+"Surname_"+(offset+1)+".focus(); success = false; } "); }
		// "Surname" field - short value
		if (success) { eval("if(document.mailform."+fieldprefix+"Surname_"+(offset+1)+".value.length < 2) { alert('You must enter a full surname for all passengers.'); document.mailform."+fieldprefix+"Surname_"+(offset+1)+".focus(); success = false; } "); }
		// replace rogue characters
		if (success) {
			eval("tempString = document.mailform."+fieldprefix+"Surname_"+(offset+1)+".value;");
			eval("document.mailform."+fieldprefix+"Surname_"+(offset+1)+".value = tempString.replace(/[\.,@~+=*&]/g,'');");
			//eval("tempString = document.mailform.Surname_"+(i+1)+".value;");
			//eval("document.mailform.Surname_"+(i+1)+".value = tempString.replace(/\-/g,'');");
		}

		// "DOB Day" field - empty value
		if (success) { eval("if(document.mailform."+fieldprefix+"Dob_Day_"+(offset+1)+".value == '') { alert('You must select a valid date of birth for all passengers.'); document.mailform."+fieldprefix+"Dob_Day_"+(offset+1)+".focus(); success = false; } "); }

		// "DOB Month" field - empty value
		if (success) { eval("if(document.mailform."+fieldprefix+"Dob_Month_"+(offset+1)+".value == '') { alert('You must select a valid date of birth for all passengers.'); document.mailform."+fieldprefix+"Dob_Month_"+(offset+1)+".focus(); success = false; } "); }

		// "DOB Year" field - empty value
		if (success) { eval("if(document.mailform."+fieldprefix+"Dob_Year_"+(offset+1)+".value == '') { alert('You must select a valid date of birth for all passengers.'); document.mailform."+fieldprefix+"Dob_Year_"+(offset+1)+".focus(); success = false; } "); }

		// lead passenger dob for first parse
		var minage=18;
		var d = new Date();
		var year = (d.getFullYear()-minage);
		if (success) { eval("if(document.mailform.Dob_Year_1.value > year) { alert('The Lead passenger must be over '+minage); document.mailform.Dob_Year_1.focus(); success = false; } "); }
	}
	return success;
}

function validateTerms() {
	var success = true;

	if (!document.getElementById('PassportSatisfied').checked){
		alert("You must check the box to confirm that all passengers have valid passports.");
		success = false;
	}
	
	//INSURANCE SECTION
	if (success) {
		var insuranceselect=-1;
/*
		for (i=0; i < document.getElementById('Ins').length; i++){
			if (document.getElementById('Ins')[i].checked){ insuranceselect = i;}
		}
*/
		if (document.getElementById('Ins1').checked){ insuranceselect = 0; }
		if (document.getElementById('Ins2').checked){ insuranceselect = 1; }
		if (insuranceselect==-1) {
			alert("You must choose an insurance option");
			success = false;
		}

		//If they select that they already have travel insurance then we need to ask who it is.
		if (success && insuranceselect==1) {
			if (document.getElementById('Insurer').value=="") {
				alert("Please confirm the name of your travel insurance provider.");
				document.getElementById('Insurer').focus();
				success = false;
			}
		}
	}
//
//	//if (document.mailform.visasatisfied.checked){
//	//}else{
//	//alert("You must check the box to confirm that all passengers satisfy the visa requirements for the countries //included in this holiday itinerary.");
//	//return false;
//	//}
//
//	if (document.mailform.havereaderrata.checked){
//	}else{
//		alert("You must check the box to confirm you have read the additional tour operators notes.");
//		return false;
//	}
//
	if (success && !document.getElementById('HaveReadAdditionalInformation').checked){
		alert("You must check the box to confirm you have read the additional information for this holiday.");
		success = false;
	}
	return success;
}


function CheckTheFields() {
alert("Test the script");
  if (document.getElementById('CTTPage_PageContent_FirstName').value==""){
alert("Sorry, the first name field is mandatory");
document.getElementById('CTTPage_PageContent_FirstName').focus();
return false;
}
  return true;
}


