<!--
// Global JavaScript Library
// Copyright 2007 CSI Manchester Ltd - All Rights Reserved

// Browser sniffer
var ns4 = (document.layers); 
var ie4 = (document.all && !document.getElementById);
var ie5 = (document.all && document.getElementById);
var ns6 = (!document.all && document.getElementById);

// START DEBUGGER
	function PageQuery(q) {
		if(q.length > 1) this.q = q.substring(1, q.length);
		else this.q = null;
		this.keyValuePairs = new Array();
		if(q) {
			for(var i=0; i < this.q.split("&").length; i++) {
				this.keyValuePairs[i] = this.q.split("&")[i];
			}
		}
		this.getKeyValuePairs = function() { return this.keyValuePairs; }
		this.getValue = function(s) {
			for(var j=0; j < this.keyValuePairs.length; j++) {
				if(this.keyValuePairs[j].split("=")[0] == s)
					return this.keyValuePairs[j].split("=")[1];
			}
			return false;
		}
		this.getParameters = function() {
			var a = new Array(this.getLength());
			for(var j=0; j < this.keyValuePairs.length; j++) {
				a[j] = this.keyValuePairs[j].split("=")[0];
			}
			return a;
		}
		this.getLength = function() { return this.keyValuePairs.length; }	
	}
	function queryString(key){
		var page = new PageQuery(window.location.search); 
		return unescape(page.getValue(key)); 
	}
	var bDebug = false;
	if(queryString('debug')=='true') {
		bDebug = true;
	}
// END DEBUGGER


var iRandomNumber=Math.floor(Math.random()*20)
function getFacts(id) {
	if(document.getElementById(id)) {
		//alert(iRandomNumber);
		var arFacts=new Array();
		arFacts[0]='Florida is -5 hours GMT.';
		arFacts[1]='Population of Florida is approx 17,789,864. ';
		arFacts[2]='There are 663 miles of beaches in the state of Florida.';
		arFacts[3]='Orlando attracts more visitors than any other amusement park destination in the U.S.';
		arFacts[4]='There are more than 370,000 hotel rooms in Florida.';
		arFacts[5]='The Walt Disney World Resort is located on a massive 30,000 acre site, yet only 7,100 acres are developed leaving a lot more room for future parks and attractions.';
		arFacts[6]='The Walt Disney World Resort employs more than 60,000 during busy holiday periods, each known as a Cast Member..';
		arFacts[7]='There are over 1,250 golf courses in Florida (more than any other state).';
		arFacts[8]='The Walt Disney World theme park was originally to be named Disney World, but when Walt Disney died in 1966, his brother Roy O. Disney took up the Disney World project & renamed it Walt Disney World. Roy stated "It\'s going to be Walt Disney World, so people will always know that this was Walt\'s dream".';
		arFacts[9]='Florida is known as the Sunshine State.';
		arFacts[10]='Kodak estimates that approximately 4 percent of all the amateur photographs taken in the United States are snapped at Walt Disney World Resort or Disneyland.';
		arFacts[11]='Mickey Mouse has more than 175 different costumes and Minnie Mouse has more than 200!';
		arFacts[12]='More than 46 million Cokes are consumed each year at Walt Disney World Resort. That goes with 7 million hamburgers, 5 million hot dogs, 5 million pounds of French fries and 265,000 pounds of popcorn.';
		arFacts[13]='There are 12,250 parking spaces on the Magic Kingdom parking lot, and by 10am each Christmas day they will all be full.';
		arFacts[14]='Each Christmas season, Walt Disney World is "decked" with more than four miles of garland, 1,000 wreaths and 300 Christmas trees. The tallest of the lot is a 96-foot tree in Disney\'s Contemporary Resort. In addition, six trees, which range in height from 50-80 feet, are placed in prominent positions in the theme parks.';
		arFacts[15]='The 550 workers at the Walt Disney World Laundry launder an average of 120,000 pounds each day. In addition, between 30,000 and 32,000 garments are dry-cleaned daily.';
		arFacts[16]='Walt Disney World Lost and Found is one busy place. Every day an average of 100 pairs of sunglasses are turned in at the Magic Kingdom alone. ';
		arFacts[17]='50,000 Sprinkler Heads and 2,000 miles of irrigation pipe are needed to water more than 3,500 acres of landscaping at Walt Disney World Resort.';
		arFacts[18]='450,000 mowing miles, to be exact -- that\'s what it takes to maintain 2,000 acres of turf. For the record, those mower miles are the equivalent of 18 trips around the earth at the equator. ';
		arFacts[19]='Christmas Day is the busiest day of the year at WDW.';
		document.getElementById(id).innerHTML = arFacts[iRandomNumber];
		iRandomNumber++;
		if(iRandomNumber>arFacts.length-1){iRandomNumber=0;}
		setTimeout("getFacts('"+id+"')",10000);
	}
}


function offerLink(sURL) {
	document.getElementById('divWebsite').style.display = 'none';
	document.getElementById('divPleasewait').style.display = '';
	location.href=sURL;
	document.getElementById('imgLoading').src='/images/pleasewait/pleasewait_loading.gif';
}


var bCarhire = false;

function changePackageSearch(airport,frm) {
	clearLocationList(frm.Packagelocationto);
	switch(airport) {
		case 'BFS':
		case 'BHX':
		case 'NCL':
			frm.Packagelocationto.options[frm.Packagelocationto.options.length] = new Option("Orlando Sanford", "SFB");
		break;
		default:
			//frm.Packagelocationto.options[frm.Packagelocationto.options.length] = new Option("Orlando International", "MCO");
			frm.Packagelocationto.options[frm.Packagelocationto.options.length] = new Option("Orlando Sanford", "SFB");
		break;
	}
}

function OpenSearch() {
	if(document.getElementById('DivLocations')) {
		showhidechangeoptions('show');
	}
}


var urlAddress = "http://www.Florida4Less.co.uk";
var pageName = "Florida4Less - Florida4Less holidays, flights, hotels, package holidays, cheap flights, hotels, Car hire";
function addToFavorites() {
	if (window.external) {
		window.external.AddFavorite(urlAddress,pageName) 
	}else{
		alert("Sorry! Your browser doesn't support this function."); 
	}
}



function checkPackageForm(sCurForm) {
	sSubmitForm = document.getElementsByName('frm'+sCurForm);
	sLocationID = document.getElementById('packageLocationTo'+sCurForm);
	var e = sSubmitForm.elements, m = '';
	if(sLocationID.value==''){m += '- Please select a destination.\n';}
	if(validateDate('startdate_d'+sCurForm,'startdate_m'+sCurForm,'startdate_y'+sCurForm)<=2) {m += '- Departure date is not valid.\n';}
	if(document.getElementById('rooms'+sCurForm)) {
		if(document.getElementById('rooms'+sCurForm).value=='0') {
			m+='- Please select no. of rooms\n';
		}
	}
	if(m) {
		OpenSearch();
		alert('The following errors occurred:\n\n' + m);
		return false;
	}else{
		sSubmitForm[0].submit();
	}	
}

function showRoomPlan(idForm) {
	if (idForm == null) {
		formid = '';
	}else{
		formid = idForm;
	}
	vRooms = parseInt(document.getElementById('rooms'+formid).value);
	oDonePressed = document.getElementById('donePressed'+formid);
	if(document.getElementById('roomPlan'+formid)) {
		oRoomPlan = document.getElementById('roomPlan'+formid);
	}
	if (!vRooms == 0) {
		if(document.getElementById('roomPlan'+formid)) {
			div_switch('roomPlan'+formid, true, true);
			div_switch('roomPlanFrame'+formid, true, true);
		}
		if(document.getElementById('donePressed'+formid)) {
			document.getElementById('donePressed'+formid).value = '0';
		}
	} else {
		if (oRoomPlan.style.display == 'block') {
			if(document.getElementById('roomPlan'+formid)) {
				div_switch('roomPlan'+formid, false, true);
				div_switch('roomPlanFrame'+formid, false, true);
			}
		} else {
			if (parseInt(oDonePressed.value) == 0) {
				alert("Select the number of rooms before choosing passengers");	
			} else {
				if(document.getElementById('donePressed'+formid)) {
					document.getElementById('donePressed'+formid).value = '0';
				}
			}
		}
	}
}

function hideRoomPlan(idForm) {
	if (idForm == null) {
		formid = '';
	}else{
		formid = idForm;
	}
	vRooms = parseInt(document.getElementById('rooms'+formid).value);
	if(document.getElementById('roomPlan'+formid)) {
		div_switch('roomPlan'+formid, false, true);
		div_switch('roomPlanFrame'+formid, false, true);
	}
	if(document.getElementById('donePressed'+formid)) {
		document.getElementById('donePressed'+formid).value = '1';
	}
}




