function  SessionTimer(url, timeOutMilli, frameName, autoRedirect, isPopup, maxKeepAlive)
{
    this.timeOutLength = timeOutMilli;
    this.timeOutTrigger = timeOutMilli - 120000;//the length of the time out subtracted two minutes
    this.timeOutUrl = "/timeOutRedirect.jsp?url="+url; //the url to which the browser should show as a link for return to where you came from on the to page;
    this.keepAliveMax = maxKeepAlive; //max number of times keep alive may be called
    this.keepAliveCount = 0; //number of times keep alive has been called
    this.keepAliveUrl = "/sessionTimerKeepAlive.do";//the url to which the keep allive is directed
    this.isPopup = isPopup;

    this.keepAliveFrame = frameName;//the frame in which the keepalive should be called
    this.keepAliveInProgress = false;

    this.initKeepAliveSequence = SessionTimer_initKeepAliveSequence;
    this.keepAliveRequest = SessionTimer_keepAliveRequest;
    this.doKeepAlive = SessionTimer_doKeepAlive;
    this.timeOutRedirect = SessionTimer_timeOutRedirect;
    this.defaultRedirect = SessionTimer_defaultRedirect;
    this.initSafeTimeOut = SessionTimer_initSafeTimeOut;

    function SessionTimer_keepAliveRequest()
    {
        with(this)
        {
           if(this.keepAliveMax > this.keepAliveCount)
           {
               if(!this.keepAliveInProgress)
               {
                    this.keepAliveInProgress = true;
                    frames[this.keepAliveFrame].location.href = (this.keepAliveUrl + "?attempt="+ this.keepAliveCount);;
               }
               else
               {

               }
           }
           else
           {
               this.timeOutRedirect();
           }
        }
    }

    function SessionTimer_doKeepAlive()
    {
        with(this)
        {
            this.keepAliveCount++;
            this.keepAliveInProgress = false;
            if(this.keepAliveMax > this.keepAliveCount)
            {
                this.initKeepAliveSequence();
            }
            else
            {

                this.timeoutId = window.setTimeout("sessionTimer.timeOutRedirect();", this.timeOutTrigger);
            }
        }
    }

    function SessionTimer_initKeepAliveSequence()
    {
        with(this)
        {
                this.timeoutId = window.setTimeout("sessionTimer.keepAliveRequest();", this.timeOutTrigger);
        }
    }


    function  SessionTimer_timeOutRedirect()
    {
        with(this)
        {
           frames[this.keepAliveFrame].location.href = this.timeOutUrl;
        }
    }

    //safe timeout function used in case time out window is unavailable
    function SessionTimer_initSafeTimeOut()
    {
       this.safeTimeoutId = window.setTimeout("sessionTimer.defaultRedirect();", this.timeOutTrigger + 120001);
    }

    //default redirection is the home page.  used only in cases where keep alive
    //has failed for unknown reasons.
    function SessionTimer_defaultRedirect()
    {
        if(this.keepAliveInProgress)
        {
            top.location.replace("/");
        }
    }




}