var eventdate = new Date("May 1, 2010 08:00:00 EST");
var vPath = "images/chevyshow/countdown/";

function toStr(n) {
    var s = "";

    if (n < 10) {
        s += "0";
    }

    return s + n.toString();
}

function curClock() {
    this.days = "";
    this.hours = "";
    this.mins = "";
    this.secs = "";
}

var Clock = new curClock();

function countdown() {
    var vDate = new Date();
    var count = Math.floor((eventdate.getTime() - vDate.getTime()) / 1000);

    Clock.secs = toStr(count % 60);
    count = Math.floor(count / 60);
    Clock.mins = toStr(count % 60);
    count = Math.floor(count / 60);
    Clock.hours = toStr(count % 24);
    count = Math.floor(count / 24);
    Clock.days = toStr(count);

    //Days
    switch (Clock.days.length) {
        case 1:
            document.cd1.src = vPath + "numblank.gif";
            document.cd2.src = vPath + "numblank.gif";
            document.cd3.src = vPath + "num" + Clock.days.substr(0, 1) + ".gif";
            break;
        case 2:
            document.cd1.src = vPath + "numblank.gif";
            document.cd2.src = vPath + "num" + Clock.days.substr(0, 1) + ".gif";
            document.cd3.src = vPath + "num" + Clock.days.substr(1, 1) + ".gif";
            break;
        case 3:
            document.cd1.src = vPath + "num" + Clock.days.substr(0, 1) + ".gif";
            document.cd2.src = vPath + "num" + Clock.days.substr(1, 1) + ".gif";
            document.cd3.src = vPath + "num" + Clock.days.substr(2, 1) + ".gif";
            break;
    }

    //Hours
    document.cd4.src = vPath + "num" + Clock.hours.substr(0, 1) + ".gif";
    document.cd5.src = vPath + "num" + Clock.hours.substr(1, 1) + ".gif";

    //Minutes
    document.cd6.src = vPath + "num" + Clock.mins.substr(0, 1) + ".gif";
    document.cd7.src = vPath + "num" + Clock.mins.substr(1, 1) + ".gif";

    //Seconds
    document.cd8.src = vPath + "num" + Clock.secs.substr(0, 1) + ".gif";
    document.cd9.src = vPath + "num" + Clock.secs.substr(1, 1) + ".gif";

    setTimeout("countdown()", 500);
}