 /**
	Uniwits System, 2011
	http://www.uniwits.com
**/ function loadzcinfo(servername,country,zipcode) { if (window.XMLHttpRequest) { xmlhttp=new XMLHttpRequest(); } else { xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } var url=window.location.protocol+'//'+servername+'/?cmd=zipcode2addressparts&country='+country+'&zipcode='+zipcode; xmlhttp.open("GET",url,false); xmlhttp.send(); xml=xmlhttp.responseXML; return xml; } function update_address_parts(servername,country_id,zipcode_id,state_id,city_id,district_id,address_id) { var zcobj=document.getElementById(zipcode_id); var countryobj=document.getElementById(country_id); var zipcode=zcobj.value; zipcode=zipcode.replace(/[^0-9]/g,''); if (zipcode) { var mb_state=document.getElementById(state_id); var mb_city=document.getElementById(city_id); var mb_district=document.getElementById(district_id); var mb_address=document.getElementById(address_id); var next_input=mb_state; mb_state.readOnly=true; mb_city.readOnly=true; mb_district.readOnly=true; mb_address.readOnly=true; try { zcobj.value=zipcode; var xml=loadzcinfo(servername,countryobj.value,zipcode); var prefectures=xml.getElementsByTagName('zc_prefecture'); if (prefectures.length==0); else if (prefectures.length==1 || prefectures[0].childNodes[0].nodeValue==prefectures[1].childNodes[0].nodeValue) { mb_state.value=prefectures[0].childNodes[0].nodeValue; next_input=mb_city; } var cities=xml.getElementsByTagName('zc_city'); if (cities.length==0); else if (cities.length==1 || cities[0].childNodes[0].nodeValue==cities[1].childNodes[0].nodeValue) { mb_city.value=cities[0].childNodes[0].nodeValue; if (city_id!=district_id) next_input=mb_district; else next_input=mb_address; } var districts=xml.getElementsByTagName('zc_district'); if (districts.length==0); else if (districts.length==1 || districts[0].childNodes[0].nodeValue==districts[1].childNodes[0].nodeValue) { if (city_id!=district_id) mb_district.value=districts[0].childNodes[0].nodeValue; else mb_city.value+=districts[0].childNodes[0].nodeValue; next_input=mb_address; } } catch (e) { } finally {} mb_state.readOnly=false; mb_city.readOnly=false; mb_district.readOnly=false; mb_address.readOnly=false; next_input.focus(); } } 