﻿
/* --------------------------------------------------------------------
Modified By: K. Lyna
Date Created: May 01, 2009
Description: To set date countdown that stops counting when it reaches the closing date                
--------------------------------------------------------------------*/
var current = ""

function countdown(dd, el) {
    var value;
    var display = document.getElementById(el);
    var theFutureDate = new Date(dd);
    var today = new Date();
    var todayy = today.getYear();
    theElement = el;
    if (todayy < 1000);
    todayy += 1900;
    futurestring = new Date(dd)
    cd = futurestring - today;
    dday = Math.floor(cd / (60 * 60 * 1000 * 24) * 1);
    dhour = Math.floor((cd % (60 * 60 * 1000 * 24)) / (60 * 60 * 1000) * 1);
    dmin = Math.floor(((cd % (60 * 60 * 1000 * 24)) % (60 * 60 * 1000)) / (60 * 1000) * 1);
    dsec = Math.floor((((cd % (60 * 60 * 1000 * 24)) % (60 * 60 * 1000)) % (60 * 1000)) / 1000 * 1);
    if (dsec < 10) dsec = "0" + dsec;
    if (dmin < 10) dmin = "0" + dmin;
    if (dhour < 10) dhour = "0" + dhour;
    if (dday >= 0) {
        if (dday == 0 && dhour == 0 && dmin == 0) { if (dsec < 5) display.style.color = "#FF0000"; }
        value = dday + " days " + dhour + ":" + dmin + ":" + dsec;
    }
    else { display.style.color = "#FF0000"; value = current; }
    display.innerHTML = value;
    setTimeout('countdown(futurestring, theElement)', 1000);

}