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('frmResults', false, true);
    div_switch('footprint_dp', false, false);
    div_switch('searchslim_dp', false, false);
	scroll(0,0);
	if (bBasket) {
	    showPleasewait('basket');
	}else{
	    showPleasewait('pricing');
	}
	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"; }



/*Added two get TransferProvider and get TransferPosition function, EZ, 2010-03-19,ticket 19268 */
function setTransferProvider(fId) { document.frmResults.transfer_provider.value = fId; }
function setTransferPosition(fId){
	document.frmResults.transfer_position.value = fId;
}
/*end 19268*/

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*/
		showPleasewait('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*/
		showPleasewait('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*/
		showPleasewait('generic', 'We\'re currently loading your next page of package holiday results.');	
	}
	function ChangePageTransport(pagenumber) {
		document.frmResults.txtLevel.value='SEARCH';
		document.frmResults.txtIsPostBack.value="true";
		document.frmResults.pagenumbertransport.value=pagenumber;
		document.frmResults.ShowDiv.value='transport';
		frmBYOSubmit();
		/*Swap the loading div*/
		showPleasewait('generic', 'We\'re currently loading your next page of transport results.');	
	}
	
	/*Loading Text Functions START
	New functions to alter the text displayed on the loading pages*/

	/*Custom overrides for the different product types*/
	function LoadingDivSwitchOverride(sTypeFlag) {
		if(sTypeFlag == 'FH_F' || sTypeFlag == 'FHC_F') {
			showPleasewait('generic', 'We\'re currently adding the flight you have chosen to your results.');
		} else if(sTypeFlag == 'FHC_C' || sTypeFlag == 'FC_C') {
		    showPleasewait('generic', 'We\'re currently adding the car you have chosen to your results.');
		} else {
		    showPleasewait('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*/
	    showPleasewait('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 setTransport(pId, tId) {
	    document.frmResults.transport_provider.value=pId;
	}
	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');
				// NE 14/01/2009 Amended as this does not sort MedHotels correctly when there is more than one room
				setSortHotels("translate(CSI_ARE/CHEAPEST_PRICE,',','')",'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();
		/*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')
	}
	
	/* NE 16/09/2009 New function for package holiday flights*/
	function setFHPFlight(fare_id, fId, provider, flightPos) {
	    document.frmResults.txtIsPostBack.value="true";
	    if (document.getElementById('FHP_FlightID') && document.getElementById('FHP_FlightProvider')) {
	        document.getElementById('FHP_FlightID').value = fare_id;
	        document.getElementById('FHP_FlightProvider').value = provider;
	        //document.frmResults.Provider_Flight.value=provider;
	    }
	}
		
	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);
		}
	}
	
	function GetSelectedRoomDetails(lStay,lStayOpt)
	{
	    var sRoomDetails;
	    if (document.getElementById('PEV2_S' + lStay + '_A' + lStayOpt + '_R1_1'))
	    {
	        // More hotel details for Tours at the pricing stage
	        for (var iRoomOpt=1; iRoomOpt<10; iRoomOpt++)
	        {
	            var roomOption = document.getElementById('PEV2_S' + lStay + '_A' + lStayOpt + '_R1_' + iRoomOpt)
	            if (roomOption)
	            {
	                if ((roomOption.type == "radio" && roomOption.checked == true) || (roomOption.type == "hidden"))
	                {
	                    if (roomOption.getAttribute('roomdetails'))
	                    {
	                        sRoomDetails = roomOption.getAttribute('roomdetails');
            	            break;
	                    }
	                }
	            }
	        }
	        
	    }
	    return sRoomDetails;
	}
	/* START MORE INFO AJAX */
		var sCurrentPosition = '';
		function GetMoreHotelInfo(sLink, sPosition, sProvider, sAccommCode, sGABProvID, sMulticomFAB, sSessionID, sRoomDetails, 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+'&roomdetails='+sRoomDetails;
				if(sURL!='') {
					document.getElementById('divHotelInfo'+sPosition).style.display = '';

					document.getElementById('Description'+sCurrentPosition).innerHTML = '<div align="center"><div id="csiLogoLoaderHotelInfo"></div><br /><span class="resultPleaseWait">Loading... Please wait.</span></div>'
					
					var so = new SWFObject("/includes/pleasewait/csi-logo-loader.swf", "soloader", "32", "32", "9", "#fff");
                    so.addParam("wmode", "transparent");
                    so.addVariable("varColour1", ""); // background colour - leave blank for transparency
	                so.addVariable("varColour2", "d0622e"); // static circles colour
	                so.addVariable("varColour3", "ea7138"); // fading circles colour
                    so.write("csiLogoLoaderHotelInfo");
            
					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;
					if (sDescription.toLowerCase().indexOf("description not available") == -1) {
					    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 information is not available');
					    document.getElementById('divHotelInfo' + sCurrentPosition).style.display = 'none';
					}
				}else{
					alert('More 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('LocatorForGoogle');
				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("'","");
				}
				
				var sSessionID = '';
				    
			    if(!sSessionID && document.getElementById('SessionID')){
			        sSessionID = document.getElementById('SessionID').value;
		        }
			    
			    var sIncludeGoogleMap = 'true';
			    
			    if (bDelayMapLoad)
			    {
			        sIncludeGoogleMap = 'false';
			    }
				
				sParams = 'location='+sLocation+'&search_type='+sSearchType+'&airportto='+sAirportTo+'&locators='+sAddressURL+'&sessionid=' + sSessionID + '&casp=casp&includegooglemap=' + sIncludeGoogleMap + '&' +sFlightMatrixUserQueryString;    
				sURL = '/includes/resortinfo.asp';				
				
				if(sURL!='') {
					if(sURL) sURL=sURL.replace(/'/g,"%27");
					if(bDebug) {
						if(confirm('Open '+ sURL)) {
							window.open(sURL);
						}
					}
					setTimeout("loadResortInfoXMLDoc('"+sURL+"', '" + sParams + "')", 100);
				}else{
					alert('No url defined');	
				}
			}
		}
		
		function loadResortInfoXMLDoc(sUrl, sParams)
	    {
	        var oXmlHttp;
	        if (window.XMLHttpRequest)
	            oXmlHttp = new XMLHttpRequest();
	        else
	            oXmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
	    
	        if (oXmlHttp)
	        {
                oXmlHttp.onreadystatechange = function()
                {
                    if (oXmlHttp.readyState == 4 && oXmlHttp.status == 200)
                    {
                        processResortInfoChange(oXmlHttp.responseXML.documentElement);
                    }
                }
	            oXmlHttp.open("POST", sUrl, true);
                oXmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
                oXmlHttp.send(sParams);
	        }
	    }
		
		var xmlDocTop = '';
		function processResortInfoChange(xmldoc)
		{
			document.getElementById('divResortInfoLoader').style.display='none';
			document.getElementById('divResortInfo').style.display='';
			
			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 (bDelayMapLoad)
			    {
			        bGoogle = true;
			    }
				else 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.png" align="absmiddle" class="imageTransparencyFix" />';
												}
											}
										}
										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());
							var iInterestCount = 0;
							var iAccommCount = 0;
							var iFlightCount = 0;
							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') {
									var point = new GLatLng(sLat,sLng);
									if(sType=='hotel') {
									    if(sLat!=0 && sLng!=0 && sLat!=''&&sLng!='' && sLat!=' ' && sLng!=' '){iAccommCount += 1;}
										map.addOverlay(createMarker(point, sPosition, sTitle, sDistance, sType));
									}
									if(sType=='airport') {
										map.addOverlay(createMarker(point, '0', sTitle, '', sType));
										iFlightCount += 1;
									}
									if(sType=='interest') {
									    if(sLat!=0&&sLng!=0){iInterestCount += 1;}
									    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='';
										if(iAccommCount>0){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') {
										if (iFlightCount > 0) {
											sIconHTML+='<img src="/images/icons/googlemap_airport.png" align="absmiddle" style="margin:0px 5px 0px 15px;" />Airport';
										}
										if(iInterestCount>0){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';
								
								document.getElementById('divDisplayContent_1').style.display = 'none';
                                    
                                if (bAutoShowMap)
                                {
                                
                                    displayResortInfo(document.getElementById('divDisplayLink_1'), '1');
                                    bAutoShowMap = false;
                                    
                                }
                                
							    document.getElementById('divDisplayContent_1').style.position = 'relative';
							}
						}
					}
				}
				//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='';
					
					if (document.getElementById('tab_1').className.indexOf('Over') < 0)
				    {
				        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 */
	
	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;
	            }
	        }
	    }
	    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];
	    var sNewEndDate = '';
	    sNewURL = sNewURL + '&startdate=' + sStartDateText;
	    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 != '')
	                {
	                    if (document.getElementById('rbUpgrades_' + lPackageID + '_' + iStay + '_' + iStayOption).value != '99999')
	                        sNewEndDate = document.getElementById('rbUpgrades_' + lPackageID + '_' + iStay + '_' + iStayOption).attributes['CheckOutDate'].value;
	                        
	                    sNewURL = sNewURL + '&rbUpgrades_' + lPackageID + '_' + iStay + '=' + document.getElementById('rbUpgrades_' + lPackageID + '_' + iStay + '_' + iStayOption).value;
	                }
	            }
	        }
	    }
	    if (sNewEndDate != '')
	    {
	        var arNewEndDate = sNewEndDate.split('/');
	        if (arNewEndDate[0].substring(0,1) == '0') 
	        {
	            arEndDate[0] = arEndDate[0].toString();
	            if (arEndDate[0].length == 1)
	                arNewEndDate[0] = arEndDate[0].substring(0,1);
	            else
	                arNewEndDate[0] = arEndDate[0].substring(1,2);
	        }
	        sNewURL = sNewURL.replace("[edd]", arNewEndDate[0]);
	        sNewURL = sNewURL.replace("[edm]", arNewEndDate[1]);
	        sNewURL = sNewURL.replace("[edy]", arNewEndDate[2]);
	        sNewURL = sNewURL + '&enddate=' + sNewEndDate;
	    }
	    else
	    {
	        sNewURL = sNewURL.replace("[edd]", arEndDate[0]);
	        sNewURL = sNewURL.replace("[edm]", arEndDate[1]);
	        sNewURL = sNewURL.replace("[edy]", arEndDate[2]);
	        sNewURL = sNewURL + '&enddate=' + sEndDateText;
	    }
	    showPleasewait('3rdpartyflights');
		div_switch('frmResults', false, false);
		div_switch('footprint_dp', false, false);
		div_switch('searchslim_dp', 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(document.getElementById('HasOptionalEmails') && document.getElementById('HasOptionalEmails').value == 'true')
		{
		    // No email validation required 
		}
		else if(document.getElementById('HasOptionalEmails') && document.getElementById('HasOptionalEmails').value == 'leadonly')
	    {
	        if(checkFormFieldValue("email", "- Email -", "Please enter a valid email address for the lead passenger!", 6, 'email', true) == false)
	        { return false; }
	    }
		else
		{
		    if(checkFormFieldValue("email", "- Email -", "Please enter a valid email address for all passengers!", 6, 'email') == 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 (checkGender(parseInt(PAX)) == 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.chkConfirmCarTerms && document.frmResults.chkConfirmCarTerms.checked == false) {
		    alert('Please confirm that you have read and understood the car hire terms and conditions');
		    document.frmResults.chkConfirmCarTerms.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;
				}
			}
		}
    }

    function checkGender(NumPax) {
        for (iPax = 1; iPax <= NumPax; iPax++) {
            if (document.getElementById('gender' + iPax) && document.getElementById('gender' + iPax).value == '') {
                alert('You must specify the gender for passenger ' + iPax);
                return false;
            }
        }
    }

	// NE 13/11/2008
	function checkPassportInfo(iNumPax, dReturnDate) {
		var sPassportNoList = new String('');
		
		//AMADEUS
		for(var i = 1; i <= iNumPax; i++) {
			if(document.getElementById('infoPassportNum'+i)) {
				if(document.getElementById('infoPassportNum'+i).disabled == false) {
				
                    regExp = /^[a-zA-Z0-9]+$/;
                    if(checkFormFieldValue("infoPassportNum", "- Passport number -", "Please enter a valid passport number for all passengers!") == false) {
                        return false;
                    } else if (!regExp.test(document.getElementById('infoPassportNum'+i).value)) {
                        alert('Passenger '+i+': The passport number entered is not valid. Please enter only letters and numbers.');
                        document.getElementById('infoPassportNum'+i).focus();
						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;
					}	
				}
			}
			
		}
		
		//MULTICOM
		for(var i = 1; i <= iNumPax; i++) {
			if(document.getElementById('FOIDVal_'+i)) {
				if(document.getElementById('FOIDVal_'+i).disabled == false) {
					
					if (checkAlpha(document.getElementById('FOIDVal_'+i).value.replace(' ', '').substring(0, 4)))
				    { //check valid 4 letter passport code
				    
				         if(!checkNumeric(document.getElementById('FOIDVal_'+i).value.replace(' ', '').substring(4)))
				         {
						    alert('Passenger '+i+': The passport number entered contains invalid characters.');
						    return false;
					    }
					    
					}				    
					else if (checkAlpha(document.getElementById('FOIDVal_'+i).value.replace(' ', '').substring(0, 3)))
					{ //check valid 3 letter passport code
					
					    if (!checkNumeric(document.getElementById('FOIDVal_'+i).value.replace(' ', '').substring(3)))
					    {
						    alert('Passenger '+i+': The passport number entered contains invalid characters.');
						    return false;
					    }
					    
					}
					else //not valid
					{
						alert('Passenger '+i+': The passport country entered is not valid, this should be a 3-4 letter code.');
						return false;
					}
					
					//Expiry date validating
					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;
					}
					
					//Issue number validating
					if (document.getElementById('infoPassportIssueD'+i)){
					    var sIssueDay = document.getElementById('infoPassportIssueD'+i).options[document.getElementById('infoPassportIssueD'+i).selectedIndex].value;
					    var sIssueMonth = document.getElementById('infoPassportIssueM'+i).options[document.getElementById('infoPassportIssueM'+i).selectedIndex].value;
					    var sIssueYear = document.getElementById('infoPassportIssueY'+i).options[document.getElementById('infoPassportIssueY'+i).selectedIndex].value;
					    var sIssue = sIssueDay + "/" + sIssueMonth + "/" + sIssueYear;
    	
					    if(!(new Date(sIssueYear, sIssueMonth, sIssueDay)).getTime()) { alert('Passenger '+i+': Invalid passport issue date.'); return false; }
					    else if(new Date(sIssueYear, sIssueMonth, sIssueDay) > new Date()) {
						    alert('Passenger '+i+': The issue date entered for this passport is in the future.');
						    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].getAttribute('placeholderText') && sObjects[x].value == sObjects[x].getAttribute('placeholderText')) || !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 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(objSelect[x].options[objSelect[x].selectedIndex].getAttribute('depositValue')!=null && objSelect[x].options[objSelect[x].selectedIndex].getAttribute('depositValue')!='NaN')
			{
				iDepositPrice += parseFloat(objSelect[x].options[objSelect[x].selectedIndex].getAttribute('depositValue'))
			}
		}
		
		/* NE 01/10/2009 For use with Tourico */
		var touricoBoard = 0;
		try {
		    var allelements = document.getElementById('frmResults').elements;
		    for(var i = 0; i < allelements.length; i++) {
		        var element = allelements[i];
                if (element.id.substring(0,2) == 'RB' && element.id.substring(element.id.length - 13) == 'Board_Tourico') {
                    if (element.value != '' && element.value.indexOf('|') > -1) touricoBoard += parseFloat(element.value.substring(element.value.indexOf('|')+1));
                } 		    
		    }		    
	    }
	    catch(err) { }
	    
	    iTotalPrice += touricoBoard;
	    iDepositPrice += touricoBoard;
		
		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;
		}
		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('RB_'+i+'_'+y)) {
						    if(document.getElementById('RB_'+i+'_'+y).checked == true)
						    {
			                    if(document.getElementById(sSelect[x].value+'_'+i+'_'+y+'_Fees')) {
			                        document.getElementById(sSelect[x].value+'_'+i+'_'+y+'_Fees').style.display='';
			                    }
			                }
			                else
			                {
			                    if(document.getElementById(sSelect[x].value+'_'+i+'_'+y+'_Fees')) {
			                        document.getElementById(sSelect[x].value+'_'+i+'_'+y+'_Fees').style.display='none';
			                    }
			                }
					    }
				    }
			    }
		    }
		}
	}
	
	//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';
						}
						if(document.getElementById(sSelect[x].value+'_'+i+'_'+y+'_Fees')) {
						    document.getElementById(sSelect[x].value+'_'+i+'_'+y+'_Fees').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;
			            if(document.getElementById(id+'_'+i+'_'+x+'_Fees')) {
			                document.getElementById(id+'_'+i+'_'+x+'_Fees').style.display='';
			            }
					}
				}
			}
		}
		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)
        {
        	        
            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()
		}
	}

