function replaceImages() {
	if(document.getElementById('pleasewaitAnimation')) {
		document.getElementById('pleasewaitAnimation').src='/images/pleasewait/animation.gif';
	}
	if(document.getElementById('pleasewaitAnimationLogos')) {
		document.getElementById('pleasewaitAnimationLogos').src='/images/pleasewait/animationlogos.gif';
	}
}
function frmBYOSubmit(bBasket) {
	div_switch('websiteDiv',false,true);
	scroll(0,0);
	if(!document.getElementById('pleasewaitDiv_Basket')){bBasket = false;}
	if(bBasket) {
		div_switch('pleasewaitDiv_Basket',true,true);
	}else{
		div_switch('pleasewaitDiv',true,true);
	}
	document.frmResults.submit();
	setTimeout('replaceImages()',100);
	if(typeof exitSurvey=='function'){
		exitSurvey(430, 390); 
	}
}
function setLevel(fId) {if(document.frmResults.txtLevel){document.frmResults.txtLevel.value=fId;}}
function setParentID(fId){document.frmResults.ParentID.value=fId;}
function setShowDiv(fId){document.frmResults.ShowDiv.value=fId;}
function setProvider(fId){document.frmResults.Provider_Flight.value=fId;document.frmResults.txtIsPostBack.value="true";}
function setCarOptionEx(position,supplier){document.frmResults.car_position.value=position;document.frmResults.car_provider.value=supplier;}
function setHotelCacheKey(key) {
	el = document.frmResults.hotelCacheKey;
	if(el){el.value = key;}
}
function resultsTimeout() {}
/* START RESULTS JS */
	function checkPackageFlightExistance(flightPos,id, position){
		if(document.getElementById('_divHideShowFlightsFH'+flightPos+'_'+position+'_'+id)) {
			document.getElementById('CountItemsFH'+flightPos).innerHTML = parseFloat(document.getElementById('CountItemsFH'+flightPos).innerHTML) + 1;
			document.getElementById('CountItemsFH'+flightPos+'_'+'Holder').style.display='';
		}
	}
	function EnquireFromNoResultsXSL() {
		document.frmResults.action = '/contact.asp';
		document.frmResults.method = 'post';
		document.frmResults.submit();
	}
	function ChangePageFlights(pagenumber) {
		document.frmResults.txtLevel.value='SEARCH';
		document.frmResults.txtIsPostBack.value="true";
		document.frmResults.pagenumberflights.value=pagenumber;
		document.frmResults.ShowDiv.value='flights';
		frmBYOSubmit();
		/*Swap the loading div*/
		LoadingDivSwitchDisplay('generic', 'We\'re currently loading your next page of flight results.');
	}
	function ChangePageHotels(pagenumber) {
		document.frmResults.txtLevel.value='SEARCH';
		document.frmResults.txtIsPostBack.value="true";
		document.frmResults.pagenumberhotels.value=pagenumber;
		document.frmResults.ShowDiv.value='accomm';
		frmBYOSubmit();
		/*Swap the loading div*/
		LoadingDivSwitchDisplay('generic', 'We\'re currently loading your next page of hotel results.');
	}
	function ChangePagePackageHolidays(pagenumber) {
		document.frmResults.txtLevel.value='SEARCH';
		document.frmResults.txtIsPostBack.value="true";
		document.frmResults.pagenumberpackageholidays.value=pagenumber;
		document.frmResults.ShowDiv.value='accomm';
		frmBYOSubmit();
		/*Swap the loading div*/
		LoadingDivSwitchDisplay('generic', 'We\'re currently loading your next page of package holiday results.');	
	}
	
	/*Loading Text Functions START
	New functions to alter the text displayed on the loading pages*/
	function LoadingDivSwitchDisplay(sDivExtension, sDivText) {	
		/*Hide the loading div pleasewaitDiv and then show the generic one*/
		div_switch('pleasewaitDiv',false,true); 
		div_switch('pleasewaitDiv_' + sDivExtension,true,true);	
		/*Set the text the text of the generic loading div*/
		document.getElementById('pleasewaitDiv_' + sDivExtension + 'Text').innerHTML = '<strong>What exactly are we doing at the moment?</strong><br />' + sDivText
	}
	/*Custom overrides for the different product types*/
	function LoadingDivSwitchOverride(sTypeFlag) {
		if(sTypeFlag == 'FH_F' || sTypeFlag == 'FHC_F') {
			LoadingDivSwitchDisplay('generic', 'We\'re currently adding the flight you have chosen to your results.');
		} else if(sTypeFlag == 'FHC_C' || sTypeFlag == 'FC_C') {
			LoadingDivSwitchDisplay('generic', 'We\'re currently adding the car you have chosen to your results.');
		} else {
			LoadingDivSwitchDisplay('generic', 'We\'re currently loading the details you have requested.');
		}
	}	
	function LoadingDivHotelFilterOverride() {
		/*Because of shared js functions we need to override the innerHTML in the generic loading div.
		The problem occurs because filtering hotel results js (setSortHotelsNEW) calls the hotel paging js (ChangePageHotels) 
		to maintain the users selected page and this function already has a div switch assigned.
		As a temporary fix call the div switch again and override*/
		LoadingDivSwitchDisplay('generic', 'We\'re currently filtering your results based on the selection you have made.');
	}
	/*Loading Text Functions END*/
	
	function clearAccomm() {
		document.frmResults.accomm_id.value='';
		document.frmResults.Provider_Accomm.value='';
	}
	
	function clearPackageHoliday() {
		document.frmResults.Provider_PackageHoliday.value='';
		document.frmResults.packageholiday_itineraryid.value='';
	}
	
	function setPackageHoliday(sProvider,sId,position) {
		document.frmResults.Provider_PackageHoliday.value=sProvider;
		document.frmResults.Provider_Flight.value=sProvider;
		document.frmResults.packageholiday_itineraryid.value=sId;
		if(sProvider=='PackageEngine') {
			var flightRadio = document.getElementsByName('tblFH_'+position);
			for(x=0;x<flightRadio.length;x++) {
				if(flightRadio[x].checked==true) {
					sFlightID=flightRadio[x].value;
				}
			}
			document.frmResults.fare_id.value = sFlightID;
		}
	}
	function setAccomm(fId, pId, sId, parentId, sessionId, expSupplier, expRoomCode, BoardCode) {
		if(BoardCode==null) BoardCode='';
		document.frmResults.accomm_id.value=fId;
		document.frmResults.Provider_Accomm.value=pId;
		document.frmResults.hrnQuoteKey.value=sId;
		document.frmResults.expRoomCode.value=expRoomCode;
		document.frmResults.ParentID.value=parentId;
		document.frmResults.exp_supplier.value=expSupplier;
		document.frmResults.BoardCode.value=BoardCode;
	}
	function setSortHotels(fId,datatype,order,sId){
		document.frmResults.txtIsPostBack.value="true";
		document.frmResults.SortHotels.value=fId + ";" + datatype + ";" + order + ";" + sId;
	}
	function setSortFlights(fId,datatype,order,sId){
		//alert(fId+','+datatype+','+order+','+sId)
		document.frmResults.txtIsPostBack.value="true";
		document.frmResults.SortFlights.value=fId + ";" + datatype + ";" + order + ";" + sId;
	}
	/*For IKnowHolidays by Andrew Bate. They have the option of specifying ascending/descending order
	This function sets the sort order.*/
	function setSortHotelsOrder (type, page) {
		document.frmResults.txtIsPostBack.value="true";
		if (type> 0) {
			var oParam = new Array();
			oParam = document.frmResults.SortHotels.value.split(';');
			if (type==1) {
				oParam[2] = 'ascending';
			}
			else {
				oParam[2] = 'descending';
			}
			setSortHotels(oParam[0], oParam[1], oParam[2], oParam[3]);			
			ChangePageHotels(page);
		}
	}
	
	function setSortHotelsNEW(type, page) {
		document.frmResults.txtIsPostBack.value="true";
		if(type>0) {
			if(type==1) {
				setSortHotels("translate(PricedRooms/PricedRoom/TotalStdPrice,',','')",'number','ascending','3');
			}
			if(type==2)	{
				setSortHotels('AccommInfo/StarRating','number','descending','2');
			}
			if(type==3)	{
				setSortHotels('AccommInfo/AccommName','text','ascending','1');
			}
			if(type==4)	{
				setSortHotels('default','','','0');
			}
			ChangePageHotels(page);
		}
	}

	/* Function to post back resort name for filtering - CP 13/10/2008 */
	function setFilterResort(resortName){
		document.frmResults.txtIsPostBack.value="true";
		document.frmResults.FilterHotels.value=resortName;
		document.frmResults.txtLevel.value='SEARCH';
		document.frmResults.txtIsPostBack.value="true";
		/*document.frmResults.pagenumberhotels.value=pagenumber;*/
		document.frmResults.ShowDiv.value='accomm';
		frmBYOSubmit();
		/*Swap the loading div*/
		LoadingDivSwitchDisplay('generic', 'We\'re currently loading the results from your selected resort.');
	}

	/* New function for flights by Casper Thun 10th August 2007 */
	function setFlight(fare_id, fId, provider, flightPos) {
		var sRouteOut = '';
		var sRouteIn = '';
		document.frmResults.txtIsPostBack.value="true";
		document.frmResults.FARE_PK.value=fId;
		document.frmResults.CSI_FAREID.value=fId;
		document.frmResults.fare_id.value=fare_id;
		document.frmResults.Provider_Flight.value=provider;
		radio = document.getElementsByTagName('input')
		for(x=0;x<radio.length-1;x++) {
			if(radio[x].type == 'radio') {
				if(radio[x].name=='tblOutbound_'+flightPos) {
					if(radio[x].checked==true) {
						sRouteOut = radio[x].value;
					}
				}
				if(radio[x].name=='tblInbound_'+flightPos) {
					if(radio[x].checked==true) {
						sRouteIn = radio[x].value;
					}
				}
			}
		}
		if(sRouteIn == ''){ sRouteIn = 1; }
		if(sRouteOut) {
			document.frmResults.route_out.value=sRouteOut;
			document.frmResults.CSI_ROUTEIDOUT.value=sRouteOut;
			document.frmResults.route_out_position.value=sRouteOut;
		}
		if(sRouteIn) {
			document.frmResults.route_in.value=sRouteIn;
			document.frmResults.CSI_ROUTEIDIN.value=sRouteIn;
			document.frmResults.route_in_position.value=sRouteIn; 
		}
		//alert(document.frmResults.txtIsPostBack.value+'\n'+document.frmResults.FARE_PK.value+'\n'+document.frmResults.CSI_FAREID.value+'\n'+document.frmResults.fare_id.value+'\n'+document.frmResults.Provider_Flight.value+'\n'+document.frmResults.route_out.value+'\n'+document.frmResults.CSI_ROUTEIDOUT.value+'\n'+document.frmResults.route_out_position.value+'\n'+document.frmResults.route_in_position.value+'\n')
	}
		
	function showHideResultItems(id, linkText ,type) {
		if(document.getElementById('_divHideShowFlights'+id+type)) {
			if(document.getElementById('_divHideShowFlights'+id+type).style.display=='none') {
				bDisplayMoreResult = false;
				sDisplay = '';
				sLinkText = 'Hide';
			}else{
				bDisplayMoreResult = true;
				sDisplay = 'none';
				sLinkText = 'Show';
			}
		}
		if(document.getElementById('_divHideShowFlights'+id+type)) {
			document.getElementById('_divHideShowFlights'+id+type).style.display = sDisplay;
		}

		
		
		radio = document.getElementsByTagName('input')
		
		bOutBoundSelected = false;
		bInBoundSelected = false;
		for(x=0;x<radio.length-1;x++) {
			if(radio[x].type == 'radio') {
				if(radio[x].name=='tbl'+type+'bound_'+id) {
					radio[x].style.display = sDisplay;
					if(bOutBoundSelected!=true) {
						radio[x].checked = true;
						bOutBoundSelected = true;
					}
				}
			}
		}
		linkText.innerHTML = sLinkText+Right(linkText.innerHTML, linkText.innerHTML.length-4);
	}
	function showHideResultItemsFH(id, linkText) {
		if(document.getElementById('_divHideShowFlightsFH_'+id)) {
			if(document.getElementById('_divHideShowFlightsFH_'+id).style.display=='none') {
				document.getElementById('_divHideShowFlightsFH_'+id).style.display='';
				document.getElementById('tblFH_'+id+'_first').style.display='';
				sLinkText = 'Hide';
			}else{
				document.getElementById('_divHideShowFlightsFH_'+id).style.display='none';
				document.getElementById('tblFH_'+id+'_first').style.display='none';
				document.getElementById('tblFH_'+id+'_first').checked=true;
				sLinkText = 'Show';
			}
			
			linkText.innerHTML = sLinkText+Right(linkText.innerHTML, linkText.innerHTML.length-4);
		}
	}
	/* START MORE INFO AJAX */
		var sCurrentPosition = '';
		function GetMoreHotelInfo(sLink, sPosition, sProvider, sAccommCode, sGABProvID, sMulticomFAB, sSessionID) {
			sCurrentPosition = sPosition
			if(!sSessionID && document.getElementById('SessionID')){
					sSessionID = document.getElementById('SessionID').value
			}
			if(document.getElementById('divHotelInfo'+sPosition).style.display=='none') {
				sURL = '/includes/hotelinfo.asp?provider='+sProvider+'&accommcode='+sAccommCode+'&gabprovid='+sGABProvID+'&multicomfab='+sMulticomFAB+'&session='+sSessionID;
				if(sURL!='') {
					document.getElementById('divHotelInfo'+sPosition).style.display = '';

					document.getElementById('Description'+sCurrentPosition).innerHTML = '<div align="center"><img src="/images/animations/ajax-loader-white.gif" /><br /><br /><span class="resultPleaseWait">Loading... Please wait.</span></div>'
					if(bDebug) {
						if(confirm('Open '+ sURL)) {
							window.open(sURL);
						}
					}
					setTimeout("loadInfoXMLDoc('"+sURL+"')", 100);
					sLink.innerHTML = sLink.innerHTML.replace('Click here for','Click here to hide');
				}else{
					alert('No url defined');	
				}
			}else{
				sLink.innerHTML = sLink.innerHTML.replace('Click here to hide','Click here for');
				document.getElementById('divHotelInfo'+sPosition).style.display = 'none';
			}
		}
		function loadInfoXMLDoc(url) {
			// branch for native XMLHttpRequest object
			if (window.XMLHttpRequest) {
				req = new XMLHttpRequest();
				req.onreadystatechange = processInfoChange;
				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 = processInfoChange;
					req.open("GET", url, true);
					req.send();
				}
			}
		}
		function processInfoChange() {
			if (req.readyState == 4) {
				if (req.status == 200){
					xmldoc = req.responseXML.documentElement;
					sDescription = xmldoc.getElementsByTagName('Description').item(0).childNodes.item(0).nodeValue;
					iGoogleLat = parseFloat(xmldoc.getElementsByTagName('GoogleLat').item(0).childNodes.item(0).nodeValue);
					iGoogleLng = parseFloat(xmldoc.getElementsByTagName('GoogleLng').item(0).childNodes.item(0).nodeValue);
					images = xmldoc.getElementsByTagName('Image');
					if(document.getElementById('IMGThumbs'+sCurrentPosition)) {
						document.getElementById('IMGThumbs'+sCurrentPosition).innerHTML = ''
						if(images.length>0) {
							for(x=0;x<images.length;x++) {
								sImage = images.item(x).childNodes.item(0).nodeValue;
								if(x==0){
									document.getElementById('IMGPlaceHolder'+sCurrentPosition).innerHTML = '<img src="'+sImage+'" id="placeHolder'+sCurrentPosition+'" onerror="this.src=\'/images/general/_noimage.gif\'" />'	
								}
								if(images.length>1) {
									document.getElementById('IMGThumbs'+sCurrentPosition).innerHTML += '<img src='+sImage+' onclick=SwitchPhoto("placeHolder'+sCurrentPosition+'","'+sImage+'") onerror="this.src=\'/images/general/_noimage.gif\'" />'
									document.getElementById('IMGThumbsText'+sCurrentPosition).style.display = '';
								}else{
									document.getElementById('IMGThumbs'+sCurrentPosition).style.display = 'none';
									document.getElementById('IMGPlaceHolder'+sCurrentPosition).style.borderBottom = '1px';
									
								}
							}
							document.getElementById('MoreInfoIMG'+sCurrentPosition).style.display='';
						}
					}
					if(document.getElementById('GoogleMapContainer'+sCurrentPosition)) {
						if(iGoogleLat!=0 && iGoogleLng!=0) {
							document.getElementById('GoogleMapContainer'+sCurrentPosition).style.display='';
							LoadGoogleMap('GoogleMap'+sCurrentPosition,iGoogleLat,iGoogleLng);
						}
					}
					document.getElementById('Description'+sCurrentPosition).innerHTML = sDescription;
				}else{
					alert('More hotel information is not available');
					document.getElementById('divHotelInfo'+sCurrentPosition).style.display = 'none';
				}
			}
		}
	/* END MORE INFO AJAX */
	
	/* START RESORT INFO AJAX */
		var currentFMVars = '';
		var currentFMUser = '';
		var currentFMOrderBy = '';
		var currentFMSortType = '';
		var currentSearchType = '';
		function GetResortInfo(sSearchType, sAirportTo, sFlightMatrixVars, sFlightMatrixOrderBy, sFlightMatrixSortType) {
			sFlightMatrixUserQueryString = '';
			if(sFlightMatrixVars) {
				currentFMVars = sFlightMatrixVars;
				arVars = sFlightMatrixVars.split('|');
				if(arVars.length>3){
					currentFMUser = arVars[0];
					sAdults = arVars[1];
					sChildren = arVars[2];
					sInfants = arVars[3];
					sOneway = arVars[4];
					currentFMOrderBy = sFlightMatrixOrderBy;
					currentFMSortType = sFlightMatrixSortType;
					var dDate = new Date();
					sFlightMatrixUserQueryString = 'flightmatrixuser='+currentFMUser+'&adults='+sAdults+'&children='+sChildren+'&infants='+sInfants+'&oneway='+sOneway+'&fmorderby='+sFlightMatrixOrderBy+'&fmsorttype='+sFlightMatrixSortType+'&'+dDate;
				}
			}
			currentSearchType = sSearchType;
			if(document.getElementById('divResortInfo')) {
				var sAddressURL='';
				sAddresses = document.getElementsByName('AddressForGoogle');
				for(x=0;x<sAddresses.length;x++) {
					if(sAddresses[x].value) {
						sAddressURL+=sAddresses[x].value.replace("'","");
						if(x<sAddresses.length-1) {
							sAddressURL+='||';
						}
					}
				}
				var sLocation='';
				if(sSearchType.toLowerCase()!='flight') {
					sLocation = document.getElementsByName('locationid')[0].value.replace("'","");
				}
				sURL = '/includes/resortinfo.asp?location='+sLocation+'&search_type='+sSearchType+'&airportto='+sAirportTo+'&addresses='+sAddressURL+'&casp=casp&'+sFlightMatrixUserQueryString;
				
				if(sURL!='') {
					sURL=sURL.replace("'","");
					if(bDebug) {
						if(confirm('Open '+ sURL)) {
							window.open(sURL);
						}
					}
					setTimeout("loadResortInfoXMLDoc('"+sURL+"')", 100);
				}else{
					alert('No url defined');	
				}
			}
		}
		
		function loadResortInfoXMLDoc(url) {
			// branch for native XMLHttpRequest object
			if (window.XMLHttpRequest) {
				reqResort = new XMLHttpRequest();
				reqResort.onreadystatechange = processResortInfoChange;
				reqResort.open("GET", url, true);
				reqResort.send(null);
			// branch for IE/Windows ActiveX version
			} else if (window.ActiveXObject) {
				reqResort = new ActiveXObject("Microsoft.XMLHTTP");
				if (reqResort) {
					reqResort.onreadystatechange = processResortInfoChange;
					reqResort.open("GET", url, true);
					reqResort.send();
				}
			}
		}
		
		var xmlDocTop = '';
		function processResortInfoChange() {
			if (reqResort.readyState == 4) {
				if (reqResort.status == 200){
					document.getElementById('divResortInfoLoader').style.display='none';
					document.getElementById('divResortInfo').style.display='';
					
					xmldoc = reqResort.responseXML.documentElement;
					if(currentSearchType.toLowerCase()=='flight') {
						var bFlightMatrix = false;
						var iReturnFlight = 1;
						flightmatrixHead = xmldoc.getElementsByTagName('FlightMatrix');
						var tophtml = '';
						if(flightmatrixHead.length>0) {
							iAdults = flightmatrixHead.item(0).attributes.getNamedItem("Adults").nodeValue;
							iChildren = flightmatrixHead.item(0).attributes.getNamedItem("Children").nodeValue;
							iInfants = flightmatrixHead.item(0).attributes.getNamedItem("Infants").nodeValue;
							iReturnFlight = flightmatrixHead.item(0).attributes.getNamedItem("ReturnFlight").nodeValue;
							tophtml='Recent searches for ';
							tophtml+=iAdults+' adult';
							if(parseFloat(iAdults)>1){tophtml+='s';}
							if(parseFloat(iChildren)>0) {
								tophtml+=', '+iChildren+' child';
								if(parseFloat(iChildren)>1){tophtml+='ren';}
							}
							if(parseFloat(iInfants)>0) {
								tophtml+=', '+iInfants+' infant';
								if(parseFloat(iInfants)>1){tophtml+='s';}
							}
							if(parseFloat(iReturnFlight)==1) {
								tophtml+=' - Return flight';
							}else{
								tophtml+=' - Oneway flight';	
							}
						}
						flightmatrix = xmldoc.getElementsByTagName('Content');
						if(flightmatrix.length>0) {
							sHTML = '<div class="FlightMatrixTopText">' + tophtml + '</div>';
							sHTML+='<table border="1" cellpadding="2" cellspacing="0" class="FlightMatrixTable">';
							sHTML+='<tr class="FlightMatrixTitles">';
							sHTML+='<td><div id="divSort_DepAirport" style="display:none;"></div><a href="javascript:flightMatrixSort(\'DepAirport\');">Departure airport</a></td>';
							sHTML+='<td><div id="divSort_StartDate" style="display:none;"></div><a href="javascript:flightMatrixSort(\'StartDate\');">Departure date</a></td>';
							sHTML+='<td><div id="divSort_ArrAirport" style="display:none;"></div><a href="javascript:flightMatrixSort(\'ArrAirport\');">Arrival airport</a></td>';
							sHTML+='<td><div id="divSort_EndDate" style="display:none;"></div><a href="javascript:flightMatrixSort(\'EndDate\');">Return date</a></td>';
							sHTML+='<td align="right" width="50"><div id="divSort_Price" style="display:none;"></div><a href="javascript:flightMatrixSort(\'Price\');">Price</a></td>';
							sHTML+='<td align="center">Actions</td>';
							sHTML+='</tr>';
							for(x=0;x<flightmatrix.length;x++) {
								iContentID = flightmatrix.item(x).attributes.getNamedItem("ID").nodeValue;
								sPrice = flightmatrix.item(x).attributes.getNamedItem("Price").nodeValue;
								sDepDate = flightmatrix.item(x).attributes.getNamedItem("StartDate").nodeValue;
								sArrDate = flightmatrix.item(x).attributes.getNamedItem("EndDate").nodeValue;
								sAirportFrom = flightmatrix.item(x).attributes.getNamedItem("DepAirportName").nodeValue+' ('+flightmatrix.item(x).attributes.getNamedItem("DepAirport").nodeValue+')';
								sAirportTo = flightmatrix.item(x).attributes.getNamedItem("ArrAirportName").nodeValue+' ('+flightmatrix.item(x).attributes.getNamedItem("ArrAirport").nodeValue+')';
								if(x==0) {
									sHTML+='<tbody id="fm_top">';	
								}else if(x==5 && !fm_listExpanded) {
									sHTML+='</tbody>'
									sHTML+='<tbody id="fm_topplustext">';
									sHTML+='<tr><td colspan="7" align="right"><a href="javascript:flightMatrixExpandList()">See full list</a></td></tr>'

									sHTML+='</tbody>'
									sHTML+='<tbody id="fm_topplus" style="display:none;">';	
								}
								sHTML+='<tr>';
								sHTML+='<td>'+sAirportFrom+'</td>';
								sHTML+='<td>'+sDepDate+'</td>';
								sHTML+='<td>'+sAirportTo+'</td>';
								if(parseFloat(iReturnFlight)==1) {
									sHTML+='<td>'+sArrDate+'</td>';
								}else{
									sHTML+='<td>N/A</td>';
								}
								sHTML+='<td align="right">'+sPrice+'</td>';
								sHTML+='<td align="center"><a href="javascript:flightMatrix_RemoveContent('+iContentID+')">Remove</a> - <a href="javascript:flightMatrix_BookContent('+iContentID+')">Book</a></td>';
								sHTML+='</tr>';
							}
							sHTML+='</tbody>';
							sHTML+='</table>';
							document.getElementById('divResortInfo_5').innerHTML = sHTML;
							flightMatrixSortIcons();
							document.getElementById('divResortInfo_5').style.display='';
							if(document.getElementById('tab_5').className.indexOf('Over') < 0) {
								document.getElementById('tab_5').className=document.getElementById('tab_5').className+'Over';
							}
							document.getElementById('tab_5').style.display='';
						}else{
							document.getElementById('divResortInfo').style.display='none';
						}
					}else{
						var bGoogle = false;
						var bWeather = false;
						var bResort = false;
						var bRegion = false;
						//alert(req.responseXML.text);
						
						//START GOOGLE MAP
						if (GBrowserIsCompatible()) {
							google = xmldoc.getElementsByTagName('Google');
							if(google.length>0) {
								// start fix to center map
								
								document.getElementById('divResortInfo_1').style.display='';
								// end fix to center map
								bGoogle = true;
								if(bGoogle) {
									divGoogle = document.getElementById("ResortGoogleMap");
									divGoogle.style.width='715px';
									divGoogle.style.height='230px';
									var hotelIcon = new GIcon();
									hotelIcon.image = "/images/icons/googlemap_hotel.png"
									hotelIcon.iconSize = new GSize(24, 25);
									hotelIcon.iconAnchor = new GPoint(9, 34);
									hotelIcon.infoWindowAnchor = new GPoint(9, 2);
									
									var airportIcon = new GIcon();
									airportIcon.image = "/images/icons/googlemap_airport.png"
									airportIcon.iconSize = new GSize(32, 32);
									airportIcon.iconAnchor = new GPoint(9, 34);
									airportIcon.infoWindowAnchor = new GPoint(11, 1);
									
									var interestIcon = new GIcon();
									interestIcon.image = "/images/icons/googlemap_interest.png"
									interestIcon.iconSize = new GSize(22, 22);
									interestIcon.iconAnchor = new GPoint(9, 34);
									interestIcon.infoWindowAnchor = new GPoint(11, 1);
									
									function createMarker(point, index, title, distance, type) {
										if(type=='hotel') {
											var marker = new GMarker(point, hotelIcon);
										}else if(type=='interest'){
											var marker = new GMarker(point, interestIcon);
										}else{
											var marker = new GMarker(point, airportIcon);
										}
										marker.image = "/images/icons/googlemap_"+type+".png";
										
										GEvent.addListener(marker, "click", function() {
											if(type=='hotel') {
												var image = '';
												var starrating = '';
												var price = '';
												var sHTML = '';
												if(document.getElementById('ImageForGoogle'+index)) {
													image = document.getElementById('ImageForGoogle'+index).value;	
												}
												if(document.getElementById('StarRatingForGoogle'+index)) {
													iStars = parseFloat(document.getElementById('StarRatingForGoogle'+index).value);
													if(typeof iStars=='number') {
														for(z=0;z<iStars;z++) {
															starrating+='<img src="/images/starrating/star_small.gif" align="absmiddle" />';
														}
													}
												}
												if(document.getElementById('PriceForGoogle'+index)) {
													price = document.getElementById('PriceForGoogle'+index).value;
													if(price=='NaN'){price='';}
												}
												sHTML+='<table border="0" cellpadding="0" cellspacing="0"><tr>'
												if(image) {
													sHTML+='<td><div class="imageContainerGoogle"><img src="'+image+'" onerror="this.src=\'/images/general/_noimage.gif\'" /></div><td>';	
												}
												sHTML+='<td valign="top"><strong>'+title+'</strong>'
												if(starrating) {
													sHTML+='<br>'+starrating
												}
												if(price) {
													sHTML+='<br><span class="standoutText">'+price+'</span>'
												}
												if(distance) {
													sHTML+='<br>'+distance+' from airport';
												}
												
												sHTML+='<br/><br/><a href="#result'+index+'">Go to hotel</a></td>'
												sHTML+='</tr></table>'
											}else{
												sHTML = title;
											}
											marker.openInfoWindowHtml(sHTML);
										});
										return marker;
									}
									var map = new GMap2(divGoogle);
									map.addControl(new GSmallMapControl());
									map.addControl(new GMapTypeControl());
									for(x=0;x<google.length;x++) {
										sTitle = google.item(x).attributes.getNamedItem("Title").nodeValue
										sLat = google.item(x).attributes.getNamedItem("Lat").nodeValue
										sLng = google.item(x).attributes.getNamedItem("Lng").nodeValue
										sPosition = google.item(x).attributes.getNamedItem("Position").nodeValue
										sType = google.item(x).attributes.getNamedItem("Type").nodeValue
										sDistance = google.item(x).attributes.getNamedItem("Distance").nodeValue
										if(x==0) {
											map.setCenter(new GLatLng(sLat,sLng), 9);	
										}
										if(sType!='resort') {
											//alert(sLat+', '+sLng);
											var point = new GLatLng(sLat,sLng);
											if(sType=='hotel') {
												map.addOverlay(createMarker(point, sPosition, sTitle, sDistance, sType));
											}
											if(sType=='airport') {
												map.addOverlay(createMarker(point, '0', sTitle, '', sType));
											}
											if(sType=='interest') {
												sImage = google.item(x).attributes.getNamedItem("Image").nodeValue
												sDescription = google.item(x).attributes.getNamedItem("Description").nodeValue
												sHTML='';
												sHTML+='<table border="0" cellpadding="0" cellspacing="0"><tr>'
												if(sImage) {
													sHTML+='<td><div class="imageContainerGoogle"><img src="'+sImage+'" onerror="this.src=\'/images/general/_noimage.gif\'" /></div><td>';	
												}
												sHTML+='<td valign="top"><strong>'+sTitle+'</strong>'
												if(sDescription) {
													sHTML+='<br>'+sDescription;
												}
												
												sHTML+='<br/><br/><a href="javascript:ResortTab(\'tab_2\');showHideThing('+sPosition+',true);">More information</a></td>'
												sHTML+='</tr></table>'
												
												map.addOverlay(createMarker(point, '0', sHTML, '', sType));
											}
											if(document.getElementById('ResortGoogleMapBot')) {
												sIconHTML='';
												sIconHTML+='<img src="/images/icons/googlemap_hotel.png" align="absmiddle" style="margin:0px 5px 0px 0px;" />Hotel information';
												if(currentSearchType=='Flight_Hotel'||currentSearchType=='Flight_Car_Hotel') {
													sIconHTML+='<img src="/images/icons/googlemap_airport.png" align="absmiddle" style="margin:0px 5px 0px 15px;" />Airport';
												}
												sIconHTML+='<img src="/images/icons/googlemap_interest.png" align="absmiddle" style="margin:0px 5px 0px 15px;" />Places of interest';
												
												document.getElementById('ResortGoogleMapBot').innerHTML = '<div style="margin-top:6px;"><strong style="color:white;"><span class="ResortGoogleMapBottext">'+sIconHTML+'</span></strong></div>';
												document.getElementById('ResortGoogleMapBot').style.display = '';
											}
										}
									}
								}
							}
						}
						//END GOOGLE MAP
						//START RESORT INFO
							var sResortInfo = '';
							var sVideoID = '';
							resort = xmldoc.getElementsByTagName('Resort');
							for(x=0;x<resort.length;x++) {
								bResort = true;
								sResortName = resort.item(x).attributes.getNamedItem("Name").nodeValue
								sVideoID = resort.item(x).attributes.getNamedItem("Video").nodeValue
								sVideoType = resort.item(x).attributes.getNamedItem("VideoType").nodeValue
								sResortDesc = resort.item(x).childNodes.item(0).childNodes.item(0).nodeValue
								sResortInfo+=sResortDesc;
							}
							thing = xmldoc.getElementsByTagName('ResortThing');
							if(thing.length>0) {
								sHTML = '<div class="thingsToSeeTitle">Things to see</div>'
								
								sHTML+='<div class="hr2" style="clear:left;"></div>'
								for(x=0;x<thing.length;x++) {
									iID = thing.item(x).attributes.getNamedItem("ID").nodeValue
									sTitle = thing.item(x).attributes.getNamedItem("Title").nodeValue
									sDescription = thing.item(x).childNodes.item(0).nodeValue
									sImg = thing.item(x).attributes.getNamedItem("Img").nodeValue
									sImgTitle = thing.item(x).attributes.getNamedItem("ImgTitle").nodeValue
									sURL = thing.item(x).attributes.getNamedItem("URL").nodeValue
									sURLTitle = thing.item(x).attributes.getNamedItem("URLTitle").nodeValue
									
									sHTML+='<div class="thingToSee">'
									sHTML+='<div class="thingTitle"><a href="javascript:showHideThing('+iID+');">'+sTitle+'</a></div>'
									sHTML+='<div id="thingtosee_'+iID+'" style="display:none">';
									if(sImg) {
										if(Left(sImg,7)=='http://') {
											sHTML+='<div class="imageContainer" style="float:left; margin-bottom:7px;"><img src="'+sImg+'" onerror="this.src=\'/images/general/_noimage.gif\'" /></div>'
										}else{
											sHTML+='<div class="imageContainer" style="float:left; margin-bottom:7px;"><img src="http://www.travelmodule.co.uk/data/resort_images/'+sImg+'" onerror="this.src=\'/images/general/_noimage.gif\'" /></div>'
										}
									}
									sHTML+='<div class="thingDescription">'+sDescription
									if(sURL && sURL!='http://') {
										if(sURLTitle) {sLinkTitle = sURLTitle;}else{sLinkTitle = sURL;}
										sHTML+='<br/><br/>More info: <a href="'+sURL+'" target="_blank">'+sLinkTitle+'</a>'
									}
									sHTML+='</div>'
									sHTML+='</div>'
									sHTML+='<div class="hr2" style="clear:left;"></div>'
									sHTML+='</div>';
								}
								sResortInfo+=sHTML;
							}
							if(sVideoID&&document.getElementById('ResortVideo')) {
								if(sVideoType=='travelistic') {
									sVideoHTML='<embed type="application/x-shockwave-flash" src="http://media.travelistic.com/flash/diversionplayer.swf" id="diversionplayer" name="diversionplayer" bgcolor="#000000" quality="high" useexpressinstall="true" flashvars="vidID='+sVideoID+'&amp;remote=true" height="152" width="184" allowFullScreen="true" allowScriptAccess="always">';
								}else if(sVideoType=='youtube') {
									sVideoHTML='<embed src="http://www.youtube.com/v/'+sVideoID+'&rel=1" type="application/x-shockwave-flash" wmode="transparent" width="184" height="152"></embed>';
								}
								if(sVideoHTML) {
									document.getElementById('ResortVideo').innerHTML = sVideoHTML;
									document.getElementById('ResortVideo').style.display = '';
								}
							}
							document.getElementById('ResortDescription').innerHTML = sResortInfo
							images = xmldoc.getElementsByTagName('ResortImage');
							if(images.length>0) {
								for(x=0;x<images.length;x++) {
									sImage = images.item(x).attributes.getNamedItem("URL").nodeValue
									if(x==0){
										document.getElementById('ResortIMGPlaceHolder').innerHTML = '<img src="'+sImage+'" onerror="this.src=\'/images/general/_noimage.gif\'" id="placeHolderResort"/>'	
									}
									if(images.length>1) {
										document.getElementById('ResortIMGThumbs').innerHTML += '<img src='+sImage+' onerror="this.src=\'/images/general/_noimage.gif\'" onclick=SwitchPhoto("placeHolderResort","'+sImage+'") />'
										document.getElementById('ResortIMGThumbsText').style.display = '';
									}else{
										document.getElementById('ResortIMGThumbs').style.display = 'none';
										document.getElementById('ResortIMGPlaceHolder').style.borderBottom = '1px';
										
									}
								}
								document.getElementById('ResortMoreInfoIMG'+sCurrentPosition).style.display='';
							}
						//END RESORT INFO
						//START REGION INFO
							region = xmldoc.getElementsByTagName('Region');
							for(x=0;x<region.length;x++) {
								bRegion = true;
								sRegionName = region.item(x).attributes.getNamedItem("Name").nodeValue
								sRegionDesc = region.item(x).childNodes.item(0).childNodes.item(0).nodeValue
								document.getElementById('RegionDescription').innerHTML = sRegionDesc;
							}
							
							images = xmldoc.getElementsByTagName('RegionImage');
							if(images.length>0) {
								for(x=0;x<images.length;x++) {
									sImage = images.item(x).attributes.getNamedItem("URL").nodeValue
									if(x==0){
										document.getElementById('RegionIMGPlaceHolder').innerHTML = '<img src="'+sImage+'" onerror="this.src=\'/images/general/_noimage.gif\'" id="placeHolderRegion"/>'	
									}
									if(images.length>1) {
										document.getElementById('RegionIMGThumbs').innerHTML += '<img src='+sImage+' onerror="this.src=\'/images/general/_noimage.gif\'" onclick=SwitchPhoto("placeHolderRegion","'+sImage+'") />'
										document.getElementById('RegionIMGThumbsText').style.display = '';
									}else{
										document.getElementById('RegionIMGThumbs').style.display = 'none';
										document.getElementById('RegionIMGPlaceHolder').style.borderBottom = '1px';
										
									}
								}
								document.getElementById('RegionMoreInfoIMG'+sCurrentPosition).style.display='';
							}
						//END REGION INFO
						//START WEATHER
							weather = xmldoc.getElementsByTagName('Weather');
							if(weather.length>0) {
								bWeather = true;
								var sHTML = '';
								sHTML+='<table border="0" cellpadding="0" cellspacing="0" width="100%" class="weatherTable"><tr>'
								for(x=0;x<weather.length;x++) {
									sLocation = weather.item(x).attributes.getNamedItem("Location").nodeValue
									sDate = weather.item(x).attributes.getNamedItem("Date").nodeValue
									sLargeIcon = weather.item(x).attributes.getNamedItem("LargeIcon").nodeValue
									sSmallIcon = weather.item(x).attributes.getNamedItem("SmallIcon").nodeValue
									sDescription = weather.item(x).attributes.getNamedItem("Description").nodeValue
									sLowestTemp = weather.item(x).attributes.getNamedItem("LowestTemp").nodeValue
									sHighestTemp = weather.item(x).attributes.getNamedItem("HighestTemp").nodeValue
									sAvgTemp =	weather.item(x).attributes.getNamedItem("AvgTemp").nodeValue
									sWindSpeed = weather.item(x).attributes.getNamedItem("WindSpeed").nodeValue
									sWindDirection = weather.item(x).attributes.getNamedItem("WindDirection").nodeValue
									if(x<4){sClass = 'rightBorder';}else{sClass = '';}
									sHTML+='<td class="'+sClass+'" width="20%">';
									sHTML+='<div class="date">'+sDate+'</div>';
									sHTML+='<div class="icon"><img src="'+sLargeIcon+'" /></div>';
									sHTML+='<div class="description">'+sDescription+'</div>';
									sHTML+='<div class="hilotemp">Lo: '+sLowestTemp+'<br>Hi: '+sHighestTemp+'</div>';
									sHTML+='<div class="wind">'+sWindSpeed+' '+sWindDirection+'</div>';
									sHTML+='<div class="avgtemp">'+sAvgTemp+'</div>';
									sHTML+='</td>';
									
								}
								sHTML+='</tr></table>'
								document.getElementById('divResortInfo_4').innerHTML = sHTML;
							}
						//END WEATHER
						
						
						//START SHOW
						if(bGoogle||bWeather||bResort||bRegion) {
							document.getElementById('divResortInfo').style.display='';	
						}
						if(bGoogle) {
							document.getElementById('tab_1').style.display='';
							document.getElementById('tab_1').className=document.getElementById('tab_1').className+'Over';
							document.getElementById('divResortInfo_1').style.display='';
						}
						if(bResort) {
							document.getElementById('tab_2').style.display='';
							document.getElementById('divResortInfoTab').innerHTML = 'Info on '+sResortName;
						}
						if(bRegion) {
							document.getElementById('tab_3').style.display='';
							document.getElementById('divRegionInfoTab').innerHTML = 'Info on '+sRegionName;
						}
						if(bWeather) {
							document.getElementById('tab_4').style.display='';
						}
						if(!bGoogle && bResort) {
							document.getElementById('tab_2').className=document.getElementById('tab_2').className+'Over';
							document.getElementById('divResortInfo_2').style.display='';
						}
						if(!bGoogle && !bResort && bRegion) {
							document.getElementById('tab_3').className=document.getElementById('tab_3').className+'Over';
							document.getElementById('divResortInfo_3').style.display='';
						}
						if(!bGoogle && !bResort && !bRegion && bWeather) {
							document.getElementById('tab_4').className=document.getElementById('tab_4').className+'Over';
							document.getElementById('divResortInfo_4').style.display='';
						}
						if(!bGoogle && !bResort && !bRegion && !bWeather) {
							document.getElementById('divResortInfoNoResults').style.display='';
							document.getElementById('divDestInfoTabHolder').style.height='0px';
							
						}
						// END SHOW
					}
				}
			}
		}
		
		function showHideThing(id,bShow) {
			if(document.getElementById('thingtosee_'+id)) {
				if(document.getElementById('thingtosee_'+id).style.display=='none'||bShow==true) {
					document.getElementById('thingtosee_'+id).style.display='';
				}else{
					document.getElementById('thingtosee_'+id).style.display='none';									
				}
			}
		}
		
		function ResortTab(div) {
			for(x=1;x<10;x++) {
				if(document.getElementById('tab_'+x)) {
					document.getElementById('tab_'+x).className = Left(document.getElementById('tab_'+x).className,3);		   
				}
				if(document.getElementById('divResortInfo_'+x)) {
					document.getElementById('divResortInfo_'+x).style.display='none';
				}
			}
			if(document.getElementById('divResortInfo_'+Right(div,1))) {
				document.getElementById(div).className = document.getElementById(div).className+'Over';
				document.getElementById('divResortInfo_'+Right(div,1)).style.display='';
				SelectedSearchTab = div
			}
		}
	/* END RESORT INFO AJAX */
	
