var fnWhenDeliveryDone = function (oXML) {
	var prices = oXML.responseText.split(':');
	var node = document.getElementById('deliveryprice');
	if ( node.hasChildNodes() ) {
    	node.removeChild( node.firstChild );       
	}
	node.appendChild(document.createTextNode(prices[0]));
	
	node = document.getElementById('totalprice')
	if ( node.hasChildNodes() ) {
    	node.removeChild( node.firstChild );       
	}
	node.appendChild(document.createTextNode(prices[1]));
	
	node = document.getElementById('gbpprice')
	if ( node.hasChildNodes() ) {
    	node.removeChild( node.firstChild );       
	}
	node.appendChild(document.createTextNode(prices[2]));
	
	var fade1 = new Fade('totalprice', '#fcff00', '#fff', 20, 50, 0); fade1.init();
	var fade2 = new Fade('deliveryprice', '#fcff00', '#fff', 20, 50, 0); fade2.init();
}

function calculate_delivery(currency, subtotal) {

	if (!myConn) {
		//no XHConn support so just submit the form normally
		obj.submit();
	} else {
	
		//remove existing price
	  	var node = document.getElementById('deliveryprice');
		if ( node.hasChildNodes() ) {
	    	while ( node.childNodes.length >= 1 ) {
	        	node.removeChild( node.firstChild );       
			} 
		}
		
		// add spinner
		var imgWait = document.createElement("img");
		imgWait.src = popBoxWaitImageSmall.src;
		imgWait.id = 'waitprice';
		node.appendChild(imgWait);
	
		var getstr = "currency="+currency+"&subtotal="+subtotal+"&";
		
		var shipping_dest = document.getElementById("shipping_dest_select");
		getstr += "country=" + shipping_dest.options[shipping_dest.selectedIndex].value;
		
		myConn.connect("calculate_delivery.php", "GET", getstr, fnWhenDeliveryDone);
	}
}

var popBoxWaitImageSmall = new Image();
popBoxWaitImageSmall.src = "/images/spinner15.gif";