﻿
var dateFuture = null;

function Toggle(id, srcpath) {
    document.getElementById(id).setAttribute('src', srcpath);
}

function GetCount() {
   
    if (document.getElementById('countsbox') != null) {
        dateNow = new Date();
        //var dateFuture = new Date(2011, 7, 29, 13, 0, 0);
        amount = dateFuture.getTime() - dateNow.getTime();
        //alert(dateFuture.getTime());
        delete dateNow;

        if (amount < 0) {
            document.getElementById('countsbox').innerHTML = "Show<span> is running</span>";
//            if (document.getElementById('ctl00_c_aPlaceBidClick') != null) {
//                document.getElementById('ctl00_c_aPlaceBidClick').style.display = 'none';
//                document.getElementById('ctl00_c_aPlaceBid').style.display = 'none';
//            }
        }
        //2011,7,29,13,0,0
        else {
            //days = 0; hours = 0; mins = 0; secs = 0; out = "<span class='day'>";
            days = 0; hours = 0; mins = 0; secs = 0; out = "";

            amount = Math.floor(amount / 1000);

            days = Math.floor(amount / 86400);
            amount = amount % 86400;

            hours = Math.floor(amount / 3600);
            amount = amount % 3600;

            mins = Math.floor(amount / 60);
            amount = amount % 60;

            secs = Math.floor(amount);

//            if (days != 0) { out += padleft(days, '0', 3) + " Days </span><span class='hour'>" + ((days != 1) ? "" : "") + " "; } else { out += padleft(days, '0', 2) + "Days </span><span class='hour'>" + ((days != 1) ? "" : "") + ""; }
//            if (days != 0 || hours != 0) { out += padleft(hours, '0', 2) + " " + ((hours != 1) ? "" : "") + "Hours </span><span class='minute'> "; }
//            if (days != 0 || hours != 0 || mins != 0) { out += padleft(mins, '0', 2) + " " + ((mins != 1) ? "" : "") + "Minutes </span><span class='second'> "; }
            //            out += padleft(secs, '0', 2) + " Sec </span>";
            if (days != 0) { out += padleft(days, '0', 3) + "<span>Days </span>" + ((days != 1) ? "" : "") + ""; } else { out += padleft(days, '0', 2) + "<span>Days</span> " + ((days != 1) ? "" : "") + ""; }
            if (days != 0 || hours != 0) { out += padleft(hours, '0', 2) + "" + ((hours != 1) ? "" : "") + "<span>Hours </span>"; }
            if (days != 0 || hours != 0 || mins != 0) { out += padleft(mins, '0', 2) + "" + ((mins != 1) ? "" : "") + "<span>Minutes </span>"; }
            out += padleft(secs, '0', 2) + "<span>Seconds  </span>";
            out += "&nbsp;&nbsp;";
            document.getElementById('countsbox').innerHTML = out;

            setTimeout("GetCount()", 1000);
        }
    }
}
function padleft(val, ch, num) 
{
    var re = new RegExp(".{" + num + "}$");
    var pad = "";
    if (!ch) ch = " ";

    do {
        pad += ch;
    }
    while (pad.length < num);
    //return re.exec(pad + val);
    return val;
    
}
