<!--
var disableOnEnter = false
var sSpecialType
var sCurForm
var sCurSearchType
var sFlasher
var bFirstTimer = false;
var intervalAutoComplete;

function submitSearchForm(sFrm) {
	var m = '';
	if(document.getElementById('idDepartureAirport'+sFrm)) {
		if(!document.getElementById('idDepartureAirport'+sFrm).value || document.getElementById('idDepartureAirport'+sFrm).value=='-') {
			m+='Please confirm your departure airport\n';
		}
	}
	if(document.getElementById('idLocationto'+sFrm)) {
		if(!document.getElementById('idLocationto'+sFrm).value || document.getElementById('idLocationto'+sFrm).value=='-') {
			m+='Please confirm your destination\n';
		}
	}
	if(document.getElementById('idAirportto'+sFrm)) {
		if(!document.getElementById('idAirportto'+sFrm).value || document.getElementById('idAirportto'+sFrm).value=='-') {
			m+='Please select your destination airport\n';
		}
	}
	if(m) {
		alert(m);
	}else{
		document.forms['frm'+sFrm].submit();
	}
}

function DisableOnEnter(bValue) {
	disableOnEnter = bValue;
}

function OpenSearch() {
	if(document.getElementById('DivLocations')) {
		showhidechangeoptions('show');
	}
}

function checkAndRemoveReturnDate(sFrm) {
	if(document.forms['frm'+sFrm].oneway) {
		var sShow = '';
		if(document.forms['frm'+sFrm].oneway.checked!=true) {
			sShow = 'none';
		}
		if(document.getElementById('idReturnDateText'+sFrm)) {
			document.getElementById('idReturnDateText'+sFrm).style.display = sShow;
		}
		if(document.getElementById('idReturnDateField'+sFrm)) {
			document.getElementById('idReturnDateField'+sFrm).style.display = sShow;
		}
	}
}

function changeCarInclude(sFrm, iType) {
	var iFound = 0;
	sList = sFrm.includecar;
	for(x=0;x<sList.length;x++) {
		if(sList[x].checked == true && sList[x].value == 'yes') {
			iFound = 1
			sFrm.flexibility.disabled = true;
			if(sFrm.flexibility.value != '0' && sFrm.flexibility.value != '') {
				alert('By including car hire, date flexibility has been disabled.');
			}
			if(iType==1){
				sFrm.flexibility.selectedIndex = 0;
			}else{
				sFrm.flexibility.selectedIndex = 1;
			}
		}else{
			if(iFound == 0) {
				sFrm.flexibility.disabled = '';
				if(iType==1){
					sFrm.flexibility.selectedIndex = 3;
				}else{
					sFrm.flexibility.selectedIndex = 4;
				}
			}
		}
	}
}

function onEnterSearch(sFrmName,sSearchType){
	//if(event.keyCode==13&&document.getElementById('doWhat'+sFrmName).value==1){
	//	getLocations(document.getElementById('idFreetext'+sFrmName).value,sFrmName,sSearchType,'contact');
	//}
}

function showFullSearch() {
	if(document.getElementById('DivShow')) {
		showhidechangeoptions('show');	
	}
}

function validateLocationForm() {
	var startdate_d = '';
	var startdate_m = '';
	var startdate_y = '';
	sSubmitForm = document.getElementsByName('frm'+sCurForm);
	sLocationID = document.getElementById('idLocationto'+sCurForm);
	var e = sSubmitForm.elements, m = '';
	if(sLocationID.value=='-'){m += '- Please select a destination.\n';}
	arStartDate = document.getElementById('startdate'+sCurForm).value.split(' ');
	if(arStartDate.length!=3){
		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) {
		showFullSearch();
		switchLocationDivs('divLocation'+sCurForm);
		alert('The following errors occurred:\n\n' + m);
		return false;
	}else{
		sSubmitForm[0].submit();
	}	
}

