	
	function changeCity(prefix) {
	
		var selectProvince;
		var selectCity;
		var XMLHTTPObject = createHTTPHandler();
		var i;
		var province;
		var url;
		
		selectProvince = document.getElementById(prefix + "_province");
		selectCity = document.getElementById(prefix + "_city");
						
		i = selectProvince.selectedIndex;
		province = selectProvince.options[i].value;
		
		if(province != '-'){
		
			url="getdata.ajax.php?province="+province+"&"+Math.floor (Math.random ( ) * 9999999999999 + 1);
					
			XMLHTTPObject.open('GET', url, true);
			XMLHTTPObject.send(null);
			
			XMLHTTPObject.onreadystatechange=function() {
				if (XMLHTTPObject.readyState==4) {
					var optArray = new Array();		
					var i = 0;
					
					selectCity.options.length=0;
					
					optArray = XMLHTTPObject.responseText.split(",");			
					for(var opt in optArray){
						
						selectCity.options[i] = new Option(optArray[opt], optArray[opt]);
						
						i++;
					}
					
				}
			}
			
		}else{
			selectCity.options.length=0;
			selectCity.options[0] = new Option("-","-");
		}
				
	}
	
	function changePostalcode(prefix) {
	
		var selectCity;
		var selectPostalcode;
		var XMLHTTPObject = createHTTPHandler();
		var i;
		var city;
		var url;
		
		selectCity = document.getElementById(prefix + "_city");
		selectPostalcode = document.getElementById(prefix + "_postalCode");
						
		i = selectCity.selectedIndex;
		city = selectCity.options[i].value;

		if(city != '-'){
		
			url="getdata.ajax.php?city="+city+"&"+Math.floor (Math.random ( ) * 9999999999999 + 1);
					
			XMLHTTPObject.open('GET', url, true);
			XMLHTTPObject.send(null);
			
			XMLHTTPObject.onreadystatechange=function() {
				if (XMLHTTPObject.readyState==4) {
					var optArray = new Array();		
					var i = 0;
					
					selectPostalcode.options.length=0;
					
					optArray = XMLHTTPObject.responseText.split(",");			
					for(var opt in optArray){
						
						selectPostalcode.options[i] = new Option(optArray[opt], optArray[opt]);
						
						i++;
					}
					
				}
			}
			
		}else{
			selectPostalcode.options.length=0;
			selectPostalcode.options[0] = new Option("-","-");
		}
				
	}
	
	function changeMap(){
		
		var sdepartureProvince = document.getElementById("departure_province");
		var sdepartureCity = document.getElementById("departure_city");
		var sdeparturePostalcode = document.getElementById("departure_postalCode");
		var sdestinationProvince = document.getElementById("destination_province");
		var sdestinationCity = document.getElementById("destination_city");
		var sdestinationPostalcode = document.getElementById("destination_postalCode");
		
		var departureProvince = sdepartureProvince.options[sdepartureProvince.selectedIndex].value;
		var departureCity = sdepartureCity.options[sdepartureCity.selectedIndex].value;
		var departurePostalcode = sdeparturePostalcode.options[sdeparturePostalcode.selectedIndex].value;
		var destinationProvince = sdestinationProvince.options[sdestinationProvince.selectedIndex].value;
		var destinationCity = sdestinationCity.options[sdestinationCity.selectedIndex].value;
		var destinationPostalcode = sdestinationPostalcode.options[sdestinationPostalcode.selectedIndex].value;
		
		var query1;
		var query2;
		
		if(departureProvince != '-' && departureCity != '-' && departurePostalcode != '-' && 
			destinationProvince != '-' && destinationCity != '-' && destinationPostalcode != '-'){
			
			if(sdeparturePostalcode.options.length == 2){
				query1 = departureCity + "," + departureProvince + ",Nederland";
			}else{
				query1 = departurePostalcode + "," + departureCity + "," + departureProvince + ",Nederland";
			}
			if(sdestinationPostalcode.options.length == 2){
				query2 = destinationCity + "," + destinationProvince + ",Nederland";		
			}else{
				query2 = destinationPostalcode + "," + destinationCity + "," + destinationProvince + ",Nederland";
			}
			
			drawRoute(query1, query2);
			
		}
		
	}
	function createHTTPHandler(){
		httphandler = false;
		/*@cc_on @*/
		/*@if (@_jscript_version >= 5)
		// JScript gives us Conditional compilation, we can cope with old IE versions.
		// and security blocked creation of the objects.
		try {
		  httphandler = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
		  try {
		   httphandler = new ActiveXObject("Microsoft.XMLHTTP");
		  } catch (E) {
			  httphandler = false;
		  }
		}
		@end @*/
		if (!httphandler && typeof XMLHttpRequest!='undefined') {
			httphandler = new XMLHttpRequest();
		}	
		return httphandler;
	}

