$(function()
{


    /* HOME PHOTOS & VIDEOS UI */
    $("#latestphotosandvideos_switcher a").each(function(index)
    {
        if (index < 3) { $(this).show(); $(this).addClass("on"); }
        else { $(this).addClass("off"); }
    })
    $("#latestphotosandvideos_switcher_container .arrow_right").bind("click", function()
    {
        $("#latestphotosandvideos_switcher a.on:last").next().show().removeClass("off").addClass("on");
        $("#latestphotosandvideos_switcher a.on:first").hide().removeClass("on").addClass("off");
    });



    /* HOME MARQUEE SWITCHER */
    var rotateSpeed = 8000; // milliseconds to wait until switching marquee.
    var currentMarquee = 0; // sets the initial on-state marquee
    var numMarquee = $("#home_marquee_switcher a").length; // count of marquees
    var autoRotate; // used for rotating

    function openMarquee(clickedMarquee)
    {
        $(".home_marquee_counter_on").removeClass("home_marquee_counter_on");
        $("#home_marquee_counter a:eq(" + clickedMarquee + ")").addClass("home_marquee_counter_on");
        $(".home_marquee_on").removeClass("home_marquee_on");
        $("#home_marquee_switcher a:eq(" + clickedMarquee + ")").addClass("home_marquee_on");
        $("#home_marquee_links a").attr("href", $("#home_marquee_switcher a.home_marquee_on").attr("href"));
        $("#home_marquee_links a").attr("title", $("#home_marquee_switcher a.home_marquee_on").attr("title"));
    }

    function rotateMarquee()
    {
        currentMarquee++;
        if (currentMarquee >= numMarquee) currentMarquee = 0
        openMarquee(currentMarquee);
    }

    $("#home_marquee_overlay").mouseover(function() { clearInterval(autoRotate) }).mouseout(function() { autoRotate = setInterval(rotateMarquee, rotateSpeed) });
    $("#home_marquee_counter").mouseover(function() { clearInterval(autoRotate) }).mouseout(function() { autoRotate = setInterval(rotateMarquee, rotateSpeed) });

    $("#home_marquee_counter a").click(function()
    {
        var getIndex = ($(this).index());
        openMarquee(getIndex);
        currentMarquee = getIndex;
    });

    $("#home_marquee_counter a:first").click();

    autoRotate = setInterval(rotateMarquee, rotateSpeed);


});


