/*
 * Copyright (C) 1995-2011 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) {
		showMessage(this.id + ": Nie wskazano komponentu do przyciągania.");
	};
};

componentMove.prototype.sendEventEndMove = function()
{
	var obj = eval("pc."+this.moveBy);
	if (obj) {
		obj.invokeEvent('EndPull');
	}
}

componentMove.prototype.refreshElement = function()
{
	var obj = eval("pc."+this.obj_name);
	if (obj) {
		if (obj.anim.animated) { //pg2
			obj.animationStop();
			obj.x = obj.beginX;
			obj.y = obj.beginY;
		}
	}
}

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