/*END PRICING JS */

/* NE 09/09/2009 */
function selectPHFlights(pid) {
    divs = document.getElementsByTagName("div");
    if (divs.length > 0) {
        for(d=0;d<divs.length;d++) {
            if (divs[d].id.indexOf('divMCPHF') > -1) {
                if (divs[d].id.substring(divs[d].id.length - pid.length) == pid) { divs[d].style.display = ''; } else { divs[d].style.display = 'none'; }
            }
        } 
    } 
}

function setSearchType(fId){document.frmResults.search_type.value=fId;}

    /* NE 25/09/2009 */
    function updateTouricoSelection(roomlist, sCode, sRate, sSymbol, bIsPerPerson) {
        for (i=0;i<roomlist.options.length;i++) {
            tablerow = document.getElementById("tr"+roomlist.options[i].value);
            if (tablerow) {
                if (i == roomlist.selectedIndex) {
                    tablerow.style.display='';
                } else {
                    tablerow.style.display = 'none'
                } 
            }
        }
       
       var scheckedids = new String();
       
	    selects = document.getElementsByTagName('select');
        for(x=0;x<selects.length;x++) {
            if(selects[x].id.indexOf('tourico_RoomID') > -1) {
                selects[x].disabled = true;
            }
        }
        
        inputs = document.getElementsByTagName('input');
        for(x=0;x<inputs.length;x++) {
            if(inputs[x].id.indexOf('touricoRoomID') > -1) {
                inputs[x].disabled = true;
            }
        }
        for(room=1;room<4;room++) {
	        inputs = document.getElementsByTagName('input');
	        for(x=0;x<inputs.length;x++) {
		        if((inputs[x].type == 'radio' || inputs[x].type == 'hidden') && inputs[x].id == 'touricoRoomID'+room+'_'+(roomlist.selectedIndex + 1) && scheckedids.indexOf('|'+'touricoRoomID'+room+'_'+(roomlist.selectedIndex + 1) + '|') == -1) {
		            inputs[x].checked = true;
		            
		           scheckedids += '|' + 'touricoRoomID'+room+'_'+(roomlist.selectedIndex + 1) + '|'; 
		        }
	        }
	        if(document.getElementById('tourico_RoomID' + room + '_' + (parseFloat(roomlist.selectedIndex) + 1))) {
                document.getElementById('tourico_RoomID' + room + '_' + (parseFloat(roomlist.selectedIndex) + 1)).disabled = '';	
	        }
	        if(document.getElementById('touricoRoomID' + room + '_' + (parseFloat(roomlist.selectedIndex) + 1))) {
                document.getElementById('touricoRoomID' + room + '_' + (parseFloat(roomlist.selectedIndex) + 1)).disabled = '';	
	        }
	    } 
	    scheckedids = '';
	    getTotalPrice(sCode, sRate, sSymbol, bIsPerPerson);
}

