history.navigationMode = 'compatible'; 
$(document).ready(function() {

    var runAmend = true;

    $('.sidebuttons').hover(function() {
        runAmend = false;
    }, function() {
        runAmend = true;
    });

    setRollover();

    setInterval(function() {
        if (runAmend) {
            var nextitem = $(".sidebuttons li.active").next();
            $('.sidebuttons li').removeClass("active");
            if (nextitem.length > 0) {
                nextitem.addClass("active");
            }
            else {
                $('.sidebuttons li:first-child').addClass("active");
            }
            amendGraphic($('.sidebuttons li.active img'));
            //setRollover();
        }
    }, 3000);
    
    $.ajax({
      url: "/facebook_feed.asp",
      success: function(feedoutput){
        $("#rssFeed").html(feedoutput);
      }
    });

});

function setRollover() {

    $('.sidebuttons li img').hover(function() {
        $('.sidebuttons li').removeClass("active");
        $(this).parent().parent().addClass("active");
        amendGraphic($('.sidebuttons li.active img'))
    }); 
}

function amendGraphic(theItem) {

    $('.sidebuttons li img').each(function() {
        $(this).attr('src', $(this).attr('src').replace('_button_on.jpg', '_button_off.jpg'));
    });

    $('.home_main').html(theItem.parent().parent().html().replace('_button_off.jpg', '_large.jpg'));

    $(".sidebuttons li.active img").attr('src', theItem.attr('src').replace('_button_off.jpg', '_button_on.jpg'));
    
}


