/**
 * Description goes here.
 * @class   ScrollingProduct
 * @author  Neal Mckinney
 * @date    13.11.2011
 * @version 0.1
**/

function ScrollingProduct(target, startY, endY) {
	this.target = target;
	this.startY = startY;
	this.endY = endY;
	this.initObjects();
	this.initEvents();
}

ScrollingProduct.prototype.toString = function() {
	return "ScrollingProduct";
}

// INITIALIZATION =======================================================================================================

ScrollingProduct.prototype.initObjects = function() {
	this.hidden = true;
	this.speed = .025;
}

ScrollingProduct.prototype.initEvents = function() {

}

// ACTIONS ==============================================================================================================

ScrollingProduct.prototype.update = function(top) {
	if (top > this.startY && top < this.endY) {
		var offset = top-this.startY;
		var destY = 25 - offset*this.speed;
		var percent = offset/500;
		this.target.setStyle("top", destY);
		this.target.setStyle("opacity", percent);
		if (this.hidden) {
			this.hidden = false;
			this.target.setStyle("display", "block");
		}
	} else {
		if (!this.hidden) {
			this.hidden = true;
			this.target.setStyle("display", "none");
		}
	}
};



// EVENTS ===============================================================================================================



