<!--
// Browser sniffer
var ns4 = (document.layers); 
var ie4 = (document.all && !document.getElementById);
var ie5 = (document.all && document.getElementById);
var ns6 = (!document.all && document.getElementById);
// START DEBUGGER
	function PageQuery(q) {
		if(q.length > 1) this.q = q.substring(1, q.length);
		else this.q = null;
		this.keyValuePairs = new Array();
		if(q.length > 1) {
			for(var i=0; i < this.q.split("&").length; i++) {
				this.keyValuePairs[i] = this.q.split("&")[i];
			}
		}
		this.getKeyValuePairs = function() { return this.keyValuePairs; }
		this.getValue = function(s) {
			for(var j=0; j < this.keyValuePairs.length; j++) {
				if(this.keyValuePairs[j].split("=")[0] == s)
					return this.keyValuePairs[j].split("=")[1];
			}
			return false;
		}
		this.getParameters = function() {
			var a = new Array(this.getLength());
			for(var j=0; j < this.keyValuePairs.length; j++) {
				a[j] = this.keyValuePairs[j].split("=")[0];
			}
			return a;
		}
		this.getLength = function() { return this.keyValuePairs.length; }	
	}
	function queryString(key){
		var page = new PageQuery(window.location.search); 
		return unescape(page.getValue(key)); 
	}
	var bDebug = false;
	if(queryString('debug')=='true') {
		bDebug = true;
	}
// END DEBUGGER
function OpenWindow(url,name,opts) {
	newwindow = window.open(url,name,opts); 
	if (window.focus){
		newwindow.focus()
	}
}
var iDarkenScreen_ExtraHeight;
function grayOut(vis, options) {
	// Pass true to gray out screen, false to ungray
	// options are optional.  This is a JSON object with the following (optional) properties
	// opacity:0-100         // Lower number = less grayout higher = more of a blackout 
	// zindex: #             // HTML elements with a higher zindex appear on top of the gray out
	// bgcolor: (#xxxxxx)    // Standard RGB Hex color code
	// grayOut(true, {'zindex':'50', 'bgcolor':'#0000FF', 'opacity':'70'});
	// Because options is JSON opacity/zindex/bgcolor are all optional and can appear
	// in any order.  Pass only the properties you need to set.
	var options = options || {}; 
	var zindex = options.zindex || 10;
	var opacity = options.opacity || 0;
	var opaque = (opacity / 100);
	var bgcolor = options.bgcolor || '#000000';
	var dark=document.getElementById('darkenScreenObject');
	if (!dark) {
		// The dark layer doesn't exist, it's never been created.  So we'll
		// create it here and apply some basic styles.
		// If you are getting errors in IE see: http://support.microsoft.com/default.aspx/kb/927917
		var tbody = document.getElementsByTagName("body")[0];
		var tnode = document.createElement('div');           // Create the layer.
		tnode.style.position='absolute';                 // Position absolutely
		tnode.style.top='0px';                           // In the top
		tnode.style.left='0px';                          // Left corner of the page
		tnode.style.overflow='hidden';                   // Try to avoid making scroll bars            
		tnode.style.display='none';                      // Start out Hidden
		tnode.id='darkenScreenObject';                   // Name it so we can find it later
		tbody.appendChild(tnode);                            // Add it to the web page
		tbody.onclick="alert('')"
		dark=document.getElementById('darkenScreenObject');  // Get the object.
	}
	if (vis) {
		var iExtraHeight = 0;
		//example in traveljunky bespoke.js
		if(iDarkenScreen_ExtraHeight) {
			iExtraHeight = iDarkenScreen_ExtraHeight;
		}
		
		sSelectHide = 'none';
		// Calculate the page width and height 
		if( document.body && ( document.body.scrollWidth || document.body.scrollHeight ) ) {
			var pageWidth = document.body.scrollWidth+'px';
			//following if statement is a fix for IE6, added 15/06/2009 id JF001
			if (document.body.scrollHeight < document.body.offsetHeight){
				var pageHeight = document.body.offsetHeight+iExtraHeight+'px';
			}else{
				var pageHeight = document.body.scrollHeight+iExtraHeight+'px';			
			}
			//end JF001
		} else if( document.body.offsetWidth ) {
			var pageWidth = document.body.offsetWidth+'px';
			var pageHeight = document.body.offsetHeight+iExtraHeight+'px';
		} else {
			var pageWidth='100%';
			var pageHeight='100%';
		} 
		//set the shader to cover the entire page and make it visible.
		dark.style.opacity=opaque;                      
		dark.style.MozOpacity=opaque;                   
		dark.style.filter='alpha(opacity='+opacity+')'; 
		dark.style.zIndex=zindex;        
		dark.style.backgroundColor=bgcolor;  
		dark.style.width= pageWidth;
		dark.style.height= pageHeight;
		dark.style.display='none';				 
	} else {
		dark.style.display='none';
		sSelectHide = '';
	}
	oSelects = document.getElementsByTagName('select');
	for(x=0;x<oSelects.length;x++) {
		//oSelects[x].style.display = sSelectHide;
	}
}

function showHideFAQ(sQuestionID) {
	var sDiv = document.getElementById('FAQ'+sQuestionID)
	if(sDiv) {
		if(sDiv.style.display=='') {
			sDiv.style.display='none';
		}else{
			sDiv.style.display='';
		}
	}
}

