<!--
// 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) {
			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()
	}
}
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 || 100;
	var opacity = options.opacity || 70;
	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) {
		sSelectHide = 'none';
		// Calculate the page width and height 
		if( document.body && ( document.body.scrollWidth || document.body.scrollHeight ) ) {
			var pageWidth = document.body.scrollWidth+'px';
			var pageHeight = document.body.scrollHeight+'px';
		} else if( document.body.offsetWidth ) {
			var pageWidth = document.body.offsetWidth+'px';
			var pageHeight = document.body.offsetHeight+'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='block';				 
	} else {
		dark.style.display='none';
		sSelectHide = '';
	}
	oSelects = document.getElementsByTagName('select');
	for(x=0;x<oSelects.length;x++) {
		//oSelects[x].style.display = sSelectHide;
	}
}

function changeCurrency(fId) {
	if(confirm('Are you sure you want to change the currency?')) {
		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.name.value || fId.name.value=='Enter your name') {m+='- Please enter your 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 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(!/.+@[^.]+(\.[^.]+)+/.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) {
	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), 13);
			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 "; }
	var isValid=true;
	var Char;
	for (i = 0; i < sText.length && isValid == true; i++) 
	{ 
		Char = sText.charAt(i); 
		if (ValidChars.indexOf(Char) == -1) 
		{ isValid = false; }
	}
	return isValid;
}
function echeck(str) {
	if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.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;
	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();
	}	
}

//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';
var SelectedHeaderTab = '';

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<8;x++) {
		if(document.getElementById('search_tab'+x)) {
			document.getElementById('search_tab'+x).className = 'searchtab';
		}
		if(document.getElementById('search'+x)) {
			document.getElementById('search'+x).style.display = 'none';
		}
	}
	SelectedSearchTab = id;
	if(document.getElementById(id)) {
		document.getElementById(id).className = 'searchtabOver';
	}
	if(document.getElementById('search'+Right(id,1))) {
		document.getElementById('search'+Right(id,1)).style.display = '';
	}
}

function SwitchLanding(id) {
	for(x=1;x<8;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);
    }
}
function Mid(str, start, len)
{
	// Make sure start and len are within proper bounds
    if (start < 0 || len < 0) return "";
    var iEnd, iLen = String(str).length;
    if (start + len > iLen)
          iEnd = iLen;
    else
          iEnd = start + len;
    return String(str).substring(start,iEnd);
}



// Clears a text field only if the value matches what is passed in
function clearField(fId, sMatch, sChange){
	if(sChange == null) sChange = '';
	if(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 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){
	if(iMinLen==undefined || iMinLen==null) { iMinLen = 1; }
	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)){
				alert(sErrTxt);
				oFormElements.item(i).focus();
				return false;
				break;
			}
		}
	}
	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){
				alert(sErrTxt);
				oFormElements.item(i).focus()
				return false;
				break;
			}
		}
	}
	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=-1000;
	var newDiv, newFrame;
	function ShowInfoPop(title,msg,newYoffset){

		if(newYoffset) {
			Yoffset = newYoffset;
		}
		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';
		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=-1000;
		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


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 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('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;
				}
				document.getElementById('FOID_ByPass').value = 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('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;
				}
				document.getElementById('FOID_ByPass').value = true;
				if (x==numPax){
					document.getElementById('FOIDlabel3').innerHTML = 'Do you have all the passengers passport details?';
					alert('Please note that passport information will still be required to complete this booking.\n\nYou will be prompted to pay offline at the next stage and one of our team will call you back as soon as possible to confirm the necessary details.');
				}
				
			}
	
		}
		
	}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;
				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;
				if (x==numPax){
					document.getElementById('FOIDlabel3').innerHTML = 'Do you have all the passengers passport details?';
					alert('Please note that passport information will still be required to complete this booking.\n\nYou will be prompted to pay offline at the next stage and one of our team will call you back as soon as possible to confirm the necessary details.');
				}
				
			}
	
		}
		
	}


}

/* 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 */

//Basket Upsell Functions
function CTdivSwitch(id) {
	o1 = document.getElementById(id);
	o1_link = document.getElementById(id + '_link');
	if(o1) {
		if(o1.style.display=='') {
			o1.style.display='none';
			o1_link.innerHTML='Click here to view';
		}else{
			o1.style.display='';
			o1_link.innerHTML='Click here to hide';
		}
	}
}

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]);
		sFlightNo = GetNode(oExtraInformation[0].getElementsByTagName("FlightNo")[0].childNodes[0]);
		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

-->