/*
Class: AnimatedElement 
extends ElementWrapper
The element will move from an initial position (y) to a destination (destY)
The index param is used by the manager to track this element's position
moveElement() sets an interval to update the element's position on screen
In order to optimize performance, X movement has been removed.
*/
var AnimatedElement = function(elem) {
	this.assignElement(elem);
	this.x = 0;
	this.y = 0;
	this.z = 0;
	this.alpha = 0;
	this.effects = [];
}

AnimatedElement.prototype = new ElementWrapper;

AnimatedElement.prototype.setX = function(x){
	this.pElement.style.left = (this.x = x) + "px";
}

AnimatedElement.prototype.setY = function(y){
	this.pElement.style.top = (this.y = y) + "px";
}

AnimatedElement.prototype.setZ = function(z){
	this.pElement.style.zIndex = (this.z = z);
}

AnimatedElement.prototype.setAlpha = function(a){
	this.alpha = a;
	setOpacity(this.pElement, (a/100));
	if(a == 0){
		this.setStyle("display", "none");	
	}
	else{
		this.setStyle("display", "block");	
	}
}

//deprecated
AnimatedElement.prototype.setYPosition = function(y){
	this.pElement.style.top = (this.y = y) + "px";
}

AnimatedElement.prototype.setYDestination = function(y, row){
	this.destY = y;
	this.setRowNumber(row);
}

/*Karmatics Stuff*/

AnimatedElement.prototype.close = function(){
	var mbContainer = document.getElementById("container");
	mbContainer.style.display = "none";
	mbContainer.innerHTML = '';
	this.isOpen = false;
	this.setRowNumber(this.row); //restore row number
}

AnimatedElement.prototype.open = function(){
	this.isOpen = true;
	var mbContainer = document.getElementById("container");
	mbContainer.style.display = "";
	this.setRowNumber(0);
}

AnimatedElement.prototype.setRowNumber = function(row){
	if(!row){
		this.pElement.firstChild.firstChild.innerHTML = "&nbsp;"; //some data has to be here to give the div some height.
		this.row = null;
	}
	else{
		this.row = row;
		this.pElement.firstChild.firstChild.innerHTML = row + "";
	}
}