function selectSeat(seg, col,row){
	if(document.getElementById('seat_' + seg + col + row)){
	    var objPax = eval('document.frmResults.pax_seats_s' + seg);
	    var iChecked = 0;
    	var prevSeat = '';
    	var bFail = false;

        if(objPax.length == null){
            prevSeat = objPax.value;
            if(objPax.value == col + ',' + row){alert('Seat already selected'); bFail = true; }
            
            if(!bFail){

	            objPax.value = col + ',' + row;

	            if(prevSeat != ''){
	                //check to unselected the previous seat
	                precAr =  prevSeat.split(',');
	                prevCol = precAr[0]
	                prevRow = precAr[1]
            	    
	                document.getElementById('seat_' + seg + prevCol + prevRow).setAttribute('src','/images/seatmap/available.gif');
	            }
            	
	            document.getElementById('seat_' + seg + col + row).setAttribute('src','/images/seatmap/selected.gif');
	            document.getElementById('pax_seat_s' + seg + '_' + (iChecked + 1)).innerHTML = col + ' ' + row;
	            document.getElementById('pax_seats_s' + seg + '_p' + (iChecked + 1)).value =   row + col;
	        }
        }else{
	        for(iPax=0;iPax < objPax.length;iPax++)
	        {
		        if(objPax[iPax].checked){
		            prevSeat = objPax[iPax].value;
			        iChecked = iPax;
		        }else{
		            if(objPax[iPax].value == col + ',' + row){alert('Seat already selected'); bFail = true; }
		        }
	        }
	        if(!bFail){

	            objPax[iChecked].value = col + ',' + row;

	            if(prevSeat != ''){
	                //check to unselected the previous seat
	                precAr =  prevSeat.split(',');
	                prevCol = precAr[0]
	                prevRow = precAr[1]
            	    
	                document.getElementById('seat_' + seg + prevCol + prevRow).setAttribute('src','/images/seatmap/available.gif');
	            }
            	
	            document.getElementById('seat_' + seg + col + row).setAttribute('src','/images/seatmap/selected.gif');
	            document.getElementById('pax_seat_s' + seg + '_' + (iChecked + 1)).innerHTML = col + ' ' + row;
	            document.getElementById('pax_seats_s' + seg + '_p' + (iChecked + 1)).value =   row + col;
    	        
	            if(iChecked == objPax.length-1){
		            objPax[0].checked = true;
	            }else{
		            objPax[iChecked + 1].checked = true;
	            }
	        }
	    }
	}else{
	    alert('This seat is unavailable');
	}
}
function deselectAllSeats(seg){
    var objPax = eval('document.frmResults.pax_seats_s' + seg);
    if(objPax.length == null){// 1 pax
        prevSeat = objPax.value;
        if(prevSeat != ''){
            //check to unselected the previous seat
            precAr =  prevSeat.split(',');
            prevCol = precAr[0]
            prevRow = precAr[1]
        	   
            document.getElementById('seat_' + seg + prevCol + prevRow).setAttribute('src','/images/seatmap/available.gif');
            objPax.value = ""
            document.getElementById('pax_seat_s' + seg + '_1').innerHTML = 'No seat selected';
        }
    }else{// >1 pax
        for(iPax=0;iPax < objPax.length;iPax++)
	    {
	        prevSeat = objPax[iPax].value;
	        if(prevSeat != ''){
	            //check to unselected the previous seat
	            precAr =  prevSeat.split(',');
	            prevCol = precAr[0]
	            prevRow = precAr[1]
            	   
	            document.getElementById('seat_' + seg + prevCol + prevRow).setAttribute('src','/images/seatmap/available.gif');
	        }
	        objPax[iPax].value = ""
	        document.getElementById('pax_seat_s' + seg + '_' + (iPax + 1)).innerHTML = 'No seat selected';
	    }
	    objPax[0].checked = true;     
    }
}