function changeCurrency(fId) {
	if(confirm('Are you sure you want to change the currency?\n\nYou could pay in GBP (which also allows you to pay a deposit if booking early) but if you opt to change the currency the price shown will only be a guide price as the actual conversion would be made by your bank or credit card company and these all have their own conversion rates.')) {
		location.href='/includes/changecurrency.asp?code='+fId+'&url='+window.location;
	}
}

function object_attach(id){
	var obj;
	if(ns4) obj = document.layers[id];
	else if(ie4) obj = document.all[id];
	else if(ie5 || ns6) obj = document.getElementById(id);
	return obj;
}

function addLoadEvent(func) {
	var oldonload = window.onload;
	if (typeof window.onload != 'function') {
		window.onload = func;
		}else{
			window.onload = function() {
				if (oldonload) {
				oldonload();
			}
		func();
		}
	}
}

function getQuerystring() {
	var URL = document.URL
	if(URL.indexOf('?')) {
		var arURL = URL.split('?')
		return arURL[1];	
	}
}

function validateNewsletter(fId) {
	var m = '';
	if(!fId.firstname.value || fId.firstname.value=='Enter your first name') {m+='- Please enter your first name\n'}
	if(!fId.lastname.value || fId.lastname.value=='Enter your last name') {m+='- Please enter your last name\n'}
	if(!/.+@[^.]+(\.[^.]+)+/.test(fId.email.value) || isValidField(fId.email.value,2) == false || fId.email.value=='Enter your email'){m+='- Please enter a valid email address\n'}
	if(m){
		alert(m);
		return false;		
	}else{
		return true;		
	}
}
function IsNumeric(sText) {
   var ValidChars = "0123456789. ";
   var IsNumber=true;
   var Char;

   for (i = 0; i < sText.length && IsNumber == true; i++) { 
      Char = sText.charAt(i); 
      if (ValidChars.indexOf(Char) == -1) {
         IsNumber = false;
      }
   }
   return IsNumber;
   
}

function validateEnquiry(fId) {
	var m = '';
	if(fId.title.value=='-'){m+='- Please select your title\n'}
	if(!fId.firstname.value || fId.firstname.value == '- First name -'){m+='- Please enter your first name\n'}
	if(!fId.surname.value || fId.surname.value == '- Surname -'){m+='- Please enter your surname\n'}
	if(fId.telephone.getAttribute('validateFId')=='true' || fId.telephone.getAttribute('validateFId')=='True') {
		if(!fId.telephone.value || isValidField(fId.telephone.value,6)==false){m+='- Please enter a valid telephone number\n'}
	}
	if(fId.telephone.value){
		if(!IsNumeric(fId.telephone.value)){
			m+='- Please enter a valid telephone number\n';
		}
	}
	
	if(!/.+@[^.]+(\.[^.]+)+/.test(fId.email.value) || isValidField(fId.email.value,2) == false){m+='- Please enter a valid email address\n'}
	if(!fId.enquiry.value){m+='- Please enter your enquiry\n'}
	if(m){
		alert(m);
		return false;		
	}else{
		return true;		
	}
}

function LoadGoogleMap(sDiv, iLat, iLng, bOverrideSize, iCustomZoomLevel, bHidePoint) {
	var iZoomLevel = 13;
	if(iCustomZoomLevel){
		iZoomLevel = iCustomZoomLevel;
	}
	if(document.getElementById(sDiv)) {
		sDiv = document.getElementById(sDiv)
		if(!bOverrideSize) {
			sDiv.style.width = '500px';
			sDiv.style.height = '220px';
		}
		if (GBrowserIsCompatible()) {
			var mygmap = new GMap2(sDiv);
			//map.addControl(new YSliderControl());
			mygmap.addControl(new GSmallMapControl());
    		mygmap.addControl(new GMapTypeControl());
			mygmap.setCenter(new GLatLng(iLat, iLng), iZoomLevel);
			if(!bHidePoint) {
				var point = new GLatLng(iLat,iLng);
				mygmap.addOverlay(new GMarker(point));
			}
		}
	}
}

function SwitchPhoto(PlaceHolderName,ThumbImg){
	var ImagePath = ThumbImg;
	if (document.all){
		document.getElementById(PlaceHolderName).style.filter="blendTrans(duration=1)";
		document.getElementById(PlaceHolderName).filters.blendTrans.Apply();
	}
	if(document.getElementById) {
		document.getElementById(PlaceHolderName).src = ImagePath;
	}else{
		document.HotelImage.src = ImagePath;
	}
	if(document.all){
		document.getElementById(PlaceHolderName).filters.blendTrans.Play();
	}
}

// Checks if field contains valid characters
// 1 - Numeric Integer, 2 - Email, 3 - Numeric Decimals
function isValidField(sText, iType){
	if(iType==1)
	{ ValidChars = "0123456789"; }
	else if(iType==2)
	{ ValidChars = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ._-@"; }
	else if(iType==3)
	{ ValidChars = "0123456789."; }
	else if(iType==4)
	{ ValidChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ "; }
	else if(iType==5)
	{ ValidChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-/' "; }
	else if(iType==6)
	{ ValidChars = "+0123456789-()[] "; }
	var isValid=true;
	var Char;
	for (iii = 0; iii < sText.length && isValid == true; iii++) 
	{ 
		Char = sText.charAt(iii); 
		if (ValidChars.indexOf(Char) == -1) 
		{ isValid = false; }
	}
	return isValid;
}
function echeck(str) {
	if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,9})+$/.test(str)){
		return (true)
	}
	return (false)
}
function writeInDiv(sText, sID) {
	if(document.getElementById(sID)) {
		document.getElementById(sID).innerHTML = sText;
	}
}

