function posting(posted, destination)
{
  var totalPostage = document.getElementById("total");
  var item1 = "Your total shipping costs are calculated as £";
  var item2 = "<br><b>Now</b> <a href=\"http://ww7.aitsafe.com/cf/add.cfm?userid=90135249&product=shipping&price=";
  var item3 = "&return=www.thehamblintrust.org.uk%2Fshipping.htm\"> Please click here to add shipping costs to final order</a>";
  posted=posted.toFixed(2);  /* gives two dec places as in currency */
  
  totalPostage.innerHTML = item1 + posted + destination + item2 + posted + item3;
}
/*cost = value entered as total cost of order and costed = cost converted to number */
/*post = calculated postage due */


function uk()
{
 
  var costed = parseFloat(document.postman.costs.value); /* converts value to a floating point number */
  var post = 0;
  var dest = " to within the UK";
  
  if(costed)
  {
    if (costed<=15)
    {   
      post = 2.70;
    }
    else 
    {
      post = costed * 0.2;
      post = Math.round(post*100)/100;	/*required incase older browser don't recognise number.toFixed() */
    }
    
    posting(post, dest);
    
  }
  else
  {
    alert ("The value you entered was not a number - did you include a £ or $ sign by accident?");
  }
}


function europe()
{
  var cost = document.postman.costs.value;
  var costed = parseFloat(cost);
  var post = 0;
  var dest = " to within Europe";
  
  if (costed)
  {
    if (costed<=15)
    {
      post = 3.70;
    }
    else
    {
      post = costed * 0.25;
      post = Math.round(post*100)/100;
    }
    posting(post, dest);
    
  }
  else
  {
    alert("The value you entered was not a number - did you include a £ or $ sign by accident?");
  }
}
    

function rest()
{
  var cost = document.postman.costs.value;
  var costed = parseFloat(cost);
  var post = 0;
  var dest = " to the Rest of the World";
  
  if (costed)
  {
    if (costed<=15)
    {
      post = 4.80;
    }
    else
    {
      post = costed * 0.35;
      post = Math.round(post*100)/100;
    }
    posting(post, dest);

  }
  else
  {
    alert("The value you entered was not a number - did you include a £ or $ sign by accident?");
  }
}

