$(document).ready(function() {        
    slideShow($('#slideshow'));
  
}); 

function slideShow(gal) { 

    $('a', gal).css({opacity: 0.0});  
      
    $('a:first', gal).css({opacity: 1.0});  
      
    setInterval(function(){gallery(gal)},4500);  
      
}  
function gallery(gal) {  
	  
    //if no IMGs have the show class, grab the first image  
    var current = ($('a.show',gal)?  $('a.show', gal) : $('a:first', gal));  
  
    //Get next image, if it reached the end of the slideshow, rotate it back to the first image  
    var next = ((current.next().length) ? ((current.next().hasClass('end'))? $('a:first', gal) :current.next()) : $('a:first', gal));    
      
    //Set the fade in effect for the next image, show class has higher z-index  
    next.css({opacity: 0.0})  
    .addClass('show')  
    .animate({opacity: 1.0}, 1000);  
  
    //Hide the current image  
    current.animate({opacity: 0.0}, 1000)  
    .removeClass('show');  
}

