
function resolveZip(inZipField){
	if(xmlHttp){
		if((inZipField.value.length == 6)&&(inZipField.value.charAt(5)=="l")){
				inZipField.value = inZipField.value.substring(0,5);
				var URL = "http://api.local.yahoo.com/MapsService/V1/geocode?appid=clafarge&zip=" + inZipField.value;
				xmlHttp.open("GET", URL, true);
				xmlHttp.onreadystatechange = updateZip;
				xmlHttp.send(null);}}}

function updateZip(){
	if(xmlHttp.readyState==4){
		if(xmlHttp.status==200){
			var theResponse = xmlHttp.responseXML.documentElement;
			if((theResponse.getElementsByTagName('City')[0])&&(theResponse.getElementsByTagName('State')[0])){
				document.newuser.city.value = theResponse.getElementsByTagName('City')[0].firstChild.data.toLowerCase().toTitleCase();
				document.newuser.state.value = theResponse.getElementsByTagName('State')[0].firstChild.data.toUpperCase();}
		}else{
			alert("Error connecting to resource");}}}

String.prototype.toTitleCase = function(){
	return this.replace(/\b([a-z])/g,function($0){return $0.toUpperCase()});}

