/**
 * Portfolio E-NOISE 2010
 */
$(document).ready(function() {
    // attach slider behaviour to portfolio items
    for (var i=1; i<18; i++) {
        $('#slider' + i).easySlider({
            continuous: true,
            nextId:     'slider' + i + 'nextBtn',
            prevId:     'slider' + i + 'prevBtn'
        });
    }

    var topNavigation = $('.navigation');
    
    topNavigation.click(function(e) {
        // Prevent browser from going to anchor in dom
        e.preventDefault();

        var content = $('#content');

        // Fade out the portfolio items (projects) before we switch slides
        content.fadeOut();

        // Switch slides
        var newSelection = $(this).attr('href');
        $('.content-item').not(newSelection).slideUp();
        $(newSelection).slideDown();

        // Mark current menu item as active
        topNavigation.removeClass('current');
        $(this).addClass('current');

        // Fade the portfolio back in
        content.fadeIn();
    });

    // Select default link in top menu on page load
    $('.topmenu ul li a[href=#websites]').click();

    // Make external links open in new window/tab
    $('a[href^=http]').attr('target', '_blank');
});

