// JavaScript Document
	 var xmlHttp; 
	 var req; 
	 var xmlHttp2; 
	 var req2; 
	 var xmlHttp3; 
	 var req3; 
	 var xmlHttp4; 
	 var req4; 
    var requestURL = getURI()+'/getstates.aspx?c='; 
    var requestURL2 = getURI()+'/getcities.aspx?s='; 
    var requestURL3 = getURI()+'/getregions.aspx?s='; 
    var requestURL4 = getURI()+'/getcities.aspx?r='; 
	 
	 function getURI() {
		var URLTemp = window.location.href
		var regexS = "(http://.*)/.*";
		var regex = new RegExp( regexS );
		var results = regex.exec( URLTemp );
		if( results == null ) {
			regex5 = "(https://.*)/.*";
			results = regex.exec(URLTemp);
			if (results == null)
				return "";
			else
				return results[1];
		} else
			return results[1];
	 }

function NewCountry(intCountry) {
		 if (intCountry > -1) {
			NewState(0);
			document.getElementById('divState').innerHTML = '<select name="drpState" id="drpState" OnChange="NewState(this.options[this.selectedIndex].value);" style="width:200px;"><option value="0">Loading...</option></select>'; 
			 var url = requestURL+intCountry;
			 GetXmlHttpObject(stateChangeHandler,url);
		 }
	 }
	 
	 
	 function NewState(intState) {
		 if (intState > -1) {
			document.getElementById('divCity').innerHTML = '<select name="drpCity" id="drpCity" style="width:200px;"><option value="0">Loading...</option></select>'; 
			document.getElementById('divRegion').innerHTML = '<select name="drpRegion" id="drpRegion" OnChange="NewRegion(this.options[this.selectedIndex].value);" style="width:200px;"><option value="0">Loading...</option></select>'; 
			 var url = requestURL2+intState;
			 GetXmlHttpObject2(stateChangeHandler2,url);
			 url = requestURL3+intState;
			 GetXmlHttpObject3(stateChangeHandler3,url);
		 }
	 }

	 function NewRegion(intRegion) {
		 if (intRegion > -1) {
			document.getElementById('divCity').innerHTML = '<select name="drpCity" id="drpCity" style="width:200px;"><option value="0">Loading...</option></select>'; 
			 var url = requestURL4+intRegion;
			 GetXmlHttpObject4(stateChangeHandler4,url);
		 }
	 }

    //stateChangeHandler will fire when the state has changed, i.e. data is received back 
    // This is non-blocking (asynchronous) 
    function stateChangeHandler() 
    { 
        //readyState of 4 or 'complete' represents that data has been returned 
        if (xmlHttp.readyState == 4 || xmlHttp.readyState == 'complete'){ 
            //Gather the results from the callback 
            var str = xmlHttp.responseText; 

            //Populate the innerHTML of the drp with the results
				document.getElementById('divState').innerHTML = '<select name="drpState" id="drpState" OnChange="NewState(this.options[this.selectedIndex].value);" style="width:200px;">'+str+'</select>'; 
				document.getElementById('drpState').focus();
		} 
    } 

    function stateChangeHandler2() 
    { 
        //readyState of 4 or 'complete' represents that data has been returned 
        if (xmlHttp2.readyState == 4 || xmlHttp2.readyState == 'complete'){ 
            //Gather the results from the callback 
            var str = xmlHttp2.responseText; 

            //Populate the innerHTML of the drp with the results
				document.getElementById('divCity').innerHTML = '<select name="drpCity" id="drpCity" style="width:200px;">'+str+'</select>'; 
		} 
    } 

    function stateChangeHandler3() 
    { 
        //readyState of 4 or 'complete' represents that data has been returned 
        if (xmlHttp3.readyState == 4 || xmlHttp3.readyState == 'complete'){ 
            //Gather the results from the callback 
            var str = xmlHttp3.responseText; 

            //Populate the innerHTML of the drp with the results
				document.getElementById('divRegion').innerHTML = '<select name="drpRegion" id="drpRegion" OnChange="NewRegion(this.options[this.selectedIndex].value);" style="width:200px;">'+str+'</select>'; 
				document.getElementById('drpRegion').focus();
		} 
    } 

    function stateChangeHandler4() 
    { 
        //readyState of 4 or 'complete' represents that data has been returned 
        if (xmlHttp4.readyState == 4 || xmlHttp4.readyState == 'complete'){ 
            //Gather the results from the callback 
            var str = xmlHttp4.responseText; 

            //Populate the innerHTML of the drp with the results
				document.getElementById('divCity').innerHTML = '<select name="drpCity" id="drpCity" style="width:200px;">'+str+'</select>'; 
				document.getElementById('drpCity').focus();
		} 
    } 

    function GetXmlHttpObject(handler,url) { 
		xmlHttp=false;
		/*@cc_on @*/
		/*@if (@_jscript_version >= 5)

		 try {
		  xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
		 } catch (e) {
		  try {
			xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
		  } catch (E) {
			xmlHttp = false;
		  }
		 }
		@end @*/
		if (!xmlHttp && typeof XMLHttpRequest!='undefined') {
			try {
				xmlHttp = new XMLHttpRequest();
			} catch (e) {
				xmlHttp=false;
			}
		}
		if (!xmlHttp && window.createRequest) {
			try {
				xmlHttp = window.createRequest();
			} catch (e) {
				xmlHttp=false;
			}
		}
		if(xmlHttp) {
			sndReq(handler,url);
		}
        
    } 
	 
    function GetXmlHttpObject2(handler,url) { 
		xmlHttp2=false;
		/*@cc_on @*/
		/*@if (@_jscript_version >= 5)

		 try {
		  xmlHttp2 = new ActiveXObject("Msxml2.XMLHTTP");
		 } catch (e) {
		  try {
			xmlHttp2 = new ActiveXObject("Microsoft.XMLHTTP");
		  } catch (E) {
			xmlHttp2 = false;
		  }
		 }
		@end @*/
		if (!xmlHttp2 && typeof XMLHttpRequest!='undefined') {
			try {
				xmlHttp2 = new XMLHttpRequest();
			} catch (e) {
				xmlHttp2=false;
			}
		}
		if (!xmlHttp2 && window.createRequest) {
			try {
				xmlHttp2 = window.createRequest();
			} catch (e) {
				xmlHttp2=false;
			}
		}
		if(xmlHttp2) {
			sndReq2(handler,url);
		}
        
    } 
	 
    function GetXmlHttpObject3(handler,url) { 
		xmlHttp3=false;
		/*@cc_on @*/
		/*@if (@_jscript_version >= 5)

		 try {
		  xmlHttp3 = new ActiveXObject("Msxml2.XMLHTTP");
		 } catch (e) {
		  try {
			xmlHttp3 = new ActiveXObject("Microsoft.XMLHTTP");
		  } catch (E) {
			xmlHttp3 = false;
		  }
		 }
		@end @*/
		if (!xmlHttp3 && typeof XMLHttpRequest!='undefined') {
			try {
				xmlHttp3 = new XMLHttpRequest();
			} catch (e) {
				xmlHttp3=false;
			}
		}
		if (!xmlHttp3 && window.createRequest) {
			try {
				xmlHttp3 = window.createRequest();
			} catch (e) {
				xmlHttp3=false;
			}
		}
		if(xmlHttp3) {
			sndReq3(handler,url);
		}
        
    } 
	 
    function GetXmlHttpObject4(handler,url) { 
		xmlHttp4=false;
		/*@cc_on @*/
		/*@if (@_jscript_version >= 5)

		 try {
		  xmlHttp4 = new ActiveXObject("Msxml2.XMLHTTP");
		 } catch (e) {
		  try {
			xmlHttp4 = new ActiveXObject("Microsoft.XMLHTTP");
		  } catch (E) {
			xmlHttp4 = false;
		  }
		 }
		@end @*/
		if (!xmlHttp4 && typeof XMLHttpRequest!='undefined') {
			try {
				xmlHttp4 = new XMLHttpRequest();
			} catch (e) {
				xmlHttp4=false;
			}
		}
		if (!xmlHttp4 && window.createRequest) {
			try {
				xmlHttp4 = window.createRequest();
			} catch (e) {
				xmlHttp4=false;
			}
		}
		if(xmlHttp4) {
			sndReq4(handler,url);
		}
        
    } 
	 
	function sndReq(handleResponse,url) {
		 var randNum = Math.round(100000*Math.random());
		 xmlHttp.open("GET", url, true);
		 /* Prevent Memory Leak on IE */
		 xmlHttp.onreadystatechange = function() {};
		 xmlHttp.onreadystatechange = handleResponse;
		 xmlHttp.send(null);
	}
	function sndReq2(handleResponse,url) {
		 var randNum = Math.round(100000*Math.random());
		 xmlHttp2.open("GET", url, true);
		 /* Prevent Memory Leak on IE */
		 xmlHttp2.onreadystatechange = function() {};
		 xmlHttp2.onreadystatechange = handleResponse;
		 xmlHttp2.send(null);
	}
	function sndReq3(handleResponse,url) {
		 var randNum = Math.round(100000*Math.random());
		 xmlHttp3.open("GET", url, true);
		 /* Prevent Memory Leak on IE */
		 xmlHttp3.onreadystatechange = function() {};
		 xmlHttp3.onreadystatechange = handleResponse;
		 xmlHttp3.send(null);
	}
	function sndReq4(handleResponse,url) {
		 var randNum = Math.round(100000*Math.random());
		 xmlHttp4.open("GET", url, true);
		 /* Prevent Memory Leak on IE */
		 xmlHttp4.onreadystatechange = function() {};
		 xmlHttp4.onreadystatechange = handleResponse;
		 xmlHttp4.send(null);
	}
