/* Main JS for Boyd Yung Motorbikes 
   Author Timo Rautiainen
   The Working Party 2011 */
   
$(document).ready(function () {
    $('#front-fader').css({
        'overflow' : 'hidden'
    });
    $('#front-fader li').each(function(i) {
        $(this).css({
            'position' : 'absolute',
            'left' : 0,
            'top' : 0,
            'width' : '840px'
        });
        if (i == 0) {
            $(this).css({
                'zIndex' : 1
            });
        }
    });
    var active = 0;
    
    //Delay the first slide change by 5 seconds
    var fader = setTimeout(function() {
        setInterval(function() {
             $('#front-fader li').eq(active).fadeOut(1000, function() {
                if ((active + 1) == $('#front-fader li').size()) {
                    active = 0;
                 } else { active++; }
                 $('#front-fader li').eq(active).fadeIn(1000);
             });
        }, 5000)}, 5000);
});
