$(function() {	 
  // Here we change the code that's invoked after a slideshow transition
  // We want it to change the text on right top of the slideshow

  var firstSlide = true;
  var sliding = false;
  $.fn.cycle.updateActivePagerLink = function(pager, currSlide, clsName) {
     if(firstSlide == true){
       firstSlide = false;
     }
     else{
	sliding = true;
	setTimeout(function(){ sliding = false }, 2000);
     }
  };

  //Event handlers for the slideshow controlls
  $('#slideshowNextBtn').click(function(e) { 
	  if(sliding == false)
	    $('#slideshowNextBtnEvent').trigger('click'); 
	  e.preventDefault(); 
  }); 
  $('#slideshowPrevBtn').click(function(e) { 
	  if(sliding == false)							
	    $('#slideshowPrevBtnEvent').trigger('click'); 
	  e.preventDefault(); 
  }); 
  
  //start the slideshow!
  $('#slidesHolder').cycle({ 
	fx:     'scrollHorz', 
	speed:  2000, 
	timeout: 8000,
	pager:  '#myFakePagerAnchor',
	next:   '#slideshowNextBtnEvent', 
	prev:   '#slideshowPrevBtnEvent' 
  });
  
});
