function BasketRecalc(frm)
{
    var lngItem = 0;
    var lngItems = ValueGet("items");
    var boolValid = true;
    for(lngItem=1; lngItem<=lngItems; lngItem++)
    {
        if (isNaN(ValueGet("quantity" + lngItem)) == true)
        {
            boolValid = false;
            alert("Please enter a valid number of units you require for the " + ValueGet("productname" + lngItem) + " product.");
            Select("quantity" + lngItem);
            break;
        }
        if (isNaN(ValueGet("weeks" + lngItem)) == true)
        {
            boolValid = false;
            alert("Please enter a valid number of weeks you require for the " + ValueGet("productname" + lngItem) + " product.");
            Select("weeks" + lngItem);
            break;
        }
    }
    if (boolValid == true)
    {
        frm.submit();
    }
}
function BasketDamageWaiver(frm, boolInclude)
{
    if (boolInclude == true)
    {
        if (confirm("Please confirm you wish to add the Damage Waiver to the products in your basket."))
        {
            frm.submit();
        }
    } else {
        if (confirm("Please confirm you wish to remove the Damage Waiver to the products in your basket."))
        {
            frm.submit();
        }
    }
}
function BasketRemove(frm, lngID)
{
    if (confirm("Are you sure you want to remove this product?"))
    {
        ValueSet("rid", lngID);
        frm.submit();
    }
}
function BasketEmpty(frm, lngID)
{
    if (confirm("Are you sure you want to remove all products from the basket?"))
    {
        frm.submit();
    }
}
function BasketFreeHirePeriod(lngItem)
{
    if (ValueGet("weeks" + lngItem) > 52)
    {
        ValueSet("weeks" + lngItem, 52);
        alert("You can only hire for a maximum of 52 weeks at a time.");
    }
    if (Number(ValueGet("freehireperiod" + lngItem)) == 1)
    {
        if (ValueGet("weeks" + lngItem) >= 12 && ValueGet("weeks" + lngItem) <= 16)
        {
            if (confirm("This product qualifies for our 36 weeks free hire.\n\nDo you want to hire for 52 weeks for the price of 16 weeks?"))
            {
                ValueSet("weeks" + lngItem, 52);
                alert("Remember to recalculate to update the totals.");
            }
        }
    }
}