/* 
    Javscript Document
    ------------ 
    Creation date:  03/03/2008
    Last edit:      06/03/2008
    Company name:   Onlime s.n.c
*/


function Attender(stato,step){
  this.step = step || 0;               // Traccia lo step lanciato
  this.nextstep = null;                // Traccia lo step successivo da lanciare
  this.stato = stato || false;         // Traccia lo stato dello step
  this.timer = 0;                      // (Internal use)
  var self;                            // (Internal use)
  
  this.run_attender = function ()
  {  
    this.timer = setInterval(function(){self.check()}, 100);
  },
    
  this.check = function()
  {
    (!this.stato) ? clearInterval(this.timer):null;
  },  
    
  this.start_attender = function()
  {
    self = this;
    this.stato=true;
    this.run_attender();
  },
  
  this.stop_attender = function () 
  {
    this.stato = false;
    this.step = (this.nextstep != null) ? (this.nextstep) : (this.step+1);
  },
    
  this.get_stato = function () 
  {
    return (this.stato);
  },
  
  this.set_step = function (val) 
  {
    this.step = val;
  },
    
  this.get_step = function () 
  {
    return (this.step);
  }
  
  this.set_nextstep = function (val) 
  {
    this.nextstep = val;
  },
    
  this.get_nextstep = function () 
  {
    return (this.nextstep);
  }    
}