function updatePax2(id, type, idForm) {
	if (idForm == null) {
		formid = '';
	}else{
		formid = idForm;
	}
	vPerson = parseFloat(document.getElementById('r'+id+type+formid).value);
	vAgeControl = parseFloat(document.getElementById('ageControl'+id+formid).value);
	var objAges = document.getElementById('trRoom'+id+'Ages'+formid);
	for(i=1;i<13;i++) {
		
		if(i>vPerson) {
			div_switch('r'+id+type+'_ages'+i+formid,false,true);
		}else{
			var personFound = 'yes'
			//div_switch('r'+id+type+'_ages'+i+formid,true,true);
			document.getElementById('r'+id+type+'_ages'+i+formid).style.display = 'block';
		}
	}
	if (personFound == 'yes') {
		if (document.getElementById('s'+type.toUpperCase()+'Ages'+id+formid).style.display == "none") {
			vAgeControl = vAgeControl + 1
		}
		//div_switch('s'+type.toUpperCase()+'Ages'+id+formid,true,true);
		document.getElementById('s'+type.toUpperCase()+'Ages'+id+formid).style.display = 'block';
	}else{
		if (document.getElementById('s'+type.toUpperCase()+'Ages'+id+formid).style.display != "none") {
			vAgeControl = vAgeControl - 1
		}
		div_switch('s'+type.toUpperCase()+'Ages'+id+formid,false,true);
	}
	if ((vAgeControl == 0) && (objAges)) {		
		div_switch('trRoom'+id+'Ages'+formid,false,true);	
	} else {
		if (objAges) {
			div_switch('trRoom'+id+'Ages'+formid,true,true);		
		}
	}
	document.getElementById('ageControl'+id+formid).value = vAgeControl;
		
}


function checkCruiseDate(id,value) {
	if(!value) {
		document.getElementById('startdate_mSearch').selectedIndex = 0;	
		document.getElementById('startdate_ySearch').selectedIndex = 0;
	}else{
		if(!document.getElementById('startdate_mSearch').value) {
			document.getElementById('startdate_mSearch').selectedIndex = 1;		
		}
		if(!document.getElementById('startdate_ySearch').value) {
			document.getElementById('startdate_ySearch').selectedIndex = 1;
		}
	}
}

function validatefrmContact(sFrm) {
	var e = '';
	if(sFrm.title.value=='-') {e+='- Please select a title\n'}
	if(!sFrm.firstname.value || sFrm.firstname.value=='- First name -') {e+='- Please enter your first name\n'}
	if(!sFrm.surname.value || sFrm.surname.value=='- Surname -') {e+='- Please enter your surname\n'}
	if(!/.+@[^.]+(\.[^.]+)+/.test(sFrm.email.value) || isValidField(sFrm.email.value,2) == false) {e+='- Please enter a valid email address\n'}
	//if(!sFrm.enquiry.value) {e+='- Please enter an enquiry\n'}
	if(e){
		alert(e);
		return false;		
	}else{
		return true;		
	}
}

function validatefrmCruise(sFrm) {
	var e = '';
	if(sFrm.title.value=='-') {e+='- Please select a title\n'}
	if(!sFrm.firstname.value || sFrm.firstname.value=='- First name -') {e+='- Please enter your first name\n'}
	if(!sFrm.surname.value || sFrm.surname.value=='- Surname -') {e+='- Please enter your surname\n'}
	if(sFrm.daytel.value.length < 8 && sFrm.eveningtel.value.length < 8 && sFrm.mobiletel.value.length < 8){e+='- Please add at least one valid contact number \n'}
	if(!/.+@[^.]+(\.[^.]+)+/.test(sFrm.email.value) || isValidField(sFrm.email.value,2) == false) {e+='- Please enter a valid email address\n'}
	if(!sFrm.prefEmail.checked&&!sFrm.prefPhone.checked){e+='- Please select how you want to be contacted\n'}
	if (!sFrm.duration.value) {e+='- Please select a duration -\n'}
	if(!sFrm.adults.value) {e+='- Please select no of adults\n'}
	if(!sFrm.enquiry.value) {e+='- Please enter an enquiry\n'}
	if(e){
		alert(e);
		return false;		
	}else{
		return true;		
	}
}

function validatefrmContact(sFrm) {
	var e = '';
	if(sFrm.title.value=='-') {e+='- Please select a title\n'}
	if(!sFrm.firstname.value || sFrm.firstname.value=='- First name -') {e+='- Please enter your first name\n'}
	if(!sFrm.surname.value || sFrm.surname.value=='- Surname -') {e+='- Please enter your surname\n'}
	if(!/.+@[^.]+(\.[^.]+)+/.test(sFrm.email.value) || isValidField(sFrm.email.value,2) == false) {e+='- Please enter a valid email address\n'}
	//if(!sFrm.enquiry.value) {e+='- Please enter an enquiry\n'}
	if(e){
		alert(e);
		return false;		
	}else{
		return true;		
	}
}

function validatefrmContactHotel(sFrm) {
	var e = '';
	var todaysDate = new Date();
	var testDate = new Date();
	if(sFrm.title.value=='-') {e+='- Please select a title\n'}
	if(!sFrm.firstname.value || sFrm.firstname.value=='- First name -') {e+='- Please enter your first name\n'}
	if(!sFrm.surname.value || sFrm.surname.value=='- Surname -') {e+='- Please enter your surname\n'}
	if(!/.+@[^.]+(\.[^.]+)+/.test(sFrm.email.value) || isValidField(sFrm.email.value,2) == false) {e+='- Please enter a valid email address\n'}
	if(!sFrm.prefEmail.checked&&!sFrm.prefPhone.checked){e+='- Please select how you want to be contacted\n'}
	//if(!sFrm.enquiry.value) {e+='- Please enter an enquiry\n'}
	//alert(sFrm.startdate_yHotel.value + " --- " + sFrm.startdate_mHotel.value + " --- " + sFrm.startdate_dHotel.value + " ---");
	testDate.setFullYear(sFrm.startdate_yHotel.value, (sFrm.startdate_mHotel.value - 1), sFrm.startdate_dHotel.value);
	if (testDate < todaysDate) {e+='- Please select a check in date that is not in the past -\n'}
	if (!sFrm.destination.value) {e+='- Please enter a destination -\n'}
	if (sFrm.starRating.value == '-') {e+='- Please select a star rating -\n'}
	if (sFrm.noAdults.value == '-') {e+='- Please select at least 1 adult -\n'}	
	if(e){
		alert(e);
		return false;		
	}else{
		return true;		
	}
}

function validatefrmContactFlight(sFrm) {
	if(document.getElementById('doWhatfrmFlight').value=='0'){
		var e = '';
		var todaysDate = new Date();
		var testDate = new Date();
		if(sFrm.title.value=='-') {e+='- Please select a title\n'}
		if(!sFrm.firstname.value || sFrm.firstname.value=='- First name -') {e+='- Please enter your first name\n'}
		if(!sFrm.surname.value || sFrm.surname.value=='- Surname -') {e+='- Please enter your surname\n'}
		if(!/.+@[^.]+(\.[^.]+)+/.test(sFrm.email.value) || isValidField(sFrm.email.value,2) == false) {e+='- Please enter a valid email address\n'}
		if(!sFrm.prefEmail.checked&&!sFrm.prefPhone.checked){e+='- Please select how you want to be contacted\n'}
		if((sFrm.freetext.value!=''&&sFrm.freetext.value!='- Type your destination -')&&(sFrm.destinationAp.value=='-'||sFrm.destinationAp.value=='')){e+='- Please lookup and select your destination airport\n'}
		testDate.setFullYear(sFrm.startdate_y.value, (sFrm.startdate_m.value - 1 ), sFrm.startdate_d.value);
		if (testDate < todaysDate) {e+='- Please select a departure date that is not in the past\n'}
		testDate.setFullYear(sFrm.enddate_y.value, (sFrm.enddate_m.value - 1), sFrm.enddate_d.value);
		if (testDate < todaysDate) {e+='- Please select a return date that is not in the past\n'}
		//if(!sFrm.returnFlight.value) {e+='- Please choose whether your flight is one way or a return\n'}
		bRadioSelected = false;
		for(var i = 0; i < sFrm.returnFlight.length; i++) {
			if(sFrm.returnFlight[i].checked==true) {
				bRadioSelected = true;	
			}
		}
		if(bRadioSelected==false){e+='- Please choose whether your flight is one way or a return\n'}
		if (sFrm.noAdults.value == '-') {e+='- Please select at least 1 adult\n'}	
		if(sFrm.airClass.value=='-') {e+='- Please select an air class\n'}
		if(e){
			alert(e);
			return false;		
		}else{
			return true;		
		}
	}else{
		return false;
	}
}

