
// JScript File
        var xmlHttp1=null;
        var mainstr;
        var DropDown ;
        var cid;
        var locid;
        
        function GetXmlHttpObject()
        {
	        try
	        {
		        // Firefox, Opera 8.0+, Safari
		        xmlHttp=new XMLHttpRequest();
	        }
	        catch (e)
	        {
                // Internet Explorer
                try
                {
                    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
                }
                catch (e)
                {
                    xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
                }
            }
            return xmlHttp;
        }

              
       var VarC , child;
       
         function showcity1(str1,strCity){
         
         VarC=strCity;
         cid = str1;
            document.getElementById("ddlCity").disabled=true;
	           var optionText = "Loading..."
               var objSelect = document.getElementById("ddlCity");
                objSelect.length=0;
                objSelect[0] = new Option(optionText);
         if (strCity == "Edit") 
          {
             //document.getElementById('ddCity').length = 0;
           //  document.getElementById('ddCity').innerHTML='';
           } 
 
            var url="AjaxValidation.aspx";
            url=url+"?mode=63&CatId="+str1.value; 
          
            xmlHttp=GetXmlHttpObject()
            
            if (xmlHttp==null){
    			alert ("Your browser does not support AJAX!");
	    		return;
		    }
		    xmlHttp.onreadystatechange=citychange;
		    xmlHttp.open("GET",url,true);
		    xmlHttp.send(null);
		 }
		 
		 
		 //This function will get the City name 
		 //CatId is the Stateid 
		  function showcity2(str1,strCity,strloc){
            VarC=strCity;
            cid = str1;
            locid =strloc; 
         if (strCity == "Edit") 
          {
             document.getElementById('ddCity').length = 0;
             document.getElementById('ddCity').innerHTML='';
           } 
 
            var url="AjaxValidation.aspx";
            url=url+"?mode=63&CatId="+str1.value; 
            xmlHttp=GetXmlHttpObject()
            
            if (xmlHttp==null){
    			alert ("Your browser does not support AJAX!");
	    		return;
		    }
		    xmlHttp.onreadystatechange=citychange;
		    xmlHttp.open("GET",url,true);
		    xmlHttp.send(null);
		    
    
		  }
	   

	    function citychange(){ 
	        var str;
	        
	        
		    if (xmlHttp.readyState==4){
		   
		   
		        document.getElementById("ddlCity").disabled=false;
			    mainstr=xmlHttp.responseText;
			    
			    FillDropDownList(document.getElementById("ddlCity"));
			  
			 }
          }	
          
          function fillloc(strc)
          {
             ShowLocation(strc,cid,locid);
          }
	    
        function FillDropDownList(dd1){
            if (dd1 != null){
                var str=mainstr.replace("@","").split("|");
			    dd1.options.length=0;	
		 	    for(inc2=0;inc2<str.length-1;inc2++){	
				    var str3=str[inc2].split("#");	
				    var newOpt = new Option(str3[1],str3[0]);
			        if (str3[0] == -2)
			        {
				        var bc = document.createElement("optgroup");
				        bc.label = "---City---";
                        dd1.appendChild(bc);
    			    }
    			    else if (str3[0] == -1)
    			    {
				        var bc = document.createElement("optgroup");
				        bc.label = "---Metro---";
                        dd1.appendChild(bc);
    			    }
				    else{
				    
			            var selLength = dd1.length;
			            dd1.options[selLength] = newOpt;
				    }
			    }
			}
        } 
        
        function FillDropDownListLocation(dd2){
      
            var str=mainstr.replace("@","").split("|");
            dd2.options.length=0;	
			for(inc2=0;inc2<str.length-1;inc2++)
			{	
			   	var str3=str[inc2].split("#");	
				var newOpt2 = new Option(str3[1],str3[0]);
				var selLength = dd2.length;
				dd2.options[selLength] = newOpt2;
			}
		}
        
        var strLocation;
        var strCity;
         function ShowLocation(str2,strLoc,VarLocation){
         
               strCity=strLoc;
               strLocation=VarLocation;  
           
                /*Make asyncrhonouz request to AjaxValidation.aspx*/
                var url="AjaxValidation.aspx";
                url=url+"?mode=24&city="+str2.value; 
                                
                xmlHttp=GetXmlHttpObject()
                if (xmlHttp==null){
			        alert ("Your browser does not support AJAX!");
    		        return;
	            }
	            xmlHttp.onreadystatechange=CompanyChanged2;
	            xmlHttp.open("GET",url,true);
		        xmlHttp.send(null);
            }
            
        
           function CompanyChanged2(){ 
	        var str;
	         if (xmlHttp.readyState==3)
	         {	        
	           var optionText = "Loading..."
               var objSelect = document.getElementById("ddllocation");
               objSelect.length=0;
               objSelect[0] = new Option(optionText);
	        
	         }
		    if (xmlHttp.readyState==4){ 
		        document.getElementById("ddllocation").disabled=false;
			    mainstr=xmlHttp.responseText;
			    FillDropDownListLocation(document.getElementById("ddllocation"));
                //document.getElementById("ddllocation").disabled=false;
                
                document.getElementById("ddllocation").value= strLocation;              
		    }           
        }	
      