function locationGoBack(sForm) {
	var sLocationID = document.getElementById('idLocationto'+sForm);
	var sFreetext = document.getElementById('idFreetext'+sForm);
	clearLocationList(sLocationID);
	div_switch('divLocationLoad'+sForm, false, true);
	div_switch('divLocation'+sForm, false, true);
	div_switch('divFreetext'+sForm, true, true);
	//sFreetext.focus(); sFreetext.select();
	
	if(document.getElementById('idConfirmedDestination'+sForm)) {
		document.getElementById('idConfirmedDestination'+sForm).style.display = 'none';
	}
	if(document.getElementById('idConfirmDestinationDDL'+sForm)) {
		document.getElementById('idConfirmDestinationDDL'+sForm).style.display = '';
	}
	if(document.getElementById('idConfirmDepartureAirport'+sForm)) {
		document.getElementById('idConfirmDepartureAirport'+sForm).style.display = 'none';
	}
	if(document.getElementById('idConfirmDepartureAirportDDL'+sForm)) {
		document.getElementById('idConfirmDepartureAirportDDL'+sForm).style.display = '';
	}
	clearInterval(intervalAutoComplete);
}

function switchLocationDivs(sDiv) {
	div_switch('divFreetext'+sCurForm, false, true);
	div_switch('divLocationLoad'+sCurForm, false, true);
	div_switch('divLocation'+sCurForm, false, true);
	div_switch(sDiv, true, true);
}

//Clear List
function clearLocationList(listElem) {
	if(listElem!=0){
		while(listElem.options.length > 0) {
			listElem.options[0] = null;
		}
		while(listElem.hasChildNodes()) {
			listElem.removeChild(listElem.firstChild);
		}
	}
}

//On Change Event

function HideAutoCompleteDiv(id) {
	if(document.getElementById(id)) {
		document.getElementById(id).style.display = 'none';
		// gets rid of iframe in ie6
		if(document.getElementById('DivShim')) {
			document.getElementById('DivShim').style.display = 'none';
			document.getElementById("DivShim").parentNode.removeChild(document.getElementById("DivShim"));
		}
		clearInterval(intervalAutoComplete);
	}	
}

function countPassengers() {
	var iNumPas = 0
	sSubmitForm = document.forms['frm'+sCurForm];
	if(sCurForm.indexOf('Flight')>-1 || sCurForm.indexOf('Package')>-1) {
		if(sCurSearchType=='Hotel') {
			for(x=1;x<parseFloat(sSubmitForm.rooms.value)+1;x++) {
				if(sSubmitForm.elements['r'+x+'a']) {
					iNumPas += parseFloat(sSubmitForm.elements['r'+x+'a'].value);
					iNumPas += parseFloat(sSubmitForm.elements['r'+x+'c'].value);
					iNumPas += parseFloat(sSubmitForm.elements['r'+x+'i'].value);
				}
			}
		}else{
			if(sSubmitForm.elements['seats_adult']) {
				iNumPas += parseFloat(sSubmitForm.elements['seats_adult'].value);
				iNumPas += parseFloat(sSubmitForm.elements['seats_child'].value);
				iNumPas += parseFloat(sSubmitForm.elements['seats_infant'].value);
			}
		}
	}
	return iNumPas;
}

