﻿function calculagraphi() {
    this._isT = null;
    this._icT = null;
    this._ieT = null;
    this._ilT = null;
    this._islT = null;
    var isdate = null;
    var icdate = null;
    var iedate = null;
    this._ielT = null;
    this._islTs = null;
    this._igT = function() {
        if (this._ilT == null) {
            isdate = this._isT.toString();
            isdate = isdate.replace(/-/g, '/');
            icdate = this._icT.toString();
            icdate = icdate.replace(/-/g, '/');
            iedate = this._ieT.toString();
            iedate = iedate.replace(/-/g, '/');
            istime = new Date(isdate);
            ictime = new Date(icdate);
            ietime = new Date(iedate);
            this._islT = ((ictime - istime) / 1000);

            this._ielT = (ietime - ictime);
            var _ixT = Math.ceil(this._ielT/(24*60*60*1000));
				//(parseInt(this._ieT.match(/-(\d+)\s/)[1]) >= parseInt(this._icT.match(/-(\d+)\s/)[1])) ? (parseInt(this._ieT.match(/-(\d+)\s/)[1]) - parseInt(this._icT.match(/-(\d+)\s/)[1])) : 0;
            this._isT = parseInt(this._isT.match(/\s(\d+)\D/)[1] * 3600) + parseInt(this._isT.split(":")[1] * 60) + parseInt(this._isT.split(":")[2]);
            this._icT = parseInt(this._icT.match(/\s(\d+)\D/)[1] * 3600) + parseInt(this._icT.split(":")[1] * 60) + parseInt(this._icT.split(":")[2]);
            this._ieT = _ixT * 24 * 3600 + parseInt(this._ieT.match(/\s(\d+)\D/)[1] * 3600) + parseInt(this._ieT.split(":")[1] * 60) + parseInt(this._ieT.split(":")[2]);
            this._ilT = this._ielT/1000;
				//(this._ieT - this._icT);
            this._islTs = (this._isT - this._icT);
        }

        if (this._islT < 0) {
            $("#LimtedTimeIter").html("<strong style='font-size:16px;color:red;'>Purchase disabled, will be enabled shortly! Stay tuned!</strong>");
            this._islT++;
            if (this._islT >= 0) {
                clearInterval(this._iinterval);
                GetHtmlStrInster();
            }
        } else {
            if (this._ielT > 0) {
                if (this._ilT >= 0) {
                    
                    var _iD = Math.floor(this._ilT / 3600 / 24);
                    var _iH = Math.floor((this._ilT - _iD * 24 * 3600) / 3600);
                    var _iM = Math.floor((this._ilT -(_iD * 24 * 3600)- (_iH * 3600)) / 60);
                    var _iS = (this._ilT - _iH * 3600) % 60;
                    $("#LimtedTimeIter").html("Time Remaining: <strong style='color:red; font-size:20px; font-weight:bold;'>" + _iD + "Days " + _iH + ":" + _iM + ":" + _iS + "</strong>");
                    this._ilT--;
                } else {
                $("#LimtedTimeIter").html("<strong style='font-size:16px;color:red;'>Purchase disabled, will be enabled shortly! Stay tuned!</strong>");
                    clearInterval(this._iinterval);
                    GetHtmlStrInster();
                }
            } else {
            $("#LimtedTimeIter").html("<strong style='font-size:16px;color:red;'>Purchase disabled, will be enabled shortly! Stay tuned!</strong>");
                clearInterval(this._iinterval);
            }
        }
    }
    this._iinterval = function() {
        var io = this;
        this._iinterval = setInterval(function() { io._igT() }, 1000)
    }
}
function GetHtmlStrInster() {
    $.ajax({
        type: "get",
        url: "IntegralMallProduct.aspx",
        data: "fresh=" + Math.random(),
        cache: false,
        success: function(result) {
            if (result != "") {
                eval(result.split('|')[0]);
                $("#tabcontent1").html(result.split('|')[1]);
            }
        }
    });
}
$(function() {
    $(window).load(function() {
        GetHtmlStrInster();
    });
});
