var secs
var transition=0;
var timerID = null
var timerRunning = false
//var delay = 500
var delay =2; 

function InitializeTimer()
{
    // Set the length of the timer, in seconds
    secs=2 

    StopTheClock()
    StartTheTimer()
}

function StopTheClock()
{
    if(timerRunning)
        clearTimeout(timerID)
    timerRunning = false
}

function StartTheTimer()
{
    if (secs==0)
    {
	transition=0;
        StopTheClock()
        // Here's where you put something useful that's
        // supposed to happen after the allotted time.
        // For example, you could display a message:
	changelight();
        //updateStory();
	InitializeTimer();
    }
    else
    {
	/*
	if (secs<3 && transition==0) {
		transition=1;
		document.getElementById('story').style.color="#999";
		document.getElementById('storydate').style.color="#999";
	} else {
		document.getElementById('story').style.color="#600";
		document.getElementById('storydate').style.color="#666";
	}
	*/
        //self.status = secs;
        secs = secs - 1;
        timerRunning = true;
        timerID = self.setTimeout("StartTheTimer()", delay)
    }
}

