function Carousel(carouselName, idNum, slides, visibleImageCount, imageWidth, imageHeight, shiftStep, titleVisibility)
{
    this.pageIndex = 0;
    this.move = shiftStep;
    this.slideNum = visibleImageCount;
    
    this.carouselName = carouselName;
    this.idNum = idNum;
    this.slides = slides;
    this.carouselElement = document.getElementById("carousel" + idNum);
    
    this.imgWidth = imageWidth;
    this.imgHeight = imageHeight;
    this.titleVisible = titleVisibility;

    if (this.slideNum > this.slides.length)
    {
		document.getElementById("linkNext" + this.idNum).style.display = "none";
		document.getElementById("linkPrev" + this.idNum).style.display = "none";
    }
}

Carousel.prototype.getSlides = function(direction)
{
    if (direction == "next") this.pageIndex++;
    if (direction == "prev") this.pageIndex--;
	
    var startIndex = this.pageIndex * this.move;
    if (startIndex < 0) startIndex = this.slides.length + startIndex;
	var endIndex = startIndex + this.slideNum - 1;
	
    var newPage = "";
	

    for (var x = startIndex; x <= endIndex; x++)
    {
		var index = x;
		if (x > this.slides.length - 1) index = x % this.slides.length;
        
		var imgStyle = "";
		if (this.imgWidth != 0 || this.imgHeight !=0) 
		{
			var imgWidthStyle = "";
			var imgHeightStyle = "";
			
			if (this.imgWidth != 0) imgWidthStyle = "width:" + this.imgWidth + "px;";
			if (this.imgHeight != 0) imgHeightStyle = "height:" + this.imgHeight + "px;";
			imgStyle = " style=\"" + imgWidthStyle + imgHeightStyle + "\" ";
		}
    
        newPage += "<div class=\"carusel_item\">";
        newPage += "<a href=\"" + this.slides[index][0] + "\">";
        newPage += "<img src=\"" + this.slides[index][1] + "\" alt=\"" + this.slides[index][2] + "\"" + imgStyle + " />";
        newPage += "</a>";
        if (this.titleVisible == true)
        {
        newPage += "<div class=\"carusel_text\">";
        newPage += "<a href=\"" + this.slides[index][0] + "\">";
        newPage += this.slides[index][2];
        newPage += "</a>";
        newPage += "</div>";
        }
        newPage += "</div>";
    }
   
    document.getElementById("slideWrapper" + this.idNum).innerHTML = newPage;
}