/* END RESULTS JS */
/* START PRICING JS */

	function checkPaxForm(sBookLevel, sParentID,startdate,PAX) {
		//if(checkFlightMealQty() == false)
		//{ return false; }
		if(checkFormFieldSelectedIndex("title", "Please select a title for all passengers!") == false)
		{ return false; }
		if(checkFormFieldValue("firstname", "- Firstname -", "Please enter a valid first name for all passengers!") == false)
		{ return false; }
		if(checkFormFieldValue("surname", "- Surname -", "Please enter a valid surname for all passengers!") == false)
		{ return false; }
		if(document.getElementById('carAddDriver51') && document.getElementById('carAddDriver51').style.display != 'none'){
			if(checkFormFieldSelectedIndex("CarDriverAddTitle1", "Please select a title for all additional drivers!") == false)
			{ return false; }
			if(checkFormFieldValue("CarDriverAddFName1", "- First name -", "Please enter a valid first name for all additional drivers!") == false)
			{ return false; }
			if(checkFormFieldValue("CarDriverAddSName1", "- Surname -", "Please enter a valid surname for all additional drivers!") == false)
			{ return false; }
		}
		if(document.getElementById('carAddDriver56') && document.getElementById('carAddDriver56').style.display != 'none'){
			if(checkFormFieldSelectedIndex("CarDriverAddTitle2", "Please select a title for all additional drivers!") == false)
			{ return false; }
			if(checkFormFieldValue("CarDriverAddFName2", "- First name -", "Please enter a valid first name for all additional drivers!") == false)
			{ return false; }
			if(checkFormFieldValue("CarDriverAddSName2", "- Surname -", "Please enter a valid surname for all additional drivers!") == false)
			{ return false; }
		}
		if(checkAgeDOBMatch(parseInt(PAX),''+startdate+'') == false)
		{ return false; }
		if(checkFormValidateAttrib('input') == false)
		{ return false; }
		if(document.frmResults.SW2B && document.frmResults.SW2B.value == '-') {
			alert('Please enter When are you likely to book?');
			document.frmResults.SW2B.focus();
			return false;
		}
		if(document.frmResults.CarFlightNo != undefined && (document.frmResults.CarFlightNo.value == "" || document.frmResults.CarFlightNo.value == "Flight No.")){
			alert('Please enter your flight number!');
			document.frmResults.CarFlightNo.focus();
			return false;
		//}
		//else if(document.frmResults.CarFlightTime != undefined && (document.frmResults.CarFlightTime.value.length != 5 || document.frmResults.CarFlightTime.value == "hh:mm")){
		//	alert('Please enter your flight arrival time!\neg. 09:00');
		//	document.frmResults.CarFlightTime.focus();
		//	return false;
		//}
		//else if(!document.frmResults.acceptterms.checked){
		//	alert('Please confirm that you have read and understood any\nimportant information and\/or terms and conditions!'); document.frmResults.acceptterms.focus();
		//	return false;
		}else{
			setLevel(sBookLevel);
			if(sParentID!='') { setParentID(sParentID); }
			frmBYOSubmit(true); 
		}
	}
	
	function checkFormValidateAttrib(type) {
		sObjects = document.getElementsByTagName(type);
		for(x=0;x<sObjects.length;x++) {
			if(sObjects[x].getAttribute('validateFId')=='true' || sObjects[x].getAttribute('validateFId')=='True') {
				if(sObjects[x].name=='email') {
					if(!/.+@[^.]+(\.[^.]+)+/.test(sObjects[x].value) || isValidField(sObjects[x].value,2) == false || sObjects[x].value=='- Email -') {
						alert('Please enter a valid email address');
						sObjects[x].focus();
						return false;
					}
				}else if(sObjects[x].name=='telephone') {
					if(sObjects[x].value=='- Phone -' || !sObjects[x].value) {
						alert('Please enter your telephone number');
						sObjects[x].focus();
						return false;
					}
				}else if(!sObjects[x].value){
					if(!sObjects[x].getAttribute('validateName')) {
						alert('Please fill in the following field: ' + sObjects[x].name);
					}else{
						alert(sObjects[x].getAttribute('validateName'));
					}
					sObjects[x].focus();
					return false;
				}
			}
		}
	}
	
	function checkAdditinalPax() {
		if (document.getElementById('AddExtraDriver')){
			if(document.getElementById('AddExtraDriver').selectedIndex == 1){
				if(checkFormFieldSelectedIndex("CarDriverAddTitle1", "Please select a title for additional driver!") == false)
				{ return false; }
				else if(checkFormFieldValue("CarDriverAddFName1", "- Firstname -", "Please enter a first name for additional driver!",2) == false)
				{ return false; }
				else if(checkFormFieldValue("CarDriverAddSName1", "- Surname -", "Please enter a surname for additional driver!") == false)
				{ return false; }
				else if(checkFormAdditionalFieldAges("Please check the additional drivers date of birth!") == false)
				{ return false; }
			}
			else
			{ return true; }
		}else
		{ return true; }
	}
	function checkAdditinalsecondPax(){
		if (document.getElementById('AddSecondExtraDriver')){
			if(document.getElementById('AddSecondExtraDriver').selectedIndex == 1){
				if(checkFormFieldSelectedIndex("CarDriverAddTitle2", "Please select a title for second additional driver!") == false)
				{ return false; }
				else if(checkFormFieldValue("CarDriverAddFName2", "- Firstname -", "Please enter a first name for second additional driver!",2) == false)
				{ return false; }
				else if(checkFormFieldValue("CarDriverAddSName2", "- Surname -", "Please enter a surname for second additional driver!") == false)
				{ return false; }
				else if(checkFormSecondAdditionalFieldAges("Please check the second additional drivers date of birth!") == false)
				{ return false; }
			}
			else
			{ return true; }
		}
		else
		{ return true; }
	}
	
	function checkAgeDOBMatch(NumPAX, DepDate){
		var i, today, d, by, bm, bd, bday, age, dif, DOB
		//alert('Checking Ages');
		var ErrTxt = "Please ensure child ages and their date of births match! -\n\n"
		//alert('AgeChecking1');
		var ageLimit=0;
		var bAdultIncluded = false;
		var bCarAdultIncluded = false;
		var bIncCar = false;
		for (i = 1; i < NumPAX+1; i++) {
			if(document.getElementById('type'+i) && document.getElementById('dobd' + i) && document.getElementById('dobm' + i) && document.getElementById('doby' + i)) {
				if(!CTisDate(document.getElementById('dobd' + i).value+'/'+document.getElementById('dobm' + i).value+'/'+document.getElementById('doby' + i).value)) {
					alert('Passenger '+i+': Please enter a valid birthdate for this passenger');
					return false;
				}else{
				
					var sType = document.getElementById('type'+i).value;
					//get depdate in correct format
					d = DepDate.split('/'); 
					by = Number(d[2]); bm = Number(d[1])-1; bd = Number(d[0]); 
					today = new Date(by,bm,bd);
					
					//get childs DOB in correct format
					DOB = document.getElementById('dobd' + i).value + "/" + document.getElementById('dobm' + i).value + "/" + document.getElementById('doby' + i).value
					d =DOB.split('/'); 
					by = Number(d[2]); bm = Number(d[1])-1; bd = Number(d[0]); 
					bday = new Date(by,bm,bd) 
					age=0; dif=bday; 
					while(dif<today){ 
						dif = new Date(by+age,bm,parseInt(bd)-1); 
						age++; 
					} 
					
					// NE 15/12/2008
					if (bday >= new Date()) { alert('Passenger '+i+': Date of birth is not valid'); return false }

					age +=-2 ;
					if(DOB.length<10) {
						alert('Passenger '+i+': Please enter this passengers birthdate');
						return false;
					}else{
						if(sType == 'CHD' || sType == 'INF') {
							if(document.getElementById('dobd' + i).getAttribute('minage')) {
								iMinAge = parseInt(document.getElementById('dobd' + i).getAttribute('minage'));
								iMaxAge = parseInt(document.getElementById('dobd' + i).getAttribute('maxage'));
							}else{
								iMinAge = (sType == 'CHD') ? 2 : 0;
								iMaxAge = (sType == 'INF') ? 2 : 12;
							}
							//alert(age + ' passenger '+i);
							if (sType == 'CHD') sPaxTypeText = "a Child";
							if (sType == 'INF') sPaxTypeText = "an Infant";
							

							if(age < iMinAge || age >= iMaxAge) {
								if(age < iMinAge){
									alert('Passenger '+i+': This passenger is too young to be classed as ' + sPaxTypeText + ' passenger');
								} else if(age >= iMaxAge && sType == 'CHD'){
									alert('Passenger '+i+': This passenger is too old to be classed as a Child passenger');
								}else{
									alert('Passenger '+i+': This passenger is too old to be classed as an Infant passenger');
								}

								
								return false;	
							}	
							
						}
						if(age >= 18 || age < 0) {
							if(bAdultIncluded==false) {
								bAdultIncluded = true;
							}
						}
						//HA 21 age check
						if(document.getElementById('carAddDriver51') || document.getElementById('carAddDriver56')){
							bIncCar = true;
							if(i==1){
								if(age >= 21) {
									if(bCarAdultIncluded==false) {
										bCarAdultIncluded = true;
									}
								}
							}
							objAddPX1 = document.getElementById('carAddDriver51');
							objAddPX2 = document.getElementById('carAddDriver56');
							intAddDriversSelected = 1;
							
							if(objAddPX1 && objAddPX1.style.display != 'none'){
								intAddDriversSelected ++
							}
							if(objAddPX2 && objAddPX2.style.display != 'none'){
								intAddDriversSelected ++
							}
							//if(objAddPX1 && objAddPX1.style.display != 'none'){
							for(iAddDrivers = 1; iAddDrivers < intAddDriversSelected; iAddDrivers++){
								dd = document.getElementById('CarDriverAddDOBD' + iAddDrivers);
								mm = document.getElementById('CarDriverAddDOBM' + iAddDrivers);
								yyyy = document.getElementById('CarDriverAddDOBY' + iAddDrivers);				
								
								strDate = dd.options[dd.selectedIndex].value + '/' + mm.options[mm.selectedIndex].value + '/' + yyyy.options[yyyy.selectedIndex].value		
								if(!CTisDate(strDate)){
									alert('Please enter a valid birthdate for addtional driver ' + iAddDrivers);
									return false;
								}else{
									var dr1d, dr1by, dr1bm, dr1bd, dr1bday, dr1age, dr1dif
									dr1d =strDate.split('/'); 
									dr1by = Number(dr1d[2]); dr1bm = Number(dr1d[1])-1; dr1bd = Number(dr1d[0]); 
									dr1bday = new Date(dr1by,dr1bm,dr1bd) 
									dr1age=0; dr1dif=dr1bday; 
									while(dr1dif<today){ 
										dr1dif = new Date(dr1by+dr1age,dr1bm,parseInt(dr1bd)-1); 
										dr1age++; 
									} 
									dr1age = dr1age - 2
									if(dr1age < 21){
										alert('Due to restrictions on car hire, the lead passenger and additional drivers must be at least 21 years of age');
										return false;
									}
								}
							}
						}
					}
				}
			}else{
				bAdultIncluded = true;
			}
		}
		if(bAdultIncluded!=true) {
			alert('A least one passenger must be 18 or over');
			return false;
		}
		if(bCarAdultIncluded!=true && bIncCar == true){
			alert('Due to restrictions on car hire, the lead passenger and additional drivers must be at least 21 years of age');
			return false;
		}
	}
	
	function Querystring(qs) { // optionally pass a querystring to parse
		this.params = new Object()
		this.get=Querystring_get
		
		if (qs == null)
			qs=location.search.substring(1,location.search.length)
	
		if (qs.length == 0) return
	
	// Turn <plus> back to <space>
	// See: http://www.w3.org/TR/REC-html40/interact/forms.html#h-17.13.4.1
		qs = qs.replace(/\+/g, ' ')
		var args = qs.split('&') // parse out name/value pairs separated via &
		
	// split out each name=value pair
		for (var i=0;i<args.length;i++) {
			var value;
			var pair = args[i].split('=')
			var name = unescape(pair[0])
	
			if (pair.length == 2)
				value = unescape(pair[1])
			else
				value = name
			
			this.params[name] = value
		}
	}
	
	function Querystring_get(key, default_) {
		// This silly looking line changes UNDEFINED to NULL
		if (default_ == null) default_ = null;
		
		var value=this.params[key]
		if (value==null) value=default_;
		
		return value
	}
	
	function getTotalPrice(sCode, sRate, sSymbol, bIsPerPerson) {
		iTotalPrice = 0
		iDepositPrice = 0
		var qs = new Querystring()
		var sDebug = qs.get("Debug")
		if(sDebug == 'true'){
			bDebug = true;
		}else{
			bDebug = false;
		}
		radio = document.getElementsByTagName('input')
		var numPax = 1;
		if(document.getElementById('numPax')) { 
			numPax = parseFloat(document.getElementById('numPax').value)
		}
		for(x=0;x<radio.length;x++) {
			
			if(radio[x].getAttribute('itemValue')!=null && radio[x].getAttribute('itemValue')!='NaN') {
				if(bDebug){alert(radio[x].getAttribute('itemValue'))};
				if(((radio[x].type=='radio' || radio[x].type=='checkbox') && radio[x].checked == true) || radio[x].type=='hidden'){
					iTotalPrice += parseFloat(radio[x].getAttribute('itemValue'))
					if(bDebug){alert('Added')};
				}
			}
			if(radio[x].getAttribute('depositValue')!=null && radio[x].getAttribute('depositValue')!='NaN') {
				if(((radio[x].type=='radio' || radio[x].type=='checkbox') && radio[x].checked == true) || radio[x].type=='hidden'){
					iDepositPrice += parseFloat(radio[x].getAttribute('depositValue'))
					//break;
				}
			}
		}
		
		objSelect = document.getElementsByTagName('select')
		for(x=0;x<objSelect.length;x++) 
		{
			if(objSelect[x].options[objSelect[x].selectedIndex].getAttribute('itemValue')!=null && objSelect[x].options[objSelect[x].selectedIndex].getAttribute('itemValue')!='NaN')
			{
				iTotalPrice += parseFloat(objSelect[x].options[objSelect[x].selectedIndex].getAttribute('itemValue'))
			}
		}
		
		if(sCode && sRate) {
			sTotalPrice = formatCurrency(iTotalPrice/100*parseFloat(sRate),true);
			sPricePerPax = formatCurrency((iTotalPrice / numPax)/100*parseFloat(sRate),true);
			sTotalDeposit = formatCurrency(iDepositPrice/100*parseFloat(sRate),true);
			if(sSymbol) {
				sTotalPrice = sSymbol + sTotalPrice;
				sPricePerPax = sSymbol + sPricePerPax;
				sTotalDeposit = sSymbol + sTotalDeposit;
			}else{
				sTotalPrice += ' ' + sCode;
				sPricePerPax += ' ' + sCode;
				sTotalDeposit += ' ' + sCode;
			}
		}else{
			sTotalPrice = formatCurrency(iTotalPrice);
			sPricePerPax = formatCurrency(iTotalPrice / numPax);
			if(bIsPerPerson) {
				sTotalDeposit = formatCurrency(iDepositPrice / numPax);
			}else{
				sTotalDeposit = formatCurrency(iDepositPrice);
			}
		}
		if(document.getElementById('TotalPrice_Top')) {
			document.getElementById('TotalPrice_Top').innerHTML = sTotalPrice;
		}
		if(document.getElementById('TotalDeposit_Top')) {
			document.getElementById('TotalDeposit_Top').innerHTML = sTotalDeposit;
		}
		if(document.getElementById('PricePerPax_Top')) {
			document.getElementById('PricePerPax_Top').innerHTML = sPricePerPax;
		}
	}
	
	//Start Functions added by Casper Thun 2007/06/28 for multiple rooms on pricing
	var bTotalRoomPricesSet = 0;
	function changeBoardtype(id) {
		var iFoundSelected = 0;
		if(document.getElementById('available_boardtypes')) {
			sSelect = document.getElementById('available_boardtypes')
			for(x=0;x<sSelect.length;x++) {
				for(i=1;i<4;i++) {
					for(y=0;y<32;y++) {
						if(document.getElementById(sSelect[x].value+'_'+i+'_'+y)) {
							document.getElementById(sSelect[x].value+'_'+i+'_'+y).style.display='none';
						}
					}
				}
			}
		}
		for(i=1;i<4;i++) {
			iFoundSelected = 0;
			for(x=0;x<32;x++) {
				if(document.getElementById(id+'_'+i+'_'+x) && document.getElementById('RB_'+i+'_'+x)) {
					if(document.getElementById(id+'_'+i+'_'+x)) {
						document.getElementById(id+'_'+i+'_'+x).style.display='';
					}
					if(iFoundSelected==0 && document.getElementById('RB_'+i+'_'+x)) {
						iFoundSelected = 1;
						document.getElementById('RB_'+i+'_'+x).checked = true;
					}
				}
			}
		}
		bTotalRoomPricesSet = 1;
	}
	//End Functions added by Casper Thun 2007/06/28 for multiple rooms on pricing

	function setRoomType(strRoomType)
	{
		radio = document.getElementsByTagName('input');
		for(x=0;x<radio.length-1;x++) {
			if(radio[x].type == 'radio' && radio[x].getAttribute('roomType')!=null && radio[x].getAttribute('roomType')!='NaN' && radio[x].getAttribute('roomType') == strRoomType){
				radio[x].checked = true;					
			}
		}
	}
	
	function checkFlightMealQty(){
		if(document.getElementById('numPax')) {
			var numPax = 1;
			var nummeals = 0;
			var x;
			var totalmeals = 0;
			var mealValue;
			numPax = parseFloat(document.getElementById('numPax').value);
			if(document.getElementById('numMeals')){
				nummeals = parseFloat(document.getElementById('numMeals').value);
				for(x=1;x<=nummeals;x++){
					mealValue = document.getElementById('mealopt_' + x).value;
					if (mealValue.split(';')[0] != ''){
						totalmeals = totalmeals + parseFloat(mealValue.split(';')[0]);
					}
				}
				if (totalmeals != numPax){
					alert('Your total number of meals must equal the number of passengers (' + numPax + ')');
					return false;
				}else{
					return true;
				}
			}else{
				return true;
			}
		}
	}

	function setClientData(){
		if(document.getElementById('BYOClientDateTime')) {
			var dteNow = new Date();
			var strDatetime = '';			
			
			var strMonth = (dteNow.getMonth() + 1).toString();
			var strDate = dteNow.getDate().toString()
			var strHours = dteNow.getHours().toString();
			var strMins = dteNow.getMinutes().toString();
			strDatetime = dteNow.getFullYear() + '-' + ((strMonth.length == 1) ? '0':'')  + strMonth + '-' + ((strDate.length == 1) ? '0':'')  + strDate + ' ';
			strDatetime +=	((strHours.length == 1) ? '0':'')  + strHours + ':' + ((strMins.length == 1) ? '0':'') + strMins;
		
			document.getElementById('BYOClientDateTime').value = strDatetime;
		}
	}
	
	// JF 13/11/2008
	function carhireDamageCheck(equiptype){
		if(equiptype=='60'){
			if (document.getElementById('ET53') != undefined){document.getElementById('ET53').checked = false}
		}
		if(equiptype=='53'){
			if (document.getElementById('ET60') != undefined){document.getElementById('ET60').checked = false}
		}
	}


/*END PRICING JS */