

      function AjaxTimeoutTimer(strLength){

        //Set all of the defaults      
        this.loaded = false;
        this.objDiv = null;
        this.sessionLength = 1000*60*20;
        if(typeof(strLength)!="undefined")this.sessionLength = strLength;
        var timerWarn = window.setTimeout(loadMessage,this.sessionLength);
        this.maxWait = 1000*60*5;
        this.message = "<span class=\"indent\"></span>Your current session is about to expire. " + 
                       "In order to remain active and avoid loosing " + 
                       "any data you may have entered, please press " + 
                       "the <b>Confirm</b> button " +
                       "to extend your session." +
                       "<br/><br/><div id=\"divAjaxBut\"><input type=\"button\" id=\"ajaxB1\" class=\"Confirm\" value=\"Confirm\" onclick=\"ajaxTimer.confirmTimer();return false;\"/></div>";
        this.confirm = "Confirm";
        this.extendedMessage = "<span class=\"indent\"></span>Your session has most likely been expired. " +
                               "Press the <b>Confirm</b> " +
                               "button to verify this." +
                               "<br/><br/><div id=\"divAjaxBut\"><input type=\"button\" id=\"ajaxB1\" class=\"Confirm\" value=\"Confirm\" onclick=\"ajaxTimer.confirmTimer();return false;\"/></div>";
        this.serverURL = null;
        var ref = this;
        

        //Start to display message on scroll
        function loadMessage(){
        
          //if(ref.loaded == false)ref.loaded = 
          ref.loaded = createAjaxConfirm();        
		  document.getElementById("divAjaxContent").innerHTML = ref.message;           
            window.addEvent('domready', function() {
	            SqueezeBox.initialize();

	            SqueezeBox.open($('divAjaxContent'), {
		            handler: 'adopt',
		            size: {x: 300, y: 200}
	            });
            });
            timerWait = window.setTimeout(extendedWait,ref.maxWait);
            
        }
       
        //some local(private) varaibles
        var timerScroll = null;
        var timerReject = null;
        var intStep = 2;
        var intStop = Math.floor(ref.intHeight/5);
    	var timerUpdate = null;
		var intDotCount = 0;
		var timerWait = null;

        
        //Confirm button pressed, make request, hide buttons, start annimation
		this.confirmTimer = function(){
          timerUpdate = window.setInterval(updateMessage,250);
          document.getElementById("divAjaxBut").style.display = "none";
          makeHttpRequest();
		}

        //Annimate the request waiting time so it looks fancy
		function updateMessage(){
		  var strDotsMessage = "Updating Session.";
		  for(x=0;x<intDotCount;x++)strDotsMessage+=".";
		  document.getElementById("divAjaxContent").innerHTML = strDotsMessage;
		  intDotCount++;
		  if(intDotCount>4)intDotCount = 0;
		}
		
		//change message from normal to extended info
		function extendedWait(){
		  document.getElementById("divAjaxContent").innerHTML = ref.extendedMessage;
		}
	
        //Function Prepares calls xmlHttpRequest
        function makeHttpRequest(){
        
          //Make sure we set the server side page          
          if(ref.serverURL==null){
            alert('Errror: Server Side Code was not specified by web master!');
            SqueezeBox.close();
            return false;
          }
          
          //create reg exp so we do not grabbed cached material
          var regEx = /(\s|:)/gi;
          var strDT = "ts=" + new Date().toString().replace(regEx,"");                              
          
          //Make the request to the server
          var loader1 = new net.ContentLoader(ref.serverURL,finishRequest,null,"POST",strDT); //Make request
        
        }
        
        //Function takes XML document 
        function finishRequest(){
          timerWarn = window.setTimeout(loadMessage,ref.sessionLength);
          var bx = window.clearTimeout(timerUpdate);
          var strDoc = this.req.responseText;  //Grab HTML
          if(strDoc.indexOf("Session Updated - Server Time:") == 0){
            document.getElementById("divAjaxContent").innerHTML = "Your session was updated sucessfully!";
            var timerHide = window.setTimeout(hideDiv,2000);
          }
          else{
              document.getElementById("divAjaxContent").innerHTML = "Warning your session has already timed out!";          
              var timerHide = window.setTimeout(hideDiv, 3000);
              document.location.href = document.location.href;
          }
        }
        
        function createAjaxConfirm(){     
          var div1 = document.createElement("div");
          div1.id = "divAjaxContent";
          document.forms[0].appendChild(div1);
            
          return  true;
        }
        
        //Hide div and iframe
        function hideDiv(){
         SqueezeBox.close();
        }
     
      }


