function Timer(obj) {this.create(obj);}

//constructor===================================================================
Timer.prototype.create = function(obj) {
  var params = obj;
  this.name = 'Timer_instance';

  //vars==========================================
  this._count = 0;
  
  //params========================================
  
  //get
  this._time = params.time;
  this._repeat = params.repeat;
  this._onTrigger = params.onTrigger;
  this._instanceName = params.instanceName;
  
  //defaults
  if (this._time==undefined) {this._time=0}
  if (this._repeat==undefined) {this._repeat=false}
  if (this._onTrigger==undefined) {this._onTrigger=function(){}}
  
  //set other vars=====================================
  
  //repeatCount
  if ( this._repeat !== false &&
      this._repeat !== true &&
      isNaN(this._repeat) != true
      ) {
    //alert('this is a number');
    this.repeatCount = this._repeat;
  }
  
  //start
  this.start();
}

//methods & properties===================================================================
Timer.prototype.start = function(){
  //this._timer = setTimeout(this._instanceName+'.trigger()',this._time);
  this._timer = setTimeout('timer_onTriggerHandler("'+this._instanceName+'")',this._time);
  this._count++;
}
Timer.prototype.trigger = function(){
  //check for repeat
  if (this._repeat===true){
    this.start();
  }
  /*
  if (this.repeatCount) {
    if (this.repeatCount){
      this.start();
      this.repeatCount--;
    }
  }
  */
}
Timer.prototype.stop = function(){
  clearTimeout(this._timer);
}
Timer.prototype.reset = function(target){
  //check for repeat
  if(this._repeat===true){
    this.stop();
    this.start();
  }
}
