﻿function calculagraph() {
    this._id = null;
    this._cT = null;
    this._eT = null;
    this._lT = null;
    var cdate = null;
    var edate = null;
    this._elT = null;
    this._gT = function() {
        if (this._lT == null) {
            cdate = this._cT.toString();
            cdate = cdate.replace(/-/g, '/');
            edate = this._eT.toString();
            edate = edate.replace(/-/g, '/');
            ctime = new Date(cdate);
            etime = new Date(edate);
            this._elT = (etime - ctime);
            var _xT =Math.ceil(this._elT/(24*60*60*1000)); 
				//(parseInt(this._eT.match(/-(\d+)\s/)[1]) >= parseInt(this._cT.match(/-(\d+)\s/)[1])) ? (parseInt(this._eT.match(/-(\d+)\s/)[1]) - parseInt(this._cT.match(/-(\d+)\s/)[1])) : 0;
            //this._sT = parseInt(this._sT.match(/\s(\d+)\D/)[1] * 3600) + parseInt(this._sT.split(":")[1] * 60) + parseInt(this._sT.split(":")[2]);
            this._cT = parseInt(this._cT.match(/\s(\d+)\D/)[1] * 3600) + parseInt(this._cT.split(":")[1] * 60) + parseInt(this._cT.split(":")[2]);
            this._eT = _xT * 24 * 3600 + parseInt(this._eT.match(/\s(\d+)\D/)[1] * 3600) + parseInt(this._eT.split(":")[1] * 60) + parseInt(this._eT.split(":")[2]);
            this._lT = this._elT/1000;
				//(this._eT - this._cT);
            //this._slTs = (this._sT - this._cT);
        }
        if (this._elT > 0) {
            if (this._lT >= 0) {
                var _H = Math.floor(this._lT / 3600);
                var _M = Math.floor((this._lT - _H * 3600) / 60);
                var _S = (this._lT - _H * 3600) % 60;
                $("#Time" + this._id).html("<strong style='color:#000000;display:inline;'>" + _H + "H:</strong><strong style='color:#000000; display:inline;'>" + _M + "M:</strong><strong style='color:#000000; display:inline;'>" + _S + "S</strong>");
                this._lT--;
            } else {
                $("#Time" + this._id).html("<strong style='font-size:16px;color:red;'>Purchase end !</strong>");
                clearInterval(this._interval);
            }
        } else {
            $("#Time" + this._id).html("<strong style='font-size:16px;color:red;'>Purchase end !</strong>");
            clearInterval(this._interval);
        }
    }
    this._interval = function() {
        var o = this;
        this._interval = setInterval(function() { o._gT() }, 1000)
    }
}
function GetHtmlStr1() {
    $.ajax({
        type: "get",
        url: "GreatDeals.aspx?time=1",
        data: "&fresh=" + Math.random(),
        cache: false,
        success: function(result) {
            if (result != "") {
                eval(result.split('|')[0]);
                $("#Time1_Name").html(result.split('|')[1]);
                $("#Time1_Img").html(result.split('|')[2]);
                $("#Time1_OldPrice").html(result.split('|')[3]);
                $("#Time1_NewPrice").html(result.split('|')[4]);
                $("#Time1_div").html(result.split('|')[5]);
            }
        }
    });
}
function GetHtmlStr2() {
    $.ajax({
        type: "get",
        url: "GreatDeals.aspx?time=2",
        data: "&fresh=" + Math.random(),
        cache: false,
        success: function(result) {
            if (result != "") {
                eval(result.split('|')[0]);
                $("#Time2_Name").html(result.split('|')[1]);
                $("#Time2_Img").html(result.split('|')[2]);
                $("#Time2_OldPrice").html(result.split('|')[3]);
                $("#Time2_NewPrice").html(result.split('|')[4]);
                $("#Time2_div").html(result.split('|')[5]);
            }
        }
    });
}
function GetHtmlStr3() {
    $.ajax({
        type: "get",
        url: "GreatDeals.aspx?time=3",
        data: "&fresh=" + Math.random(),
        cache: false,
        success: function(result) {
            if (result != "") {
                eval(result.split('|')[0]);
                $("#Time3_Name").html(result.split('|')[1]);
                $("#Time3_Img").html(result.split('|')[2]);
                $("#Time3_OldPrice").html(result.split('|')[3]);
                $("#Time3_NewPrice").html(result.split('|')[4]);
                $("#Time3_div").html(result.split('|')[5]);
            }
        }
    });
}
function GetHtmlStr4() {
    $.ajax({
        type: "get",
        url: "GreatDeals.aspx?time=4",
        data: "&fresh=" + Math.random(),
        cache: false,
        success: function(result) {
            if (result != "") {
                eval(result.split('|')[0]);
                $("#Time4_Name").html(result.split('|')[1]);
                $("#Time4_Img").html(result.split('|')[2]);
                $("#Time4_OldPrice").html(result.split('|')[3]);
                $("#Time4_NewPrice").html(result.split('|')[4]);
                $("#Time4_div").html(result.split('|')[5]);
            }
        }
    });
}
function GetHtmlStr5() {
    $.ajax({
        type: "get",
        url: "GreatDeals.aspx?time=5",
        data: "&fresh=" + Math.random(),
        cache: false,
        success: function(result) {
            if (result != "") {
                eval(result.split('|')[0]);
                $("#Time5_Name").html(result.split('|')[1]);
                $("#Time5_Img").html(result.split('|')[2]);
                $("#Time5_OldPrice").html(result.split('|')[3]);
                $("#Time5_NewPrice").html(result.split('|')[4]);
                $("#Time5_div").html(result.split('|')[5]);
            }
        }
    });
}
function GetHtmlStr6() {
    $.ajax({
        type: "get",
        url: "GreatDeals.aspx?time=6",
        data: "&fresh=" + Math.random(),
        cache: false,
        success: function(result) {
            if (result != "") {
                eval(result.split('|')[0]);
                $("#Time6_Name").html(result.split('|')[1]);
                $("#Time6_Img").html(result.split('|')[2]);
                $("#Time6_OldPrice").html(result.split('|')[3]);
                $("#Time6_NewPrice").html(result.split('|')[4]);
                $("#Time6_div").html(result.split('|')[5]);
            }
        }
    });
}
function GetHtmlCustomer() {
    $.ajax({
        type: "get",
        url: "ShowCustomer.aspx?param=true",
        data: "&fresh=" + Math.random(),
        cache: false,
        success: function(result) {
            $("#textdiv").html(result);
            new Marquee("textdiv", 0, 1, 150, 350, 20, 4000, 500,150);
        }
    });
}
$(function() {
    $(window).load(function() {
        GetHtmlStr1();
        GetHtmlStr2();
        GetHtmlStr3();
       // GetHtmlStr4();
       // GetHtmlStr5();
        //GetHtmlStr6();
        //GetHtmlCustomer();
    });
});
