var url=addContextPath("/data/CountryandStates.xml");function initmethod(B,E,G,D,C,F,A){oform_global=B;countryarg_global=E;statearg_global=G;cityarg_global=D;othercountries_global=C;otherstates_global=F;othercities_global=A}var xmlDoc;function loadXML(B,F,H,D,C,G,A){var E="document."+B+".";hideformelements(E,F,H,D,C,G,A);initmethod(B,F,H,D,C,G,A);if(window.ActiveXObject){xmlDoc=new ActiveXObject("Microsoft.XMLDOM");xmlDoc.async=false;xmlDoc.load(url);getmessage(B,F,H,D,C,G,A)}else{if(document.implementation&&document.implementation.createDocument){xmlDoc=document.implementation.createDocument("","",null);xmlDoc.load(url);xmlDoc.onload=getmessage(B,F,H,D,C,G,A)}else{alert("Your browser cannot handle this script")}}}function LTrim(B){var A=/\s*((\S+\s*)*)/;return B.replace(A,"$1")}function RTrim(B){var A=/((\s*\S+)*)\s*/;return B.replace(A,"$1")}function trim(A){return LTrim(RTrim(A))}function hideformelements(formof,countryarg,statearg,cityarg,othercountries,otherstates,othercities){eval("document.getElementById(othercountries).style.display='none'");eval("document.getElementById(otherstates).style.display='none'");eval("document.getElementById(othercities).style.display='none'")}function showformelements(val){if(val=="othercountry"){eval("document.getElementById(othercountries_global).style.display='block'")}if(val=="otherstate"){eval("document.getElementById(otherstates_global).style.display='block'");eval("document.getElementById(cityarg_global).style.display='none'");eval("document.getElementById(othercities_global).style.display='block'")}if(val=="othercity"){eval("document.getElementById(cityarg_global).style.display='none'");eval("document.getElementById(othercities_global).style.display='block'")}if(val=="notothers"){eval("document.getElementById(cityarg_global).style.display='block'");eval("document.getElementById(othercountries_global).style.display='none'");eval("document.getElementById(otherstates_global).style.display='none'");eval("document.getElementById(othercities_global).style.display='none'")}}function getmessage(oform,countryarg,statearg,cityarg,othercountries,otherstates,othercities){var formof="document."+oform+".";var root=xmlDoc.getElementsByTagName("LocationData")[0];var opt;for(k=0;k<root.childNodes.length;k++){var items=root.childNodes[k];var country=trim(items.childNodes[0].nodeValue);opt=document.createElement("option");opt.text=country;opt.value=country;if(country=="India"){opt.selected="selected"}eval("document.getElementById('"+countryarg+"').add(opt)")}opt=document.createElement("option");opt.text="Others";opt.value="others";eval("document.getElementById('"+countryarg+"').add(opt)");getcountry_states()}function getcountry_states(){var formof="document."+oform_global+".";eval(formof+statearg_global+".options.length=0");opt=document.createElement("option");opt.text="Select States";opt.value="0";eval(formof+statearg_global+".add(opt)");var opt;var country_selected=eval("document.getElementById(countryarg_global).value");if(country_selected=="others"){showformelements("othercountry")}var root=xmlDoc.getElementsByTagName("LocationData")[0];for(k=0;k<root.childNodes.length;k++){var items=root.childNodes[k];var country=trim(items.childNodes[0].nodeValue);if(country==country_selected){var statelen=items.childNodes.length;for(i=1;i<statelen;i++){var state=trim(items.childNodes[i].childNodes[0].nodeValue);opt=document.createElement("option");opt.text=state;opt.value=state;eval(formof+statearg_global+".add(opt)")}}}opt=document.createElement("option");opt.text="Others";opt.value="others";eval(formof+statearg_global+".add(opt)");var state_selected=eval("document.getElementById(statearg_global).value");if(country_selected!="others"){showformelements("notothers")}}function getstates(){var formof="document."+oform_global+".";eval("document.getElementById(countryarg_global).value");var country_selected=eval("document.getElementById(countryarg_global).value");var state_selected=eval("document.getElementById(statearg_global).value");if(state_selected=="others"){showformelements("otherstate")}else{ajaxfun(country_selected,state_selected)}}function ajaxfun(A,B){if(window.XMLHttpRequest){req=new XMLHttpRequest()}else{if(window.ActiveXObject){req=new ActiveXObject("Microsoft.XMLHTTP")}}var C=addContextPath("/data/");req.open("GET",C+A+"/"+B+".xml",true);req.onreadystatechange=callback;req.send(null)}function callback(){if(req.readyState==4){if(req.status==200){getcities()}}}function selectcities(){var city_selected=eval("document.getElementById(cityarg_global).value");if(city_selected=="others"){showformelements("othercity")}}function getcities(){var formof="document."+oform_global+".";var state_selected=eval("document.getElementById(statearg_global).value");if(state_selected=="others"){showformelements("otherstate")}eval(formof+cityarg_global+".options.length=0");opt=document.createElement("option");opt.text="Select Cities";opt.value="0";eval(formof+cityarg_global+".add(opt)");var opt;var root=req.responseXML.getElementsByTagName("cities-list")[0];for(k=0;k<root.childNodes.length;k++){var items=root.childNodes[k];var city=trim(items.childNodes[0].nodeValue);opt=document.createElement("option");opt.text=city;opt.value=city;eval(formof+cityarg_global+".add(opt)")}opt=document.createElement("option");opt.text="Others";opt.value="others";eval(formof+cityarg_global+".add(opt)")};