function validatefrmContactHoliday(sFrm) {
	if(document.getElementById('doWhatfrmHoliday').value=='0'){
		var e = '';
		var todaysDate = new Date();
		var testDate = new Date();
		if(sFrm.title.value=='-') {e+='- Please select a title\n'}
		if(!sFrm.firstname.value || sFrm.firstname.value=='- First name -') {e+='- Please enter your first name\n'}
		if(!sFrm.surname.value || sFrm.surname.value=='- Surname -') {e+='- Please enter your surname\n'}
		if(!/.+@[^.]+(\.[^.]+)+/.test(sFrm.email.value) || isValidField(sFrm.email.value,2) == false) {e+='- Please enter a valid email address\n'}
		if(!sFrm.prefEmail.checked&&!sFrm.prefPhone.checked){e+='- Please select how you want to be contacted\n'}
		testDate.setFullYear(sFrm.startdate_y.value, (sFrm.startdate_m.value - 1), sFrm.startdate_d.value);
		if (testDate < todaysDate) {e+='- Please select a departure date that is not in the past\n'}
		testDate.setFullYear(sFrm.enddate_y.value, sFrm.enddate_m.value, sFrm.enddate_d.value);
		if (testDate < todaysDate) {e+='- Please select a return date that is not in the past\n'}
		
		if (sFrm.noAdults.value == '-') {e+='- Please select at least 1 adult\n'}	
		if((sFrm.freetext.value!=''&&sFrm.freetext.value!='- Type your destination -')&&(sFrm.destinationAp.value=='-'||sFrm.destinationAp.value=='')){e+='- Please lookup and select your destination airport\n'}
		
		bRadioSelected = false;
		for(var i = 0; i < sFrm.returnFlight.length; i++) {
			if(sFrm.returnFlight[i].checked==true) {
				bRadioSelected = true;	
			}
		}
		if(bRadioSelected==false){e+='- Please choose whether your flight is one way or a return\n'}
		
		testDate.setFullYear(sFrm.startdate_y2.value, sFrm.startdate_m2.value, sFrm.startdate_d2.value);
		if (testDate < todaysDate) {e+='- Please select a check in date that is not in the past\n'}
		if (!sFrm.destination.value) {e+='- Please enter a destination\n'}
		if (sFrm.starRating.value == '-') {e+='- Please select a star rating\n'}
		
		
		
		
		if(e){
			alert(e);
			return false;		
		}else{
			return true;		
		}
	}else{
		return false;
	}
}

function validatefrmContactCarHire(sFrm) {
	var e = '';
	if(sFrm.title.value=='-') {e+='- Please select a title\n'}
	if(!sFrm.firstname.value || sFrm.firstname.value=='- First name -') {e+='- Please enter your first name\n'}
	if(!sFrm.surname.value || sFrm.surname.value=='- Surname -') {e+='- Please enter your surname\n'}
	if(!/.+@[^.]+(\.[^.]+)+/.test(sFrm.email.value) || isValidField(sFrm.email.value,2) == false) {e+='- Please enter a valid email address\n'}
	if(!sFrm.prefEmail.checked&&!sFrm.prefPhone.checked){e+='- Please select how you want to be contacted\n'}
	if (sFrm.noAdults.value == '-') {e+='- Please select at least 1 adult\n'}	
	if(e){
		alert(e);
		return false;		
	}else{
		return true;		
	}
}


function validatefrmContactCallBack(sFrm) {
	var e = '';
	if(sFrm.title.value=='-') {e+='- Please select a title\n'}
	if(!sFrm.firstname.value || sFrm.firstname.value=='- First name -') {e+='- Please enter your first name\n'}
	if(!sFrm.surname.value || sFrm.surname.value=='- Surname -') {e+='- Please enter your surname\n'}
	if(!sFrm.telSmall.value || sFrm.telSmall.value=='- Telephone number -') {e+='- Please enter a telephone contact number\n'}

	if(e){
		alert(e);
		return false;		
	}else{
		return true;		
	}
}

function validatefrmContactWebmaster(sFrm) {
	var e = '';
	if(sFrm.title.value=='-') {e+='- Please select a title\n'}
	if(sFrm.daytel.value.length < 8 && sFrm.eveningtel.value.length < 8 && sFrm.mobiletel.value.length < 8){e+='- Please add at least one valid contact number \n'}
	if(!sFrm.firstname.value || sFrm.firstname.value=='- First name -') {e+='- Please enter your first name\n'}
	if(!sFrm.surname.value || sFrm.surname.value=='- Telephone -') {e+='- Please enter your surname\n'}
	if(!/.+@[^.]+(\.[^.]+)+/.test(sFrm.email.value) || isValidField(sFrm.email.value,2) == false) {e+='- Please enter a valid email address\n'}
	if(!sFrm.message.value || sFrm.message.value=='- Message -') {e+='- Please enter your enquiry\n'}	
if(e){
		alert(e);
		return false;		
	}else{
		return true;		
	}
}

//topsearch
function showhidechangeoptions(type) {
	if(type == "show") {
		div_switch("DivLocations", true, true);
		div_switch("DivOptions", true, true);
		div_switch("DivShow", false, true);
		div_switch("DivHide", true, true);
	}
		if(type == "hide") {
		div_switch("DivLocations", false, true);
		div_switch("DivOptions", false, true);
		div_switch("DivShow", true, true);
		div_switch("DivHide", false, true);
	}
}


function searchSwitch(searchNum,searchType){
	for(i=0;i<5;i++) {
		div_switch('Search'+i,false,true);
	}
	div_switch('Search'+searchNum,true,true);

	switch (searchType){
	case 'f':
		//document.frmFlight.includecar.value = 'no';
		document.frmFlight.flexibility.disabled = false;
		div_switch('flexibilitydivFlight',true,false);
		div_switch('flexibilitytextFlight',true,false);
		div_switch('idLocationtoFlightFlights',true,true);
		//div_switch('idLocationtoFlightFlightCar',false,true)
	break;
	case 'fh':
		//document.frmFlightHotel.includecar.value = 'no';
		document.frmFlightHotel.flexibility.disabled = false;
		div_switch('flexibilitydivFlightHotel',true,false);
		div_switch('flexibilitytextFlightHotel',true,false);
	break;
	case 'fch':
		//document.frmFlightHotel.includecar.value = 'yes';
		document.frmFlightHotel.flexibility.disabled = true;
		div_switch('flexibilitydivFlightHotel',false,false);
		div_switch('flexibilitytextFlightHotel',false,false);
	break;
	case 'fc':
		//document.frmFlight.includecar.value = 'yes';
		document.frmFlight.flexibility.disabled = true;
		div_switch('flexibilitydivFlight',false,false);
		div_switch('flexibilitytextFlight',false,false);
		div_switch('idLocationtoFlightFlights',true,true);
		//div_switch('idLocationtoFlightFlightCar',true,true);
	break;
	case 'fv':
		//document.frmFlightHotel.includecar.value = 'no';
		document.frmFlightHotel.flexibility.disabled = false;
		div_switch('flexibilitydivFlightHotel',true,false);
		div_switch('flexibilitytextFlightHotel',true,false);
	break;
	case 'fcv':
		//document.frmFlightHotel.includecar.value = 'yes';
		//document.frmFlightHotel.flexibility.disabled = true;
		//div_switch('flexibilitydivFlightHotel',false,false);
		//div_switch('flexibilitytextFlightHotel',false,false);
	break;
	}
}

function detailsSwitch(id) {
	for(i=1;i<6;i++) {
		if(document.getElementById('idDetail'+i)) {
			document.getElementById('idDetail'+i).className	= Left(document.getElementById('idDetail'+i).className,10);
			div_switch('divDetail'+i,false,true);
		}
	}
	document.getElementById('idDetail'+id).className = document.getElementById('idDetail'+id).className + 'Over';
	div_switch('divDetail'+id,true,true);
}


function topTabs(id) {
	for(i=0;i<10;i++) {		
		document.getElementById('nav'+i).className = Left(document.getElementById('nav'+i).className,4);
	}
	document.getElementById('nav'+id).className = document.getElementById('nav'+id).className + 'Over';
}


