/*

Shows weather forecast in element.
Requires gwproxy.php to be present on webserver
container is a jQuery element or selector
locale and location are strings.
location could be whatever google accepts like 
'New York' or ',,,22500000,31000000' to get weather for lat=22.5 and long=31

*/

function showWeather(container,location,locale,url){

	$(container).text('Veuillez patienter...');

	$.get(url+'/wp-content/themes/dailygolf/js/weather/gwproxy.php?weather=' + encodeURI(location) + '&hl='+encodeURI(locale), function(xml) {

		function addForecastDiv( condition, temp, icon){
			
			$(container).append("<label>Méteo : </label>");
			var icon_name = icon.split('/');
			icon_name.reverse();
			$res_icon = icon_name[0].split('.');
			$(container).append( "<span class='"+$res_icon[0]+"'>&nbsp;</span>" );
			$(container).append( "<span class='temp'>" + temp + "</span>" );
			
		}

		$(container).text('');
		
		//if( $(xml).find('forecast_information').find('unit_system').attr('data') == 'SI' )$(xml).find('current_conditions').find('temp_f').attr('data') + t_unit_f + ' '+
		t_unit = '&deg;C';
		t_unit_f = '&deg;F';
		
		addForecastDiv(
			$(xml).find('current_conditions').find('condition').attr('data'),
			$(xml).find('current_conditions').find('temp_c').attr('data') + t_unit ,
			$(xml).find('current_conditions').find('icon').attr('data')
		);

		
	},'xml');

}