function getLocations(sLocation,sForm,sSearchType,sType) {
	if(!disableOnEnter) {
		sSpecialType = sType;
		sCurForm = sForm;
		sCurSearchType = sSearchType;
		var sFreetextID = document.getElementById('idFreetext'+sCurForm);
		var bPopularDestinationSelected = false;
		var bFreetextDeparturePoint = false;
		var bAutoSuggestSelection = false;
		
		if(document.getElementById('idPopularDestinations'+sCurForm)) {
			if(document.getElementById('idPopularDestinations'+sCurForm).value != ''){
				var sLocationID = document.getElementById('idPopularDestinations'+sCurForm);
				sLocation = document.getElementById('idPopularDestinations'+sCurForm).options[document.getElementById('idPopularDestinations'+sCurForm).selectedIndex].text
				sLocation = sLocation.replace("-", "");
				sLocation = LTrim(sLocation);
				bPopularDestinationSelected=true;
			}else{
				var sLocationID = document.getElementById('idLocationto'+sCurForm);
			}
		}else{
			var sLocationID = document.getElementById('idLocationto'+sCurForm);
		}
		
		if(document.getElementById('idHdnLocationTo'+sCurForm)) {
			if(document.getElementById('idHdnLocationTo'+sCurForm).value != ''){
			    var sLocationID = document.getElementById('idHdnLocationTo'+sCurForm);
			    sLocation = document.getElementById('idFreetext'+sCurForm).value;
			    bAutoSuggestSelection=true;
			}
		}
		
		if(document.getElementById('idFreetextDep'+sCurForm)) { //checks whether site has freetext departure point searching fields present
		    bFreetextDeparturePoint = true;
		    var sFreetextDepID = document.getElementById('idFreetextDep'+sCurForm);
		    var sDepartureID = document.getElementById('idDepartureAirport'+sCurForm);
		    var sDeparture = sFreetextDepID.value.replace("'","")
		}else{
		    var sFreetextDepID = '';
		    var sDepartureID = '';
		    var sDeparture = '';
		}
		
		sLocation = sLocation.replace("'","");
		if(countPassengers()>9) {
			alert('You can only search for a maximum of 9 passengers when your search includes a flight');
		}else if(bFreetextDeparturePoint && (sFreetextDepID.value.length < 1 || sFreetextDepID.value == "- type your departure airport -")) { 
		    showFullSearch()
		    alert('Please enter your departure airport');
		    sFreetextDepID.focus(); //Without this check this code will break in IE7
		}else if((sFreetextID.value.length < 1 || sFreetextID.value == "- type your destination -" || sFreetextID.value == " - Type your destination here -") && !bPopularDestinationSelected) {
			showFullSearch()
			alert('Please enter your destination');
			if(document.getElementById('idFreetextSearch'+sCurForm).style.display != 'none'){sFreetextID.focus();} //Without this check this code will break in IE7
		}else if(sLocationID.value=='' || (bFreetextDeparturePoint && sDepartureID.value =='') || (bPopularDestinationSelected && sCurForm != 'Hotel') || (bAutoSuggestSelection && sCurForm != 'Hotel')) {
			intervalAutoComplete = setInterval("HideAutoCompleteDiv('as_idFreetext"+sForm+"')", 500);
			sURL = "/includes/search/LookupXML.asp?searchtype="+sCurSearchType+"&location=" + sLocation + "&departure=" + sDeparture + "&hund"
			if(sURL!='') {
				if(bDebug){
					if(confirm('Open '+ sURL)) {
						window.open(sURL);
					}
				}
				if (!bPopularDestinationSelected && !bAutoSuggestSelection) {clearLocationList(sLocationID);}
				setTimeout("loadLocationXMLDoc('"+sURL+"')", 100);
			}else{
				alert('No url defined');	
			}
		}else{
			validateLocationForm();	
		}
	}
}

function LTrim(value) {
	
	var re = /\s*((\S+\s*)*)/;
	return value.replace(re, "$1");
	
}

//XML Loader
function loadLocationXMLDoc(url) {
    // branch for native XMLHttpRequest object
	var processChange = processLocationChange
	
	if (window.XMLHttpRequest) {
        req = new XMLHttpRequest();
		req.onreadystatechange = processChange;
        req.open("GET", url, true);
        req.send(null);
    // branch for IE/Windows ActiveX version
    } else if (window.ActiveXObject) {
        req = new ActiveXObject("Microsoft.XMLHTTP");
        if (req) {
            req.onreadystatechange = processChange;
            req.open("GET", url, true);
            req.send();
        }
    }
}

