var secs
var nextval
var timerID = null
var timerRunning = false
var delay = 1000

function InitializeTimer(nxtvl)
{
    secs = 4
    nextval = nxtvl
    StopTheClock()
    StartTheTimer()
}

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

function StartTheTimer()
{
    if (secs==0)
    {
        StopTheClock()
        refreshframes(nextval)
    }
    else
    {
        self.status = secs
        secs = secs - 1
        timerRunning = true
        timerID = self.setTimeout(\"StartTheTimer()\", delay)
    }
}

function refreshframes(nextval) {
   parent.frames[\"featimg\"].window.location.href=('index.php?page=featimg&lastindex='+nextval)
   parent.frames[\"feattext\"].window.location.href=('index.php?page=feattext&lastindex='+nextval)
}


