﻿//Set of functions for the drop down menu's
//Dependancies: Jquery and jquery.hoverIntent.minified.js

function onHover() {
    $('.section').css({ 'z-index': -1 });
    $('.toptabs .ui-tabs-nav').css({ 'z-index': -1 });
    $('.navBar-sub').width($(this).parent().outerWidth(false));

    var parentSelector = '.li' + $(this).attr('class');
    var navBarSelector = parentSelector + ' .navBar-sub';
    //7 is the width of the right image; 15 is the combined width of the corner images
    $(parentSelector + ' .navBar-sub_bottom').width(($(navBarSelector).outerWidth(false) + 7) - 15);

    //8 is the height of the bottom image; 15 is the combined height of the corner images
    $(parentSelector + ' .navBar-sub_right').height(($(navBarSelector).outerHeight(false) + 8) - 15);

    $(parentSelector + ' .navBar-sub_right').css('left', $(navBarSelector).width() + "px");
    $(parentSelector + ' .navBar-sub_bottom-right').css('left', $(navBarSelector).width() + "px");
    $(parentSelector + ' .navBar-sub_top-right').css('left', $(navBarSelector).width() + "px");

    //34 height of the 1st level menu item
    $(parentSelector + ' .navBar-sub_bottom-left').css('top', ($(navBarSelector).outerHeight(false) + 34) + "px");
    $(parentSelector + ' .navBar-sub_bottom').css('top', ($(navBarSelector).outerHeight(false) + 34) + "px");
    $(parentSelector + ' .navBar-sub_bottom-right').css('top', ($(navBarSelector).outerHeight(false) + 34) + "px");

    $(parentSelector + ' .navBar-sub_shadow').addClass("navBar-sub_shadow_ie6");
};

function unHover() {
    $('.toptabs .ui-tabs-nav').css({ 'z-index': 1 });
    $('.section').css({ 'z-index': 1 });
};

$(document).ready(function() {

    var sensitivity = 2; // number = sensitivity threshold (must be 1 or higher)
    var interval = 200; // number = milliseconds for onMouseOver polling interval   
    var timeout = 200; // number = milliseconds delay before onMouseOut  
    
    var rolloverconfig = {
        sensitivity: sensitivity, 
        interval: interval,  
        over: function() { $(this).addClass("hovering"); },
        timeout: timeout,   
        out: function() { $(this).removeClass("hovering"); }
    };

    var config = {
        sensitivity: sensitivity,
        interval: interval,
        over: onHover,
        timeout: timeout,
        out: unHover
    };

    $("#navigationBar > ul > li").hoverIntent(rolloverconfig);
    $('.partner, .about, .navBar-sub').hoverIntent(config);
});
