	function loadContinent() 
	{
		delData('regionId');
		var xhr;
		try {
			xhr = new XMLHttpRequest();
		} 
		catch(e) {
			xhr = new ActiveXObject("Microsoft.XMLHTTP");
		}	
			
		xhr.onreadystatechange  = function(){
			if(xhr.readyState  == 4){
				if(xhr.status  == 200)
				{
					//alert (xhr.responseText); 
					fillData('regionId', xhr.responseText, '1');
				}
				else 
					alert("Error code " + xhr.status);
			}
		}
		
		xhr.open("GET", "country.php",  true); 
		xhr.send(null);
		
	}
	
		
	function loadCountry(country) 
	{	
		delData('countryId');
		var xhr;
		try {
			xhr = new XMLHttpRequest();
		} 
		catch(e) {
			xhr = new ActiveXObject("Microsoft.XMLHTTP");
		}
		
		xhr.onreadystatechange  = function()
		{
		
			if(xhr.readyState  == 4){
				if(xhr.status  == 200) 
				{
					fillData('countryId', xhr.responseText, '2');
				}
				else 
					alert("Error code " + xhr.status);
			}
		}
		
		xhr.open("GET", "city.php?continent="+country,  true); 
		xhr.send(null);
			
	}
	
	function loadCity(continent,country) {		
			
		delData('cityId');
	
		var xhr;
		try {
			xhr = new XMLHttpRequest();
		} 
		catch(e) {
			xhr = new ActiveXObject("Microsoft.XMLHTTP");
		}
		xhr.onreadystatechange  = function(){
			if(xhr.readyState  == 4){
				if(xhr.status  == 200) 
				{
					fillData('cityId', xhr.responseText, '3');
				}
				else 
					alert("Error code " + xhr.status);
			}
		}
		
				
		xhr.open("GET", "city.php?continent="+continent+"&country="+country,  true); 
		xhr.send(null);
		
	}
	
	
	function fillData(list, data, run) 
	{
		var cList=document.getElementById(list);
		var x=data.split(":");
		
		for(var i=0;i<x.length-1;i++)
		{
			var d=x[i].split("-");
			var y=document.createElement('option');
			
			y.value=d[0];
			y.text=d[1];
			
			try {
				cList.add(y,null);
			} catch(ex)	{
				cList.add(y);
			}
		}
		
		
		
		if (run == 1) 
		{
			document.getElementById('regionId').value=2;
			for(i=0; i< cList.options.length; i++)
				if(cList.options[i].value==document.getElementById('countryId').value)
				{
					
				cList.selectedIndex = i; 
				break;
				}
		loadCountry(document.getElementById('regionId').value);

		}

		else if (run == 2) 
		{
			if(document.getElementById('countryId').value==2)
			{
				document.getElementById('countryId').value='CA';
			}
			for(i=0; i< cList.options.length; i++)
				if(cList.options[i].value==document.getElementById('cityId').value)
				{
					cList.selectedIndex = i; 
					break;
				}
			loadCity(document.getElementById('regionId').value,document.getElementById('countryId').value);

		}

		else if (run == 3)
		 {
		 	if(document.getElementById('cityId').value=='CA')
		 	{
		 		document.getElementById('cityId').value=39;
		 	}
			for(i=0; i< cList.options.length; i++)
				if(cList.options[i].value==document.getElementById('cityId').value){ cList.selectedIndex = i; break;}
		}

	}
	
	function delData(list) {
		var cList=document.getElementById(list);
		cList.options.length = 0;
	}
	