function selectSeatMap(iSeatMap,iMaxSeaps){
	for(intSeatMap = 1; intSeatMap<=iMaxSeaps; intSeatMap++){
		document.getElementById('sm' + intSeatMap).style.display = (intSeatMap == iSeatMap) ? '' : 'none';
		document.getElementById('smFlightDetail' + intSeatMap).style.display = (intSeatMap == iSeatMap) ? '' : 'none';
	}
}

/* 2010-03-30 - Transfer prices shown at results stage*/
function getCheapestTransferPrice(sLocationTo, sAirportFrom, sAirportTo, iNumAdults, iNumChildren, iNumInfants, sArrivalDateTime, sReturnDateTime, sCurrencyCode) {
	
	var sDivID = 'transferBanner';
	
	var sURL = '/transfers/transfer_ajax.asp?locationto=' + sLocationTo + '&airportfrom=' + sAirportFrom + '&airportto=' + sAirportTo + '&NumAdults=' + iNumAdults + '&NumChildren=' + iNumChildren + '&NumInfants=' + iNumInfants + '&arrivaldatetime=' + sArrivalDateTime + '&returndatetime=' + sReturnDateTime + '&sitecurrency=' + sCurrencyCode
	var oTransferBox = new ajaxObjectTransfers(sDivID, sURL);
	oTransferBox.update(sDivID + '1');

}

