﻿// JScript File

function CreateXmlHttp()
{
	try
	{
		XmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
	}
	catch(e)
	{
		try
		{
			XmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
		}
		catch(oc)
		{
			XmlHttp = null;				
		}
	}
	if(!XmlHttp && typeof XMLHttpRequest != "undefined")
	{
		XmlHttp = new XMLHttpRequest();
	}
}



	//For Getting Symbol Drop Down Contains
	
	 function Get_City()
     {
		
	     var State = document.getElementById('ddstate').value;
	    var City = document.getElementById('ddlCity');
	    var str2 = State.replace ("&", "and");
         var AreaS = document.getElementById('ddlArea');
	    
	    CreateXmlHttp();
	                     City.options.length = 0 ; 
	                     City.options[City.options.length] = new Option("Loading...."," "); 
	                     AreaS.options.length = 0 ; 
	                     AreaS.options[AreaS.options.length] = new Option("Select Area",""); 
	//	document.body.style.cursor = "progress";
		var requestUrl = "GetCity.aspx?timeStamp="+ new Date().getTime() +"&State="+str2;
			//alert(requestUrl);
		if(XmlHttp)	{
	
					XmlHttp.onreadystatechange = function(){getStateResp(City)};
					XmlHttp.open("GET", requestUrl,  true);
					XmlHttp.send(null);
				}
		
 }
 
 //Called when response comes back from server Only For Symbol
function getStateResp(ig_)
{

	// To make sure receiving response data from server is completed
	if(XmlHttp.readyState == 4)
	{
		
		// To make sure valid response is received from the server, 200 means response received is OK
		if(XmlHttp.status == 200)
		{		
			
			var strData = XmlHttp.responseText
	
			if(strData != "") 
			{	
			    
				var arrSchm = strData.split("|");
				ig_.length = 0; 	
				
				for(i=0; i<arrSchm.length-1; i++) 
				{	
								
					var strSchm = arrSchm[i];
					var arrSchmCode = strSchm.split("~");
					
					ig_.options[i] = new Option();
					
					ig_.options[i].value = arrSchmCode[0];
					ig_.options[i].text = arrSchmCode[1];
				}
				
			}
			else {
					ig_.length = 0;
					ig_.options[0] = new Option(); 
					ig_.options[0].value = "";
					ig_.options[0].text = "Select City";	
					
					
				
					 document.body.style.cursor = "auto";
					
					
					
			    }
			document.body.style.cursor = "auto";	
		}
		else {
					ig_.length = 0;
					ig_.options[0] = new Option(); 
					ig_.options[0].value = "";
					ig_.options[0].text = "server is not ready";
					document.body.style.cursor = "auto";		
		    }
	}   
	
	
	
}

 function Get_Area()
     {
		
	     var AreaS = document.getElementById('ddlArea');
	    var City = document.getElementById('ddlCity').value;
	    CreateXmlHttp();
        AreaS.options.length = 0 ; 
	                     AreaS.options[AreaS.options.length] = new Option("Loading...."," "); 
		var requestUrl = "GetArea.aspx?timeStamp="+ new Date().getTime() +"&City="+City;
		
		if(XmlHttp)	{
	
					XmlHttp.onreadystatechange = function(){getCityResp(AreaS)};
					XmlHttp.open("GET", requestUrl,  true);
					XmlHttp.send(null);
				}
		
 }
 
 //Called when response comes back from server Only For Symbol
function getCityResp(ig_)
{
    
	// To make sure receiving response data from server is completed
	if(XmlHttp.readyState == 4)
	{
		
		// To make sure valid response is received from the server, 200 means response received is OK
		if(XmlHttp.status == 200)
		{		
			
			var strData = XmlHttp.responseText
			
			if(strData != "") 
			{	
			    
				var arrSchm = strData.split("|");
				ig_.length = 0; 	
				
				for(i=0; i<arrSchm.length-1; i++) 
				{	
								
					var strSchm = arrSchm[i];
					var arrSchmCode = strSchm.split("~");
					
					ig_.options[i] = new Option();
					
					ig_.options[i].value = arrSchmCode[0];
					ig_.options[i].text = arrSchmCode[1];
				}
				
			}
			else {
					ig_.length = 0;
					ig_.options[0] = new Option(); 
					ig_.options[0].value = "";
					ig_.options[0].text = "Select City";	
					
					
				
					 document.body.style.cursor = "auto";
					
					
					
			    }
			document.body.style.cursor = "auto";	
		}
		else {
					ig_.length = 0;
					ig_.options[0] = new Option(); 
					ig_.options[0].value = "";
					ig_.options[0].text = "server is not ready";
					document.body.style.cursor = "auto";		
		    }
	}   
	
	
	
}



	 function AjaxData(State,City,Area)
 {
        if(State.value=="")
        {
            alert("Please Select State");
            State.focus();
            return false;
        }
       
        if(City.value=="" || City.value=="Select City" )
        {
            alert("Please Select City");
            City.focus();
            return false;
        }
    
          if(Area.value=="" || Area.value=="Select Area" )
        {
            alert("Please Select Area");
            Area.focus();
            return false;
        }
		
	   //    
	    CreateXmlHttp();
	    var str2 = State.value.replace ("&", "and");

		var requestUrl = "AjaxStaticData.aspx?timeStamp="+ new Date().getTime() +"&State="+str2+"&City="+City.value+"&Area="+Area.value;
		//alert(requestUrl);
		if(XmlHttp)	{
		//alert(requestUrl)
					XmlHttp.onreadystatechange = function(){getdataResp()};
					XmlHttp.open("GET", requestUrl,  true);
					XmlHttp.send(null);
				}
		
 }
 
 
 //Called when response comes back from server Only For Symbol
function getdataResp()
{
if(XmlHttp.readyState == 4)
	{
		//alert(XmlHttp.status)
		// To make sure valid response is received from the server, 200 means response received is OK
		if(XmlHttp.status == 200)
		{		
			
			var strData = XmlHttp.responseText
	//alert(strData);
			if(strData != "") 
			{	
			
			    document.getElementById('TdSaticData').innerHTML=strData;
			
				
			}
			
			document.body.style.cursor = "auto";	
		    }
		else {
				
					document.getElementById('TdSaticData').innerHTML = "server is not ready";
					document.body.style.cursor = "auto";		
		    }
	}   
	
	}

