//Function alerts the index of the selected option within form
function calcPostage(){
alert(document.frmCart.shipping.options[document.frmCart.shipping.options.selectedIndex].value)
document.frmCart.shippingCost = 5
window.location.reload()
}

// This script and many more are available free online at
//The JavaScript Source :: http://javascript.internet.com
//Created by: Kevin Hartig :: http://www.grafikfx.net/ 

// Calculate the total for items in the form which are selected.
function calculateTotal(exchange) {
	var b=document.frmCart.shipping.options[document.frmCart.shipping.options.selectedIndex].value
        var x=document.getElementById(b).value;

document.frmCart.postageTotal.value = formatCurrency(x)
    return(formatCurrency(x))
}
// Format a value as currency.
function formatCurrency(num) {
  num = num.toString().replace(/\$|\,/g,'');
  if(isNaN(num))
     num = "0";
  sign = (num == (num = Math.abs(num)));
  num = Math.floor(num*100+0.50000000001);
  cents = num%100;
  num = Math.floor(num/100).toString();
  if(cents<10)
      cents = "0" + cents;
  for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
      num = num.substring(0,num.length-(4*i+3)) + ',' + num.substring(num.length-(4*i+3));
  return (((sign)?'':'-') + num + '.' + cents);
}



