var secs
var timerID = null
var timerRunning = false
var delay = 1000

function InitializeTimer(setSecs)
{
    // Set the length of the timer, in seconds
    secs = setSecs
    StopTheClock()
    if (secs > 0){
    	StartTheTimer()
    }
}

function StopTheClock()
{
    if(timerRunning)
        clearTimeout(timerID)
    timerRunning = false
}

function StartTheTimer()
{
    if (secs==0)
    {
        document.getElementById('redirTimer').innerHTML = secs
        location.href='http://www.psykologiguiden.se';
    }
    else
    {
        document.getElementById('redirTimer').innerHTML = secs
        secs = secs - 1
        timerRunning = true
        timerID = self.setTimeout("StartTheTimer()", delay)
    }
}