function processLocationChange() {
	switchLocationDivs('divLocationLoad'+sCurForm);
	if(document.getElementById('idAirportto'+sCurForm)) {
		sLocationList = document.getElementById('idAirportto'+sCurForm);
		sLocationList.disabled='true';	
	}
	var sLocationID = document.getElementById('idLocationto'+sCurForm);
	
	if(document.getElementById('idDepartureAirport'+sCurForm)){
	    var bFreetextDeparturePoint = true
	    var sDepartureID = document.getElementById('idDepartureAirport'+sCurForm);
	}else{
	    var sDepartureID = ""
	}
	
	var sFreetext = document.getElementById('idFreetext'+sCurForm);
	if (req.readyState == 4)
	{
		if (req.status == 200)
		{
			xmldoc = req.responseXML.documentElement;
			
			//section which populates the locations
			nodes = xmldoc.getElementsByTagName('Location');
			nodesDeparturePoints = xmldoc.getElementsByTagName('DepartureAirport');
			
			sLocationID.options[0] = new Option('- Select a destination -','-');
			for(var i = 0; i < nodes.length; i++) {
				if (nodes.length != 0) {
					var GroupName = nodes.item(i).attributes.getNamedItem("title").nodeValue
					if(PreGroupName!=GroupName){
						var RegionName = document.createElement('optgroup');
						RegionName.label = GroupName;
						if(GroupName!='zzz') {
							sLocationID.appendChild(RegionName);
						}else if(i>0) {
							RegionName.label = 'Others';
							sLocationID.appendChild(RegionName);
						}
					}
					var PreGroupName = GroupName
					sCode = nodes.item(i).attributes.getNamedItem("code").nodeValue;
					sName = nodes.item(i).childNodes.item(0).nodeValue;
					sLocationID.options[sLocationID.options.length] = new Option(sName, sCode);
					
				}
			}
			if(nodes.length==1&&sSpecialType!='contact') {
			    
				if(document.getElementById('idConfirmDestinationDDL'+sCurForm)) {
					document.getElementById('idConfirmDestinationDDL'+sCurForm).style.display = 'none';
				}
				if(document.getElementById('idConfirmedDestination'+sCurForm)) {
					document.getElementById('idConfirmedDestination'+sCurForm).style.display = '';
					document.getElementById('idConfirmedDestinationText'+sCurForm).innerHTML = sLocationID.options[1].innerHTML
				}
				sLocationID.options[1].selected = true;
				findDestAirport(sCurForm, sLocationID.options[1].value)
				bFirstTimer = true
				//validateLocationForm();
			}else if(nodes.length<1){
				showFullSearch();
				var sConfirmText = 'No destinations found.\n\nClick OK to open the destination guide or cancel to go back and refine your search!';
				switch(sCurForm){
					case 'FlightHotel':
					sConfirmText = 'No destinations found for your flight and hotel search.\nWe may only be able to provide you with a flight to this destination.\n\nClick OK to open the destination guide or cancel to go back and refine your search!';
					break;
					case 'Hotel':
					sConfirmText = 'No destinations found for your hotel search.\n\nClick OK to open the destination guide or cancel to go back and refine your search!';
					break;
					case 'Flight':
					sConfirmText = 'No destinations found for your flight search.\n\nClick OK to open the destination guide or cancel to go back and refine your search!';
					break;
				}
				if(confirm(sConfirmText)) {
					locationGoBack(sCurForm);
					openDestinationHelp(sCurSearchType.toLowerCase(), 'frm'+sCurForm);
				}else{
					locationGoBack(sCurForm);
					sFreetext.focus();sFreetext.select();
				}				
				//alert('No destinations found.\n\nPlease refine your search.');
			}else{
				showFullSearch();
				switchLocationDivs('divLocation'+sCurForm);
				sFlasher = setInterval('selectFlash();',600);
			}
			
			//Section to display list of possible departure airports
			if(bFreetextDeparturePoint && sCurForm.toLowerCase().indexOf('flight') != -1){
			    clearLocationList(sDepartureID);
			    sDepartureID.options[0] = new Option('- Select a departure airport -','-');
			    for(var i = 0; i < nodesDeparturePoints.length; i++) {
				    if (nodesDeparturePoints.length != 0) {
					    var GroupName = nodesDeparturePoints.item(i).attributes.getNamedItem("title").nodeValue
					    if(PreGroupName!=GroupName){
						    var RegionName = document.createElement('optgroup');
						    RegionName.label = GroupName;
						    if(GroupName!='zzz') {
							    sDepartureID.appendChild(RegionName);
						    }else if(i>0) {
							    RegionName.label = 'Others';
							    sDepartureID.appendChild(RegionName);
						    }
					    }
					    var PreGroupName = GroupName
					    sCode = nodesDeparturePoints.item(i).attributes.getNamedItem("code").nodeValue;
					    sName = nodesDeparturePoints.item(i).childNodes.item(0).nodeValue;
					    sDepartureID.options[sDepartureID.options.length] = new Option(sName, sCode);
    					
				    }
			    }
			    if(nodesDeparturePoints.length==1&&sSpecialType!='contact') {
				    if(document.getElementById('idConfirmDepartureAirportDDL'+sCurForm)) {
				    	document.getElementById('idConfirmDepartureAirportDDL'+sCurForm).style.display = 'none';
				    }
				    if(document.getElementById('idConfirmDepartureAirport'+sCurForm)) {
				    	document.getElementById('idConfirmDepartureAirport'+sCurForm).style.display = '';
				    	document.getElementById('idConfirmedDepartureAirportText'+sCurForm).innerHTML = sDepartureID.options[1].innerHTML
				    }
				    sDepartureID.options[1].selected = true;
			    }else if(nodesDeparturePoints.length<1){
				    showFullSearch();
				    var sConfirmText = 'No departure airports found.';
				    switch(sCurForm){
					    case 'FlightHotel':
					    sConfirmText = 'No departure airports found for your flight and hotel search.';
					    break;
					    case 'Flight':
					    sConfirmText = 'No departure airports found for your flight search.';
					    break;
				    }
				    if(confirm(sConfirmText)) {
					    locationGoBack(sCurForm);
					    openDestinationHelp('departureairport', 'frm'+sCurForm);
				    }else{
				        var sDepartureFreetext = document.getElementById('idFreetextDep'+sCurForm);
					    locationGoBack(sCurForm);
					    //switchLocationDivs('divFreetext'+sCurrentFormID);
					    sDepartureFreetext.focus();sDepartureFreetext.select();
				    }				
				    //alert('No destinations found.\n\nPlease refine your search.');
			    }else{
				    showFullSearch();
				    switchLocationDivs('divLocation'+sCurForm);
				    sFlasher = setInterval('selectFlash();',600);
			    }
			}	
		}
		else
		{
			alert("There was a problem retrieving the XML data:\n" + req.statusText);
		}
	}
}




