<!--
var secs
var timerID = null
var timerRunning = false
var delay = 1000 // 1 second

function InitializeTimer(timeout)
{
    // Set the length of the timer, in seconds; 15 minutes = 900 seconds
    secs = timeout 
    StopTheClock()
    StartTheTimer()
}

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

function StartTheTimer()
{
    if (secs==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:
        //alert("Timeout!")
        //window.location = "/sharing/webtimeout";
                // use msg function from formval.js to write warning
                //msg(fld,     // id of element to display message in
                //    msgtype, // class to give element ("warn" or "error")
                //    message) // string to display
        //msg('warn_timeout', 'error', "Your selections are no longer being held for you, as your session was inactive for longer than 15 minutes.");
        toggleLayer('warnTimeout');
    }
    else if (secs==120) 
    {
        self.status = secs
        secs = secs - 1
        timerRunning = true
        timerID = self.setTimeout("StartTheTimer()", delay)
        alert("Your Sharing Gift Box session has been inactive for almost 15 minutes. To keep your selections active, simply continue browsing the Sharing Gift Box site, or you may confirm your selections and check out. Otherwise, your selections will be released in order to maximize the opportunity for all needs and wishes to be met.")
    }
    else
    {
        self.status = secs
        secs = secs - 1
        timerRunning = true
        timerID = self.setTimeout("StartTheTimer()", delay)
                                                                                }
}
//The code decreases the "secs" variable by 1 each second. When "secs" gets to 0, the clock is stopped and that's when you do whatever it is you want to do once the timer is done (such as display a message or send the user to another page).
//In the example above, I use a simple form button to start the timer (it also displays the countdown in the status bar). You could also start the timer (that is, run the InitializeTimer() function) automatically by adding the following to the <BODY> tag:
//onLoad="InitializeTimer()" 
//-->