function validateEshoutz(fId) {
	var m = '';
	if(!fId.name.value) {m+='- Please enter your name\n'}
	if(!/.+@[^.]+(\.[^.]+)+/.test(fId.email.value) || isValidField(fId.email.value,2) == false){m+='- Please enter a valid email address\n'}
	if(m){
		alert(m);
		return false;		
	}else{
		return true;		
	}
}

function navDesc (inav){
	document.getElementById('Words').innerHTML = description[inav];
}

function Left(str, n){
	if (n <= 0)
	    return "";
	else if (n > String(str).length)
	    return str;
	else
	    return String(str).substring(0,n);
}
function Right(str, n){
    if (n <= 0)
       return "";
    else if (n > String(str).length)
       return str;
    else {
       var iLen = String(str).length;
       return String(str).substring(iLen, iLen - n);
    }
}

// Attaches objects dependent on browser
function object_attach(id)
{
	var obj;
	if(ns4) obj = document.layers[id];
	else if(ie4) obj = document.all[id];
	else if(ie5 || ns6) obj = document.getElementById(id);
	return obj;
}

function openWindow(file,name,extra) {
	newwindow = window.open(file,name,extra);
	if (window.focus) {newwindow.focus()}
}

function OpenInfoWindow(sTitle, sText) {
	openWindow('/guides/popup_moreinfo.asp?title='+sTitle+'&text='+sText,'moreinfo','width=445,height=300,top=50,left=100,scrollbars=yes')
}

function loadimg(){
	
	//document.getElementById("loadingimg").innerHTML = '';
	if (document.getElementById("loadingimg")){ document.getElementById("loadingimg").innerHTML = '';}
	//alert('mmm');
	loadimg2();
}
function loadimg2(){
	//document.getElementById("loadingimg").innerHTML = '<img src="/images/searching-animation.gif" style="margin-top:30px;" loop="-1" start="fileopen"/>';
	if (document.getElementById("loadingimg")){ document.getElementById("loadingimg").innerHTML = '<img src="/images/searching-animation.gif" style="margin-top:30px;" loop="-1" start="fileopen"/>';}
}

function echeck(str) {
if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(str)){
	return (true)
}
return (false)
}
// Shows/hides div objects
function div_switch(id, bShow, bBlock)
{
	if(document.getElementById(id)){
		//if(id!='cars'){
			temp_Obj = object_attach(id);
			if(ns4)
			{
				if(bShow==true)
				{
					if(bBlock==true) { temp_Obj.display = ""; }
					else { temp_Obj.visibility = "show"; }
				}
				else
				{
					if(bBlock==true) { temp_Obj.display = "none"; }
					else { temp_Obj.visibility = "hide"; }
				}
			}
			else
			{
				if(bShow==true)
				{
					if(bBlock==true) { temp_Obj.style.display = ""; }
					else { temp_Obj.style.visibility = "visible"; }
				}
				else
				{
					if(bBlock==true) { temp_Obj.style.display = "none"; 
					}else{ 
						if(temp_Obj){
							//alert("Yes");
							temp_Obj.style.visibility = "hidden"; 
						}else{
							//alert("No");
						}
					}
				}
			}
		//}
	}
}

// Shows/hides div objects
function div_toggle(id){
	var obj = object_attach(id);
	if(obj.style.display == 'none'){
		obj.style.display = '';
	}else{
		obj.style.display = 'none';
	}
}



	


function popupDIV(bool,title,text,verth){
	var left = object_attach('paneLeft');
	var left2 = object_attach('paneLeft2');
	var right = object_attach('paneRight');
	var right2 = object_attach('paneRight2');
	left.style.height = verth
	left2.style.height = verth
	right.style.height = verth
	right2.style.height = verth
	writeInDiv(title,'title');
	writeInDiv(text,'notice');
	div_switch('paneBG',bool,true);
	div_switch('paneFore',bool,true);
	if (bool == true){
		hideSelects();
		}
		else if (bool == false)
		{
		showSelects();
		}
}

function hideSelects(){
   var elements = document.getElementsByTagName("select");
   for (i=0;i< elements.length;i++){
   elements[i].style.visibility='hidden';
   }
}
function showSelects(){
   var elements = document.getElementsByTagName("select");
   for (i=0;i< elements.length;i++){
      elements[i].style.visibility='visible';
   }
}
function showHideResultItems(id,sHideText,sShowText)
{
	var oObjLayer = document.getElementById("_divHideShow" + id);
	var oObjImg = document.getElementById("_imgHideShow" + id);
	var oObjHref = document.getElementById("_hrefHideShow" + id);
	if(!oObjLayer) return;
	if(oObjLayer.style.display == "none")
	{
		if(oObjImg){oObjImg.src = "/images/ico_minus.gif";}
		oObjHref.innerText = sHideText;
	}
	else
	{
		if(oObjImg){oObjImg.src = "/images/ico_plus.gif";}
		oObjHref.innerText = sShowText;
	}
	oObjLayer.style.display = (oObjLayer.style.display == "none"?"":"none");
}

function checkAge(min_age, max_age, dobd, dobm, doby)
{
	if(dobd.selectedIndex == 0 || dobm.selectedIndex == 0 || doby.selectedIndex == 0)
	{ return false; }
	else if(isDate(dobd[dobd.selectedIndex].value + '/' + dobm[dobm.selectedIndex].value + '/' + doby[doby.selectedIndex].value)==false)
	{ return false; }
	else
	{
		dtTodaysDate = new Date();
		iMonth = dtTodaysDate.getMonth();              
		iDay = dtTodaysDate.getDate();                 
		iYear = dtTodaysDate.getYear();
		if(iYear < 1000) { iYear += 1900; }
		iHour = dtTodaysDate.getHours();
		iMinute = dtTodaysDate.getMinutes();
		iSecond = dtTodaysDate.getSeconds();   
		iBdy = (doby[doby.selectedIndex].value);
		iBdm = (dobm[dobm.selectedIndex].value);
		iBdd = (dobd[dobd.selectedIndex].value);
		dtBDate = Date.UTC(iBdy,iBdm,iBdd,'1','0','0');
		if(iYear < 2000)
		{ dtCDate = Date.UTC(iYear,iMonth,iDay,iHour,iMinute,iSecond); }
		else
		{ dtCDate = Date.UTC(iYear,iMonth,iDay,iHour,iMinute,iSecond); }
		iAge = dtCDate - dtBDate + (1000*60*60*24*30);
		iAge_Years = parseInt(((((iAge/1000)/60)/60)/24)/365.25,10);
		iAge_Days = parseInt((((iAge/1000)/60)/60)/24,10);
		iAge_Hrs = parseInt(((iAge/1000)/60)/60,10);
		iAge_Mins = parseInt((iAge/1000)/60,10);
		iAge_Secs = parseInt(iAge/1000,10);
		if(iAge_Years > max_age || iAge_Years < min_age)
		{ return false; }
		else
		{ return true; }
	}
}

var dtCh= "/";
var minYear=1900;
var maxYear=2100;

function isInteger(s){
	var i;
    for (i = 0; i < s.length; i++){   
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    // All characters are numbers.
    return true;
}

function stripCharsInBag(s, bag){
	var i;
    var returnString = "";
    // Search through string's characters one by one.
    // If character is not in bag, append to returnString.
    for (i = 0; i < s.length; i++){   
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}

function daysInFebruary (year){
	// February has 29 days in any year evenly divisible by four,
    // EXCEPT for centurial years which are not also divisible by 400.
    return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 );
}


function DaysArray(n) {
	for (var i = 1; i <= n; i++) {
		this[i] = 31
		if (i==4 || i==6 || i==9 || i==11) {this[i] = 30}
		if (i==2) {this[i] = 29}
   } 
   return this
}

function isDate(dtStr){
	var daysInMonth = DaysArray(12)
	var pos1=dtStr.indexOf(dtCh)
	var pos2=dtStr.indexOf(dtCh,pos1+1)
	var strDay=dtStr.substring(0,pos1)
	var strMonth=dtStr.substring(pos1+1,pos2)
	var strYear=dtStr.substring(pos2+1)
	strYr=strYear
	if (strDay.charAt(0)=="0" && strDay.length>1) strDay=strDay.substring(1)
	if (strMonth.charAt(0)=="0" && strMonth.length>1) strMonth=strMonth.substring(1)
	for (var i = 1; i <= 3; i++) {
		if (strYr.charAt(0)=="0" && strYr.length>1) strYr=strYr.substring(1)
	}
	month=parseInt(strMonth)
	day=parseInt(strDay)
	year=parseInt(strYr)
	if (pos1==-1 || pos2==-1) { return false; }
	if (strMonth.length<1 || month<1 || month>12) { return false; }
	if (strDay.length<1 || day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month]) { return false; }
	if (strYear.length != 4 || year==0 || year<minYear || year>maxYear) { return false; }
	if (dtStr.indexOf(dtCh,pos2+1)!=-1 || isInteger(stripCharsInBag(dtStr, dtCh))==false) { return false; }
	return true;
}