/* START GET SERVED AIRPORT SCRIPT BY Casper Thun August 2007 */
	var sCurrentFormID = '';
	var sCurrentForm = '';
	function findDestAirport(sFormID, sLocation) {
		sCurrentForm = document.getElementsByName('frm'+sFormID)
		sCurrentFormID = sFormID
		if(document.getElementById('idAirportto'+sFormID)) {
			sLocationList = document.getElementById('idAirportto'+sFormID);
			sLocationList.disabled='true';
			if(sLocation.length>0 && sLocation!='-') {
				sURL = "/includes/search/LookupXML.asp?searchtype=findairports&location=" + sLocation + "&c"
				if(sURL!='') {
					if(bDebug){
						if(confirm('Open '+ sURL)) {
							window.open(sURL);
						}
					}
					clearLocationList(sLocationList);
					sLocationList.options[0] = new Option('Loading... Please wait','');
					setTimeout("loadServedAirportXMLDoc('"+sURL+"')", 100);
				}else{
					alert('No url defined');	
				}
			}else{
				sLocationList.options[0] = new Option('- Select destination airport -','');
				sLocationList.selectedIndex = 0;
				sLocationList.disabled='true';
			}
		}else{
		    if(!document.getElementById('idDepartureAirport'+sFormID)){
			    sCurrentForm[0].submit();	
			}else{switchLocationDivs('divLocation'+sFormID);}
		}
	}
	
	//XML Loader
	function loadServedAirportXMLDoc(url) {
		// branch for native XMLHttpRequest object
		if (window.XMLHttpRequest) {
			req = new XMLHttpRequest();
			req.onreadystatechange = processServedAirportChange;
			req.open("GET", url, true);
			req.send(null);
		// branch for IE/Windows ActiveX version
		} else if (window.ActiveXObject) {
			req = new ActiveXObject("Microsoft.XMLHTTP");
			if (req) {
				req.onreadystatechange = processServedAirportChange;
				req.open("GET", url, true);
				req.send();
			}
		}
	}
	
	function processServedAirportChange() {
		if (req.readyState == 4){
			if (req.status == 200){
				sLocationList = document.getElementById('idAirportto'+sCurrentFormID);
				xmldoc = req.responseXML.documentElement;
				nodes = xmldoc.getElementsByTagName('Location');
				sLocationList.options[0] = new Option('- Select destination airport -','');
				for(var i = 0; i < nodes.length; i++) {
					if (nodes.length != 0) {
						sCode = nodes.item(i).attributes.getNamedItem("code").nodeValue;
						sName = nodes.item(i).childNodes.item(0).nodeValue;
						sLocationList.options[sLocationList.options.length] = new Option(sName, sCode);
					}
				}
				sLocationList.disabled='';
				if(nodes.length==1) {
					sLocationList.selectedIndex = 1;
					if(!document.getElementById('idDepartureAirport'+sCurrentFormID)){
					    sCurrentForm[0].submit();
					}else{switchLocationDivs('divLocation'+sCurrentFormID);}
				}else if(nodes.length==0 && bFirstTimer==true){
					alert('No airports found for this destination');
					locationGoBack(sCurrentFormID);
				}else{
					switchLocationDivs('divLocation'+sCurrentFormID);
				}
			}
		}
	}
	


