var defaultLocationId="KAPA";
//var _host="www.reumcomputing.com/tools/" 
var _host="tdf.reumcomputing.com/rci_2009/tools/" 
//city and state of location user searched for
var _cit = "";
var _stat = "";


function sendToServer (location){

	//have to do the time thing to fake ie out so they don't cash things
	time = new Date();
	Spry.Utils.submitForm('form55', updateWeather, {url:'tools/contactFunct.php', additionalData:'locationId=' + location + '&time=' + time});
	document.getElementById('loading').innerHTML = "<img src=\"images/loading.gif\"  />";
}//end of function

function updateWeather(req) {
	// do something with the response from the server
	//alert("got from server");
	var divInfo = "otDiv_";
	
	var doc = req.xhRequest.responseXML;
	if (!doc || !doc.firstChild)
	{
		doc = Spry.Utils.stringToXMLDoc(req.xhRequest.responseText);
		if (!doc || !doc.firstChild)
		{
			alert("Failed to get XML document DOM!");
			return;
		}
	}

	// Convert the XML DOM document to a JS object.
	var xml = Spry.XML.documentToObject(doc);
	
	document.getElementById("city_state").innerHTML = xml.current_observation.location._value();
	document.getElementById("time").innerHTML = xml.current_observation.observation_time._value();
	document.getElementById("lat").innerHTML = "Lat: " + xml.current_observation.latitude._value();
	document.getElementById("lng").innerHTML = "Long: " + xml.current_observation.longitude._value();
	
	if((typeof xml.current_observation.icon_url_base === 'undefined') && (typeof xml.current_observation.icon_url_name === 'undefined')){
		document.getElementById("icon").innerHTML = "";
	}
	else{
		document.getElementById("icon").innerHTML = "<img src=\"" + xml.current_observation.icon_url_base._value() +  xml.current_observation.icon_url_name._value() + "\">";
	}  
	document.getElementById("tmp").innerHTML = xml.current_observation.temperature_string._value();
	document.getElementById("desc").innerHTML = xml.current_observation.weather._value();
	document.getElementById("bar").innerHTML = "Barametric Pressuse: " + xml.current_observation.pressure_in._value();
	document.getElementById("humid").innerHTML = "Relative Humidity: " + xml.current_observation.relative_humidity._value() + "%";
	document.getElementById("wind").innerHTML = "Wind: " + xml.current_observation.wind_string._value();
	
	document.getElementById('loading').innerHTML = "";
}


