function Product(i_iImagesNumber, i_sNextArrow)
{
	this.image = new Array();
	this.layers = new Array();
	for (var i = 0; i < i_iImagesNumber; i++)
	{
		this.layers[i] = new Layer("layer"+(i+1));
	}
	
	this.currentlyDisplayed = 0;
	this.lastImage = i_iImagesNumber-1;
	
	this.sNextArrow = i_sNextArrow;
	this.sPrevArrow = this.sNextArrow == "Right"? "Left": "Right";
	this.oNextArrow = document.getElementById("img_arrow"+this.sNextArrow);
	this.oPrevArrow = document.getElementById("img_arrow"+this.sPrevArrow);
	this.oNextArrow.disabled = false;
	this.oPrevArrow.disabled = true;
}

Product.prototype.ChangeImage = function(i_sNextPrev)
{
	if (i_sNextPrev == "next")
	{
		this.layers[this.currentlyDisplayed+1].setOpacity(0);
		this.layers[this.currentlyDisplayed+1].show();
		this.layers[this.currentlyDisplayed].fadeTo(0,25,20);
		this.layers[this.currentlyDisplayed+1].fadeTo(100,25,20);
		this.currentlyDisplayed = this.currentlyDisplayed + 1;
		
		if (this.currentlyDisplayed == this.lastImage)
			this.DisableArrow("next");
		if (this.oPrevArrow.disabled)
			this.EnableArrow("prev");
	}
	else
	{
		this.layers[this.currentlyDisplayed-1].setOpacity(0);
		this.layers[this.currentlyDisplayed-1].show();
		this.layers[this.currentlyDisplayed].fadeTo(0,25,20);
		this.layers[this.currentlyDisplayed-1].fadeTo(100,25,20);
		this.currentlyDisplayed = this.currentlyDisplayed - 1;
		
		if (this.currentlyDisplayed == 0)
			this.DisableArrow("prev");
		if (this.oNextArrow.disabled)
			this.EnableArrow("next");
	}
}

Product.prototype.DisableArrow = function(i_sNextPrev)
{
	if(i_sNextPrev == "next")
	{
		this.oNextArrow.src = "../images/general/arrow_"+this.sNextArrow+"_d.gif";
		this.oNextArrow.onmouseover = null;
		this.oNextArrow.onmouseout = null;
		this.oNextArrow.onclick = null;
		this.oNextArrow.disabled = true;
	}
	else
	{
		this.oPrevArrow.src = "../images/general/arrow_"+this.sPrevArrow+"_d.gif";
		this.oPrevArrow.onmouseover = null;
		this.oPrevArrow.onmouseout = null;
		this.oPrevArrow.onclick = null;
		this.oPrevArrow.disabled = true;
	}
}

Product.prototype.EnableArrow = function(i_sNextPrev)
{
	that = this;
	if(i_sNextPrev == "next")
	{
		this.oNextArrow.src = "../images/general/arrow_"+this.sNextArrow+"_e.gif";
		this.oNextArrow.onmouseover = Function("changeImage(this, '../images/general/arrow_"+this.sNextArrow+"_r.gif')");
		this.oNextArrow.onmouseout = Function("changeImage(this, '../images/general/arrow_"+this.sNextArrow+"_e.gif')");
		this.oNextArrow.onclick = function(){that.ChangeImage("next")};
		this.oNextArrow.disabled = false;
	}
	else
	{
		this.oPrevArrow.src = "../images/general/arrow_"+this.sPrevArrow+"_e.gif";
		this.oPrevArrow.onmouseover = Function("changeImage(this, '../images/general/arrow_"+this.sPrevArrow+"_r.gif')");
		this.oPrevArrow.onmouseout = Function("changeImage(this, '../images/general/arrow_"+this.sPrevArrow+"_e.gif')");
		this.oPrevArrow.onclick = function(){that.ChangeImage("prev")};
		this.oPrevArrow.disabled = false;
	}
}
