function ProdSlide(sObjName, sLayerName, iProdCount) {
	this.DEFAULT_SLIDE_INCREMENT = (typeof(window.PS_SLIDE_INCREMENT) != "undefined")? window.PS_SLIDE_INCREMENT : 3;
	this.DEFAULT_SLIDE_TIMEOUT = (typeof(window.PS_SLIDE_TIMEOUT) != "undefined")? window.PS_SLIDE_TIMEOUT : 15;
	this.DEFAULT_PRODUCT_WIDTH = (typeof(window.PS_PRODUCT_WIDTH) != "undefined")? window.PS_PRODUCT_WIDTH : 163;
	this.DEFAULT_PRODUCTS_SHOWN = (typeof(window.PS_PRODUCTS_SHOWN) != "undefined")? window.PS_PRODUCTS_SHOWN : 4;
	this.DEFAULT_VIEW_WIDTH = (typeof(window.PS_VIEW_WIDTH) != "undefined")? window.PS_VIEW_WIDTH : (this.DEFAULT_PRODUCT_WIDTH * this.DEFAULT_PRODUCTS_SHOWN);
	
	this.name = sObjName;
	this.slideIncrement = this.DEFAULT_SLIDE_INCREMENT;
	this.slideTimeout = this.DEFAULT_SLIDE_TIMEOUT;
	this.prodWidth = this.DEFAULT_PRODUCT_WIDTH;
	this.viewWidth = this.DEFAULT_VIEW_WIDTH;
	this.layerName = sLayerName;
	this.prodCount = iProdCount;
	this.canSlideRight = (this.prodCount > this.DEFAULT_PRODUCTS_SHOWN);
	this.canSlideLeft = false;
	
	this.init();
}
ProdSlide.prototype.init = function() {
	eval('this.layer = new elcLayer(\'' + this.layerName + '\');');
	this.layer.defaultX = this.layer.x;
	this.layer.w = this.prodCount * this.prodWidth;
}

ProdSlide.prototype.setLeftArrow = function(oImg) {
	this.setArrow(oImg,'left');
	if (this.canSlideLeft) {
		this.leftArrow.setOn();
	}			
}

ProdSlide.prototype.setRightArrow = function(oImg) {
	this.setArrow(oImg,'right');
	if (this.canSlideRight) {
		this.rightArrow.setOn();
	}
}

ProdSlide.prototype.setArrow = function(oImg, sDir) {
	eval('this.' + sDir + 'Arrow = new elcImage(oImg,null,true);');
}

ProdSlide.prototype.slide = function(sDir, iFinalX) {
	if (this.isSliding) {
		window.clearInterval(this.slideTimer);
	}
	if (sDir && (sDir == 'left') && this.canSlideLeft) {
		this.isSliding = true;
		if (this.leftArrow) {
			this.leftArrow.setOver();
			this.leftArrow.isActive = true;
		}
		if (typeof(iFinalX) != "undefined") {
			this.slideTimer = window.setInterval(this.name + '._slideLoop(' + this.slideIncrement + ',' + iFinalX + ',true)',this.slideTimeout);
		} else {
			this.slideTimer = window.setInterval(this.name + '._slideLoop(' + this.slideIncrement + ')',this.slideTimeout);
		}
	} else if (sDir && (sDir == 'right') && this.canSlideRight) {
		this.isSliding = true;
		if (this.rightArrow) {
			this.rightArrow.setOver();
			this.rightArrow.isActive = true;
		}
		if (typeof(iFinalX) != "undefined") {
			this.slideTimer = window.setInterval(this.name + '._slideLoop(' + -this.slideIncrement + ',' + iFinalX + ',true)',this.slideTimeout);
		} else {
			this.slideTimer = window.setInterval(this.name + '._slideLoop(' + -this.slideIncrement + ')',this.slideTimeout);
		}
	}
}