function tabMouseOver(id,className)
{
	temp_Obj = object_attach(id);
	temp_Obj.className = className;
}

// Clears a text field only if the value matches what is passed in
function clearField(fId, sMatch, sChange)
{
	if(sChange == null) sChange = '';
	if(fId.value == sMatch)
	{ fId.value = sChange; }
}

// Cross-browser function to change the contents inside a DIV tag
function writeInDiv(text, id)
{
	if(typeof text != "undefined" && text != "") {
		//alert(id);
		//alert(text);
		if (document.getElementById)
		{ x = document.getElementById(id); if (x) x.innerHTML = text; }
		else if (document.all)
		{ x = document.all[id]; if (x) x.innerHTML = text;}
		else if (document.layers)
		{ x = document.layers[id]; text2 = '<p>' + text + '</p>'; if (x) { x.document.open();  x.document.write(text2); x.document.close() }; }
	}
}

// Shows popup calendar
function showCalendar3(calTitle,calTarget,calInit){
	var sExtra = '';
	if(calInit!=null) {
		if(Right(calTarget,7)=='enddate') {
			sExtra = "&nowdate=" + eval("document." + calTarget.replace("enddate","startdate") + "_d.value") + "/" + eval("document." + calTarget.replace("enddate","startdate") + "_m.value") + "/" + eval("document." + calTarget.replace("enddate","startdate") + "_y.value");
		}
		calendarWin=window.open("/includes/calendar.asp?initDate=" + eval("document." + calInit + "_d.value") + "/" + eval("document." + calInit + "_m.value") + "/" + eval("document." + calInit + "_y.value") + "&title=" + escape(calTitle) + "&field=" + escape(calTarget) + sExtra,"calendarWin","width=321,height=237,left=" + ((screen.width-220)/2) + ",top=" + ((screen.height-200)/2) + ",status=no,toolbar=no,menubar=no,scrollbars=no,resizable=no");
	}else{ 
		calendarWin=window.open("/includes/calendar.asp?initDate=" + eval("document." + calTarget + "_d.value") + "/" + eval("document." + calTarget + "_m.value") + "/" + eval("document." + calTarget + "_y.value") + "&title=" + escape(calTitle) + "&field=" + escape(calTarget),"calendarWin","width=321,height=237,left=" + ((screen.width-220)/2) + ",top=" + ((screen.height-200)/2) + ",status=no,toolbar=no,menubar=no,scrollbars=no,resizable=no");
	}
	
	if(!calendarWin.opener) calendarWin.opener=self;
}

// Opens a popup window
function openPopupWin(popUrl, popWid, popHgt, popScroll, popResize)
{
	popupWin=window.open(popUrl,"popupWin","width=" + popWid + ",height=" + popHgt + ",left=" + ((screen.width-popWid)/2) + ",top=" + ((screen.height-popHgt)/2) + ",status=no,toolbar=no,menubar=no,scrollbars=" + popScroll + ",resizable=" + popResize);
	if(!popupWin.opener) popupWin.opener=self;
	if (window.focus) {popupWin.focus()}
}

// Print page function
function printPage()
{
	if(window.print)
	{ window.print(); }
	else
	{ alert("Your browser does not support this feature!\nPlease try pressing CTRL + P to print this page."); }
}

// Bookmark page function
function bookmarkPage(url, title)
{
	if (document.all) { window.external.AddFavorite(url, title); } else if (window.sidebar) { window.sidebar.addPanel(title, url, ""); }
}

// Enquiry form validation
function checkEnquiryForm(fId)
{
	if(fId.enqEmail.value == '' || isValidField(fId.enqEmail.value,2) == false)
	{ alert("Please enter a valid email address before submitting your enquiry!"); fId.enqEmail.focus(); return false; }
	else if(fId.enqTitle.selectedIndex == 0)
	{ alert("Please select a title before submitting your enquiry!"); fId.enqTitle.focus(); return false; }
	else if(fId.enqFirstname.value == '' || fId.enqFirstname.value == '- Firstname -')
	{ alert("Please enter a firstname before submitting your enquiry!"); fId.enqFirstname.focus(); return false; }
	else if(fId.enqSurname.value == '' || fId.enqSurname.value == '- Surname -')
	{ alert("Please enter a surname before submitting your enquiry!"); fId.enqSurname.focus(); return false; }
	else if(fId.enqTelDay.value == '' && fId.enqTelEve.value == '' && fId.enqTelMob.value == '')
	{ alert("Please enter at least one contact telephone number!"); fId.enqTelDay.focus(); return false; }
	else if(fId.enqEnquiry.value == '')
	{ alert("Please enter a valid comment before submitting your enquiry!"); fId.enqEnquiry.focus(); return false; }
	else
	{ return true; }
}

