var totalSlides = 0;
var currentSlide = 1;
var contentSlides = "";
var slideDuration = 3000;

$(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);
});



function showPreviousSlide()
{
  
  if(currentSlide == 1) { currentSlide = totalSlides; } else { currentSlide--; }
  updateContentHolder();
  int=window.clearInterval(int);

  //updateButtons();
}

function showNextSlide()
{
  
  if(currentSlide == totalSlides) { currentSlide = 1; } else { currentSlide++; }
  updateContentHolder();
  int=window.clearInterval(int);

  //updateButtons();
  
}

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

/*
function updateButtons()
{

  if(currentSlide < totalSlides) {
    $("#slideshow-next").show();
  } else {
    $("#slideshow-next").show();
  }
  if(currentSlide > 1) {
    $("#slideshow-previous").show();
  } else {
    $("#slideshow-previous").show();
  }

}
*/

var int=self.setInterval("showNextSlide()", slideDuration);




