/*
 * Copyright (C) 1995-2011 by 4system Polska Sp. z o.o.
 * All Rights Reserved. v4
 */

componentTimer = function(name)
{
  //inherited
  this.componentElement = componentElement;
  this.componentElement(name);
  
  this.iTimerID = null;
};

componentTimer.prototype = new componentElement;
componentTimer.prototype.type = "componentTimer";

componentTimer.prototype._setHTMLDef = function(valStr)
{
	if (PageInterface.GetValue("state") == psDesigning) {
	    var t = '<img src="'+ resourcesURL + this.src +'" />';
	    this.setHTML( t );
	}else{
		this.noDisplay();
	};
}

componentTimer.prototype.onCreate = function(obj)
{
	this._setHTMLDef();
};

componentTimer.prototype.show = function()
{
	this.run();
};

componentTimer.prototype.run = function() 
{
	if (this.iTimerID == null && (eval(this.visibleIf) || this.visibleIf == '')) {
		this.iTimerID = window.setTimeout('pc.'+this.id+'.stop(); pc.'+this.id+'.invokeEvent("Timer");', this.offsetTime);
	};
};

componentTimer.prototype.hide = function()
{
	this.stop();
}

componentTimer.prototype.stop = function()
{
	if (this.iTimerID != null) {
		window.clearTimeout(this.iTimerID);
		this.iTimerID = null;
	}
};

componentTimer.prototype.onRemove = function() {
	this.stop();
};

componentTimer.prototype.actionRun = function() {
	this.run();
};

componentTimer.prototype.actionStop = function() {
	this.stop();
};

componentTimer.prototype.onFree = function() {
	if (this.iTimerID != null) 
		window.clearTimeout(this.iTimerID);
};

/********************************************************************/
