//<![CDATA[

	function loadWeather() {
		if (document.getElementById) {
			if (document.getElementById('meteo_city')) {
				var oMeteo = document.getElementById('meteo_city');
				oMeteo.onchange = function() {
					document.getElementById('meteo').innerHTML = '<div id="loading"><img src="/images/loading.gif" alt="Chargement des données" /><br/>Chargement des données</div>';
					changeWeather(document.getElementById('meteo_city').value) ;
				}
			}
		}
	}

	function changeWeather(pid) {
		var XHR = new XHRConnection();
		XHR.setRefreshArea('meteo');
		XHR.sendAndLoad("/media/script/weather.php?id="+pid, "GET");
	}

	function loadCurrency() {
		if (document.getElementById) {
			if (document.getElementById('toconvert')) {
				var oObject = document.getElementById('toconvert') ;

				oObject.onkeyup = function() {
					var iValue = document.getElementById('toconvert').value;
					var sFrom = document.getElementById('currency_from').options[document.getElementById('currency_from').selectedIndex].value;
					var sTo = document.getElementById('currency_to').options[document.getElementById('currency_to').selectedIndex].value;
					changeCurrency(iValue, sFrom, sTo) ;
				}
			}

			if (document.getElementById('currency_from')) {
				var oObject = document.getElementById('currency_from') ;

				oObject.onchange = function() {
					var iValue = document.getElementById('toconvert').value;
					var sFrom = document.getElementById('currency_from').options[document.getElementById('currency_from').selectedIndex].value;
					var sTo = document.getElementById('currency_to').options[document.getElementById('currency_to').selectedIndex].value;
					changeCurrency(iValue, sFrom, sTo) ;
				}
			}

			if (document.getElementById('currency_to')) {
				var oObject = document.getElementById('currency_to') ;

				oObject.onchange = function() {
					var iValue = document.getElementById('toconvert').value;
					var sFrom = document.getElementById('currency_from').options[document.getElementById('currency_from').selectedIndex].value;
					var sTo = document.getElementById('currency_to').options[document.getElementById('currency_to').selectedIndex].value;
					changeCurrency(iValue, sFrom, sTo) ;
				}
			}
		}
	}

	function changeCurrency(pi_value, ps_from, ps_to) {
		var XHR = new XHRConnection();
		XHR.setRefreshArea('currency_result');
		XHR.sendAndLoad("/media/script/currency.php?value="+pi_value+"&from="+ps_from+"&to="+ps_to, "GET");

	}

    addLoadEvent(loadWeather) ;
    addLoadEvent(loadCurrency) ;

//]]>