﻿function popUpCard() {
    day = new Date();
    id = day.getTime();
    eval("page" + id + " = window.open('MembershipCard.aspx', '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=366,height=285,left = 490.5,top = 312');");
}

function updateAirPrice(id,price) {
    var ele = document.getElementById("P1");
    var total = document.getElementById("total");
    ele.innerHTML = "$" + parseFloat(price.substring().replace(',', '')).formatMoney(2).toString();
    var totalPrice = parseFloat(ele.innerHTML.substring(1).replace(',', ''));

    total.innerHTML = ("$" + totalPrice.formatMoney(2).toString());

    createCookie("air", id, 1);
}

function createCookie(name, value, days) {
    if (days) {
        var date = new Date();
        date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
        var expires = "; expires=" + date.toGMTString();
    }
    else var expires = "";
    document.cookie = name + "=" + value + expires + "; path=/";
}


Number.prototype.formatMoney = function(c, d, t) {
    var n = this, c = isNaN(c = Math.abs(c)) ? 2 : c, d = d == undefined ? "." : d, t = t == undefined ? "," : t, s = n < 0 ? "-" : "",
    i = parseInt(n = Math.abs(+n || 0).toFixed(c)) + "", j = (j = i.length) > 3 ? j % 3 : 0;
    return s + (j ? i.substr(0, j) + t : "") + i.substr(j).replace(/(\d{3})(?=\d)/g, "$1" + t)
    + (c ? d + Math.abs(n - i).toFixed(c).slice(2) : "");
};

function setItinerary(itineraryNo, amount) {
    document.getElementById('ctl00_Main_Itinerary').value = itineraryNo;
    document.getElementById('air' + itineraryNo.toString()).checked = true
    updateAirPrice(itineraryNo, amount);
}

function openWindow(url) {
    day = new Date();
    id = day.getTime();
    eval("page" + id + " = window.open('" + url + "', '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=640,height=597,left=10,top=10');");
}