function ajaxObjectTransfers(layer, url) {
    var sDivID = layer
    layer = layer + '1'
	var sAdditionalParams = '';
	if(url.indexOf('?') > -1){
		sAdditionalParams = '&' + url.split('?')[1];
		url = url.split('?')[0];
	}
	var that=this;                                                    // A workaround for some javascript idiosyncrocies   
	var updating = false;                                             // Set to true if this object is already working on a request   
	this.callback = function() {}                                     // A post-processing call -- a stub you overwrite.   
	this.update = function(passData) {                                // Initiates the server call.      
		if (updating==true) { return false; }                          // Abort if we're already processing a call.      
		updating=true;                                                 // Set the updating flag.      
		var AJAX = null;                                               // Initialize the AJAX variable.      
		if (window.XMLHttpRequest) {                                   // Are we working with mozilla?         
			AJAX=new XMLHttpRequest();                                  //  Yes -- this is mozilla.      
		} else {                                                       // Not Mozilla, must be IE         
			AJAX=new ActiveXObject("Microsoft.XMLHTTP");                //  Wheee, ActiveX, how do we format c: again?      
		}                                                              // End setup Ajax.      
		if (AJAX==null) {                                              // If we couldn't initialize Ajax...         
			alert("Your browser doesn't support AJAX.");                // Sorry msg.                                                       
			return false                                                // Return false (WARNING - SAME AS ALREADY PROCESSING!)      
		} else {        
			AJAX.onreadystatechange = function() {                      // When the browser has the request info..       
			if(LayerID){
				if (AJAX.readyState==4 || AJAX.readyState=="complete") { //   see if the complete flag is set.   
					var sText = AJAX.responseText
					if(sText.indexOf("|") > -1){
						sText = sText.split("|")[1]
					}
					if(sText.length > 0){
					    document.getElementById(LayerID.id).innerHTML= '<div class="result"><div class="hr" style="clear:left; margin-bottom:10px; margin-top:5px;">&#160;</div><div class="transfersAvailable"><strong>Transfers are available to this resort from as little as '+sText+'</strong>. You will be offered the chance to add this to your booking before checkout.</div></div>';                 	 //   It is, so put the new data in the object's layer               
                    }
					delete AJAX;                                          //   delete the AJAX object since it's done.               
					updating=false;                                       //   Set the updating flag to false so we can do a new request               
					
					for(x=2;x<=15;x++) {                                     //  Update other transfer div on the page from the initial result
	                    if (document.getElementById(sDivID + x)){
	                        document.getElementById(sDivID + x).innerHTML = document.getElementById(sDivID + '1').innerHTML
	                    }
	                }
					
					that.callback();                                      //   Call the post-processing function.            
				}                                                       // End Ajax readystate check.   
			}
		}                                                           // End create post-process fucntion block.         
		var timestamp = new Date();                                 // Get a new date (this will make the url unique)        
		var uri=urlCall+'?'+passData+'&timestamp='+(timestamp*1) + sAdditionalParams;   // Append date to url (so the browser doesn't cache the call)         
		
		AJAX.open("GET", uri, true);                                // Open the url this object was set-up with.         
		AJAX.send(null);                                            // Send the request.         
		return true;                                                // Everything went a-ok.     
		}                                                              // End Ajax setup aok if/else block                    
	}         // This area set up on constructor calls.   
	var LayerID = document.getElementById(layer);                     // Remember the layer associated with this object.   
	var urlCall = url;  
	// Remember the url associated with this object.
}

