<!--

function checkCarOnlyForm(sForm) {
	var sError = '';
	if(sForm.freetext.value=='- Type your pick-up location -') {
		sError = sError + 'Please type in a pick-up point\n';
	}
	if(sError!=''){
	    alert(sError);
	    return false;
	}
    return true;
}

//Clear List
function clearListCar(listElem) {
	if(listElem!=0){
		while(listElem.options.length > 0) {
			listElem.options[0] = null;
			listElem.disabled="disabled"
		}
		while(listElem.hasChildNodes()) {
			listElem.removeChild(listElem.firstChild);
		}
		listElem.options[0] = new Option('- Loading pickup points -','-');
		listElem.options[1] = new Option('- Select a pickup point -','-');
	}
}

//On Change Event
function changePickupPoints(sCountry) {
	var idPickup = document.getElementById('idPickup');
	sURL = "/includes/HolidayAutos/pickuppointsXML.asp?country=" + sCountry
	if(sURL!='') {
		clearListCar(idPickup);
		//if(confirm('Open ' + sURL)) {
		//	window.open(sURL);	
		//}
		setTimeout("loadCarhireXMLDoc('"+sURL+"')", 100);
	}else{
		alert('No url defined');	
	}
}

//XML Loader
function loadCarhireXMLDoc(url) {
    // branch for native XMLHttpRequest object
	var processChange = processCarhireChange
	
	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 processCarhireChange() {	
	var idPickup = document.getElementById('idPickup');
	if (req.readyState == 4)
	{
		if (req.status == 200)
		{
			xmldoc = req.responseXML.documentElement;
			nodes = xmldoc.getElementsByTagName('pp');
			for(var i = 0; i < nodes.length; i++) {
				if (nodes.length != 0) {
					var GroupName = nodes.item(i).attributes.getNamedItem("regionname").nodeValue
					if(PreGroupName!=GroupName){
						var RegionName = document.createElement('optgroup');
						RegionName.label = GroupName;
						if(GroupName!='zzz') {
							idPickup.appendChild(RegionName);
						}else if(i>0) {
							RegionName.label = 'Others';
							idPickup.appendChild(RegionName);
						}
					}
					var PreGroupName = GroupName
					sId = nodes.item(i).attributes.getNamedItem("id").nodeValue;
					sName = nodes.item(i).childNodes.item(0).nodeValue;
					idPickup.options[idPickup.options.length] = new Option(sName, sId);
					
				}
			}
			idPickup.options[0] = null
			idPickup.disabled='';			
			if(nodes.length==1) {
				idPickup.options[1].selected = true;
			}
		}
		else
		{
			alert("There was a problem retrieving the XML data:\n" + req.statusText);
		}
	}
}
 -->
