/********
 ****** (C) Wipplinger EDV Dienstleistungen 2003 - 2008
 **** All Rights Reserved
 ** Confidential
 *
 ******************************************************************************/

 /**
  * caveseekers.executor class
  * utility class to support timed execution of class methods, including 
  * parameters.
  */

/*
================================================================================
Namespace Defintion
================================================================================
*/

var caveseekers;

if (!caveseekers) 
{
  caveseekers = {};
}
else if (typeof caveseekers != "object")
{
  throw new Error("module caveseekers already exists");
}

if (caveseekers.executor)
{
  throw new Error("caveseeker.executor already exists");
}

caveseekers.executor = {};

/*
================================================================================
Statics:
================================================================================
*/


/*
================================================================================
Constructor and Memberdefinition
================================================================================
*/

caveseekers.executor = function (clObjectReference, 
		                      			iDelay,
		                      			strMethodName
		                      			)
{

  // Step 001: Member Definition

  this.m_Id = 'caveseeker.executor|' + (caveseekers.executor.m_iCounter++);
  this.m_clObjectReference = clObjectReference;
  this.m_iDelay = iDelay;
  this.mTimerId = 0;
  this.m_strMethodName = strMethodName;
  
  // Step 002: Copying Parameters
  
  this.m_clArgument = new Array();
  
  for(i=0;i<arguments.length-3;i++)
  { 
   this.m_clArgument[i] = arguments[i+3];
  } 

  caveseekers.executor.m_iPendingCalls[this.m_Id] = this;
  
  // Step 003: Starting Timer
  
  setTimeout('caveseekers.executor.m_iPendingCalls["' + this.m_Id + '"].execute()', this.m_iDelay);
}

/*
================================================================================
Class Methods:
================================================================================
*/

caveseekers.executor.prototype.execute = function()
{
  this.m_clObjectReference[this.m_strMethodName](this.m_clArgument[0],
                                                 this.m_clArgument[1],
                                                 this.m_clArgument[2],
                                                 this.m_clArgument[3],
                                                 this.m_clArgument[4],
                                                 this.m_clArgument[5]
                                                 );
                                                 
  delete caveseekers.executor.m_iPendingCalls[this.m_Id];
}

caveseekers.executor.m_iCounter = 0;
caveseekers.executor.m_iPendingCalls = {};

/*
 ** (C) Wipplinger EDV Dienstleistungen 2008
 **** All Rights Reserved
 ****** Confidential
 ********
 **************************************************/