<!--
var sSpecialType
var sCurForm
var sCurSearchType
var sFlasher

function onEnterSearch(sFrmName,sSearchType){
	if(event.keyCode==13&&document.getElementById('doWhat'+sFrmName).value==1){
		getLocations(document.getElementById('idFreetext'+sFrmName).value,sFrmName,sSearchType,'contact');
	}
}

function showFullSearch() {
	if(document.getElementById('DivShow')) {
		showhidechangeoptions('show');	
	}
}

function validateLocationForm() {
	sSubmitForm = document.getElementsByName('frm'+sCurForm);
	sLocationID = document.getElementById('idLocationto'+sCurForm);
	var e = sSubmitForm.elements, m = '';
	if(sLocationID.value=='-'){m += '- Please select a destination.\n';}
	if(validateDate('startdate_d'+sCurForm,'startdate_m'+sCurForm,'startdate_y'+sCurForm)<=2) {m += '- Departure date is not valid.\n';}
	if(document.getElementById('rooms'+sCurForm)) {
		if(document.getElementById('rooms'+sCurForm).value=='0') {
			m+='- Please select no. of rooms\n';
		}
	}
	if(m) {
		showFullSearch();
		switchLocationDivs('divLocation'+sCurForm);
		if(sCurForm=='Flight'||sCurForm=='FlightHotel') {
			m += '\nTo book a flight departing within 72 hours please call our reservations team on 0800 389 05 82';	
		}
		alert('The following errors occurred:\n\n' + m);
		return false;
	}else{
		sSubmitForm[0].submit();
	}	
}

function locationGoBack(sForm) {
	var sLocationID = document.getElementById('idLocationto'+sForm);
	var sFreetext = document.getElementById('idFreetext'+sForm);
	//alert(parseInt(GetElementWidth('idLocationto'+sForm)+6));
	sLocationID.style.width = '178px';
	//clearLocationList(sLocationID);
	div_switch('divLocationLoad'+sForm, false, true);
	div_switch('divLocation'+sForm, false, true);
	div_switch('divFreetext'+sForm, true, true);
	//sFreetext.focus();
	sFreetext.select();
}

function switchLocationDivs(sDiv) {
	div_switch('divFreetext'+sCurForm, false, true);
	div_switch('divLocationLoad'+sCurForm, false, true);
	div_switch('divLocation'+sCurForm, false, true);
	div_switch(sDiv, true, true);
}

//Clear List
function clearLocationList(listElem) {
	if(listElem!=0){
		if(listElem.options){
		while(listElem.options.length > 0) {
			listElem.options[0] = null;
		}}
		while(listElem.hasChildNodes()) {
			listElem.removeChild(listElem.firstChild);
		}
	}
}

//On Change Event
function getLocations(sLocation,sForm,sSearchType,sType) {
	sSpecialType = sType;
	sCurForm = sForm;
	sCurSearchType = sSearchType;
	var sLocationID = document.getElementById('idLocationto'+sCurForm);
	var sFreetextID = document.getElementById('idFreetext'+sCurForm);
	if(sForm != "Flight"){
		if(sLocationID.selectedIndex < 0){
			sLocationValue = '';
		}else{
			sLocationValue = sLocationID.options[sLocationID.selectedIndex].value
		}
	}
	
	
	//######Florida4Less Specific#######
	var bRefined = document.getElementById('SearchFloridaOnly').value;	
	var BYOIncCar = eval('document.frm' + sForm + '.includecar');
	if(BYOIncCar){
		bCarIncluded = (BYOIncCar.value == "yes")? true:false;
	}else{bCarIncluded = false}

	if(sForm == "Flight"){
		oFlight = document.getElementById('idLocationtoFlightFlights');
		oFlightCar = document.getElementById('idLocationtoFlightFlightCar');
		//sLocationValue = (bCarIncluded) ? oFlightCar.options[oFlightCar.selectedIndex].value : oFlight.options[oFlight.selectedIndex].value;
		sLocationValue = oFlight.options[oFlight.selectedIndex].value;
		sLocationID.value = sLocationValue;
		//sLocationID = (bCarIncluded) ? document.getElementById('idLocationto' + sCurForm + 'FlightCar') : document.getElementById('idLocationto' + sCurForm + 'Flights');
	}
	//##################################


	if(((sFreetextID.value.length<1 || sFreetextID.value == "- Type your destination -") && bRefined == 'false') || (bRefined == 'true' && sLocationValue == '')) {
		showFullSearch()

		if(bRefined == 'false'){
			alert('Please type your destination');	
		}else{
			alert('Please select a destination');
		}
		
		//sFreetextID.focus();
	}else if(sLocationID.value=='') {
		if(bRefined){
			sURL = "/includes/search/LookupXML.asp?searchtype="+sCurSearchType+"&location=" + sLocation + '&refined=' + bRefined + '&includecar=' +  bCarIncluded
		}else{
			sURL = "/includes/search/LookupXML.asp?searchtype="+sCurSearchType+"&location=" + sLocation + '&includecar=' + bCarIncluded
		}
		if(sURL!='') {
			//if(confirm('Open '+ sURL)) {
			//	window.open(sURL);
			//}
			clearLocationList(sLocationID);
			setTimeout("loadLocationXMLDoc('"+sURL+"')", 100);
		}else{
			alert('No url defined');	
		}
	}else{
		validateLocationForm();	
	}
}

