
function GetDirections(URL) {
var state=document.frmregister.state.value;
var area=document.frmregister.area.value;
//document.getElementById('sDirection').innerHTML=URL+"AJAXDirection.php?state="+state+"&area="+area;
if(DirectionsGet(URL+"AJAXDirection.php?state="+state+"&area="+area) == true){return true;}else{ return false;}
}

  function trimmer(untrimed){
  		var regexp = /^\s+/ 		
		return untrimed.replace(regexp, "") 

  }
	
	function DirectionsGet(url) {
						/*************************************************************************/
							var xmlhttp=false;
							try { 
								xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); //here simply we are creating object
							} catch (e) { 
										try { 
											xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); //here simply we are creating object
										} catch (E) { 
											xmlhttp = false; 
										}//try {  
							}//	try { 
						
							if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
								xmlhttp = new XMLHttpRequest();//here simply we are creating object
							}
						/*************************************************************************/
	

		xmlhttp.open("POST", url,false); 
	
		xmlhttp.onreadystatechange = function() { 
		if (xmlhttp.readyState == 4 && xmlhttp.status == 200) { 		
		var finalprice=trimmer(xmlhttp.responseText);
	
	//alert(finalprice);
		if(finalprice=='Y'){
			return true;
			document.getElementById('sDirection').innerHTML='';
		}else{

			var data=xmlhttp.responseText.split("-RIZ-");
			//sDirection
			var text='Wrong City.';
			var alText='Wrong City.';
//			alert(data.length);
			if(data[1]!=''){
				text=text+'Look at following Suggestions<br>';
				alText=alText+'Look at following Suggestions\n';
			}
			 for(var i=1;i<data.length-1;i++) {
				text =text+data[i]+"<br>";
				alText=alText+data[i]+"\n";
			 }
			 alert(alText);
			 document.getElementById('sDirection').innerHTML=text;
			 return false;

		}
//		alert(xmlhttp.responseText);
//		window.focus();
		} 
		}//xmlhttp.onreadystatechange = function() { 
		xmlhttp.send(null);
	}
	function DirectionsGetOlder(url) {
						/*************************************************************************/
							var xmlhttp=false;
							try { 
								xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); //here simply we are creating object
							} catch (e) { 
										try { 
											xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); //here simply we are creating object
										} catch (E) { 
											xmlhttp = false; 
										}//try {  
							}//	try { 
						
							if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
								xmlhttp = new XMLHttpRequest();//here simply we are creating object
							}
						/*************************************************************************/
	

		xmlhttp.open("POST", url,true); 
	
		xmlhttp.onreadystatechange = function() { 
		if (xmlhttp.readyState == 4 && xmlhttp.status == 200) { 		
		var finalprice=trimmer(xmlhttp.responseText);
	
	document.getElementById('sDirection').innerHTML='<select name="area"  ></select>';
	//alert(finalprice);
		if(finalprice==''){
				var option1 = document.createElement("OPTION") 
				document.frmregister.area.options.add(option1) 
				option1.value="";
				option1.innerHTML="No Area Exist";
		}else{

			var data=xmlhttp.responseText.split("-RIZ-");
			 for(var i=0;i<data.length-1;i++) {
				option1 = document.createElement("OPTION") 
				document.frmregister.area.options.add(option1) 
				option1.value=data[i];
				option1.innerHTML=data[i];
			 }

		}
//		alert(xmlhttp.responseText);
//		window.focus();
		} 
		}//xmlhttp.onreadystatechange = function() { 
		xmlhttp.send(null);
	}
