var bRules = {
	'select.e4xselect' : function(el)
	{
		el.onchange = function()
		{
			set_currency(this.value);
		}
	}
};

Behaviour.register(bRules);

////////////////////////////////////////////////////////////////////////////////////////////////////
//
// Change currency prefs via ajax call for checkout
//
////////////////////////////////////////////////////////////////////////////////////////////////////	

	function set_currency(symbol)
	{
			vars = "&ajax=1&symbol="+symbol;
			new Ajax.Request('/e4x.php', {parameters:vars,
				method:'post',
				onSuccess : handlerFunc,
				onFailure : errFunc});
		return false;
	}
	
	var handlerFunc = function(t)
	{
		
		result = t.responseText
		redirect = $('e4x_redirect');
		if(redirect.value != "") {
			window.location = redirect.value;
		} else {
			$('currency_change').submit();
		}
	}
	
	var errFunc = function(t)
	{
		alert('We have encountered a problem while trying to update your currency options.\n\nPlease try again in a few moments.');
//		alert('Error ' + t.status + ' -- ' + t.statusText);
	}