//XML Loader
function loadLocationXMLDoc(url) {
    // branch for native XMLHttpRequest object
	var processChange = processLocationChange
	
	if (window.XMLHttpRequest) {
        req = new XMLHttpRequest();
		req.onreadystatechange = processChange;
        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 = processChange;
            req.open("GET", url, true);
            req.send();
        }
    }
}

function processLocationChange() {
	switchLocationDivs('divLocationLoad'+sCurForm);
	var divLocationBorder = document.getElementById('divLocationBorder'+sCurForm);
	//var divLocationPointer = document.getElementById('divLocationPointer'+sCurForm);
	var sLocationID = document.getElementById('idLocationto'+sCurForm);
	var sFreetext = document.getElementById('idFreetext'+sCurForm);
	//######Florida4Less Specific
	if(document.getElementById('stFO').checked){
		sLocationID = document.getElementById('idLocationto' + sCurForm + 'Flights');
		
	}else if(document.getElementById('stFC').checked){
		sLocationID = document.getElementById('idLocationto' + sCurForm + 'FlightCar');
	}
	clearLocationList(sLocationID);
	//######Florida4Less Specific
	
	
	if (req.readyState == 4)
	{
		if (req.status == 200)
		{
			xmldoc = req.responseXML.documentElement;
			nodes = xmldoc.getElementsByTagName('Location');
			sLocationID.options[0] = new Option('- Select a destination -','-');
			for(var i = 0; i < nodes.length; i++) {
				if (nodes.length != 0) {
					var GroupName = nodes.item(i).attributes.getNamedItem("title").nodeValue
					if(PreGroupName!=GroupName){
						var RegionName = document.createElement('optgroup');
						RegionName.label = GroupName;
						if(GroupName!='zzz') {
							sLocationID.appendChild(RegionName);
						}else if(i>0) {
							RegionName.label = 'Others';
							sLocationID.appendChild(RegionName);
						}
					}
					var PreGroupName = GroupName
					sCode = nodes.item(i).attributes.getNamedItem("code").nodeValue;
					sName = nodes.item(i).childNodes.item(0).nodeValue;
					sLocationID.options[sLocationID.options.length] = new Option(sName, sCode);
					
				}
			}
			if(nodes.length==1&&sSpecialType!='contact') {
				sLocationID.options[1].selected = true;
				validateLocationForm();
			}else if(nodes.length<1){
				showFullSearch();
				alert('No destinations found.\n\nPlease refine your search.');
				locationGoBack(sCurForm);
				sFreetext.focus();sFreetext.select();
			}else{
				showFullSearch();
				switchLocationDivs('divLocation'+sCurForm);
				divLocationBorder.className='chooseDropDown';
				
				sFlasher = setInterval('selectFlash();',600);
				//sLocationID.className = 'redSelectBox';
				div_switch('divLocationPointer'+sCurForm, true, true);
				//sLocationID.style.width = parseInt(GetElementWidth('idLocationto'+sCurForm)-6)+'px';
				sLocationID.style.width = '191px';
			}
				
		}
		else
		{
			alert("There was a problem retrieving the XML data:\n" + req.statusText);
		}
	}
}

