﻿

function validate(p) {
 
    var sngRoomQty = document.getElementById(p + "dataSingleRoom").value;
    var dblRoomQty = document.getElementById(p + "dataDoubleRoom").value;
    var trpRoomQty = document.getElementById(p + "dataTripleRoom").value;
    if (sngRoomQty == 0 && dblRoomQty == 0 && trpRoomQty == 0) {
        alert('You must select one of the rooms single, double or triple.')
        return false;
    }
    return true;
}

function hidePaxQty(p) {
    hideSingle(p);
    hideDouble(p);
    hideTriple(p);
}

function hideSingle(p) {
    var sngRoomQty = document.getElementById(p + "dataSingleRoom").value;

    if (sngRoomQty == 0)
        document.getElementById("tdSngPax").style.display = 'none';
    else
        document.getElementById("tdSngPax").style.display = 'block';

    document.getElementById(p + "dataSingleRoomAdults").value = sngRoomQty * 1;
}

function hideDouble(p) {
    var dblRoomQty = document.getElementById(p + "dataDoubleRoom").value;

    if (dblRoomQty == 0)
        document.getElementById("tdDblPax").style.display = 'none';
    else
        document.getElementById("tdDblPax").style.display = 'block';

    document.getElementById(p + "dataDoubleRoomAdults").value = dblRoomQty * 2;
}
function hideTriple(p) {
    var trpRoomQty = document.getElementById(p + "dataTripleRoom").value;

    if (trpRoomQty == 0)
        document.getElementById("tdTrpPax").style.display = 'none';
    else
        document.getElementById("tdTrpPax").style.display = 'block';

    document.getElementById(p + "dataTripleRoomAdults").value = trpRoomQty * 3;
}


function openPopUp(URLStr, w, h) {
    winparam = 'copyhistory=no,directories=no,dependent=yes,height=' + h + ',width=' + w + ',location=no,status=yes,menubar=no,toolbar=no,resizable=yes,scrollbars=yes';
    open(URLStr, 'popup', winparam);
}

// number formatting function
// copyright Stephen Chapman 24th March 2006, 22nd August 2008
// permission to use this function is granted provided
// that this copyright notice is retained intact
function formatCurrency(num) {

    return formatNumber(num, 2, ',', '.', '$', '', '(', ')');
}

function formatNumber(num, dec, thou, pnt, curr1, curr2, n1, n2) {

    var x = Math.round(num * Math.pow(10, dec));
    if (x >= 0) n1 = n2 = '';
    var y = ('' + Math.abs(x)).split('');
    var z = y.length - dec;
    if (z < 0) z--;
    for (var i = z; i < 0; i++) y.unshift('0');
    if (z < 0) z = 1; y.splice(z, 0, pnt);
    if (y[0] == pnt) y.unshift('0');
    while (z > 3) { z -= 3; y.splice(z, 0, thou); }
    var r = curr1 + n1 + y.join('') + n2 + curr2;
    return r;
}
