$(document).ready(function() {
    /* SIDEBAR ACCORDION */
    $('#accordian').accordion({ autoHeight: true, collapsible: true, active: 3 });
        
    /* CONTROLLING NAVIGATION TABS */    
    $('#tabs .topLevelLi').hover(function(){
		    $('#tabs .topLevelLi').attr("class", "topLevelLi");
		    $(this).attr("class", "topLevelLi current");
		},
		function(){
		    $(this).attr("class", "topLevelLi");
	});

    /* HOMEPAGE IMAGE CAROUSEL */
    if ($('#imageScrollerCarousel').length) {
        $('#imageScrollerCarousel').jcarousel({
            auto: 5,
            scroll: 1,
            wrap: "circular",
            animation: "slow",
            initCallback: myImageCarousel_initCallback,
            buttonNextHTML: null,
            buttonPrevHTML: null
        });
        $('#imageScrollerCarouselControls').removeClass('jCarouselControls');
    }    
    /* END OF CAROUSEL */

    /* GENERAL FUNCTIONALITY */
    $('a[rel*="external"]').click(function() {
        this.target = '_blank';
    });
});

function myImageCarousel_initCallback(carousel) {
        $('li#nextButton a').bind('click', function() {
            carousel.next();
            carousel.startAuto(0);
            return false;
        });

        $('li#previousButton a').bind('click', function() {
            carousel.prev();
            carousel.startAuto(0);
            return false;
        });

        carousel.clip.hover(function() {
            carousel.stopAuto();
        }, function() {
            carousel.startAuto();
        });
    };