function showPleasewait(sType,sCustomText) {
    div_switch('pleasewaitDiv', true, true);
    
    objTitle = document.getElementById('pleasewaitDiv_Title');
    objText = document.getElementById('pleasewaitDiv_Text');

    if (objTitle && objText) {
        switch (sType.toLowerCase()) {
            case "pricing":
                objTitle.innerHTML = 'We are now checking final prices for your products';
                objText.innerHTML = (sCustomText == undefined) ? 'Now you\'ve chosen a product to look at, we are double checking the prices again with the supplier to make sure that nothing has changed since you first did your search.' : sCustomText;
                break;
            case "basket":
                objTitle.innerHTML = 'We are now adding your products to the basket';
                objText.innerHTML = (sCustomText == undefined) ? 'We\'re now adding your products to the basket. Here you can review your booking and make any amendments before you go on and book.' : sCustomText;
                break;
            case "filtering":
                objTitle.innerHTML = 'We are now filtering your results';
                objText.innerHTML = (sCustomText == undefined) ? 'We\'re currently filtering your results based on the selection you have made.' : sCustomText;
                break;
            case "3rdpartyflights":
                objTitle.innerHTML = 'We are now searching for flights for your package';
                objText.innerHTML = (sCustomText == undefined) ? 'We are currently contacting multiple suppliers to get the cheapest flights for your package. This might take a couple of minutes, as we have to get as many results as possible to give you the cheapest price.' : sCustomText;
                break;
            case "generic":
                objTitle.innerHTML = 'One moment please';
                objText.innerHTML = (sCustomText == undefined) ? 'We are currently contacting multiple suppliers to get the cheapest flights for your package. This might take a couple of minutes, as we have to get as many results as possible to give you the cheapest price.' : sCustomText;
                break;
            default:
                break;
        } 
    }
}
/* */

function showredress(checkbox, redressdiv) {
    if (checkbox) {
        if (checkbox.checked) {
            div_switch(redressdiv, true, true);
        } else {
            div_switch(redressdiv, false, true);
        }
    }
}
