if (typeof (currDate) == 'undefined') {
    currDate = new Date();
}

function renderTime(adate, el) {
    var hours;
    if (adate.getHours() < 10) {
        hours = "0" + adate.getHours();
    }
    else {
        hours = adate.getHours();
    }

    var minutes;
    if (adate.getMinutes() < 10) {
        minutes = "0" + adate.getMinutes();
    }
    else {
        minutes = adate.getMinutes();
    }

    var sec;
    if (adate.getSeconds() < 10) {
        sec = "0" + adate.getSeconds();
    }
    else {
        sec = adate.getSeconds();
    }

    var thisTime = hours + ':' + minutes + ':' + sec;
    //$('span#tm').text(thisTime);
    $(el).text(thisTime);
}

function incCurrDate() {
    currDate.setTime(currDate.getTime() + 1000);
}

$(document).ready(function () {
    setInterval(function () { incCurrDate(); }, 1000);
});

