function addCommas(nStr)
{
    nStr += '';
    x = nStr.split('.');
    x1 = x[0];
    x2 = x.length > 1 ? '.' + x[1] : '';
    var rgx = /(\d+)(\d{3})/;
    while (rgx.test(x1)) {
	    x1 = x1.replace(rgx, '$1' + ',' + '$2');
    }
    return x1 + x2;
}

function validateBooking(f)
{
    var msg = 'The following errors occured...\n';

    // Booking Details

    var adults = parseInt(f.adults.options[f.adults.selectedIndex].value)
    var children = parseInt(f.children.options[f.children.selectedIndex].value)

    // Group Leader Contact Details
    if ( f.fullname.value == '' ) msg = msg + '\n    Your name is required.'
    if ( f.address.value == '' ) msg = msg + '\n    Your address is required.'
    if ( f.postcode.value == '' ) msg = msg + '\n    Your postcode address is required.'
    if ( !checkMail(f.email.value) ) msg = msg + '\n    Your email address is invalid.'

    if ( f.telhome.value + f.telwork.value + f.telmobile.value == '' ) msg = msg + '\n    At least one phone number is required.'

    // Confirmation
    if ( f.iagree != null )
    {
        if ( f.iagree.value != 'I Agree' ) msg = msg + '\n    The confirmation value needs to be \'I Agree\'.'
    }

    if ( msg != 'The following errors occured...\n' )
    {
        alert(msg)
        return false;
    }
    return true;
}
function checkMail(email)
{
	var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,6})+$/;
	return filter.test(email)
}