function checkPackageForm(sForm) {
	sCurForm = sForm;
	sCurSearchType = 'Package';
	sSubmitForm = document.getElementsByName('frm'+sForm);
	sLocationID = document.getElementById('packageLocationTo'+sForm);
	var e = sSubmitForm.elements, m = '';
	if(countPassengers()>9) {
		alert('You can only search for a maximum of 9 passengers when your search includes a flight');
		return false;
	}
	if(sLocationID.value==''){m += '- Please select a destination.\n';}
	if(validateDate('startdate_d'+sForm,'startdate_m'+sForm,'startdate_y'+sForm)<=2) {m += '- Departure date is not valid.\n';}
	bBoard = false;
	if(document.forms['frm'+sForm].board != null){
		for(x=0;x<document.forms['frm'+sForm].board.length;x++) {
			if(document.forms['frm'+sForm].board[x].checked==true) {
				bBoard = true;	
			}
		}
		if(!bBoard){m += '- Please select at least one board option.\n';}
	}
	
	if(document.getElementById('rooms'+sForm)) {
		if(document.getElementById('rooms'+sForm).value=='0') {
			m+='- Please select no. of rooms\n';
		}
	}
	if(m) {
		OpenSearch();
		alert('The following errors occurred:\n\n' + m);
		return false;
	}else{
		sSubmitForm[0].submit();
	}	
}

function checkTourForm(sForm) {
	sSubmitForm = document.getElementsByName('frm'+sForm);
	oDDLCountry = document.getElementById('country'+sForm);
    if (oDDLCountry.selectedIndex == 0)
    {
        alert('Please select a country');
        return false;
    }
	oDDLType = document.getElementById('tourtype'+sForm);
    if (oDDLType.selectedIndex == 0)
    {
        alert('Please select the type of holiday you would like');
        return false;
    }
	oDDLTM = document.getElementById('tourtransportmethod'+sForm);
    if (oDDLTM.selectedIndex == 0)
    {
        alert('Please select a transport method');
        return false;
    }
    if (oDDLTM.selectedIndex == 1)
    {
        oDDLAirport = document.getElementById('airportfrom'+sForm);
        if (oDDLAirport.selectedIndex == 0)
        {
            alert('Please select a departure airport');
            return false;
        }
    }
	oDDLDate = document.getElementById('startdate'+sForm);
    if (oDDLDate.selectedIndex == 0)
    {
        alert('Please select a leave date');
        return false;
    }
    
    return true;
}

//topsearch
function showhidechangeoptions(type) {
	if(type == "show") {
		div_switch("slimSearchTop", true, true);
		div_switch("slimSearchBottom", true, true);
		div_switch("DivShow", false, true);
		div_switch("DivHide", true, true);
	}
	if(type == "hide") {
		div_switch("slimSearchTop", false, true);
		div_switch("slimSearchBottom", false, true);
		div_switch("DivShow", true, true);
		div_switch("DivHide", false, true);
	}
}
var SelectedSearchTab = 'search_tab1';
function SwitchTabs(id, on) {
	if(SelectedSearchTab!=id && SelectedHeaderTab!=id) {
		sExtra = '';
		if(on==1){
			if(document.getElementById(id).className.indexOf('Over')<0){
				document.getElementById(id).className = document.getElementById(id).className + 'Over'
			}else{
				SelectedSearchTab = id;
			}
		}else{
			if(document.getElementById(id).className.indexOf('Over') > -1) {
				document.getElementById(id).className = Left(document.getElementById(id).className,document.getElementById(id).className.length-4);
			}
		}
	}
}
function SwitchSearch(id) {
	/* HIDE PREDICTIVE TEXT OPTIONS IF SHOWING */
	if(document.getElementById('as_idFreetextHotel')) {
		document.getElementById('as_idFreetextHotel').style.display = 'none';
	}
	if(document.getElementById('as_idFreetextFlight')) {
		document.getElementById('as_idFreetextFlight').style.display = 'none';
	}
	if(document.getElementById('as_idFreetextFlightHotel')) {
		document.getElementById('as_idFreetextFlightHotel').style.display = 'none';
	}
	for(x=1;x<9;x++) {
		idSearchTab = document.getElementById('search_tab'+x);
		if(idSearchTab) {
			idSearchTab.className = 'searchtab';
		}
		if(document.getElementById('search'+x)) {
			document.getElementById('search'+x).style.display = 'none';
		}
	}
	SelectedSearchTab = id;
	sSelectedSearchTab = document.getElementById(id)
	if(sSelectedSearchTab) {
		sRadarBars = sSelectedSearchTab.getElementsByTagName('input');
		if(sRadarBars.length>0) {
			for(xx=0;xx<sRadarBars.length;xx++) {
				if(sRadarBars[xx].type.toLowerCase()=='radio') {
					sRadarBars[xx].checked = true;
				}
			}
		}
		sSelectedSearchTab.className = 'searchtabOver';
	}
	if(document.getElementById('search'+Right(id,1))) {
		document.getElementById('search'+Right(id,1)).style.display = '';
	}
}


