function Order_update_price()
{
    // find the form!
    var form = document.order_form;
    var i;
    
    // total is the total price in pence
    var total = 0;
    
    // if this ends up being true, we'll show the discount message,
    // otherwise hide it.
    var show_discount = false;
    
    // Go through all the input elements for the form, and
    // if they are a 'text' element (i.e. a box), then add
    // the number of items specified in the box to the total.
    // Note that this requires us to get the price for each item
    // (supplied by function price_from_element())
    
    for (i = 0; i < form.elements.length; i++)
    {
        var el = form.elements[i];
        if (el.type == 'text' &&
        	el.id.substring(0,5) == "prod_" &&
            !isNaN(el.value))
        {
            var quantity = Number(el.value);
           
            
            total += price_from_element(el) * quantity;
            
            if (quantity > 3)
                show_discount = true;
        }
    }
    
    // add delivery if checked:
    
    var sp_el = document.getElementById('prod_sp_450');
    
    if (sp_el.checked)
    {
        total += price_from_element(sp_el);
    }

    // convert the pence into pounds and pence for display
    // (% is 'modulo' - it gives the remainder...
    // (e.g. 5%2 = 1... 5/2 goes twice, remainder 1... geddit?)
    
    var pence  = total % 100;
    var pounds = (total - pence) / 100;
    
    if (pence < 10)
        pence = "0" + pence;
    
    var price = pounds + '.' + pence;
    document.getElementById('order_total').innerHTML = price;
    
    // finally, show the discount message if they want more than 3 of something:
    
    var disc_msg_el = document.getElementById('bulk_discount');
    
    if (show_discount)
        disc_msg_el.style.display='block';
    else
        disc_msg_el.style.display='none';
            
}





// Given an element, this function assumes that the id of the
// element ends in _X where X is a number (e.g. _324), and returns
// the number

function price_from_element(el)
{
    var last_uscore = el.id.lastIndexOf('_');
            
    var price = Number(el.id.substr(last_uscore+1));
    
    return price;
}
