$(setupSlideshow);

function setupSlideshow()
{
    if (!document.getElementById('slideshow'))
        return false;
    
    var theContainer = $('#slideshow'),
        theDL = theContainer.children('dl'),
        theDTs = theDL.children('dt'),
        theDDs = theDL.children('dd').not('dd+dd')
    ;
    
    theDDs.not(':first').hide();
    
    theDTs
        .hover(
            function () {
                $(this).css('cursor', 'pointer');
            },
            function () {
                $(this).css('cursor', 'default');
            }
        )
        .click(function () {

            clearTimeout(window.FlipStudios.slideshow_timer);
            
            var self = $(this),
                displayDD = self.next(),
                oldDD = theDDs.filter(':visible');
            
            displayDD
                .css({
                    'z-index':1//,'opacity':0
                })
                .fadeIn(
                    600,
                    function () {
                        oldDD.hide();
                        $(this).show().css({'z-index':0, 'opacity': 1});
                    }
                );

        });
    
    window.FlipStudios = {slideshow_timer : setTimeout('nextSlide()', 5000) };
}
function nextSlide()
{
    var nextDT = $('#slideshow dd:visible').next('dt');
    if (nextDT.length < 1)
        nextDT = $('#slideshow dt:first');
    
    nextDT.click();
    
    window.FlipStudios = {slideshow_timer : setTimeout('nextSlide()', 5500) };
}