function SwitchLanding(id) {
	for(x=1;x<9;x++) {
		if(document.getElementById('landing_tab'+x)) {
			document.getElementById('landing_tab'+x).className = 'searchtab';
		}
		if(document.getElementById('divLanding'+x)) {
			document.getElementById('divLanding'+x).style.display = 'none';
		}
	}
	SelectedSearchTab = id;
	if(document.getElementById(id)) {
		document.getElementById(id).className = 'searchtabOver';
	}
	if(document.getElementById('divLanding'+Right(id,1))) {
		document.getElementById('divLanding'+Right(id,1)).style.display = '';
	}
	if(Right(id,1)=='4'){
		if(document.getElementById('divLandingSearch')) {
			document.getElementById('divLandingSearch').style.display = '';
		}	
	}else{
		if(document.getElementById('divLandingSearch')) {
			document.getElementById('divLandingSearch').style.display = 'none';
		}
	}
	if(Right(id,1)=='3'){
		if(document.getElementById('divLandingOffers')) {
			document.getElementById('divLandingOffers').style.display = '';
		}	
	}else{
		if(document.getElementById('divLandingOffers')) {
			document.getElementById('divLandingOffers').style.display = 'none';
		}
	}
}

function Left(str, n){
	if (n <= 0)
	    return "";
	else if (n > String(str).length)
	    return str;
	else
	    return String(str).substring(0,n);
}
function Right(str, n){
    if (n <= 0)
       return "";
    else if (n > String(str).length)
       return str;
    else {
       var iLen = String(str).length;
       return String(str).substring(iLen, iLen - n);
    }
}

// Clears a text field only if the value matches what is passed in
function clearField(fId, sMatch, sChange){
	if(sChange == null) sChange = '';
	if(trim(fId.value) == sMatch)
	{ fId.value = sChange; }
}
// Shows/hides div objects
function div_switch(id, bShow, bBlock) {
	if(document.getElementById(id)){
		if(bShow==true) {
			document.getElementById(id).style.display = '';
		}else{
			document.getElementById(id).style.display = 'none';
		}
	}
}

function toggle_switch(id){
	if(document.getElementById(id)){
		if(document.getElementById(id).style.display == 'none'){
			document.getElementById(id).style.display = '';
		}else{
			document.getElementById(id).style.display = 'none';
		}
	}
}

function checkFormFieldSelectedIndex(sFieldName, sErrTxt) {
	oTitleElements = document.getElementsByTagName("select")
	for (i = 0; i < oTitleElements.length; i++)
	{
		if(oTitleElements.item(i).id.indexOf(sFieldName) == 0)
		{
			if(oTitleElements.item(i).selectedIndex == 0)
			{ alert(sErrTxt); oTitleElements.item(i).focus(); return false; break; }
		}
	}
	return true;
}

function checkFormFieldValue(sFieldName, sDefaultVal, sErrTxt, iMinLen, sType, bLeadOnly){
	if(iMinLen==undefined || iMinLen==null) { iMinLen = 1; }
	if(bLeadOnly==undefined) { bLeadOnly = false; }
	var bFoundLead = false;
	oFormElements = document.getElementsByTagName("input");
	for (i = 0; i < oFormElements.length; i++){
		if(oFormElements.item(i).id.indexOf(sFieldName) == 0){
			if((oFormElements.item(i).value == '' || oFormElements.item(i).value == sDefaultVal || oFormElements.item(i).value.length < iMinLen || (sFieldName == 'surname' && oFormElements.item(i).value.indexOf(' ') > -1) || ((sFieldName == 'surname' || sFieldName == 'firstname') && (isValidField(oFormElements.item(i).value,5)==false || Left(oFormElements.item(i).value,1)=='-' || Left(oFormElements.item(i).value,1)=='/' || oFormElements.item(i).value.length < 2 || oFormElements.item(i).value==sDefaultVal))) && bFoundLead == false){
				alert(sErrTxt);
				oFormElements.item(i).focus();
				return false;
				break;
			}else {
				if(sType != ''){
					if(sType =='telno'){
					    if(bFoundLead == false) {
						    if(!isValidPhone(oFormElements.item(i).value)){ 
							    alert(sErrTxt);
							    oFormElements.item(i).focus();
							    return false;
							    break;
						    }
						}
					}
					if (sType == 'email'){
					    if(bFoundLead == false) {
					        if(!/.+@[^.]+(\.[^.]+)+/.test(oFormElements.item(i).value)){ 
		                        alert(sErrTxt);
							    oFormElements.item(i).focus();
							    return false;
							    break;
						    }
						}
					}
				}
			}
			if(bLeadOnly) bFoundLead = true;
		}
	}
	
	bFoundLead = false; // Reset to false as new field type to be searched for
	oFormElements = document.getElementsByTagName("textarea")
	for (i = 0; i < oFormElements.length; i++){
		if(oFormElements.item(i).id.indexOf(sFieldName) == 0){
			if(oFormElements.item(i).value == '' || oFormElements.item(i).value == sDefaultVal && bFoundLead == false){
				alert(sErrTxt);
				oFormElements.item(i).focus();
				return false;
				break;
			}
			if(bLeadOnly) bFoundLead = true;
		}
	}
	return true;
}


function formatCurrency(num, bHidePound){
	if(typeof num != "undefined") {
		num = num.toString().replace(/\$|\,/g,'');
		if(isNaN(num))
		num = "0";
		sign = (num == (num = Math.abs(num)));
		num = Math.floor(num*100+0.50000000001);
		cents = num%100;
		num = Math.floor(num/100).toString();
		if(cents<10)
		cents = "0" + cents;
		for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
		num = num.substring(0,num.length-(4*i+3))+','+
		num.substring(num.length-(4*i+3));
		if(bHidePound==true) {
			return (((sign)?'':'-') + num + '.' + cents);
		}else{
			return (((sign)?'':'-') + '&pound;' + num + '.' + cents);
		}
	}
}