ProdSlide.prototype.stop = function() {
	if (this.isSliding) {
		this.isSliding = false;
		if (this.leftArrow) {
			this.leftArrow.isActive = null;
		}
		if (this.rightArrow) {
			this.rightArrow.isActive = null;
		}
		window.clearInterval(this.slideTimer);
		var stopProd = Math.floor((this.layer.defaultX - this.layer.x) / this.prodWidth);
		if ((((this.layer.defaultX - this.layer.x) % this.prodWidth) / this.prodWidth) > .5) {
			stopProd++;
		}
		this.moveTo(this.layer.defaultX - (stopProd * this.prodWidth));
		this._setArrows();
	}
}

ProdSlide.prototype.moveTo = function(finalX) {
	if (this.isSliding) {
		this.isSliding = false;
		window.clearInterval(this.slideTimer);
	}
	if (this.layer.x < finalX) {
		this.isSliding = true;
		this.slideTimer = window.setInterval(this.name + '._slideLoop(' + this.slideIncrement + ',' + finalX + ')',this.slideTimeout);
	} else if (this.layer.x > finalX) {
		this.isSliding = true;
		this.slideTimer = window.setInterval(this.name + '._slideLoop(' + -this.slideIncrement + ',' + finalX + ')',this.slideTimeout);
	}
}

ProdSlide.prototype.jog = function(iDistance) {
	var dir = (iDistance > 0)? "right" : "left";
	this.slide(dir,(this.layer.x - iDistance));
}

ProdSlide.prototype._slideLoop = function(iSlideIncrement, finalX, bReset) {
	if (typeof(finalX) != "undefined") {
		var willPassFinalX = ((this.layer.x > finalX) && ((this.layer.x + iSlideIncrement) <= finalX)) || ((this.layer.x < finalX) && ((this.layer.x + iSlideIncrement) >= finalX))
		if (willPassFinalX) {
			window.clearInterval(this.slideTimer);
			if (typeof(bReset) != "undefined") {
				this.layer.moveTo(finalX,this.layer.y);
				this.moveTo(this.layer.defaultX);
			} else {
				this.layer.moveTo(finalX,this.layer.y);
			}
			this.layer.moveTo(finalX,this.layer.y);
			this.isSliding = false;
			if (this.leftArrow) {
				this.leftArrow.isActive = null;
			}
			if (this.rightArrow) {
				this.rightArrow.isActive = null;
			}
		} else {
			this._slideLoop(iSlideIncrement);
		}
	} else {
		var willMaxLeft = ((this.layer.x + iSlideIncrement) > this.layer.defaultX);
		var willMaxRight = (this.layer.x + this.layer.w + iSlideIncrement) < (this.viewWidth + this.layer.defaultX);
		if (willMaxLeft || willMaxRight) {
			if (willMaxLeft) {
				this.layer.moveTo(this.layer.defaultX,this.layer.y);
				this.isSliding = false;
				if (this.leftArrow) {
					this.leftArrow.isActive = null;
				}
				if (this.rightArrow) {
					this.rightArrow.isActive = null;
				}
				window.clearInterval(this.slideTimer);
			}
			if (willMaxRight) {
				this.layer.moveTo((this.viewWidth + this.layer.defaultX - this.layer.w),this.layer.y);
				this.isSliding = false;
				if (this.leftArrow) {
					this.leftArrow.isActive = null;
				}
				if (this.rightArrow) {
					this.rightArrow.isActive = null;
				}
				window.clearInterval(this.slideTimer);
			}
		} else {
			this.layer.moveBy(iSlideIncrement,0);
		}
	}
		
	if (this.layer.x < this.layer.defaultX) {
		this.canSlideLeft = true;
	} else {
		this.canSlideLeft = false;
	}
	if ((this.layer.x + this.layer.w) > (this.viewWidth + this.layer.defaultX)) {
		this.canSlideRight = true;
	} else {
		this.canSlideRight = false;
	}
	this._setArrows();
}

ProdSlide.prototype._setArrows = function() {
	if (this.leftArrow && (!this.leftArrow.isActive)) {
		if (this.canSlideLeft) {
			this.leftArrow.setOn();
		} else {
			this.leftArrow.setOff();
		}
	}
	if (this.rightArrow && (!this.rightArrow.isActive)) {
		if (this.canSlideRight) {
			this.rightArrow.setOn();
		} else {
			this.rightArrow.setOff();
		}
	}
}