function clearFlash() {
	try{
		var sLocationID = document.getElementById('idLocationto'+sCurForm);
		clearInterval(sFlasher);
		sLocationID.className = 'redSelectBox_Swtich';
	}catch(err){}
}

function selectFlash() {
	var sLocationID = document.getElementById('idLocationto'+sCurForm);
	if(sLocationID.className=='redSelectBox'){
		sLocationID.className = 'redSelectBox_Switch';
	}else{
		sLocationID.className = 'redSelectBox';
	}
}

function addDurationBYO(sform)
{
	var months = new Array('January','February','March','April','May','June','July','August','September','October','November','December');
	
		oSelect = document.getElementById('startdate_d'+sform);
		iDay = oSelect.options[oSelect.selectedIndex].value;
		oSelect = document.getElementById('startdate_m'+sform);
		iMonth = oSelect.options[oSelect.selectedIndex].value;
		oSelect = document.getElementById('startdate_y'+sform);
		iYear = oSelect.options[oSelect.selectedIndex].value;
	
	cindate = new Date(iYear, iMonth - 1, iDay, 0, 0, 0);
	
	oSelect = document.getElementById('duration'+sform);
	//alert('duration'+sform);
	if (oSelect.options[oSelect.selectedIndex].value == 'other')
	{
		tmpDuration = prompt("Please enter the number of nights","")
		if ( (tmpDuration==' ') || (tmpDuration==null) || (tmpDuration == ''))
		{
			iDuration = 7
			oSelect.options[0].selected = 'selected';
		}
		else
		{
			var stemp = tmpDuration
			if (stemp < 10)
			{
				stemp = "0" + stemp
			}
			for (loop=0; loop < oSelect.options.length; loop++)
			{
				if (oSelect.options[loop].value == stemp)
				{
					oSelect.options[loop].selected = 'selected';
					iDuration = stemp
				}
			}

			if (isNumeric(tmpDuration) == true)
			{	
				var opt = new Option(tmpDuration + ' days', tmpDuration);
				insertOptionAt (oSelect, opt, oSelect.options.length);
				iDuration = oSelect.options[oSelect.options.length-1].value;
				oSelect.selectIndex = oSelect.options.length;
				oSelect.options[oSelect.options.length-1].selected = 'selected';
			}
			else
			{
				iDuration = 7
				oSelect.options[0].selected = 'selected';
			}
		}
	}
	else
	{
		iDuration = oSelect.options[oSelect.selectedIndex].value;
	}

	// Amend the end date
	days = 1000 * 60 * 60 * 24 * iDuration;
	newdate = new Date(cindate.valueOf() + days);
	if ((newdate.getHours() != 0) || (newdate.getMinutes() != 0) || (newdate.getSeconds() != 0)) {
		// Workaround to JavaScript bug: sometimes when adding days represented as milliseconds it would onhly add 23 hrs
		// Work out time in milliseconds
		time = newdate.getHours() * 60 * 60 * 1000;
		time += newdate.getMinutes() * 60 * 1000;
		time += newdate.getSeconds() * 1000;
		newdate = new Date(newdate.getTime() + time);
		//alert(newdate);
	}
	
	if(newdate.getDate()+'' != "NaN") {
		sArrDate = newdate.getDate() + ' ' + months[newdate.getMonth()] + ' ' + newdate.getFullYear();
	 } else {
		 sArrDate = 'Please select a departure date.';
	 }
	
	//alert(sArrDate);
	document.getElementById("arrdate"+sform).innerHTML = '<b>' + sArrDate + '</b>'
	//document.getElementById("arrdate"+sform).value = sArrDate	
}

function GetElementWidth(sObject) {
	var elem;
	if(typeof(sObject) == "object") {
		elem = sObject;
	} else {
		elem = document.getElementById(sObject);
	}
	return parseInt(elem.offsetWidth);
}


 -->