// START ALT POP JS
	// onmouseover="ShowInfoPop('This is a test','And it works!!')" onmouseout="HideInfoPop()"
	Xoffset=20;
	Yoffset=20;
	var yyy=-4000;
	var newDiv, newFrame;
	function ShowInfoPop(title,msg,newYoffset,newXoffset){
		if(newYoffset) {
			Yoffset = newYoffset;
		}
		if(newXoffset) {
			Xoffset = newXoffset;
		}
		if(window.Event && document.captureEvents)
		document.captureEvents(Event.MOUSEMOVE);
		document.onmousemove=get_mouse;
		sHTML='';
		sHTML+='<div class="infotitle">'+title+'</div>'
		sHTML+='<div class="infotext">'+msg+'</div>'
		yyy=Yoffset;
		document.getElementById('CTInfoBox').innerHTML = sHTML;
		document.getElementById('CTInfoBox').style.display='block';
		document.getElementById('CTInfoBox').style.position='absolute';
		if(document.getElementById('CTInfoBoxFrame')) {
			document.getElementById('CTInfoBoxFrame').style.display='block';
			document.getElementById('CTInfoBoxFrame').style.width=document.getElementById('CTInfoBox').offsetWidth+'px';
			document.getElementById('CTInfoBoxFrame').style.height=document.getElementById('CTInfoBox').offsetHeight+'px';
		}
		
	}
	function HideInfoPop(){
		yyy=-4000;
		if(document.getElementById('CTInfoBoxFrame')) {
			document.getElementById('CTInfoBoxFrame').style.display='none';
		}
		document.getElementById('CTInfoBox').style.display='none';
	}
	function get_mouse(e){
		if (!e) {
			var e = window.event||window.Event;
		}
		if('undefined'!=typeof e.pageX){
			mouseX = e.pageX;
			mouseY = e.pageY;
		}else{
			mouseX = e.clientX + document.documentElement.scrollLeft;
			mouseY = e.clientY + document.documentElement.scrollTop;
		}
		
		iMouseX = mouseX+Xoffset;
		//alert(document.documentElement.scrollTop);
		if(document.getElementById('CTInfoBoxFrame')) {
			document.getElementById('CTInfoBoxFrame').style.left=mouseX+Xoffset+'px';
			document.getElementById('CTInfoBoxFrame').style.top=mouseY+yyy+'px';
		}
		if(document.getElementById('CTInfoBox')) {
			document.getElementById('CTInfoBox').style.left=mouseX+Xoffset+'px';
			document.getElementById('CTInfoBox').style.top=mouseY+yyy+'px';
		}
	}
// END ALT POP JS

// START AJAX DIV UPDATER
	function updateDivAJAX(sDiv, sURL, sLoadingContent){
		if(document.getElementById(sDiv) && sLoadingContent) {
			document.getElementById(sDiv).innerHTML = sLoadingContent;				   
		}
		var divLoader = new ajaxObject(sDiv, sURL);
		divLoader.update(sDiv);
	}
	function ajaxObject(layer, url) {                                   
		var that=this;                                                  
		var updating = false;       
		this.callback = function() {}
		this.update = function(passData) {
			if (updating==true) { return false; }   
			updating=true;
			var AJAX = null;    
			if (window.XMLHttpRequest) {       
				AJAX=new XMLHttpRequest();     
			} else {       
				AJAX=new ActiveXObject("Microsoft.XMLHTTP");   
			}   
			if (AJAX==null) {        
				alert("Your browser doesn't support AJAX.");                                                   
				return false 
			} else {        
				AJAX.onreadystatechange = function() { 
				if(LayerID){
					if (AJAX.readyState==4 || AJAX.readyState=="complete") {
						var sText = AJAX.responseText
						if(sText.indexOf("|") > -1){
							sText = sText.split("|")[1]
						}
						LayerID.innerHTML=sText;            
						delete AJAX;
						updating=false;
						that.callback();        
					} 
				}
			}     
			var timestamp = new Date();      
			var uri=urlCall+'?'+passData+'&timestamp='+(timestamp*1);  
			
			AJAX.open("GET", uri, true);        
			AJAX.send(null);   
			return true;   
			}                   
		}
		var LayerID = document.getElementById(layer);  
		var urlCall = url;
	}
// END AJAX DIV UPDATED

