$(document).ready(function() {ÊÊÊÊÊ 
ÊÊÊÊÊ
ÊÊÊÊ//Execute the slideShow, set 4 seconds for each images
ÊÊÊÊslideShow(2000);
Ê
});
Ê
function slideShow(speed) {
Ê
Ê
ÊÊÊÊ//append a LI item to the UL list for displaying caption
ÊÊÊÊ$('ul.slideshow').append('<li id="slideshow-caption" class="caption"><div class="slideshow-caption-container"><h3></h3><p></p></div></li>');
Ê
ÊÊÊÊ//Set the opacity of all images to 0
ÊÊÊÊ$('ul.slideshow li').css({opacity: 0.0});
ÊÊÊÊÊ
ÊÊÊÊ//Get the first image and display it (set it to full opacity)
ÊÊÊÊ$('ul.slideshow li:first').css({opacity: 1.0});
ÊÊÊÊÊ
ÊÊÊÊ//Get the caption of the first image from REL attribute and display it
ÊÊÊÊ$('#slideshow-caption h3').html($('ul.slideshow a:first').find('img').attr('title'));
ÊÊÊÊ$('#slideshow-caption p').html($('ul.slideshow a:first').find('img').attr('alt'));
ÊÊÊÊÊÊÊÊÊ
ÊÊÊÊ//Display the caption
ÊÊÊÊ$('#slideshow-caption').css({opacity: 0.7, bottom:0});
ÊÊÊÊÊ
ÊÊÊÊ//Call the gallery function to run the slideshowÊÊÊ 
ÊÊÊÊvar timer = setInterval('gallery()',speed);
ÊÊÊÊÊ
ÊÊÊÊ//pause the slideshow on mouse over
ÊÊÊÊ$('ul.slideshow').hover(
ÊÊÊÊÊÊÊÊfunction () {
ÊÊÊÊÊÊÊÊÊÊÊÊclearInterval(timer);ÊÊ 
ÊÊÊÊÊÊÊÊ},Ê 
ÊÊÊÊÊÊÊÊfunction () {
ÊÊÊÊÊÊÊÊÊÊÊÊtimer = setInterval('gallery()',speed);ÊÊÊÊÊÊÊÊ 
ÊÊÊÊÊÊÊÊ}
ÊÊÊÊ);
ÊÊÊÊÊ
}
Ê
function gallery() {
Ê
Ê
ÊÊÊÊ//if no IMGs have the show class, grab the first image
ÊÊÊÊvar current = ($('ul.slideshow li.show')?Ê $('ul.slideshow li.show') : $('#ul.slideshow li:first'));
Ê
ÊÊÊÊ//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().attr('id') == 'slideshow-caption')? $('ul.slideshow li:first') :current.next()) : $('ul.slideshow li:first'));
ÊÊÊÊÊÊÊÊÊ
ÊÊÊÊ//Get next image caption
ÊÊÊÊvar title = next.find('img').attr('title'); 
ÊÊÊÊvar desc = next.find('img').attr('alt');ÊÊÊ 
ÊÊÊÊÊÊÊÊÊ
ÊÊÊÊ//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 caption first, and then set and display the caption
ÊÊÊÊ$('#slideshow-caption').slideToggle(300, function () { 
ÊÊÊÊÊÊÊÊ$('#slideshow-caption h3').html(title); 
ÊÊÊÊÊÊÊÊ$('#slideshow-caption p').html(desc); 
ÊÊÊÊÊÊÊÊ$('#slideshow-caption').slideToggle(500); 
ÊÊÊÊ}); 
Ê
ÊÊÊÊ//Hide the current image
ÊÊÊÊcurrent.animate({opacity: 0.0}, 1000).removeClass('show');
Ê
}
