/*
 * Copyright (C) 1995-2014 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() 
{
	try {
		if (this.iTimerID == null && (eval(this.visibleIf) || this.visibleIf == '')) {
			this.iTimerID = window.setTimeout('pc.'+this.id+'.stop(); pc.'+this.id+'.invokeEvent("Timer");', this.offsetTime);
		};
	} catch(e) {
		if (typeof(page) != "undefined" && page.state == psView) alert(this.id + '.run() eval execution error\nMessage:\n' + e.message); //pg2
	};
};

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.stop(); //pg2-axa_af
	this.run();
};

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

componentTimer.prototype.onFree = function() {
	this.stop(); //pg2
};
