/* Create a namespace */
var UnisysV2 = {};

//The left rail navigation menu (top section)
UnisysV2.enableCollapsibleNavigationMenu = function() {
    //menu level variables
    var selection = null;
    var last      = 0;
    var delay     = 250;
    $("ul.collapsible-navigation-menu li.head").css("backgroundColor", "#EEE"); //This needs to be set for the jquery.color module.
    $('ul.collapsible-navigation-menu li.head').each(function(){
        //item level variables
        var item    = $(this);
        var heading = $('> a', this);
        var list    = $('ul', this);
        var timeout;

        list.hide()
        item.hover(
            function() {
                var openMenu = function() {
                    var now = new Date().getTime();
                    if ( (now - last) > (delay * 3) ) {
                        selection = item;
                        window.clearInterval(timeout);
                        item.animate({backgroundColor:"#CCC"}, delay, function(){
                            if ( selection == item ) {
                                last = now;
                                heading.addClass("open");
                                list.slideDown(delay);
                            }
                        });
                    }
                }
                timeout = window.setInterval(function() {openMenu()}, 5);
            },
            function() {
                selection = null;
                window.clearInterval(timeout);
                item.animate({backgroundColor:"#EEE"}, delay, function(){
                    list.slideUp(delay);
                });
                heading.removeClass("open");
            }
        );
    });
};

//Left column menu, bottom section (top news, case studies, etc)
// set up the form on 'unisys around the world' part of about unisys section
UnisysV2.removeHideStyles = function(id) {
    if (id) {
        $(id).remove();
    } else {
        $('style.loading-styles').remove();
    }
};
