var rates = new Array();

window.onload = function() {
	if (typeof dlOnly == 'undefined' || !dlOnly) {
		$('CartCountry').observe('change', lookupRates);
		$('CartZip').observe('change', lookupRates);
		$('CartZip').observe('blur', lookupRates);
		
		lookupRates();
	}
}

lookupRates = function(event) {
	$('shipping_rates').innerHTML = "<img src='/en/img/ajax-loader.gif' alt='Shipping rates are loading...' style='margin:1em;' />";
	new Ajax.Updater('shipping_rates', 'http://discark.com/en/cart/shipping_options/' + $('CartCountry').value + '/' + $('CartZip').value);
	new Ajax.Request('http://discark.com/en/cart/shipping_json/' + $('CartCountry').value + '/' + $('CartZip').value, {
		method:'get',
		onSuccess: function(transport){
			rates = eval(transport.responseText);
	   }
	});
}

checkShipping = function() {
	if (!dlOnly) {
		//if (!($('shipping_method_Express_Mail') || $('shipping_method_First-Class_Mail_Parcel')) ||
		//!($('shipping_method_Express_Mail').getValue() || $('shipping_method_First-Class_Mail_Parcel').getValue())) {
		if (jQuery('.shipping-option:checked').length == 0) {
			alert("Please enter your postal code and select a shipping method.");
			return false;
		}
	}
};
