var now=new Date();
var d=now.getDate();
if (eval(d)<10) d='0' + d
var m=now.getMonth()+1;
if (eval(m)<10) m='0' + m
var y=now.getFullYear();
var h=now.getHours();
if (eval(h)<10) h='0' + h
var min=now.getMinutes();
if (eval(min)<10) min='0' + min
var s=now.getSeconds();
if (eval(s)<10) s='0' + s

document.write(y + '-' + m + '-' + d + ' &nbsp; ');
document.write('<font id="timeFont"></font>');

if (eval(h)>=18 || eval(h)<=5) {
    var obj=document.getElementById("timeBG");
    obj.style.backgroundImage = "url(images/timerBG2.jpg)";
    obj.className="timer2";
}

var timerID = null

var timerRunning = false

function stopTimer(){

        //stop the clock

        if(timerRunning) {

                clearTimeout(timerID)

                timerRunning = false

        }

} 

function startTimer(){

     // Stop the clock (in case it's running), then make it go.

    stopTimer()

    runClock()

}

function runClock(){
        
        var obj=document.getElementById("timeFont");
        obj.innerHTML = timeNow()

        //Notice how setTimeout() calls its own calling function, runClock().

        timerID = setTimeout("runClock()",1000)

        timerRunning = true

}

function timeNow() {

        //Grabs the current time and formats it into hh:mm:ss am/pm format.

        now = new Date()

        hours = now.getHours()

        minutes = now.getMinutes()

        seconds = now.getSeconds()

        timeStr = "" + ((hours > 12) ? hours - 12 : hours)

        timeStr  += ((minutes < 10) ? ":0" : ":") + minutes

        timeStr  += ((seconds < 10) ? ":0" : ":") + seconds

        timeStr  += (hours >= 12) ? " PM" : " AM"

        return timeStr
}
// End of custom functions, stop hiding code -->

startTimer()