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;
		}
		if(sProvider=='MultiCOM') {
			var flightRadio = document.getElementsByName('tblFH_'+position);
			if(flightRadio){
				for(x=0;x<flightRadio.length;x++) {
					if(flightRadio[x].checked==true) {
						sFlightID=flightRadio[x].value;
					}
				}
				document.frmResults.packageholiday_itineraryid.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 setTour(fId, cId, pId, sessionId) {
		document.frmResults.tour_provider.value=pId;
		document.frmResults.tour_id.value=cId;
		document.frmResults.search_type.value='Tour';
		document.frmResults.Provider_Flight.value='';
	}
	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 setSortMCPackages(type, page) {
		document.frmResults.txtIsPostBack.value="true";
		if(type>0) {
			if(type==1) {
				setSortHotels("translate(@STANDARD_PRICE,',','')",'number','descending','1');
			}
			if(type==2)	{
				setSortHotels("translate(@STANDARD_PRICE,',','')",'number','ascending','2');
			}
			if(type==3)	{
				setSortHotels('substring(Accommodation/@ClassCode,1,1)','number','descending','3');
			}
			if(type==4)	{
				setSortHotels('substring(Accommodation/@ClassCode,1,1)','number','ascending','4');
			}
			if(type==5)	{
				setSortHotels('Accommodation/@AccommodationName','text','ascending','5');
			}
			if(type==6)	{
				setSortHotels('Accommodation/@AccommodationName','text','descending','6');
			}
			if(type==7)	{
				setSortHotels('default','','','0');
			}
			ChangePageHotels(page);
		}
	}
	
	function setSortHotelsNEW(type, page) {
		document.frmResults.txtIsPostBack.value="true";
		if(type>0) {
			if(type==1) {
				setSortHotels("translate(CSI_ARE/CHEAPEST_PRICE,',','')",'number','descending','1');
			}
			if(type==2)	{
				setSortHotels("translate(CSI_ARE/CHEAPEST_PRICE,',','')",'number','ascending','2');
			}
			if(type==3)	{
				setSortHotels('AccommInfo/StarRating','number','descending','3');
			}
			if(type==4)	{
				setSortHotels('AccommInfo/StarRating','number','ascending','4');
			}
			if(type==5)	{
				setSortHotels('AccommInfo/AccommName','text','ascending','5');
			}
			if(type==6)	{
				setSortHotels('AccommInfo/AccommName','text','descending','6');
			}
			if(type==7)	{
				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();
		/*Page override set the paging back to 1 as we don't know how many pages are going to come back*/
		ChangePageHotels(0);		
	}

	/* 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, sUnknown, sExtra) {
			if (sLink=='' && document.getElementById('linkshowhidehotelinfo'+sPosition)){
				sLink = document.getElementById('linkshowhidehotelinfo'+sPosition)
			}
			sCurrentPosition = sPosition
			sPosition = sPosition.replace('_spec', '');
			if(!sSessionID && document.getElementById('SessionID')){
				sSessionID = document.getElementById('SessionID').value
			}
			if(sExtra != undefined) {
				if(sExtra.length > 0) {
					sPosition = sExtra + sPosition;
				}
			}
			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 = '';
		
		var fnReloadResortInfo = ''; //store the function call so that we can call it again	       
	    var bDelayMapLoad = true; //should the google map be delayed (not loaded until the customer wishes to view it)
        var bAutoShowMap = false; //flag stating that the google map loader should show the map straight away

	    function ShowLoadingDiv ()
	    {
	    
	        document.getElementById('divResortInfoLoader').style.display = '';
	        document.getElementById('divResortInfo').style.display='none';
	    
	    }	
		
		function GetResortInfo(sSearchType, sAirportTo, sFlightMatrixVars, sFlightMatrixOrderBy, sFlightMatrixSortType) {
			
			//store the function call
	        fnReloadResortInfo = function ReloadResortInfo ()
	        {
	            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="0" cellpadding="3" cellspacing="1" 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 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 noWrap>'+sAirportFrom+'</td>';
								sHTML+='<td noWrap>'+sDepDate+'</td>';
								sHTML+='<td>'+sAirportTo+'</td>';
								if(parseFloat(iReturnFlight)==1) {
									sHTML+='<td noWrap>'+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><br /><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='904px';
									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;"><span class="ResortGoogleMapBottext">'+sIconHTML+'</span></div>';
												document.getElementById('ResortGoogleMapBot').style.display = '';
											}
										}
									}
									if(document.getElementById('divDisplayContent_1')) {
										document.getElementById('divDisplayContent_1').style.display = 'none';
									}
								}
							}
						}
						//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>'
								if (document.getElementById('divDisplayContent_4')){
									document.getElementById('divDisplayContent_4').innerHTML = sHTML;
								}else{
									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='';
							document.getElementById('divDisplayLink_1').className='bulletLink_down';
			                document.getElementById('divDisplayLink_1').innerHTML = document.getElementById('divDisplayLink_1').innerHTML.replace('Click here to view','Click here to hide');
							document.getElementById('divDisplayContent_1').style.display='';
							document.getElementById('ResortGoogleMapBot').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 */
	
	function redirectTourToFlightHotel(lPackageID, lDuration, sNewURL)
	{
	    var lCacheID = document.getElementById('ddlDate_' + lPackageID).options[document.getElementById('ddlDate_' + lPackageID).selectedIndex].attributes['CacheID'].value;
	    var sStartDate = document.getElementById('ddlDate_' + lPackageID).options[document.getElementById('ddlDate_' + lPackageID).selectedIndex].value;
	    var arStartDate = sStartDate.split('/');
	    var arEndDate = sStartDate.split('/');
	    if (arStartDate[0].substring(0,1) == '0') 
	    {
	        arStartDate[0] = arStartDate[0].substring(1,2);
	        arEndDate[0] = arEndDate[0].substring(1,2);
	    }
	        
	    if (arStartDate[1].substring(0,1) == '0') 
	    {
	        arStartDate[1] = arStartDate[1].substring(1,2);
	        arEndDate[1] = arEndDate[1].substring(1,2);
	    }
	    sNewURL = sNewURL.replace("[sdd]", arStartDate[0]);
	    sNewURL = sNewURL.replace("[sdm]", arStartDate[1]);
	    sNewURL = sNewURL.replace("[sdy]", arStartDate[2]);
	    for (var iDur = 0; iDur < lDuration; iDur++)
	    {
	        arEndDate[0] = parseInt(arEndDate[0]) + 1;
	        if (!CTisDate(arEndDate[0] + '/' + arEndDate[1] + '/' + arEndDate[2]))
	        {
	            arEndDate[1] = parseInt(arEndDate[1]) + 1;
	            arEndDate[0] = 1;
	            if (!CTisDate(arEndDate[0] + '/' + arEndDate[1] + '/' + arEndDate[2]))
	            {
	                arEndDate[2] = parseInt(arEndDate[2]) + 1;
	                arEndDate[1] = 1;
	                arEndDate[0] = 1;
	            }
	        }
	    }
	    sNewURL = sNewURL.replace("[edd]", arEndDate[0]);
	    sNewURL = sNewURL.replace("[edm]", arEndDate[1]);
	    sNewURL = sNewURL.replace("[edy]", arEndDate[2]);
	    var sStartDateText;
	    sStartDateText = arStartDate[0] + ' ';
	    switch (arStartDate[1])
	    {
	        case '1': sStartDateText = sStartDateText + 'January '; break;
	        case '2': sStartDateText = sStartDateText + 'February '; break;
	        case '3': sStartDateText = sStartDateText + 'March '; break;
	        case '4': sStartDateText = sStartDateText + 'April '; break;
	        case '5': sStartDateText = sStartDateText + 'May '; break;
	        case '6': sStartDateText = sStartDateText + 'June '; break;
	        case '7': sStartDateText = sStartDateText + 'July '; break;
	        case '8': sStartDateText = sStartDateText + 'August '; break;
	        case '9': sStartDateText = sStartDateText + 'September '; break;
	        case '10': sStartDateText = sStartDateText + 'October '; break;
	        case '11': sStartDateText = sStartDateText + 'November '; break;
	        case '12': sStartDateText = sStartDateText + 'December '; break;
	    }
	    sStartDateText = sStartDateText + arStartDate[2];
	    var sEndDateText;
	    sEndDateText = arEndDate[0] + ' ';
	    switch (arEndDate[1])
	    {
	        case '1': sEndDateText = sEndDateText + 'January '; break;
	        case '2': sEndDateText = sEndDateText + 'February '; break;
	        case '3': sEndDateText = sEndDateText + 'March '; break;
	        case '4': sEndDateText = sEndDateText + 'April '; break;
	        case '5': sEndDateText = sEndDateText + 'May '; break;
	        case '6': sEndDateText = sEndDateText + 'June '; break;
	        case '7': sEndDateText = sEndDateText + 'July '; break;
	        case '8': sEndDateText = sEndDateText + 'August '; break;
	        case '9': sEndDateText = sEndDateText + 'September '; break;
	        case '10': sEndDateText = sEndDateText + 'October '; break;
	        case '11': sEndDateText = sEndDateText + 'November '; break;
	        case '12': sEndDateText = sEndDateText + 'December '; break;
	    }
	    sEndDateText = sEndDateText + arEndDate[2];
	    
	    sNewURL = sNewURL + '&startdate=' + sStartDateText;
	    sNewURL = sNewURL + '&enddate=' + sEndDateText;
	    sNewURL = sNewURL + '&tourcacheid='+lCacheID;
	    sNewURL = sNewURL + '&CreateSession=true';
	    
	    for (var iStay = 0; iStay < 30; iStay++)
	    {
	        for (var iStayOption = 0; iStayOption < 100; iStayOption++)
	        {
	            if(document.getElementById('rbUpgrades_' + lPackageID + '_' + iStay + '_' + iStayOption))
	            {
	                if(document.getElementById('rbUpgrades_' + lPackageID + '_' + iStay + '_' + iStayOption).checked == true && document.getElementById('rbUpgrades_' + lPackageID + '_' + iStay + '_' + iStayOption).value != '')
	                {
	                    sNewURL = sNewURL + '&rbUpgrades_' + lPackageID + '_' + iStay + '=' + document.getElementById('rbUpgrades_' + lPackageID + '_' + iStay + '_' + iStayOption).value;
	                }
	            }
	        }
	    }
	    
		div_switch('pleasewaitDiv_3rdPartyFlights',true,true);
		div_switch('websiteDiv',false,false);
	    location.href = sNewURL;
	}
	
/* END RESULTS JS */
/* START PRICING JS */
	function checkPaxForm(sBookLevel, sParentID,startdate,PAX) {
		if(validatePricing(sBookLevel,sParentID,startdate,PAX)){
			setLevel(sBookLevel);
			if(sParentID!='') { setParentID(sParentID); }
			frmBYOSubmit(true);   
		}
	}
	
	function validatePricing(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!", 2) == false)
		{ return false; }
		if(checkFormFieldValue("email", "- Email -", "Please enter a valid email address for all passengers!", 6, 'email') == false)
		{ return false; }	
        if (document.getElementById('confirmemail').value != document.getElementById('email').value)
        { alert("Please confirm your email address!"); document.getElementById('confirmemail').focus(); 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(document.getElementById('AgeCheckNoChilds') && document.getElementById('AgeCheckNoAdults') && document.getElementById('AgeCheckDepDate') && document.getElementById('AgeCheckSearchType')) {
			if(checkAgeDOBMatch2(document.getElementById('AgeCheckNoChilds').value, document.getElementById('AgeCheckNoAdults').value, document.getElementById('AgeCheckDepDate').value, document.getElementById('AgeCheckSearchType').value) == false)
			{ return false; }
		}
		if (checkDuplicateNames(parseInt(PAX)) == false)
		{ return false; }
		if(checkPassportInfo(parseInt(PAX), startdate) == false) 
		{ return false; }
		if(checkFormValidateAttrib('input') == false)
		{ return false; }
		//if(checkAdultInfantNameLength(parseInt(PAX)) == false) 
		//{ return false; }
		//Emergency contact check details check
		if(document.frmResults.emergencyContactType != undefined){
			if(document.frmResults.emergencyContactType.value == '1'){
				if(checkFormFieldValue("ECName_", "- Contact name -", "Please enter a valid emergency contact name for all passengers!") == false)
				{return false; }
				if(checkFormFieldValue("ECTel_", "- Contact tel no. -", "Please enter a valid emergency telephone number for all passengers!", "", "telno") == 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{
			return true;
		}
	}
	
	function checkAdultInfantNameLength(NumPAX){
		var intADT = 0;
		var intINF = 0;
		
		
		for (i = 1; i < NumPAX+1; i++) {
			if(document.getElementById('type'+i) && document.getElementById('type'+i).value == 'ADT'){
				intADT++; 
			}
			if(document.getElementById('type'+i) && document.getElementById('type'+i).value == 'INF'){
				intINF++; 
			}
		}
		if(intINF > 0){
			var joinedname = new Array(intINF);
			for(intNames = 0; intNames < joinedname.length; intNames++)
			{
				joinedname[intNames] = '';
			}
			var intAdultCounter = 0;
			var intInfantCounter = 0;

			for (i = 1; i < NumPAX+1; i++) {
				if(document.getElementById('type'+i) && document.getElementById('type'+i).value == 'ADT' && i == intAdultCounter + 1){
					if(intAdultCounter + 1 <= joinedname.length){
						joinedname[intAdultCounter] = joinedname[intAdultCounter] + document.getElementById('title'+i).options[document.getElementById('title'+i).selectedIndex].value + document.getElementById('firstname'+i).value + document.getElementById('surname'+i).value;
						intAdultCounter++;
					}
				}
				if(document.getElementById('type'+i) && document.getElementById('type'+i).value == 'INF'){
					joinedname[intInfantCounter] = joinedname[intInfantCounter] + document.getElementById('firstname'+i).value + document.getElementById('surname'+i).value;
					intInfantCounter ++;
				}
			}
			
			for(intNames = 0; intNames < joinedname.length; intNames++)
			{
				if(joinedname[intNames].length > 38){
					alert('The passenger names for the adult and infant are too long, could you please contact our helpline to continue the booking process');
					return false;
				}
			}
		}
	}

	// NE 13/11/2008
	function checkPassportInfo(iNumPax, dReturnDate) {
			
		var sPassportNoList = new String('');
		
		for(var i = 1; i <= iNumPax; i++) {
			if(document.getElementById('infoPassportNum'+i)) {
				if(document.getElementById('infoPassportNum'+i).disabled == false) {
					if(!checkAlpha(document.getElementById('infoPassportNum'+i).value.replace(' ', '').substring(0, 3))) {
						alert('Passenger '+i+': The passport country entered is not valid, this should be a three letter code.');
						return false;
					} else if(!checkNumeric(document.getElementById('infoPassportNum'+i).value.replace(' ', '').substring(3))) {
						alert('Passenger '+i+': The passport number entered contains invalid characters.');
						return false;
					}
					var sExpiryDay = document.getElementById('infoPassportExpiryD'+i).options[document.getElementById('infoPassportExpiryD'+i).selectedIndex].value;
					var sExpiryMonth = document.getElementById('infoPassportExpiryM'+i).options[document.getElementById('infoPassportExpiryM'+i).selectedIndex].value;
					var sExpiryYear = document.getElementById('infoPassportExpiryY'+i).options[document.getElementById('infoPassportExpiryY'+i).selectedIndex].value;
					var arReturn = dReturnDate.split('/');
					var sExpiry = sExpiryDay + "/" + sExpiryMonth + "/" + sExpiryYear;
	
					if(!(new Date(sExpiryYear, sExpiryMonth, sExpiryDay)).getTime()) { alert('Passenger '+i+': Invalid passport expiry date.'); return false; }
					else if((new Date(sExpiryYear, sExpiryMonth, sExpiryDay)).getTime() <= (new Date(arReturn[2], arReturn[1], arReturn[0])).getTime()) {
						alert('Passenger '+i+': The expiry date for the passport entered will expire before the return date. A valid passport at time of travel is required in order to book.');
						return false;
					}
					
					if (sPassportNoList.indexOf('|' + document.getElementById('infoPassportNum'+i).value.replace(' ', '') + '|') == -1)
					{
						sPassportNoList += '|' + document.getElementById('infoPassportNum'+i).value.replace(' ', '') + '|';
					} else {
						alert('Passenger '+i+': The passport number has already been used. Each passenger must have their own passport.');
						return false;
					}	
				}
			}
			
		}
	}
	
	// NE 15/12/2008 Check duplicate names
	function checkDuplicateNames(iNumPax)
	{
		var sPaxList = new String('');
		var sPax = new String('');
		
		for(var i = 1; i <= iNumPax; i++) {
			sPax = '';
//		if (document.getElementById('title'+i)) sPax += document.getElementById('title'+i).value.toUpperCase() + '|';
			if (document.getElementById('firstname'+i)) sPax += document.getElementById('firstname'+i).value.toUpperCase() + '|';
			if (document.getElementById('surname'+i)) sPax += document.getElementById('surname'+i).value.toUpperCase() + '|';

			if (document.getElementById('dobd'+i)) sPax += document.getElementById('dobd'+i).options[document.getElementById('dobd'+i).selectedIndex].value;
			if (document.getElementById('dobm'+i)) sPax += document.getElementById('dobm'+i).options[document.getElementById('dobm'+i).selectedIndex].value;
			if (document.getElementById('doby'+i)) sPax += document.getElementById('doby'+i).options[document.getElementById('doby'+i).selectedIndex].value;
			
			if (sPaxList.indexOf(sPax) > -1) {
				alert('Passenger '+i+': The passenger details have been duplicated.');
				return false;
			} else {
				sPaxList += '|' + sPax + '|';
			}
		}
	}
	
	function checkAlpha(alphane)
	{
		var numaric = alphane;
		for(var j=0; j<numaric.length; j++)
			{
				var alphaa = numaric.charAt(j);
				var hh = alphaa.charCodeAt(0);
				if((hh > 64 && hh<91) || (hh > 96 && hh<123))
				{
				}
			else	{
				 return false;
				}
			}
	 return true;
	}
	
	function checkNumeric(alphane)
	{
		var numaric = alphane;
		for(var j=0; j<numaric.length; j++)
			{
				var alphaa = numaric.charAt(j);
				var hh = alphaa.charCodeAt(0);
				if((hh > 47 && hh<58))
				{
				}
			else	{
				 return false;
				}
			}
	 return 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 >= 14 || 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 14 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 checkAgeDOBMatch2(NumChildren, NumAdults, DepDate, SearchType){
		var Str = document.getElementById('AgeCheckSearchType').value
		if (Str.indexOf("Hotel") >= 0 && document.getElementById('AgeCheckNoChilds').value != "0")
		{
			var i, today, d, by, bm, bd, bday, age, dif, DOB
			var ErrTxt = "Please ensure child ages and their date of births match! -\n\n"
				for (i = 1; i <= NumChildren; i++)
				{
					//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 + Number(NumAdults))).value + "/" + document.getElementById('dobm' + (i + Number(NumAdults))).value + "/" + document.getElementById('doby' + (i + Number(NumAdults))).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++; 
					} 
					age +=-2 ; 
					if (document.getElementById('AgeCheck' + i).value != age)
					{
					ErrTxt = ErrTxt + "Child " + i + ": " + DOB + " makes the child " + age + ", child must be " + document.getElementById('AgeCheck' + i).value + " at time of departure.\n"
					//return false; break;
					}
				}
				if (ErrTxt == "Please ensure child ages and their date of births match! -\n\n")
					{return true;}
				else
					{alert(ErrTxt); 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 && totalmeals != 0){
					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}
		}
	}
	
	function displayResortInfo(sLink,iResortId){
	    //clicked on show map link and the map has not been loaded yet
        if (iResortId == '1' && bDelayMapLoad)
        {

			var sSearchType = queryString('search_type');
			var sAirportTo = queryString('airportto');

			GetResortInfo(sSearchType,sAirportTo,'');

            ShowLoadingDiv(); //show loading animation
            bDelayMapLoad = false; //mark that the map has now been loaded
            bAutoShowMap = true; //tell the loading function to show the map straight away
            
            if (fnReloadResortInfo)
            {
                fnReloadResortInfo(); //load the map
            }
        
        }
        else
        {
        
		    var oLink = document.getElementById('divDisplayLink_' + iResortId);
		    var oContent = document.getElementById('divDisplayContent_' + iResortId);
    		
		    if(oContent.style.display=='none') {
			    oLink.className='bulletLink_down';
			    sLink.innerHTML = sLink.innerHTML.replace('Click here to view','Click here to hide');
			    oContent.style.display='';
		    }else{
			    oLink.className='bulletLink';
			    sLink.innerHTML = sLink.innerHTML.replace('Click here to hide','Click here to view');
			    oContent.style.display = 'none';
		    }
		    
		}
		
	}
	
	
	
	
	
	
	
	function ucasePassortNumber(fID,value){
		if (value!='e.g. GBR 123456789'){
			fID.value = fID.value.toUpperCase()
		}
	}
	function checkPackage186() {
		var bContinue = false;
		checkboxes = document.getElementsByTagName('input');
		for(x=0;x<checkboxes.length;x++) {
			if(checkboxes[x].type == 'checkbox') {
				if(checkboxes[x].checked==true) {
					bContinue = true;
				}
			}
		}
		if(bContinue) {
			frmBYOSubmit(true);
		}else{
			alert('Please choose your coach times!');
		}
	}
	
			
			/*END PRICING JS */
