// JavaScript Document
	 var ServxmlHttp; 
	 var Servreq; 
	 var ServxmlHttp2; 
	 var Servreq2; 
	 var ServxmlHttp3; 
	 var Servreq3; 
	 var ServxmlHttp4; 
	 var Servreq4; 
    var ServrequestURL = getURI()+'/getstates.aspx?c='; 
    var ServrequestURL2 = getURI()+'/getcities.aspx?s='; 
    var ServrequestURL3 = getURI()+'/getregions.aspx?s='; 
    var ServrequestURL4 = 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 NewServCountry(intCountry) {
		 if (intCountry > -1) {
			NewServState(0);
			document.getElementById('divServState').innerHTML = '<select name="drpServState" id="drpServState" style="width:200px;" OnChange="NewServState(this.options[this.selectedIndex].value);"><option value="0">Loading...</option></select>'; 
			 var url = ServrequestURL+intCountry;
			 ServGetXmlHttpObject(ServstateChangeHandler,url);
		 }
	 }
	 
	 
	 function NewServState(intState) {
		 if (intState > -1) {
			document.getElementById('divServCity').innerHTML = '<select name="drpServCity" id="drpServCity" style="width:200px;"><option value="0">Loading...</option></select>'; 
			document.getElementById('divServRegion').innerHTML = '<select name="drpServRegion" id="drpServRegion" style="width:200px;" OnChange="NewServRegion(this.options[this.selectedIndex].value);"><option value="0">Loading...</option></select>'; 
			 var url = ServrequestURL2+intState;
			 ServGetXmlHttpObject2(ServstateChangeHandler2,url);
			 url = ServrequestURL3+intState;
			 ServGetXmlHttpObject3(ServstateChangeHandler3,url);
		 }
	 }

	 function NewServRegion(intRegion) {
		 if (intRegion > -1) {
			document.getElementById('divServCity').innerHTML = '<select name="drpServCity" id="drpServCity" style="width:200px;"><option value="0">Loading...</option></select>'; 
			 var url = ServrequestURL4+intRegion;
			 ServGetXmlHttpObject4(ServstateChangeHandler4,url);
		 }
	 }

    //stateChangeHandler will fire when the state has changed, i.e. data is received back 
    // This is non-blocking (asynchronous) 
    function ServstateChangeHandler() 
    { 
        //readyState of 4 or 'complete' represents that data has been returned 
        if (ServxmlHttp.readyState == 4 || ServxmlHttp.readyState == 'complete'){ 
            //Gather the results from the callback 
            var str = ServxmlHttp.responseText; 

            //Populate the innerHTML of the drp with the results
				document.getElementById('divServState').innerHTML = '<select name="drpServState" id="drpServState" style="width:200px;" OnChange="NewServState(this.options[this.selectedIndex].value);">'+str+'</select>'; 
				document.getElementById('drpServState').focus();
		} 
    } 

    function ServstateChangeHandler2() 
    { 
        //readyState of 4 or 'complete' represents that data has been returned 
        if (ServxmlHttp2.readyState == 4 || ServxmlHttp2.readyState == 'complete'){ 
            //Gather the results from the callback 
            var str = ServxmlHttp2.responseText; 

            //Populate the innerHTML of the drp with the results
				document.getElementById('divServCity').innerHTML = '<select name="drpServCity" id="drpServCity" style="width:200px;">'+str+'</select>'; 
		} 
    } 

    function ServstateChangeHandler3() 
    { 
        //readyState of 4 or 'complete' represents that data has been returned 
        if (ServxmlHttp3.readyState == 4 || ServxmlHttp3.readyState == 'complete'){ 
            //Gather the results from the callback 
            var str = ServxmlHttp3.responseText; 

            //Populate the innerHTML of the drp with the results
				document.getElementById('divServRegion').innerHTML = '<select name="drpServRegion" id="drpServRegion" style="width:200px;" OnChange="NewServRegion(this.options[this.selectedIndex].value);">'+str+'</select>'; 
				document.getElementById('drpServRegion').focus();
		} 
    } 

    function ServstateChangeHandler4() 
    { 
        //readyState of 4 or 'complete' represents that data has been returned 
        if (ServxmlHttp4.readyState == 4 || ServxmlHttp4.readyState == 'complete'){ 
            //Gather the results from the callback 
            var str = ServxmlHttp4.responseText; 

            //Populate the innerHTML of the drp with the results
				document.getElementById('divServCity').innerHTML = '<select name="drpServCity" id="drpServCity" style="width:200px;">'+str+'</select>'; 
				document.getElementById('drpServCity').focus();
		} 
    } 

    function ServGetXmlHttpObject(handler,url) { 
		ServxmlHttp=false;
		/*@cc_on @*/
		/*@if (@_jscript_version >= 5)

		 try {
		  ServxmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
		 } catch (e) {
		  try {
			ServxmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
		  } catch (E) {
			ServxmlHttp = false;
		  }
		 }
		@end @*/
		if (!ServxmlHttp && typeof XMLHttpRequest!='undefined') {
			try {
				ServxmlHttp = new XMLHttpRequest();
			} catch (e) {
				ServxmlHttp=false;
			}
		}
		if (!ServxmlHttp && window.createRequest) {
			try {
				ServxmlHttp = window.createRequest();
			} catch (e) {
				ServxmlHttp=false;
			}
		}
		if(ServxmlHttp) {
			ServsndReq(handler,url);
		}
        
    } 
	 
    function ServGetXmlHttpObject2(handler,url) { 
		ServxmlHttp2=false;
		/*@cc_on @*/
		/*@if (@_jscript_version >= 5)

		 try {
		  ServxmlHttp2 = new ActiveXObject("Msxml2.XMLHTTP");
		 } catch (e) {
		  try {
			ServxmlHttp2 = new ActiveXObject("Microsoft.XMLHTTP");
		  } catch (E) {
			ServxmlHttp2 = false;
		  }
		 }
		@end @*/
		if (!ServxmlHttp2 && typeof XMLHttpRequest!='undefined') {
			try {
				ServxmlHttp2 = new XMLHttpRequest();
			} catch (e) {
				ServxmlHttp2=false;
			}
		}
		if (!ServxmlHttp2 && window.createRequest) {
			try {
				ServxmlHttp2 = window.createRequest();
			} catch (e) {
				ServxmlHttp2=false;
			}
		}
		if(ServxmlHttp2) {
			ServsndReq2(handler,url);
		}
        
    } 
	 
    function ServGetXmlHttpObject3(handler,url) { 
		ServxmlHttp3=false;
		/*@cc_on @*/
		/*@if (@_jscript_version >= 5)

		 try {
		  ServxmlHttp3 = new ActiveXObject("Msxml2.XMLHTTP");
		 } catch (e) {
		  try {
			ServxmlHttp3 = new ActiveXObject("Microsoft.XMLHTTP");
		  } catch (E) {
			ServxmlHttp3 = false;
		  }
		 }
		@end @*/
		if (!ServxmlHttp3 && typeof XMLHttpRequest!='undefined') {
			try {
				ServxmlHttp3 = new XMLHttpRequest();
			} catch (e) {
				ServxmlHttp3=false;
			}
		}
		if (!ServxmlHttp3 && window.createRequest) {
			try {
				ServxmlHttp3 = window.createRequest();
			} catch (e) {
				ServxmlHttp3=false;
			}
		}
		if(ServxmlHttp3) {
			ServsndReq3(handler,url);
		}
        
    } 
	 
    function ServGetXmlHttpObject4(handler,url) { 
		ServxmlHttp4=false;
		/*@cc_on @*/
		/*@if (@_jscript_version >= 5)

		 try {
		  ServxmlHttp4 = new ActiveXObject("Msxml2.XMLHTTP");
		 } catch (e) {
		  try {
			ServxmlHttp4 = new ActiveXObject("Microsoft.XMLHTTP");
		  } catch (E) {
			ServxmlHttp4 = false;
		  }
		 }
		@end @*/
		if (!ServxmlHttp4 && typeof XMLHttpRequest!='undefined') {
			try {
				ServxmlHttp4 = new XMLHttpRequest();
			} catch (e) {
				ServxmlHttp4=false;
			}
		}
		if (!ServxmlHttp4 && window.createRequest) {
			try {
				ServxmlHttp4 = window.createRequest();
			} catch (e) {
				ServxmlHttp4=false;
			}
		}
		if(ServxmlHttp4) {
			ServsndReq4(handler,url);
		}
        
    } 
	 
	function ServsndReq(handleResponse,url) {
		 var randNum = Math.round(100000*Math.random());
		 ServxmlHttp.open("GET", url, true);
		 /* Prevent Memory Leak on IE */
		 ServxmlHttp.onreadystatechange = function() {};
		 ServxmlHttp.onreadystatechange = handleResponse;
		 ServxmlHttp.send(null);
	}
	function ServsndReq2(handleResponse,url) {
		 var randNum = Math.round(100000*Math.random());
		 ServxmlHttp2.open("GET", url, true);
		 /* Prevent Memory Leak on IE */
		 ServxmlHttp2.onreadystatechange = function() {};
		 ServxmlHttp2.onreadystatechange = handleResponse;
		 ServxmlHttp2.send(null);
	}
	function ServsndReq3(handleResponse,url) {
		 var randNum = Math.round(100000*Math.random());
		 ServxmlHttp3.open("GET", url, true);
		 /* Prevent Memory Leak on IE */
		 ServxmlHttp3.onreadystatechange = function() {};
		 ServxmlHttp3.onreadystatechange = handleResponse;
		 ServxmlHttp3.send(null);
	}
	function ServsndReq4(handleResponse,url) {
		 var randNum = Math.round(100000*Math.random());
		 ServxmlHttp4.open("GET", url, true);
		 /* Prevent Memory Leak on IE */
		 ServxmlHttp4.onreadystatechange = function() {};
		 ServxmlHttp4.onreadystatechange = handleResponse;
		 ServxmlHttp4.send(null);
	}
