/*
    Coded By Steven Bower
    TurnWheel Designs (cc) 2009
*/

$(function() {
    // Handle arrow hovers
    $('#teaser_left a,#teaser_right a').hover(function() {
        var img = $(this).children('img');
        img.attr('src',img.attr('src').replace(/.png/,'_on.png'));
    },function() {
        var img = $(this).children('img');
        img.attr('src',img.attr('src').replace(/_on.png/,'.png'));
    });
    
    // Switch between entries
    $('#teaser_left a').click(function() {
        var current = $('#teaser .teaser_entry:visible');
        var next = current.prev().is('.teaser_entry') ? current.prev() : $('.teaser_entry:last');
        
        current.fadeOut('slow');
        next.fadeIn('slow');
        
        return false;
    });
    
    $('#teaser_right a').click(function() {
        var current = $('#teaser .teaser_entry:visible');
        var next = current.next().is('.teaser_entry') ? current.next() : $('.teaser_entry:first');
        
        current.fadeOut('slow');
        next.fadeIn('slow');
        
        return false;
    });
    
    var entries = $('.teaser_entry');
    var length = entries.length;
    
    for (var i = 0; i < length; ++i) {
        $(entries[i]).css('z-index', String(length-i)).hide();
    }
    
    $(entries[0]).show();
});