﻿getTime();
var time = new Date();
function Reactivation() {
    var value = getReactivationValue();
    document.getElementById("btnReactivation1").value = value;
}

function ReactivationUnlimited() {
    var value = getReUnlimitedValue();
    document.getElementById("btnUnlReactivation1").value = value;
}

function Upgrading() {
    var value = getUpgradeValue();
    document.getElementById("btnUpgrade1").value = value;
}

function getReactivationValue() {
    return Reactivate[getIndex()];
}

function getReUnlimitedValue() {
    return ReUnlimited[getIndex()];
}

function getUpgradeValue() {
    return Upgrade[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 Reactivate = {
    0: "7771736",
    1: "7752050",
    2: "7769834",
    3: "7770929",
    4: "7770939",
    5: "7770949",
    6: "7770973",
    7: "7771008",
    8: "7771064",
    9: "7771085",
    10: "7771102",
    11: "7771119",
    12: "7771154",
    13: "7771169",
    14: "7771178",
    15: "7771198",
    16: "7771208",
    17: "7771234",
    18: "7771243",
    19: "7771291",
    20: "7771394",
    21: "7771435",
    22: "7771503",
    23: "7771514",
    24: "7771523",
    25: "7771542",
    26: "7771579",
    27: "7771626",
    28: "7771646",
    29: "7771685",
    30: "7771736"
};

var Upgrade = {
    0: "7798030",
    1: "7797180",
    2: "7797194",
    3: "7797204",
    4: "7797222",
    5: "7797243",
    6: "7797260",
    7: "7797272",
    8: "7797288",
    9: "7797304",
    10: "7797336",
    11: "7797365",
    12: "7797389",
    13: "7797458",
    14: "7797489",
    15: "7797513",
    16: "7797534",
    17: "7797704",
    18: "7797771",
    19: "7797785",
    20: "7797803",
    21: "7797825",
    22: "7797853",
    23: "7797869",
    24: "7797891",
    25: "7797906",
    26: "7797933",
    27: "7797951",
    28: "7797968",
    29: "7797982",
    30: "7798012"
};

var ReUnlimited = {
    0: "7799952",
    1: "7799200",
    2: "7799218",
    3: "7799284",
    4: "7799305",
    5: "7799316",
    6: "7799328",
    7: "7799349",
    8: "7799366",
    9: "7799383",
    10: "7799399",
    11: "7799414",
    12: "7799454",
    13: "7799501",
    14: "7799621",
    15: "7799636",
    16: "7799677",
    17: "7799695",
    18: "7799716",
    19: "7799731",
    20: "7799746",
    21: "7799761",
    22: "7799777",
    23: "7799791",
    24: "7799812",
    25: "7799831",
    26: "7799847",
    27: "7799883",
    28: "7799898",
    29: "7799913",
    30: "7799941"
};


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;
}