﻿getTime();
var time = new Date();
function BasicActivation() {
    var value = getBasicValue();
    document.getElementById("btnBasicActivation1").value = value;
    document.getElementById("btnBasicActivation2").value = value;	_gaq.push(['_trackEvent', 'Plans', 'PaypalButtonClick', 'Basic Plan']);
}

function UnlimitedActivation() {
    var value = getUnlimitedValue();
    document.getElementById("btnUnlActivation1").value = value;
    document.getElementById("btnUnlActivation2").value = value;		_gaq.push(['_trackEvent', 'Plans', 'PaypalButtonClick', 'Unlimited Plan']);
}

function getBasicValue() {
    return Basic[getIndex()];
}

function getUnlimitedValue() {
    return Unlimited[getIndex()];
}

function getIndex() {
    var index;
    var date = new Date();
    var day = date.getDate();
    var payperiodEndDay = 7;
    var totalDaysInMonth = Months[date.getMonth()];
    if (isLeapYear(date.getFullYear())) {
        if (date.getMonth() == 2)
            totalDaysInMonth++;
    }

    if (day <= payperiodEndDay) {
        index = payperiodEndDay - day;
    }
    else {
        index = totalDaysInMonth + payperiodEndDay - day;
    }
    return index;
}



function isLeapYear(year) {
    if (((year % 400) == 0) || (((year % 100) != 0) && ((year % 4) == 0)))
        return true;
    else
        return false;
}

var Months = { 0: 31, 1: 28, 2: 31, 3: 30, 4: 31,
    5: 30, 6: 31, 7: 31, 8: 30, 9: 31,
    10: 30, 11: 31
};

var Basic = {
    0: "7751906",
    1: "7751034",
    2: "7751107",
    3: "7751223",
    4: "7751263",
    5: "7751357",
    6: "7751410",
    7: "7751434",
    8: "7751453",
    9: "7751474",
    10: "7751499",
    11: "7751516",
    12: "7751538",
    13: "7751574",
    14: "7751585",
    15: "7751601",
    16: "7751618",
    17: "7751646",
    18: "7751662",
    19: "7751681",
    20: "7751702",
    21: "7751718",
    22: "7750198",
    23: "7751748",
    24: "7751772",
    25: "7751794",
    26: "7751805",
    27: "7751819",
    28: "7751845",
    29: "7751866",
    30: "7751906"
};

var Unlimited = {
    0: "7797059",
    1: "7796325",
    2: "7796349",
    3: "7796370",
    4: "7796381",
    5: "7796400",
    6: "7796411",
    7: "7796437",
    8: "7796458",
    9: "7796555",
    10: "7796568",
    11: "7796590",
    12: "7796604",
    13: "7796622",
    14: "7796640",
    15: "7796664",
    16: "7796680",
    17: "7796694",
    18: "7796709",
    19: "7796845",
    20: "7796872",
    21: "7796885",
    22: "7796897",
    23: "7796911",
    24: "7796930",
    25: "7796955",
    26: "7796984",
    27: "7796994",
    28: "7797009",
    29: "7797027",
    30: "7797042"
};

function getTime() {
    var url = "";
    if (window.location.href.indexOf("www") == -1) {
        url = "http://qwertcorp.com/scripts/time.php";
    }
    else
        url = "http://www.qwertcorp.com/scripts/time.php";
    $.get(url, function(response) { dateConvert(response); });
}

function dateConvert(unix) {
    var dt = new Date();
    dt.setTime(unix * 1000);
    time = dt;
}
