// Last edited on 03/08/11 by Spyke
// Added the tabs and photo gallery

$(document).ready(function () {
    $("a[href$=pdf]").addClass("pdf");

    function megaHoverOver() {
        $(this).find(".dropDown").stop().fadeTo('fast', 1).show();
        //Calculate width of all ul's
        (function ($) {
            jQuery.fn.calcSubWidth = function () {
                rowWidth = 0;
                //Calculate row
                $(this).find("ul").each(function () {
                    rowWidth += $(this).width();
                });
            };
        })(jQuery);
        if ($(this).find(".row").length > 0) { //If row exists...
            var biggestRow = 0;
            //Calculate each row
            $(this).find(".row").each(function () {
                $(this).calcSubWidth();
                //Find biggest row
                if (rowWidth > biggestRow) {
                    biggestRow = rowWidth;
                }
            });
            //Set width
            $(this).find(".dropDown").css({ 'width': biggestRow });
            $(this).find(".row:last").css({ 'margin': '0' });
        } else { //If row does not exist...			
            $(this).calcSubWidth();
            //Set Width
            $(this).find(".dropDown").css({ 'width': rowWidth });
        }
    }
    function megaHoverOut() {
        $(this).find(".dropDown").stop().fadeTo('fast', 0, function () {
            $(this).hide();
        });
    }
    var config = {
        sensitivity: 2, // number = sensitivity threshold (must be 1 or higher)    
        interval: 100, // number = milliseconds for onMouseOver polling interval    
        over: megaHoverOver, // function = onMouseOver callback (REQUIRED)    
        timeout: 500, // number = milliseconds delay before onMouseOut    
        out: megaHoverOut // function = onMouseOut callback (REQUIRED)    
    };
    $("ul#audience li .dropDown").css({ 'display': 'none' });
    $("ul#audience li .dropDown").css({ 'opacity': '0' });
    $("ul#audience li").hoverIntent(config);
});


// Start tabs
$(document).ready(function () {
    //Default Action
    $(".tab_content").hide(); //Hide all content
    $("ul.tabs li:first").addClass("active").show(); //Activate first tab
    $(".tab_content:first").show(); //Show first tab content
    //On Click Event
    $("ul.tabs li").click(function () {
        $("ul.tabs li").removeClass("active"); //Remove any "active" class
        $(this).addClass("active"); //Add "active" class to selected tab
        $(".tab_content").hide(); //Hide all tab content
        var activeTab = $(this).find("a").attr("href"); //Find the rel attribute value to identify the active tab + content
        $(activeTab).fadeIn(); //Fade in the active content
        return false;
    });
});
// End tabs


// Start photo gallery
$(document).ready(function () {
    $('#photos').galleryView({
        panel_width: 694,
        panel_height: 422,
        frame_width: 85,
        frame_height: 55,
        frame_margin: 10,
        filmstrip_size: 6,
        transition_speed: 1200,
        transition_interval: 8000,
        border: 'none',
        easing: 'easeInOutBack',
        pause_on_hover: true,
        fade_panels: true,
        show_captions: false,
        easing: 'swing',
        nav_theme: 'slideshow',
        overlay_height: 50,
        filmstrip_position: 'bottom',
        overlay_position: 'bottom'
    });
});
// End photo gallery
