// Profiles
$(function () {
    $('#profiles li:first').addClass('active_profile');
    var mouseoutHtml = $('#profiles li:first .content').html();
    $('#selected-content').html(mouseoutHtml);
    $('#profiles li').mouseover(function () {
        $('#selected-content').html($('.content', this).html());
    }).mouseout(function () {
        $('#selected-content').html(mouseoutHtml);
    }).click(function () {
        $('#profiles li.active_profile').removeClass();
        $(this).addClass('active_profile');
        mouseoutHtml = $('.content', this).html();
    });

});

// Latest jobs scroller
$(function () {
    var viewportHeight = 0;
    $("#latest_jobs li").each(function () {
        var itemHeight = $(this).height();
        if (itemHeight > viewportHeight) {
            viewportHeight = itemHeight;
        }
    });
    $("#latest_jobs .marquee").css({ height: viewportHeight+"px" });
    $("#latest_jobs .marquee li").css({ height: (viewportHeight*2)+"px" });
    $("#latest_jobs .marquee ul").css({ top: viewportHeight+"px" });

    var marqueeHeight = $("#latest_jobs .marquee ul").height();
    var top = viewportHeight;
    var running = true;

    // Animate the marquee
    setInterval(function () {
        if (!running) { return; }
        top = (top <= (-marqueeHeight + viewportHeight)) ?
            viewportHeight : top - 1;
        var items = $("#latest_jobs .marquee ul").each(function () {
            $(this).css({ top: top + 'px', left: 0 });
        });
    }, 1000 / 24);

    // Pause the marquee on mouseover
    $("#latest_jobs .marquee").mouseover(function () {
        running = false;
    }).mouseout(function () {
        running = true;
    });
});

