﻿// JScript File

  var xmlHttp1=null;
        var mainstr;
        var DropDown ;
        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;
        }
	    
        function showregstate(str,List){     
            debugger 
            DropDown=List;            
            /*Make asyncrhonouz request to searchajax.aspx*/
            var url="Email.aspx";
            url=url+"?mode=22&CatId="+str.value;            
            xmlHttp=GetXmlHttpObject()
            if (xmlHttp==null){
    			alert ("Your browser does not support AJAX!");
	    		return;
		    }
		    xmlHttp.onreadystatechange=stateChanged;
		    xmlHttp.open("GET",url,true);
    		xmlHttp.send(null);
    		
    		var optionText = "Choose City/Town"
            var objSelect = document.getElementById("ddregcity");
            objSelect.length=0;
            objSelect[0] = new Option(optionText,"0");
	    }

	    function showregcity(str,List){      
            
            DropDown=List;            
            /*Make asyncrhonouz request to searchajax.aspx*/
            var url="Email.aspx";
            url=url+"?mode=23&CatId="+str.value;            
            xmlHttp=GetXmlHttpObject()
            if (xmlHttp==null){
    			alert ("Your browser does not support AJAX!");
	    		return;
		    }
		    xmlHttp.onreadystatechange=cityChanged;
		    xmlHttp.open("GET",url,true);
    		xmlHttp.send(null);
	    }
	    
	    function stateChanged(){ 
	        var str;
	         if (xmlHttp.readyState==3)
	         {
	           document.getElementById("ddregstate").disabled=true;
	           var optionText = "Loading..."
               var objSelect = document.getElementById("ddregstate");
               objSelect.length=0;
               objSelect[0] = new Option(optionText);
	
	         }
	    	    if (xmlHttp.readyState==4){ 
		        document.getElementById("ddregstate").disabled=false;
			    mainstr=xmlHttp.responseText;
                FillDropDownList(document.getElementById("ddregstate"));
     		    }
        }	

	    function cityChanged(){ 
	        var str;
	         if (xmlHttp.readyState==3)
	         {
	           document.getElementById("ddregcity").disabled=true;
	              document.getElementById("ddlcity").disabled=true;
	           var optionText = "Loading..."
               var objSelect = document.getElementById("ddregcity");
                    var objSelect = document.getElementById("ddlcity");
               objSelect.length=0;
               objSelect[0] = new Option(optionText);
                objSelect1.length=0;
               objSelect1[0] = new Option(optionText);
	          }
		    if (xmlHttp.readyState==4){ 
		        document.getElementById("ddregcity").disabled=false;
		          document.getElementById("ddlcity").disabled=false;
			    mainstr=xmlHttp.responseText;
                FillDropDownList(document.getElementById("ddregcity"));
                    FillDropDownList(document.getElementById("ddlcity"));
               
		    }
             	
        }	
	 
	     function FillDropDownList(dd1){
            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]);
				var selLength = dd1.length;
				dd1.options[selLength] = newOpt;
			}
        } 
        
      