/* START GET SERVED AIRPORT SCRIPT BY Casper Thun August 2007 */

function addDurationBYO(sform)
{
	var months = new Array('January','February','March','April','May','June','July','August','September','October','November','December');
	
		oSelect = document.getElementById('startdate_d'+sform);
		iDay = oSelect.options[oSelect.selectedIndex].value;
		oSelect = document.getElementById('startdate_m'+sform);
		iMonth = oSelect.options[oSelect.selectedIndex].value;
		oSelect = document.getElementById('startdate_y'+sform);
		iYear = oSelect.options[oSelect.selectedIndex].value;
	
	cindate = new Date(iYear, iMonth - 1, iDay, 0, 0, 0);
	
	oSelect = document.getElementById('duration'+sform);
	//alert('duration'+sform);
	if (oSelect.options[oSelect.selectedIndex].value == 'other')
	{
		tmpDuration = prompt("Please enter the number of nights","")
		if ( (tmpDuration==' ') || (tmpDuration==null) || (tmpDuration == ''))
		{
			iDuration = 7
			oSelect.options[0].selected = 'selected';
		}
		else
		{
			var stemp = tmpDuration
			if (stemp < 10)
			{
				stemp = "0" + stemp
			}
			for (loop=0; loop < oSelect.options.length; loop++)
			{
				if (oSelect.options[loop].value == stemp)
				{
					oSelect.options[loop].selected = 'selected';
					iDuration = stemp
				}
			}

			if (isNumeric(tmpDuration) == true)
			{	
				var opt = new Option(tmpDuration + ' days', tmpDuration);
				insertOptionAt (oSelect, opt, oSelect.options.length);
				iDuration = oSelect.options[oSelect.options.length-1].value;
				oSelect.selectIndex = oSelect.options.length;
				oSelect.options[oSelect.options.length-1].selected = 'selected';
			}
			else
			{
				iDuration = 7
				oSelect.options[0].selected = 'selected';
			}
		}
	}
	else
	{
		iDuration = oSelect.options[oSelect.selectedIndex].value;
	}

	// Amend the end date
	days = 1000 * 60 * 60 * 24 * iDuration;
	newdate = new Date(cindate.valueOf() + days);
	if ((newdate.getHours() != 0) || (newdate.getMinutes() != 0) || (newdate.getSeconds() != 0)) {
		// Workaround to JavaScript bug: sometimes when adding days represented as milliseconds it would onhly add 23 hrs
		// Work out time in milliseconds
		time = newdate.getHours() * 60 * 60 * 1000;
		time += newdate.getMinutes() * 60 * 1000;
		time += newdate.getSeconds() * 1000;
		newdate = new Date(newdate.getTime() + time);
		//alert(newdate);
	}
	
	if(newdate.getDate()+'' != "NaN") {
		sArrDate = newdate.getDate() + ' ' + months[newdate.getMonth()] + ' ' + newdate.getFullYear();
	 } else {
		 sArrDate = 'Please select a departure date.';
	 }
	
	//alert(sArrDate);
	document.getElementById("arrdate"+sform).innerHTML = '<b>' + sArrDate + '</b>'
	//document.getElementById("arrdate"+sform).value = sArrDate	
}