/* START DATE VALIDATION */
	var dtCh= "/";
	var minYear=1900;
	var maxYear=2100;
	function isInteger(s){
		var i;
		for (i = 0; i < s.length; i++){   
			// Check that current character is number.
			var c = s.charAt(i);
			if (((c < "0") || (c > "9"))) return false;
		}
		// All characters are numbers.
		return true;
	}
	
	function stripCharsInBag(s, bag){
		var i;
		var returnString = "";
		// Search through string's characters one by one.
		// If character is not in bag, append to returnString.
		for (i = 0; i < s.length; i++){   
			var c = s.charAt(i);
			if (bag.indexOf(c) == -1) returnString += c;
		}
		return returnString;
	}
	function daysInFebruary (year){
		// February has 29 days in any year evenly divisible by four,
		// EXCEPT for centurial years which are not also divisible by 400.
		return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 );
	}
	function DaysArray(n) {
		for (var i = 1; i <= n; i++) {
			this[i] = 31
			if (i==4 || i==6 || i==9 || i==11) {this[i] = 30}
			if (i==2) {this[i] = 29}
	   } 
	   return this
	}
	
	function CTisDate(dtStr){
		var daysInMonth = DaysArray(12)
		var pos1=dtStr.indexOf(dtCh)
		var pos2=dtStr.indexOf(dtCh,pos1+1)
		var strDay=dtStr.substring(0,pos1)
		var strMonth=dtStr.substring(pos1+1,pos2)
		var strYear=dtStr.substring(pos2+1)
		strYr=strYear
		if (strDay.charAt(0)=="0" && strDay.length>1) strDay=strDay.substring(1)
		if (strMonth.charAt(0)=="0" && strMonth.length>1) strMonth=strMonth.substring(1)
		for (var i = 1; i <= 3; i++) {
			if (strYr.charAt(0)=="0" && strYr.length>1) strYr=strYr.substring(1)
		}
		month=parseInt(strMonth)
		day=parseInt(strDay)
		year=parseInt(strYr)
		if (pos1==-1 || pos2==-1){
			//alert("The date format should be : mm/dd/yyyy")
			return false
		}
		if (strMonth.length<1 || month<1 || month>12){
			//alert("Please enter a valid month")
			return false
		}
		if (strDay.length<1 || day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month]){
			//alert("Please enter a valid day")
			return false
		}
		if (strYear.length != 4 || year==0 || year<minYear || year>maxYear){
			//alert("Please enter a valid 4 digit year between "+minYear+" and "+maxYear)
			return false
		}
		if (dtStr.indexOf(dtCh,pos2+1)!=-1 || isInteger(stripCharsInBag(dtStr, dtCh))==false){
			//alert("Please enter a valid date")
			return false
		}
		return true
	}
/* END DATE VALIDATION */



var MouseYPosition = 0;
var MouseXPosition = 0;
function GetMousePosition() {
	if(window.Event && document.captureEvents)
	document.captureEvents(Event.CLICK);
	document.onclick=GetMousePositionScript;
}
function GetMousePositionScript(e){
	if(!e) {
		var e = window.event||window.Event;
	}
	if('undefined'!=typeof e.pageX){
		MouseXPosition = e.pageX;
		MouseYPosition = e.pageY;
	}else{
		MouseXPosition = e.clientX + document.documentElement.scrollLeft;
		MouseYPosition = e.clientY + document.documentElement.scrollTop ;
		//alert('mouseY: '+e.clientY+'\nscrollTop: '+document.documentElement.scrollTop);
		//alert(document.documentElement.scrollHeight)
	}
}
GetMousePosition();


function updateLocationTo(sValue) {
	document.getElementById('PackageLocation').value = sValue;
}

function setCookie(c_name,value,expiredays){
	if(value != null && value != ''){
		var exdate=new Date();exdate.setDate(exdate.getDate()+expiredays);
		document.cookie=c_name+ "=" + value +
		((expiredays==null) ? "" : "; expires="+exdate.toGMTString()) +
		((value.indexOf('path=')==-1) ? "; path=/" : "");
	}
}
function getCookie(c_name){
	if(document.cookie.length>0){
		c_start=document.cookie.indexOf(c_name + "=");
		if(c_start!=-1){ 
			c_start=c_start + c_name.length+1; 
			c_end=document.cookie.indexOf(";",c_start);
			if(c_end==-1) c_end=document.cookie.length;
			return unescape(document.cookie.substring(c_start,c_end).replace(new RegExp("^[&]+", "g"), "").replace(new RegExp("[&]+$", "g"), ""));
		} 
	}
	return "";
}
function PersistCookies(name,affiliatedays){
	setCookie(name + 'Affiliate',getCookie(name + 'Affiliate'),affiliatedays);
	setCookie(name,getCookie(name),1);
}

function readFile(url) {
	if (window.XMLHttpRequest) {              
		SyncDOM=new XMLHttpRequest();              
	} else {                                  
		SyncDOM=new ActiveXObject("Microsoft.XMLHTTP");
	}
	if (SyncDOM) {
		if(bDebug){
			var timestamp = new Date();
			if(url.indexOf('?')>-1) {
				url	= url+'&'+timestamp;
			}else{
				url	= url+'?'+timestamp;
			}
		}
		SyncDOM.open("GET", url, false);                             
		SyncDOM.send(null);
		return SyncDOM.responseText;                                         
	} else {
		return false;
	}                                             
}

