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

componentMove = function(name)
{
  this.__componentImage = __componentImage;
  this.__componentImage(name);
};

componentMove.prototype = new __componentImage();
componentMove.prototype.type = "componentMove";

componentMove.prototype.onStep = function(obj)
{
	if (this.step == PageInterface.GetValue("stepIndex")) this.moveElement();
};

componentMove.prototype.onShow = function(obj)
{
	this.moveElement();
};

componentMove.prototype.moveElement = function(obj)
{
	this.setVisible(false);

	try {
		var obj = eval("pc."+this.obj_name);
		if (obj) {
			obj.moveBy = this.id;
			obj.sendEventEndMove = this.sendEventEndMove;
			obj.animationMoveTo(this.x, this.y, this.actTime*1000);
		};
	} catch(e) {
		if (typeof(page) != "undefined" && page.state == psView) showMessage(this.id + ": Nie wskazano komponentu do przyciągania."); //pg2 - if...
	};
};

componentMove.prototype.sendEventEndMove = function()
{
	try {
		var obj = eval("pc." + this.moveBy);
		if (obj) {
			obj.invokeEvent('EndPull');
		};
	} catch(e) {
		if (typeof(page) != "undefined" && page.state == psView) alert(this.id + '.sendEventEndMove() eval execution error\nMessage:\n' + e.message); //pg2
	};
};

componentMove.prototype.refreshElement = function()
{
	try {
		var obj = eval("pc." + this.obj_name);
		if (obj) {
			if (obj.anim && obj.anim.animated) { //pg2
				obj.animationStop();
				obj.x = obj.beginX;
				obj.y = obj.beginY;
			};
		};
	} catch(e) {
		if (typeof(page) != "undefined" && page.state == psView) alert(this.id + '.refreshElement() eval execution error\nMessage:\n' + e.message); //pg2
	};
};

componentMove.prototype.isReady = function()
{
	return true;
};
