
	function request(url, methodrequest, asyn, params, finish)
	{
			new Ajax.Request(url,
			{
				method: methodrequest,
				asynchronous: asyn,
				parameters: params,
				onComplete: finish,
				onFailure: function() { }
			});
	}
	
    function init() 
	{
		request('http://www.fisgonia.com/weather.php', 'get', true, {country: country, city: city}, showWeather);
		
		if (GBrowserIsCompatible()) 
	  	{
	        var map = new GMap2($("map"));
	        var zonemap = new GMap2($("zonemap"), {mapTypes:[G_NORMAL_MAP, G_PHYSICAL_MAP]});
	        
	        var point = new GLatLng(latitude, longitude);
	        map.setCenter(point, 13);
	        zonemap.setCenter(point, 4);
	        
	        map.addControl(new GSmallMapControl());
			map.addControl(new GMapTypeControl());
			map.enableDoubleClickZoom();
			map.setMapType(G_SATELLITE_MAP);
			
			zonemap.addControl(new GSmallMapControl());
			zonemap.addControl(new GMapTypeControl());
			zonemap.enableDoubleClickZoom();
	        
	        map.addOverlay(new GMarker(point));
	        zonemap.addOverlay(new GMarker(point));
		}
    }
	

	function showWeather(response)
	{
		try {
			var weatherXML = response.responseXML;

			$('weather').update('');
			if (weatherXML.getElementsByTagName('tiempo')[0].firstChild == null)
			{
				$('weather').appendChild(document.createTextNode(message[7]));
			}
			else
			{
				var tm = weatherXML.getElementsByTagName('tm')[0].firstChild.nodeValue;
				var temperatura = weatherXML.getElementsByTagName('temperatura')[0].firstChild.nodeValue;
				var quehace = weatherXML.getElementsByTagName('quehace')[0].firstChild.nodeValue;
				var icono = weatherXML.getElementsByTagName('icono')[0].firstChild.nodeValue;
							
				$('weather').appendChild(document.createTextNode(message[4]+': '+ tm));
				$('weather').appendChild(new Element('br'));
				$('weather').appendChild(document.createTextNode(message[5]+': '+ temperatura+'º C'));
				$('weather').appendChild(new Element('br'));
				$('weather').appendChild(document.createTextNode(message[6]+': '+quehace));
			
				if (!isNaN(icono))
				{
					var img = new Element('img', {src: '/32x32/'+icono+'.png'});
					img.addClassName('icono');
					$('weather').appendChild(img);
				}
			}
		} 
		catch (e)
		{
			//alert(e.name+": "+e.message);
		}
	}

	
Event.observe(window, 'load', init);
Event.observe(window, 'unload', GUnload);