function hideShowPassportInfo(numPax, provider) {
	if (provider == 'multicom'){
		for(x=1;x<=numPax;x++) {
			if (document.getElementById('FOIDVal_' + x).disabled == true){
				document.getElementById('FOIDVal_' + x).disabled = false;
				document.getElementById('FOIDVal_' + x).style.display='';
				document.getElementById('FOIDValTitle_' + x).style.display='';
				document.getElementById('FOID_ByPass').value = false;
				document.getElementById('infoPassportExpiryD' + x).disabled = false;
				document.getElementById('infoPassportExpiryM' + x).disabled = false;
				document.getElementById('infoPassportExpiryY' + x).disabled = false;
				if (document.getElementById('infoPassportIssueD' + x)){
				    //These fields only exist when flight is from EZJ
				    document.getElementById('infoPassportIssueD' + x).disabled = false;
				    document.getElementById('infoPassportIssueM' + x).disabled = false;
				    document.getElementById('infoPassportIssueY' + x).disabled = false;
				}
				if (x==numPax){
					document.getElementById('FOIDlabel3').innerHTML = 'Don\'t have all the passengers passport details right now?';
				}
			}else{
				document.getElementById('FOIDVal_' + x).disabled = true;
				document.getElementById('FOIDVal_' + x).style.display='none';
				document.getElementById('FOIDValTitle_' + x).style.display='none';
				document.getElementById('FOID_ByPass').value = true;
				document.getElementById('infoPassportExpiryD' + x).disabled = true;
				document.getElementById('infoPassportExpiryM' + x).disabled = true;
				document.getElementById('infoPassportExpiryY' + x).disabled = true;
				if (document.getElementById('infoPassportIssueD' + x)){
				    //These fields only exist when flight is from EZJ
				    document.getElementById('infoPassportIssueD' + x).disabled = true;
				    document.getElementById('infoPassportIssueM' + x).disabled = true;
				    document.getElementById('infoPassportIssueY' + x).disabled = true;
				}
				if (x==numPax){
					document.getElementById('FOIDlabel3').innerHTML = 'Do you have all the passengers passport details?';
					alert('Our staff will contact you once the booking is complete for your passport details.\n\nPlease note that if these are not provided the airline may refuse boarding.');
				}
				
			}
	
		}
		
	}else{ //AMADEUS
	
		for(x=1;x<=numPax;x++) {
			if (document.getElementById('infoPassportNum' + x).disabled == true){
				document.getElementById('FOID_ByPass').value = false;
				document.getElementById('infoPassportNum' + x).disabled = false;
				document.getElementById('infoPassportExpiryD' + x).disabled = false;
				document.getElementById('infoPassportExpiryM' + x).disabled = false;
				document.getElementById('infoPassportExpiryY' + x).disabled = false;
				document.getElementById('infoPassportNumTitle' + x).style.display='';
				document.getElementById('infoPassportExpiryTitle' + x).style.display='';
				document.getElementById('infoPassportNum' + x).style.display='';
				document.getElementById('infoPassportExpiryD' + x).style.display='';
				document.getElementById('infoPassportExpiryM' + x).style.display='';
				document.getElementById('infoPassportExpiryY' + x).style.display='';
				if (x==numPax){
					document.getElementById('FOIDlabel3').innerHTML = 'Don\'t have all the passengers passport details right now?';
				}
			}else{
				document.getElementById('FOID_ByPass').value = true;
				document.getElementById('infoPassportNum' + x).disabled = true;
				document.getElementById('infoPassportExpiryD' + x).disabled = true;
				document.getElementById('infoPassportExpiryM' + x).disabled = true;
				document.getElementById('infoPassportExpiryY' + x).disabled = true;
				document.getElementById('infoPassportNumTitle' + x).style.display='none';
				document.getElementById('infoPassportExpiryTitle' + x).style.display='none';
				document.getElementById('infoPassportNum' + x).style.display='none';
				document.getElementById('infoPassportExpiryD' + x).style.display='none';
				document.getElementById('infoPassportExpiryM' + x).style.display='none';
				document.getElementById('infoPassportExpiryY' + x).style.display='none';
				if (x==numPax){
					document.getElementById('FOIDlabel3').innerHTML = 'Do you have all the passengers passport details?';
					alert('Our staff will contact you once the booking is complete for your passport details.\n\nPlease note that if these are not provided the airline may refuse boarding.');
				}
				
			}
	
		}
		
	}


}

//Basket Upsell Functions
function CTdivSwitch(id) {
	o1 = document.getElementById(id);
	if(o1) {
		if(o1.style.display=='') {
			o1.style.display='none';
		}else{
			o1.style.display='';
		}
	}
}

