﻿// cahg menu

function initMenu(){
    $("div.menuItem").mouseover(function() {
        var linkImg = $(this).find("img");
        if(linkImg)
        {
            if(!$(linkImg).attr("src").endsWith("On.png"))
                $(linkImg).attr("src",$(linkImg).attr("src").replace("Off.png","Over.png"));
        }
    });
    
    $("div.menuItem").mouseout(function() {
        var linkImg = $(this).find("img");
        if(linkImg)
        {
            if($(linkImg).attr("src").endsWith("Over.png"))
                $(linkImg).attr("src",$(linkImg).attr("src").replace("Over.png","Off.png"));
        }
    });
    
    $("#topNav a, #bottomNav a").mouseover(function() {
        var linkImg = $(this).find("img");
        if(linkImg)
        {
            $(linkImg).attr("src",$(linkImg).attr("src").replace(".png","On.png"));
        }
    }); 
    
    $("#topNav a, #bottomNav a").mouseout(function() {
        var linkImg = $(this).find("img");
        if(linkImg)
        {
            $(linkImg).attr("src",$(linkImg).attr("src").replace("On.png",".png"));
        }
    }); 
    
    $("#buHeader a").mouseover(function() {
        $(this).removeClass("clientsLink").addClass("clientsLinkOver");
    }); 
    
    $("#buHeader a").mouseout(function() {
        $(this).removeClass("clientsLinkOver");
        if(!$(this).hasClass("clientsLinkOn"))
        {
            $(this).addClass("clientsLink");            
        }
    });     
    
        
    
    $("#contentLeft a").mouseover(function() {
        $(this).removeClass("clientsLink");
        $(this).addClass("clientsLinkOver");
    });
            
    $("#contentLeft a").mouseout(function() {
        $(this).removeClass("clientsLinkOver");
        if(!$(this).hasClass("clientsLinkOn"))
        {
            $(this).addClass("clientsLink");            
        }
    });

    $("#contentLeft a").click(function() {
        $("#contentLeft a.clientsLinkOn").removeClass("clientsLinkOn").removeClass("clientsLinkOver").addClass("clientsLink");
        $(this).addClass("clientsLinkOn");
        
    });
    
    if(currentPage.toLowerCase() == 'brands' || currentPage.toLowerCase() == 'talent' || currentPage.toLowerCase() == 'ideas' || currentPage.toLowerCase() == 'network')
    {
        if(currentSubPage == '')
        
            $("#body").addClass(currentPage.toLowerCase() + "Back");
    menuel = $("#menu div[id=" + currentPage + "]");
    $(menuel).css({height:"37px"}).find("img").attr("src",$(menuel).find("img").attr("src").replace("Off.png","On.png").replace("Over.png","On.png"));
    }
    
    if(currentSubPage != '')
    {
        var linkImg = $("#blueBar div[id=" + currentSubPage + "]").find("img");
        $(linkImg).attr("src",$(linkImg).attr("src").replace("Off.png","On.png").replace("Over.png","On.png"));   
    }
    
    if(currentSubSubPage != '')
    {
        $("#contentLeft a.clientsLink[title=" + currentSubSubPage + "]").removeClass("clientsLinkOver").addClass("clientsLink").addClass("clientsLinkOn");
    }
    
    if(currentSubSubSubPage != '')
    {
        var linkImg = $("#buHeader a[title=" + currentSubSubSubPage + "]");
        $(linkImg).addClass("clientsLinkOn");
    }    
}

function animateMenu() {
    
    if(!fromSplash && fromSplash != 'true')
    {   
        $("#blueBar").stop().hide().css({width:"0px",top:"125px"});
        $(".menusub").hide(); 
    }
        
    $("#topWing").stop().hide().css({top:"125px",height:"0px"});              
    $("#bottomWing").stop().hide().css({top:"162px",height:"0px"}); 
    
    $("#menu").animate({top:$("#menu").position().top+menuOffset-$(menuel).position().top},"fast","linear",function() { 
    //$("#menu").animate({top:$("#menu").position().top-8 + "px"},"fast","linear",function() {
    //$(menuel).animate({height:"20px","padding-top":"8px","padding-bottom":"9px"},"fast","linear", function() {
        
        var linkImg = $(menuel).find("img")
        if(linkImg)
        {
            //$(menuel).css({height:"37px","padding":"0px"},"fast");
            $(linkImg).attr("src",$(linkImg).attr("src").replace("Off.png","On.png").replace("Over.png","On.png"));
        }
        $("#blueBar").show().animate({width:"604px"},"fast","linear", function() {
              //$("#blueBar span").html("this is a test");
              $("#submenu").show();
              $("#topWing").show().animate({top:"-20",height:"145px"},"fast");              
              $("#bottomWing").show().animate({top:"162px",height: contentHeight - 200 + "px"},"fast","linear",function() {
                $(".delayedShow").show();
              });
                
              
        });
    //});

});
}

function animateMenuLevel2()
{
    $("#menu").animate({top:0-$(menuel).position().top + "px"},"fast", "linear", function() {});
    $("#blueBar").animate({top:"0px"}, "fast", "linear",function() { 
    
    $("#contentMain").css({height:contentHeight-86 + "px"});
    $("#contentLeft").css({height:contentHeight-86 + "px"});
        $("#contentBreaker").css({height:contentHeight-86 + "px"});
        $("#contentWrapper").show().animate({height:contentHeight-86 + "px"},"slow");
        $(".delayedShow").show();
        
    });
}

function animateMenuLevel21()
{
    $("#menu").animate({top:0-$(menuel).position().top + "px"},"fast", "linear", function() {});
    $("#blueBar").animate({top:"0px"}, "fast", "linear",function() { 
    
    $("#contentMain").css({height:contentHeight-86 + "px"});
    $("#contentLeft").css({height:contentHeight-66 + "px"});
        $("#contentBreaker").css({height:contentHeight-86 + "px"});
        $("#contentWrapper").show().animate({height:contentHeight-86 + "px"},"slow");
        $(".delayedShow").show();
        
    });
}

function animateMenuLevel3() {
    $("#contentMain").css({height:contentHeight-86 + "px"});
    $("#contentLeft").css({height:contentHeight-86 + "px"});
        $("#contentBreaker").css({height:contentHeight-86 + "px"});
        $("#contentWrapper").show().css({height:contentHeight-86 + "px"},"slow");
        $(".delayedShow").show();
}

function animateMenuLevel10() {
    $("#contentMain").css({height:contentHeight-49 + "px"});
    $("#contentWrapper").show().css({height:contentHeight-49 + "px"});
    $("#menu").animate({top:"125px"},"fast");
     $(".delayedShow").show();
}