var totalSlides = 9;
var currentSlide = 1;
var contentSlides = "";


function autoScroll()
{
	//currentSlide--;
	if(currentSlide < totalSlides) {
        showNextSlide();
    }
	else if (currentSlide == totalSlides) {
        currentSlide = 1;
        updateContentHolder();

    }
}

$(document).ready(function(){
 // $("#slideshow-previous").click(showPreviousSlide);
  //$("#slideshow-next").click(showNextSlide);
  
  var totalWidth = 0;
  contentSlides = $(".slideshow-content");
  contentSlides.each(function(i){
    totalWidth += this.clientWidth;
    //totalSlides++;
  });
  $("#slideshow-holder").width(totalWidth);
  $("#slideshow-scroller").attr({scrollLeft: 0});

});

function showPreviousSlide()
{
  currentSlide--;
  updateContentHolder();

}

function showNextSlide()
{
  currentSlide++;
  updateContentHolder();


}

function updateContentHolder()
{
  var scrollAmount = 0;
  contentSlides.each(function(i){
    if(currentSlide - 1 > i) {
      scrollAmount += this.clientWidth;
    }
  });
  $("#slideshow-scroller").animate({scrollLeft: scrollAmount}, 1000);
}


setInterval('autoScroll()', 4000);

