/*
 * Copyright 2006, Peter Rowntree. All Rights Reserved.
 * http://www.hdyn.com/wr/common/contact.php?addr=pr
 */

function SSTimer(obName,startProc,endProc,delay)
{
	this.i_timer=null;
	this.i_obName=obName;
	this.i_startProc=startProc;
	this.i_endProc=endProc;
	this.i_delay=delay;
	this.run=function()
   {
	   if(this.i_timer != null)
	   {
	      clearTimeout(this.i_timer);
	      this.i_timer=null;
	   }
	   if(this.i_startProc != null)
	   	this.i_startProc();
	  	if(this.i_endProc != null)
			this.i_timer=setTimeout(this.i_obName+".end()",this.i_delay);
   }
	this.end=function()
   {
	  	if(this.i_endProc != null)
	  		this.i_endProc();
   }
}

function GPTimer()
{
   this.i_timer=null;
   this.doAfter=function(execStr,delay)
   {
      this.clear();
      this.i_timer=setTimeout(execStr,delay);
   }
   this.clear=function()
   {
      if(this.i_timer != null)
      {
         clearTimeout(this.i_timer);
         this.i_timer=null;
      }
   }
}