function GetElementWidth(sObject) {
	var elem;
	if(typeof(sObject) == "object") {
		elem = sObject;
	} else {
		elem = document.getElementById(sObject);
	}
	return parseInt(elem.offsetWidth);
}
function clearFlash() {
	try{
		var sLocationID = document.getElementById('idLocationto'+sCurForm);
		clearInterval(sFlasher);
		sLocationID.className = 'redSelectBox';
	}catch(err){}
}
function selectFlash() {
	var sLocationID = document.getElementById('idLocationto'+sCurForm);
	if(sLocationID.className=='redSelectBox'){
		sLocationID.className = 'redSelectBox_Switch';
	}else{
		sLocationID.className = 'redSelectBox';
	}
}




// 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 = '';
						}
					}
				}				
			}		
		}	
	}
}


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 = 'block'; }
					}
				//}
			/*} 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 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<15;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);
		}
	}
	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);	
	}else{
        div_switch('s'+type.toUpperCase()+'Ages'+id+formid,false,true);	
		if (document.getElementById('s'+type.toUpperCase()+'Ages'+id+formid).style.display == "none") {
			vAgeControl = vAgeControl - 1
		}
	}
	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;
}
// End functions relating to MultipleRoomTypes

function switchPopularFreetextSearch(sFormID){
	if(document.getElementById('idPopularSearch' + sFormID).style.display == ''){
		document.getElementById('idPopularSearch' + sFormID).style.display = 'none';
		document.getElementById('idFreetextSearch' + sFormID).style.display = '';
		document.getElementById('idSearchSwitchLink' + sFormID).innerHTML = 'View our popular destinations?';
		document.getElementById('idPopularDestinations' + sFormID).selectedIndex = 0;
	}else{
		document.getElementById('idPopularSearch' + sFormID).style.display = '';
		document.getElementById('idFreetextSearch' + sFormID).style.display = 'none';
		document.getElementById('idSearchSwitchLink' + sFormID).innerHTML = 'Can\'t find your destination?';
		document.getElementById('idHdnLocationTo' + sFormID).value = '';
		document.getElementById('idFreetext' + sFormID).value = '- type your destination -';
	}
}

 -->