// Checks if field contains valid characters
// 1 - Numeric Integer, 2 - Email, 3 - Numeric Decimals
function isValidField(sText, iType)
{
	if(iType==1)
	{ ValidChars = "0123456789"; }
	else if(iType==2)
	{ ValidChars = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ._-@"; }
	else if(iType==3)
	{ ValidChars = "0123456789."; }
	var isValid=true;
	var Char;
	for (i = 0; i < sText.length && isValid == true; i++) 
	{ 
		Char = sText.charAt(i); 
		if (ValidChars.indexOf(Char) == -1) 
		{ isValid = false; }
	}
	return isValid;
}
function formatCurrency(num)
{
	if(typeof num != "undefined") {
		num = num.toString().replace(/\$|\,/g,'');
		if(isNaN(num))
		num = "0";
		sign = (num == (num = Math.abs(num)));
		num = Math.floor(num*100+0.50000000001);
		cents = num%100;
		num = Math.floor(num/100).toString();
		if(cents<10)
		cents = "0" + cents;
		for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
		num = num.substring(0,num.length-(4*i+3))+','+
		num.substring(num.length-(4*i+3));
		return (((sign)?'':'-') + '&pound;' + num + '.' + cents);
	}
}
function checkFormPaxTitles(sErrTxt)
{
	oTitleElements = document.getElementsByTagName("select")
	for (i = 0; i < oTitleElements.length; i++)
	{
		if(oTitleElements.item(i).id.indexOf("title") == 0)
		{
			if(oTitleElements.item(i).selectedIndex == 0)
			{ alert(sErrTxt); oTitleElements.item(i).focus(); return false; break; }
		}
	}
	return true;
}
function checkFormFieldSelectedIndex(sFieldName, sErrTxt)
{
	oTitleElements = document.getElementsByTagName("select")
	for (i = 0; i < oTitleElements.length; i++)
	{
		if(oTitleElements.item(i).id.indexOf(sFieldName) == 0)
		{
			if(oTitleElements.item(i).selectedIndex == 0)
			{ alert(sErrTxt); oTitleElements.item(i).focus(); return false; break; }
		}
	}
	return true;
}
function checkFormFieldValue(sFieldName, sDefaultVal, sErrTxt, iMinLen)
{
 if(iMinLen==undefined || iMinLen==null) { iMinLen = 1; }
 oFormElements = document.getElementsByTagName("input")
 for (i = 0; i < oFormElements.length; i++)
 {
  if(oFormElements.item(i).id.indexOf(sFieldName) == 0)
  {
   if(oFormElements.item(i).value == '' || oFormElements.item(i).value == sDefaultVal || oFormElements.item(i).value.length < iMinLen || (sFieldName == 'surname' && oFormElements.item(i).value.indexOf(' ') > -1))
   { alert(sErrTxt); oFormElements.item(i).focus(); return false; break; }
  }
 }
 oFormElements = document.getElementsByTagName("textarea")
 for (i = 0; i < oFormElements.length; i++)
 {
  if(oFormElements.item(i).id.indexOf(sFieldName) == 0)
  {
   if(oFormElements.item(i).value == '' || oFormElements.item(i).value == sDefaultVal)
   { alert(sErrTxt); oFormElements.item(i).focus(); return false; break; }
  }
 }
 return true;
}

function checkFormFieldAges(sErrTxt)
{
	oFormElements = document.getElementsByTagName("select")
	for (i = 0; i < oFormElements.length; i++)
	{
		if(oFormElements.item(i).id.indexOf("dob") == 0 && oFormElements.item(i).id.lastIndexOf("d") == 3)
		{
			temp_Obj1 = object_attach(oFormElements.item(i).id);
			temp_Obj1a = Math.abs(temp_Obj1.idmin);
			temp_Obj1b = Math.abs(temp_Obj1.idmax);
			temp_Obj2 = object_attach('dobm' + temp_Obj1.id.substr(4,temp_Obj1.id.length-4));
			temp_Obj3 = object_attach('doby' + temp_Obj1.id.substr(4,temp_Obj1.id.length-4));
			if(checkAge(temp_Obj1a, temp_Obj1b, temp_Obj1, temp_Obj2, temp_Obj3) == false)
			{ alert(sErrTxt + '\nPassenger ' + temp_Obj1.id.substr(4,temp_Obj1.id.length-4) + ' is out of the acceptable age range (' + temp_Obj1a + '-' + temp_Obj1b + 'yrs).'); temp_Obj1.focus(); return false; break; }
		}
	}
	return true;
}

function checkFormAdditionalFieldAges(sErrTxt)
{
	oFormElements = document.getElementsByTagName("select")
	for (i = 0; i < oFormElements.length; i++)
	{
		if(oFormElements.item(i).id.indexOf("CarDriverAddDOBD1") == 0)
		{
			
			temp_Obj1 = object_attach(oFormElements.item(i).id);
			temp_Obj1a = Math.abs(temp_Obj1.idmin);
			temp_Obj1b = Math.abs(temp_Obj1.idmax);
			temp_Obj2 = object_attach('CarDriverAddDOBM1' + temp_Obj1.id.substr(17,temp_Obj1.id.length-17));
			temp_Obj3 = object_attach('CarDriverAddDOBY1' + temp_Obj1.id.substr(17,temp_Obj1.id.length-17));
			if(checkAge(temp_Obj1a, temp_Obj1b, temp_Obj1, temp_Obj2, temp_Obj3) == false)
			{ alert(sErrTxt + '\nAdditional Driver ' + temp_Obj1.id.substr(16,temp_Obj1.id.length-16) + ' is out of the acceptable age range (' + temp_Obj1a + '-' + temp_Obj1b + 'yrs).'); temp_Obj1.focus(); return false; break; }
		}
	}
	return true;
}

function checkFormSecondAdditionalFieldAges(sErrTxt)
{
	oFormElements = document.getElementsByTagName("select")
	for (i = 0; i < oFormElements.length; i++)
	{
		if(oFormElements.item(i).id.indexOf("CarDriverAddDOBD2") == 0)
		{
			
			temp_Obj1 = object_attach(oFormElements.item(i).id);
			temp_Obj1a = Math.abs(temp_Obj1.idmin);
			temp_Obj1b = Math.abs(temp_Obj1.idmax);
			temp_Obj2 = object_attach('CarDriverAddDOBM2' + temp_Obj1.id.substr(17,temp_Obj1.id.length-17));
			temp_Obj3 = object_attach('CarDriverAddDOBY2' + temp_Obj1.id.substr(17,temp_Obj1.id.length-17));
			if(checkAge(temp_Obj1a, temp_Obj1b, temp_Obj1, temp_Obj2, temp_Obj3) == false)
			{ alert(sErrTxt + '\nAdditional Driver ' + temp_Obj1.id.substr(16,temp_Obj1.id.length-16) + ' is out of the acceptable age range (' + temp_Obj1a + '-' + temp_Obj1b + 'yrs).'); temp_Obj1.focus(); return false; break; }
		}
	}
	return true;
}

function checkRadio(sFieldName)
{
	oFormElements = document.getElementsByTagName("input")
	for (i = 0; i < oFormElements.length; i++)
	{
		if(oFormElements.item(i).type == "radio" && oFormElements.item(i).name == sFieldName)
		{
			if(oFormElements.item(i).checked)
			{ return oFormElements.item(i).value; break; }
		}
	}
	return '';
}

//preload navigation images
nav1 = new Image()
nav1.src = "images/nav1_1.gif" 
nav2 = new Image()
nav2.src = "images/nav2_1.gif" 
nav3 = new Image()
nav3.src = "images/nav3_1.gif" 
nav4 = new Image()
nav4.src = "images/nav4_1.gif" 
nav5 = new Image()
nav5.src = "images/nav5_1.gif" 
nav6 = new Image()
nav6.src = "images/nav6_1.gif" 
nav7 = new Image()
nav7.src = "images/nav7_1.gif" 
search_button1 = new Image()
search_button1.src = "images/search_button1.gif" 
newsletter_button1 = new Image()
newsletter_button1.src = "images/newsletter_button1.gif" 

//swap background image
function swapImage(id,state){
		document.getElementById(id).style.backgroundImage = 'url(/images/'+id+state+'.gif)';
	}
// -->

function setSearchGrid(sClass, sSearch, sButtonID){
	var bDebug; bDebug = false;
	var bShow; bShow = false;
	var bDoNothing;
	
	var oClass
	oClass = sClass.split(",");
	
	sDebug = "sClass:" + sClass + "\n";
	sDebug = sDebug + "sSearch:" + sSearch + "\n";
	sDebug = sDebug + "sButtonID:" + sButtonID + "\n";
	
	if(bDebug) alert(sDebug);

	// Loop through all the fields on the page and only show the ones that are relevant to the button they
	// have clicked (ie Flight + Hotel)
	// This uses class names to choose the fields to show / hide
	var alltags=document.all? document.all : document.getElementsByTagName("*"); 
	for (i=0; i<alltags.length; i++){ 
		bShow = false;
		bDoNothing = false;
		if(alltags[i].id.lastIndexOf('rowCarhire')==0){
			bDoNothing = true;
		}else{
			for(x=0; x<oClass.length; x++){	
				if(sClass=='ALL'){
					if (alltags[i].className.lastIndexOf('fieldCar')>=0 && bCarhire == false){
						bShow = false;
					}else if(alltags[i].className.substr(0, 5) == 'field'){
						bShow = true;
					}
				}else if (alltags[i].className.lastIndexOf(oClass[x])>=0){
					bShow = true;
				}
			}
		}

		
		if(bDoNothing == false){
			if(bShow == true){
				alltags[i].style.display = 'inline';
			}else if(alltags[i].className.substr(0, 5) == 'field'){
				alltags[i].style.display = 'none';
			}
		}
	} 
	
	sSearch = sSearch.substr(0,1).toUpperCase() + sSearch.substr(1,sSearch.length);
	
	if(document.getElementById("search_type"))
		document.getElementById("search_type").value = sSearch;
	
	
	if(document.getElementById('Button1')){
		for (i=1; i<5; i++){
			if('Button'+i == sButtonID){
					document.getElementById('Button'+i).src='/images/search_'+sSearch.toLowerCase()+'1.gif';
					if(bDebug) alert("y:" + i);
			}else if('Button'+i != sButtonID){
					document.getElementById('Button'+i).src=document.getElementById('Button'+i).src.replace('1.gif', '0.gif');
					if(bDebug) alert("n:" + i);
			}
			if(sButtonID != ''){
				if(document.getElementById('Button'+i).src.lastIndexOf('/images/search_'+sSearch.toLowerCase()+'0.gif')>=0){
					document.getElementById('Button'+i).src='/images/search_'+sSearch.toLowerCase()+'1.gif';
				}
			}
		}
	}
	if(document.getElementById("rowCarhireON")) checkCarhire();
}
	
function mouseOut(sID, sSearch){
	if(document.getElementById("search_type").value != sSearch){
		document.getElementById(sID).src='/images/search_'+sSearch+'0.gif';
	}
}


//Validate the imput from Special offers dropdowns
function ValidateSpecialForm(FormID, WhichForm) {

	var theMessage = ""
	//alert(WhichForm);

	if (WhichForm == 1) {
		if (FormID.Closest_Resort.options[FormID.Closest_Resort.selectedIndex].value == "-") {
			theMessage = theMessage + "Please Select a Destination from the drop down list provided.\n";
		}
	} else {
		if (FormID.Category.options[FormID.Category.selectedIndex].value == "-") {
			theMessage = theMessage + "Please Select a Category from the drop down list provided.\n";
		}					
	}
	
	if (theMessage == "") {
		return true;
	
	} else {
	
		alert(theMessage);
		return false;
	}
	
}

function checkHO(){
	country = document.getElementById("lstDestCountriesho");
	lstDestinationLocationsho = document.getElementById("lstDestLocationsho");
	freetextbox = document.getElementById("freetext");
	
	if(lstDestinationLocationsho.options[lstDestinationLocationsho.selectedIndex].value == "-" && country.value != "US"){
		alert('Can you please complete your hotel criteria before searching?');
		return false;
	}else if(country.value == "US" && freetextbox.value.length < 3){
		alert('Can you please enter a US destination?');
		freetextbox.focus();
		return false;
	}else{
		return true;
	}
}
function checkFO(){
	DepDays = document.getElementById("depdaysfo")
	useDepDays = document.getElementById("usedepdaysfo")
	
	if (DepDays.options[DepDays.selectedIndex].value == "-" && useDepDays.value == 1){
		alert('Can you please complete your flight criteria before searching?');
		return false;
	}else{					
		return true;
	}
}
function checkCO(){
	sCar_pickup = document.getElementById("car_pickup");
	
	if (sCar_pickup.options[sCar_pickup.selectedIndex].value == "-"){
		alert('Can you please complete your carhire criteria before searching?');
		return false;
	}else{					
		return true;
	}
}
function checkFH(){
	DepDays = document.getElementById("depdaysfh")
	useDepDays = document.getElementById("usedepdaysfh")
	
	if (DepDays.options[DepDays.selectedIndex].value == "-" && useDepDays.value == 1){
		alert('Can you please complete your Flight & Hotel criteria before searching?');
		return false;
	}else{					
		return true;
	}
}

function formatCurrency(num){
	if(typeof num != "undefined") {
		num = num.toString().replace(/\$|\,/g,'');
		if(isNaN(num))
		num = "0";
		sign = (num == (num = Math.abs(num)));
		num = Math.floor(num*100+0.50000000001);
		cents = num%100;
		num = Math.floor(num/100).toString();
		if(cents<10)
		cents = "0" + cents;
		for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
		num = num.substring(0,num.length-(4*i+3))+','+
		num.substring(num.length-(4*i+3));
		return (((sign)?'':'-') + '&pound;' + num + '.' + cents);
	}
}


function checkContactForm(fId, travelModule)
{
	//alert("'" + fId.firstname.value + "'");
    if(fId.title.value == "" || fId.title.value == "-"){
		alert("Please enter a title"); 
		fId.title.focus(); 
		return false; 
	}
    else if(fId.firstname.value == ""  || fId.firstname.value == "- First name -"){
		alert("Please enter a first name"); 
		fId.firstname.focus(); 
		return false; 
	}
    else if(fId.surname.value == "" || fId.surname.value == "- Surname -"){ 
		alert("Please enter a surname"); 
		fId.surname.focus(); 
		return false; 
	}
     else if(fId.telephone.value == ""){ 
		alert("Please enter a telephone number"); 
		fId.telephone.focus(); 
		return false; 
	}	
	else if(!echeck(fId.email.value)){ 
		alert("Please enter a valid email address"); 
		fId.email.focus(); 
		return false; 
	}
	else if(fId.enquiry.value ==""){
		alert("Please enter your enquiry");
		fId.enquiry.focus();
		return false;	
	}
    else if(fId.dep_airport.value == "" && travelModule == 1){ 
		alert("Please enter a departure airport"); 
		fId.dep_airport.focus(); 
		return false; 
	}
    else if(fId.contactMethod.options[fId.contactMethod.selectedIndex].value == 0){ 
		alert("Please enter a contact method"); 
		fId.contactMethod.focus(); 
		return false; 
	}
}
function isNumeric(sText)
{
   var ValidChars = "0123456789.";
   var IsNumber=true;
   var Char;

 
   for (i = 0; i < sText.length && IsNumber == true; i++) 
      { 
      Char = sText.charAt(i); 
      if (ValidChars.indexOf(Char) == -1) 
         {
         IsNumber = false;
         }
      }
   return IsNumber;
   
   }
   
function insertOptionAt (select, option, index) {
    for (var i = select.options.length; i > index; i--)
      select.options[i] = select.options[i - 1];
    select.options[index] = option;
  }

function formatNumber(num,dec,thou,pnt,curr1,curr2,n1,n2) {
	var x = Math.round(num * Math.pow(10,dec));
	if (x >= 0) n1=n2='';var y = (''+Math.abs(x)).split('');
	var z = y.length - dec;
	if (z<0) z--;
	for(var i = z; i < 0; i++) y.unshift('0');
	y.splice(z, 0, pnt);
	while (z > 3) {
		z-=3; y.splice(z,0,thou);
	}
	var r = curr1+n1+y.join('')+n2+curr2;
	return r;
}

/* Start functions relating to MultipleRoomTypes */
function updateRooms(control, maxRooms, idForm) {
	if (idForm == null) {
		formid = '';
	}else{
		formid = idForm;
	}
	if (control) {
		var iRooms = parseInt(control.options[control.selectedIndex].value);
		if (!iRooms == 0) {
			
			for (var iRoom=1;iRoom<=maxRooms;iRoom++) {
				var obj = document.getElementById('trRoom'+iRoom+'Values'+formid)
				var obj2 = document.getElementById('trRoom'+iRoom+'Ages'+formid)
				vAgeControl = parseFloat(document.getElementById('ageControl'+iRoom+formid).value);
				if (obj) {
					if (iRoom > iRooms) {
						obj.style.display = 'none';
					} else {
						obj.style.display = '';
					}
				}			
				if (obj2) {
					if (iRoom > iRooms) {
						obj2.style.display = 'none';
					} else {
						if (!vAgeControl == 0) {
							obj2.style.display = '';
						}
					}
				}				
			}		
		}	
		//showRoomPlan(formid);
	}
}


function updatePax(maxPax, maxAdults, maxChild, maxInfant) {
	var oRooms = document.getElementById('rooms');
	var iPax = 0, iAdults = 0, iChildren = 0, iInfants = 0, iTotalAdults = 0, iTotalChildren = 0, iTotalInfants = 0;
	var paxOkay =  false;

	if (oRooms) {
		paxOkay = true;
		var iRooms = parseInt(oRooms.options[oRooms.selectedIndex].value);
		for (var iRoom=1;iRoom<=iRooms;iRoom++) {
			iAdults = 0;
			iChildren = 0;
			iInfants = 0;
			
			var objAdult = document.getElementById('r'+iRoom+'a');
			if (objAdult) { iAdults = parseInt(objAdult.options[objAdult.selectedIndex].value); }

			var objChild = document.getElementById('r'+iRoom+'c');
			if (objChild) { iChildren = parseInt(objChild.options[objChild.selectedIndex].value); }	

			var objInfant = document.getElementById('r'+iRoom+'i');
			if (objInfant) { iInfants = parseInt(objInfant.options[objInfant.selectedIndex].value); }
			
			iPax += iAdults + iChildren + iInfants;

			if (maxPax != -1) {
				if (iPax > maxPax) { alert('The maximum number of people allowed across all rooms is ' + maxPax); paxOkay = false;}
			}

			if (paxOkay && maxAdults != -1) {
				if (iAdults > maxAdults) { alert('The maximum number of adults allowed in room ' + iRoom + ' is ' + maxAdults); paxOkay = false; }
			}

			if (paxOkay && maxChild != -1) {
				if (iChildren > maxChild) { alert('The maximum number of children allowed in room ' + iRoom + ' is ' + maxChild); paxOkay = false; }
			} 

			if (paxOkay && maxInfant != -1) {
				if (iInfants > maxInfant) { alert('The maximum number of infants allowed in room ' + iRoom + ' is ' + maxInfant); paxOkay = false; }
			}
			
			if (iChildren > 0 || iInfants > 0) {
				//var obj = document.getElementById('trRoom'+iRoom+'Ages');	
				//if (obj) { 
				//	obj.style.display = 'block'; 
					for (var iChild=1;iChild<=maxChild;iChild++) {
						obj = document.getElementById('r'+iRoom+'c_ages'+iChild);
						if (obj) {
							if (iChild <= iChildren) { obj.style.display = 'block'; } else { obj.style.display = 'none'; }
						}
					}	

					obj = document.getElementById('sCAges'+iRoom);
					if (obj) {
						if (iChildren < 1) { obj.style.display = 'none'; } else { obj.style.display = 'block'; }
					}
					
					for (var iInfant=1;iInfant<=maxInfant;iInfant++) {
						obj = document.getElementById('r'+iRoom+'i_ages'+iInfant);
						if (obj) {
							if (iInfant <= iInfants) { obj.style.display = 'block'; } else { obj.style.display = 'none'; }
						}
					}			
					
					obj = document.getElementById('sIAges'+iRoom);
					if (obj) {
						if (iInfants < 1) { obj.style.display = 'none'; } else { obj.style.display = ''; }
					}
				//}
			/*} else {
				var obj = document.getElementById('trRoom'+iRoom+'Ages');
				if (obj) { obj.style.display = 'none'; }*/
			}
			
			if (iChildren < 1) {
				// Hide children
				for (var iChild=1;iChild<=maxChild;iChild++) {
					obj = document.getElementById('r'+iRoom+'c_ages'+iChild);
					if (obj) { obj.style.display = 'none'; }
				}	

				obj = document.getElementById('sCAges'+iRoom);
				if (obj) { obj.style.display = 'none'; }		
			}

			if (iInfants < 1) {
				// Hide infants
				for (var iInfant=1;iInfant<=maxInfant;iInfant++) {
					obj = document.getElementById('r'+iRoom+'i_ages'+iInfant);
					if (obj) { obj.style.display = 'none'; }
				}	

				obj = document.getElementById('sIAges'+iRoom);
				if (obj) { obj.style.display = 'none'; }		
			}
			
			iTotalAdults += iAdults
			iTotalChildren += iChildren
			iTotalInfants += iInfants
		}

		var objSeats = document.getElementById('seats_adult')
		if (objSeats && iAdults <= objSeats.options.length) { objSeats.options[iTotalAdults].selected = true; }
		var objSeats = document.getElementById('seats_child')
		if (objSeats && iChildren <= objSeats.options.length) { objSeats.options[iTotalChildren].selected = true; }
		var objSeats = document.getElementById('seats_infant')
		if (objSeats && iInfants <= objSeats.options.length) { objSeats.options[iTotalInfants].selected = true; }
	}
	
	return paxOkay;
}
function checkRadio(sFieldName)
{
	oFormElements = document.getElementsByTagName("input")
	for (i = 0; i < oFormElements.length; i++)
	{
		if(oFormElements.item(i).type == "radio" && oFormElements.item(i).name == sFieldName)
		{
			if(oFormElements.item(i).checked)
			{ return oFormElements.item(i).value; break; }
		}
	}
	return '';
}

function onChangeCarCountry(fId)
{
	div_switch('car_pickup', false, true);
	div_switch('car_pickup_loading', true, true);
	fId.pickup.selectedIndex = 0;
	fId.submit();
}

function updateAttractionPrices(iResult){
	oAdults = document.getElementById('Adult' + iResult);
	oChildren = document.getElementById('Child' + iResult);
	
	iAdults = parseInt(oAdults.options[oAdults.selectedIndex].value);
	iChildren = parseInt(oChildren.options[oChildren.selectedIndex].value);
	
	arPrice = document.getElementById('ticketPrices' + iResult).value.split(';');
	dPrice = (parseFloat(arPrice[0]) * iAdults) + (parseFloat(arPrice[1]) * iChildren);

	document.getElementById('price_pp' + iResult).innerHTML = (dPrice / (iAdults + iChildren)).toFixed(2);
	document.getElementById('price_full' + iResult).innerHTML = dPrice.toFixed(2);
}

function selectAirport(){
	sAirport = document.getElementById('multipleAirports').options[document.getElementById('multipleAirports').selectedIndex].value;
	if(sAirport.length < 3){
		alert('Before you can continue you must select an aiport');
	}else{
		document.frmSearching.airportto.value = sAirport;
		div_switch('searching',true,true);
		div_switch('confirm',false,true)
		document.frmSearching.submit();document.getElementById('imgLoading').src='/images/pleasewait/pleasewait_loading.gif';
	}
}

function selectPickupPoint(){
	sLocation = document.getElementById('multipleLocations').options[document.getElementById('multipleLocations').selectedIndex].value;
	if(!sLocation){
		alert('Before you can continue you must select a pick up point');
	}else{
		document.frmSearching.locationto.value = sLocation;
		div_switch('searching',true,true);
		div_switch('confirm',false,true)
		document.frmSearching.submit();document.getElementById('imgLoading').src='/images/pleasewait/pleasewait_loading.gif';
	}
}

function SwapOneWay(fId){
	for (var i=0; i < eval("document.frm" + fId + ".oneway").length; i++){
   		if(eval("document.frm" + fId + ".oneway")[i].checked){
      		oOneWayRadio = eval("document.frm" + fId + ".oneway")[i].value;
      	}
   	}

	if(oOneWayRadio == 'true'){
		div_switch('returndates' + fId,false,false);
		div_switch('returndatestext' + fId,false,false);
	}else{
		div_switch('returndates' + fId,true,false);
		div_switch('returndatestext' + fId,true,false);
	}
}

function grayOut(vis, options) {
	// Pass true to gray out screen, false to ungray
	// options are optional.  This is a JSON object with the following (optional) properties
	// opacity:0-100         // Lower number = less grayout higher = more of a blackout 
	// zindex: #             // HTML elements with a higher zindex appear on top of the gray out
	// bgcolor: (#xxxxxx)    // Standard RGB Hex color code
	// grayOut(true, {'zindex':'50', 'bgcolor':'#0000FF', 'opacity':'70'});
	// Because options is JSON opacity/zindex/bgcolor are all optional and can appear
	// in any order.  Pass only the properties you need to set.
	var options = options || {}; 
	var zindex = options.zindex || 100;
	var opacity = options.opacity || 70;
	var opaque = (opacity / 100);
	var bgcolor = options.bgcolor || '#000000';
	var dark=document.getElementById('darkenScreenObject');
	if (!dark) {
		// The dark layer doesn't exist, it's never been created.  So we'll
		// create it here and apply some basic styles.
		// If you are getting errors in IE see: http://support.microsoft.com/default.aspx/kb/927917
		var tbody = document.getElementsByTagName("body")[0];
		var tnode = document.createElement('div');           // Create the layer.
		tnode.style.position='absolute';                 // Position absolutely
		tnode.style.top='0px';                           // In the top
		tnode.style.left='0px';                          // Left corner of the page
		tnode.style.overflow='hidden';                   // Try to avoid making scroll bars            
		tnode.style.display='none';                      // Start out Hidden
		tnode.id='darkenScreenObject';                   // Name it so we can find it later
		tbody.appendChild(tnode);                            // Add it to the web page
		tbody.onclick="alert('')"
		dark=document.getElementById('darkenScreenObject');  // Get the object.
	}
	if (vis) {
		sSelectHide = 'none';
		// Calculate the page width and height 
		if( document.body && ( document.body.scrollWidth || document.body.scrollHeight ) ) {
			var pageWidth = document.body.scrollWidth+'px';
			var pageHeight = document.body.scrollHeight+'px';
		} else if( document.body.offsetWidth ) {
			var pageWidth = document.body.offsetWidth+'px';
			var pageHeight = document.body.offsetHeight+'px';
		} else {
			var pageWidth='100%';
			var pageHeight='100%';
		}   
		//set the shader to cover the entire page and make it visible.
		dark.style.opacity=opaque;                      
		dark.style.MozOpacity=opaque;                   
		dark.style.filter='alpha(opacity='+opacity+')'; 
		dark.style.zIndex=zindex;        
		dark.style.backgroundColor=bgcolor;  
		dark.style.width= pageWidth;
		dark.style.height= pageHeight;
		dark.style.display='block';				 
	} else {
		dark.style.display='none';
		sSelectHide = '';
	}
	oSelects = document.getElementsByTagName('select');
	for(x=0;x<oSelects.length;x++) {
		oSelects[x].style.display = sSelectHide;
	}
}
function ShowHomePageMap(vis){
	grayOut(vis);
	div_switch('HomepageMap',vis,true);
}
function ShowOrlandoMap(vis){
	grayOut(vis);
	div_switch('OrlandoMap',vis,true);
	document.getElementById('OrlandoMap').style.top = document.body.scrollTop;
}
function EnquireFromNoResultsXSL() {
	document.frmResults.action = '/contact.asp';
	document.frmResults.method = 'post';
	document.frmResults.submit();
}

function updateEnddate(sFormID) {
	iDuration = document.getElementById('noOfNights'+sFormID)[document.getElementById('noOfNights'+sFormID).selectedIndex].value
	var m_names = new Array("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec");
	sStartdate = document.getElementById('startdate'+sFormID).value;
	var dNewEndDate=new Date(sStartdate);
	dNewEndDate.setDate(dNewEndDate.getDate()+parseInt(iDuration));
	dNewEndDate = dNewEndDate.getDate() + " " + m_names[dNewEndDate.getMonth()] + " " + dNewEndDate.getFullYear()
	document.getElementById('enddate'+sFormID).value = dNewEndDate;
}

function setAnchor(sID, sStage){
    if (sStage == 'storeAnchor'){document.getElementById('resultAnchor').value = sID}
    if (sStage == 'addAnchor'){document.frmResults.action = document.frmResults.action + '#anchor' + document.getElementById('resultAnchor').value;}
}