﻿$(document).ready(function () {

    // ************* Start Jquery For TopNavPushDown Menu **************************

    //this part deals with the top nav push down menu for EMEA Language

    $('#tabMenu_EMEA > li > a[data-divToShowOnClick]').click(function () {
        var current = $(this);

        //remove the selected class from all LI    
        $('#tabMenu_EMEA > li').removeClass('topNavSelected');

        //Reassign the LI
        current.parent().addClass('topNavSelected');

        //Hide all the DIV in .boxBody
        $('.boxBody div').slideUp("slow", "swing");

        $('#' + current.attr('data-divToShowOnClick')).slideDown("slow", "swing");
    });


    // this part deals with the top nav push down menu for US language
    $('#tabMenu_US > li > a[data-divToShowOnClick]').click(function () {
        var current = $(this);

        //remove the selected class from all LI    
        $('#tabMenu_US > li').removeClass('topNavSelected');

        //Reassign the LI
        current.parent().addClass('topNavSelected');

        //Hide all the DIV in .boxBody
        $('.boxBody div').slideUp("slow", "swing");

        $('#' + current.attr('data-divToShowOnClick')).slideDown("slow", "swing");
    });

    //For EMEA Language
    $('#tabMenu_EMEA > li > a[data-divToClickOnClick]').click(function () {
        window.location = $('#' + $(this).attr('data-divToClickOnClick') + ' a:first').attr('href');
    });

    //For US Language
    $('#tabMenu_US > li > a[data-divToClickOnClick]').click(function () {
        window.location = $('#' + $(this).attr('data-divToClickOnClick') + ' a:first').attr('href');
    });


    $('a.close').click(function () {
        $('.boxBody div').slideUp("slow", "swing");
    });



    //This part deals with left nav menu. It applies a class to the active menu item so it retains its active state

    $('ul.leftNav > li').click(function () {

        //remove the selected class from all LI    
        $('ul.leftNav > li').removeClass('leftNavSelected');

        //Reassign the LI
        $(this).addClass('leftNavSelected');

    });


    //This part deals with footer nav menu. It applies a class to the active menu item so it retains its active state

    $('ul.footerNav > li > ul > li').click(function () {

        //remove the selected class from all LI    
        $('ul.footerNav > li > ul > li').removeClass('footertNavSelected');

        //Reassign the LI
        $(this).addClass('footertNavSelected');

    });

    // ************************ End TopNav Push Down Menu *******************************************




    //************************* Start Jquery for Partners Page **************************************

    $('.folderLink').click(function () {

        //remove the selected class from all LI    
        $('ul.verticalTabList > li > a').removeClass('verticalTabListItemActive');

        var clickedElement = $(this);
        var selectedClass = clickedElement.attr('class').replace('folderLink ', '');

        $('div.verticalTabListContentBox').hide();
        $('div.' + selectedClass).fadeIn('slow');

        //Reassign the LI
        $(this).addClass('verticalTabListItemActive');

    });

    // show the 'All' items when the page first loads
    $('div.' + 'All').show();

    // show the 'All' text as the active Item
    $('a.' + 'All').addClass('verticalTabListItemActive');




    //************************** End Partners Jquery ************************************************



    //************************** Start Jquery for Offices Tabs ****************************************

    $(".officeMenu > li").click(function (e) {
        switch (e.target.id) {
            case "americas":
                //change status & style officeMenu
                $("#americas").addClass("active");
                $("#emea").removeClass("active");
                $("#apac").removeClass("active");
                //display selected division, hide others
                $("div.americas").fadeIn();
                $("div.emea").css("display", "none");
                $("div.apac").css("display", "none");
                $("div.americasHQ").fadeIn();
                $("div.emeaHQ").css("display", "none");
                $("div.apacHQ").css("display", "none");

                break;
            case "emea":
                //change status & style officeMenu
                $("#americas").removeClass("active");
                $("#emea").addClass("active");
                $("#apac").removeClass("active");
                //display selected division, hide others
                $("div.emea").fadeIn();
                $("div.americas").css("display", "none");
                $("div.apac").css("display", "none");
                $("div.emeaHQ").fadeIn();
                $("div.americasHQ").css("display", "none");
                $("div.apacHQ").css("display", "none");
                break;
            case "apac":
                //change status & style officeMenu
                $("#americas").removeClass("active");
                $("#emea").removeClass("active");
                $("#apac").addClass("active");
                //display selected division, hide others
                $("div.apac").fadeIn();
                $("div.americas").css("display", "none");
                $("div.emea").css("display", "none");
                $("div.apacHQ").fadeIn();
                $("div.americasHQ").css("display", "none");
                $("div.emeaHQ").css("display", "none");
                break;
        }
        //alert(e.target.id);
        return false;
    });


    //*************************** End Juery for Offices Tabs *******************************************

});

