/*** 
    Simple jQuery Slideshow Script
    Released by Jon Raasch (jonraasch.com) under FreeBSD license: free to use or modify, not responsible for anything, etc.  Please link out to me if you like it :)
***/

function slideSwitch(prev) {
    var $active = $('#home-showcases a.active');
    
    if ( $active.length == 0 ) $active = $('#home-showcases a:last');
    
    var $next =  $active.next().length ? $active.next() : $('#home-showcases a:first');
    
    // disable too-fast clicking
    $("#home-showcase-arrow").removeClass("home-showcase-next");
    
    $active.addClass('last-active');
    
    $next.css({opacity: 0.0})
        .addClass('active')
        .animate({opacity: 1.0}, 1000, function() {
            $active.removeClass('active last-active');
            // reenable clicking
            $("#home-showcase-arrow").addClass("home-showcase-next");
        });
}

$(function() {
    
    slideSwitch();
    
    // flip the switch
    var refreshIntervalId = setInterval( "slideSwitch()", 5000 );
    
    // set the controls
    $("#home-showcase .home-showcase-next").live('click', function() {
        clearInterval(refreshIntervalId);
        slideSwitch();
    });
    
});