function fillPassengerData() {
	sURL = '/includes/getpassengerxml.asp?ts='+new Date();
	var bHidePersonalDetails = false;
	var sResponse = readFile(sURL);
	if(window.DOMParser) {
		var parser=new DOMParser();
		var XMLDocTemp=parser.parseFromString(sResponse,"text/xml");
	}else{
		var XMLDocTemp=new ActiveXObject("Microsoft.XMLDOM");
		XMLDocTemp.async='false';
		XMLDocTemp.loadXML(sResponse);
	}
	var oPassengers = XMLDocTemp.getElementsByTagName('Passenger');
	if(oPassengers.length > 0) {
		bHidePersonalDetails = true;
		for(x=0;x<oPassengers.length;x++) {
			iID = x+1
			sTitle = GetNode(oPassengers[x].getElementsByTagName("Title")[0].childNodes[0]);
			sFirstName = GetNode(oPassengers[x].getElementsByTagName("FName")[0].childNodes[0]);
			sSurname = GetNode(oPassengers[x].getElementsByTagName("SName")[0].childNodes[0]);
			sDOBd = GetNode(oPassengers[x].getElementsByTagName("DOB_D")[0].childNodes[0]);
			sDOBm = GetNode(oPassengers[x].getElementsByTagName("DOB_M")[0].childNodes[0]);
			sDOBy = GetNode(oPassengers[x].getElementsByTagName("DOB_Y")[0].childNodes[0]);
			
			if (sTitle == '' || sFirstName == '' || sSurname == '' || sDOBd == '' || sDOBm == '' || sDOBy == ''){bHidePersonalDetails = false; alert(sTitle +'-' + sFirstName + '-' + sSurname + '-' + sDOBd + '-' + sDOBm + '-' + sDOBy);}
			
			o1 = document.getElementById('title'+iID);
			o2 = document.getElementById('firstname'+iID);
			o3 = document.getElementById('surname'+iID);
			o4 = document.getElementById('dobd'+iID);
			o5 = document.getElementById('dobm'+iID);
			o6 = document.getElementById('doby'+iID);
			if(o1) {
				for(y=0;y<o1.length;y++) {
					if(o1[y].value.toLowerCase()==sTitle.toLowerCase()) {
						o1.selectedIndex = y;
						y = o1.length;
					}
				}
			}
			if(o2){o2.value=sFirstName;}
			if(o3){o3.value=sSurname;}
			if(o4&&o5&&o6) {
				for(y=0;y<o4.length;y++) {
					if(o4[y].value.toLowerCase()==sDOBd.toLowerCase()) {
						o4.selectedIndex = y;
						y = o4.length;
					}
				}
				for(y=0;y<o5.length;y++) {
					if(o5[y].value.toLowerCase()==sDOBm.toLowerCase()) {
						o5.selectedIndex = y;
						y = o5.length;
					}
				}
				for(y=0;y<o6.length;y++) {
					if(o6[y].value.toLowerCase()==sDOBy.toLowerCase()) {
						o6.selectedIndex = y;
						y = o6.length;
					}
				}
			}
		}
	}
	var oExtraInformation = XMLDocTemp.getElementsByTagName('ExtraInformation');
	if(oExtraInformation.length > 0) {
		sEmail = GetNode(oExtraInformation[0].getElementsByTagName("Email")[0].childNodes[0]);
		sTelNo = GetNode(oExtraInformation[0].getElementsByTagName("TelNo")[0].childNodes[0]);
		if(oExtraInformation[0].getElementsByTagName("FlightNo")[0] != undefined){
            sFlightNo = GetNode(oExtraInformation[0].getElementsByTagName("FlightNo")[0].childNodes[0]);
        }
        if(oExtraInformation[0].getElementsByTagName("OutboundArrivalTime")[0] != undefined){
            sArrivalTime = GetNode(oExtraInformation[0].getElementsByTagName("OutboundArrivalTime")[0].childNodes[0]);
        }
		o1 = document.getElementById('email');
		o2 = document.getElementById('telephone');
		o3 = document.getElementById('CarFlightNo');
		o4 = document.getElementById('CarFlightTime');
		if(o1){o1.value=sEmail;}
		if(o2){o2.value=sTelNo;}
		if(o3){o3.value=sFlightNo;}
		if(o4){
			for(y=0;y<o4.length;y++) {
				if(o4[y].value.toLowerCase()==sArrivalTime.toLowerCase()) {
					o4.selectedIndex = y;
					y = o4.length;
				}
			}
		}
	}
	
	checkHideInputs(bHidePersonalDetails); //looks to hide the personal information section if all details prepopulated
	
}

function readFile(url) {
	if (window.XMLHttpRequest) {              
		SyncDOM=new XMLHttpRequest();              
	} else {                                  
		SyncDOM=new ActiveXObject("Microsoft.XMLHTTP");
	}
	if (SyncDOM) {
		if(bDebug){
			var timestamp = new Date();
			if(url.indexOf('?')>-1) {
				url	= url+'&'+timestamp;
			}else{
				url	= url+'?'+timestamp;
			}
		}
		SyncDOM.open("GET", url, false);                             
		SyncDOM.send(null);
		return SyncDOM.responseText;                                         
	} else {
		return false;
	}                                             
}

function GetNode(object) {
	if(object) {
		return object.nodeValue;
	}
	return '';
}

function checkHideInputs(hidePersonalInfo) {
	if (document.getElementById('PersonalInputAreaHidden') && document.getElementById('PersonalInputAreaShown')){
		if (hidePersonalInfo){
			document.getElementById('PersonalInputAreaHidden').style.display = '';
			document.getElementById('PersonalInputAreaShown').style.display = 'none';
		}
	}
}
//Basket Upsell Functions END

//Extras upsell (NE 16/06/2009)
function upsell_showpax(ticketnolist, divid, divcount) {
	// Show passengers depnding on the number of tickets selected
	
	for (i=1; i<=50; i++) {
		var oTR = document.getElementById(divid + '_' + i);
		if(oTR) {
			oTR.style.display = 'none';	
			var oTDs = oTR.getElementsByTagName('td');
			for (j=0; j<=oTDs.length; j++) {
				var oTD = oTDs[j];
				if(oTD) {
					oTD.style.display = 'none';	
				}
			}
		}else{
			break;	
		}
	}
    var bShow = true;
    if(ticketnolist.type === 'checkbox'){
        if (ticketnolist.checked == false){
            bShow = false;
        }
    }
    if(bShow){
        for (i=1; i<=ticketnolist.value; i++) {
            var oTR = document.getElementById(divid + '_' + i);
            if(oTR) {
	            oTR.style.display = '';
	            var oTDs = oTR.getElementsByTagName('td');
	            for (j=0; j<=oTDs.length; j++) {
		            var oTD = oTDs[j];
		            if(oTD) {
			            oTD.style.display = '';	
		            }
	            }
            }
	    }	
	}
}

function trim(str) {
	return str.replace(/^\s+|\s+$/g,"");
}

function isValidPhone(sTelvalue){
	isValid = false;
	if (!sTelvalue==''){
		sTelvalue = sTelvalue.replace(/\s/g,'');
		if (/^(01|02|07|08)[0-9]{8,9}.*$/.test(sTelvalue)){
			isValid = true;
		}
	}	
	return isValid
}


function isValidPostcode(sValue){
	isValid = false;
	if (!sValue==''){
		sValue = sValue.toUpperCase();
		if (/^([A-PR-UWYZ0-9][A-HK-Y0-9][AEHMNPRTVXY0-9]?[ABEHMNPRVWXY0-9]? {1,2}[0-9][ABD-HJLN-UW-Z]{2}|GIR 0AA)$/.test(sValue)){
			isValid = true;
		}
	}	
	return isValid
}


-->