

var droplinemenu={

arrowimage: {classname: 'downarrowclass', src: 'down.gif', leftpadding: 5}, //customize down arrow image
animateduration: {over: 0, out: 0}, //duration of slide in/ out animation, in milliseconds

buildmenu:function(menuid){
	jQuery(document).ready(function($){

		var $mainmenu=$("#"+menuid+">ul")
		var $headers=$mainmenu.find("ul").parent()
		$headers.each(function(i){
			var $curobj=$(this)
			var $subul=$(this).find('ul:eq(0)')
			this._dimensions={h:$curobj.find('a:eq(0)').outerHeight()}
			this.istopheader=$curobj.parents("ul").length==1? true : false
			if (!this.istopheader)
				$subul.css({left:0, top:this._dimensions.h})
			var $innerheader=$curobj.children('a').eq(0)
			$innerheader=($innerheader.children().eq(0).is('span'))? $innerheader.children().eq(0) : $innerheader //if header contains inner SPAN, use that
		
			$curobj.hover(
				function(e){
                var $targetul=$(this).children("ul:eq(0)");
                
				if (this.istopheader)
                {
                    $targetul.css({left: $mainmenu.position().left, top: $mainmenu.position().top+this._dimensions.h});
                }
                
                //ANIMATION
                if($targetul.css('white-space')!="nowrap")
                {
                    $targetul.slideDown(droplinemenu.animateduration.over);
                    $targetul.css({ 'position':'absolute' , 'z-index':'20000' }); 
                }
				},
				function(e){
                var $targetul=$(this).children("ul:eq(0)");
                
                // ANIMATION
                if($targetul.css('white-space')!="nowrap")
                {
                    $targetul.slideUp(droplinemenu.animateduration.over);
                    $targetul.css({ 'z-index': '100' });
                }
                }
                
			) //end hover
            
            // SET SUBMENU POSITION
            $('ul#ul-escola').css({left: $mainmenu.position().left, top: $mainmenu.position().top+this._dimensions.h});
            $('ul#ul-linguas').css({left: $mainmenu.position().left, top: $mainmenu.position().top+this._dimensions.h});
            $('ul#ul-cursos').css({left: $mainmenu.position().left, top: $mainmenu.position().top+this._dimensions.h});
            $('ul#ul-cambridge').css({left: $mainmenu.position().left, top: $mainmenu.position().top+this._dimensions.h});
            $('ul#ul-verao').css({left: $mainmenu.position().left, top: $mainmenu.position().top+this._dimensions.h});
            
		}) //end $headers.each()
        
		$mainmenu.find("ul").css({display:'none', visibility:'visible', width:$mainmenu.width()});
        
        checkPage();
        
        
        function checkPage() {
		
		var loc = window.location;
        //alert(loc);
        
        // ------------------------- HOME ----------------------------
        // -----------------------------------------------------------
        if(loc=="http://www.ihbraga.com/" || loc=="http://ihbraga.com/") 
        { 
            //ANIMATION
            $('li#menuTabHome a').css({ 'background':'url(http://www.ihbraga.com/images/hover_esq.png) left bottom no-repeat', 'line-height':'90%' , 'color':'#EF4123' });
            $('li#menuTabHome #menuRightCorner').css({ 'background':'url(http://www.ihbraga.com/images/hover_dir.png) left bottom no-repeat' });
            
            resetSubs();
        }
        
        // ---------------------------- ESCOLA / ESCOLA ----------------------------
        // -------------------------------------------------------------------------
		if(loc=="http://www.ihbraga.com/escola/" || loc=="http://ihbraga.com/escola/") 
        { 
            //ANIMATION
            $('li.li-escola a').css({ 'background':'url(http://www.ihbraga.com/images/hover_esq.png) left bottom no-repeat', 'line-height':'90%' , 'color':'#F68B1F'  });
            $('li.li-escola #menuRightCorner').css({ 'background':'url(http://www.ihbraga.com/images/hover_dir.png) left bottom no-repeat' });
            
            resetSubs();
            
            $('ul#ul-escola').slideDown(droplinemenu.animateduration.over);
            $('ul#ul-escola').css({ 'z-index':'10000', 'white-space':'nowrap' });
            $('ul#ul-escola li:first-child a').css({ 'color':'#FFC425', });
        }
        
        // ---------------------------- ESCOLA / METODOLOGIA ----------------------------
        // ------------------------------------------------------------------------------
		if(loc=="http://www.ihbraga.com/escola/metodologia/" || loc=="http://ihbraga.com/escola/metodologia/") 
        { 
            //ANIMATION
            $('li.li-escola a').css({ 'background':'url(http://www.ihbraga.com/images/hover_esq.png) left bottom no-repeat', 'line-height':'90%' , 'color':'#F68B1F' });
            $('li.li-escola #menuRightCorner').css({ 'background':'url(http://www.ihbraga.com/images/hover_dir.png) left bottom no-repeat' });
            
            resetSubs();
            
            $('ul#ul-escola').slideDown(droplinemenu.animateduration.over);
            $('ul#ul-escola').css({ 'z-index':'10000' , 'white-space':'nowrap' });
            $('ul#ul-escola li:last-child a').css({ 'color':'#FFC425', });
        }
        
        // ---------------------------- LINGUAS / INGLES ----------------------------
        // --------------------------------------------------------------------------
		if(loc=="http://www.ihbraga.com/linguas/" || loc=="http://ihbraga.com/linguas/" ||
           loc=="http://www.ihbraga.com/linguas/ingles/" || loc=="http://ihbraga.com/linguas/ingles/") 
        { 
            //ANIMATION
            $('li.li-linguas a').css({ 'background':'url(http://www.ihbraga.com/images/hover_esq.png) left bottom no-repeat', 'line-height':'90%' , 'color':'#941E5E', });
            $('li.li-linguas #menuRightCorner').css({ 'background':'url(http://www.ihbraga.com/images/hover_dir.png) left bottom no-repeat' });
            
            resetSubs();
            
            $('ul#ul-linguas').slideDown(droplinemenu.animateduration.over);
            $('ul#ul-linguas').css({ 'z-index':'10000', 'white-space':'nowrap' });
            $('ul#ul-linguas li:first-child a').css({ 'color':'#FFC425', });
        }
        
        // ---------------------------- LINGUAS / OUTRAS ----------------------------
        // --------------------------------------------------------------------------
		if(loc=="http://www.ihbraga.com/linguas/outras/" || loc=="http://ihbraga.com/linguas/outras/") 
        { 
            //ANIMATION
            $('li.li-linguas a').css({ 'background':'url(http://www.ihbraga.com/images/hover_esq.png) left bottom no-repeat', 'line-height':'90%' , 'color':'#941E5E'  });
            $('li.li-linguas #menuRightCorner').css({ 'background':'url(http://www.ihbraga.com/images/hover_dir.png) left bottom no-repeat' });
            
            resetSubs();
            
            $('ul#ul-linguas').slideDown(droplinemenu.animateduration.over);
            $('ul#ul-linguas').css({ 'z-index':'10000', 'white-space':'nowrap' });
            $('ul#ul-linguas li:last-child a').css({ 'color':'#FFC425', });
        }
        
        // ---------------------------- CURSOS / KIDS&JUNIOR ----------------------------
        // ------------------------------------------------------------------------------
		if(loc=="http://www.ihbraga.com/cursos/" || loc=="http://ihbraga.com/cursos/" ||
           loc=="http://www.ihbraga.com/cursos/kids&junior/" || loc=="http://ihbraga.com/cursos/kids&junior/") 
        { 
            //ANIMATION 
            $('li.li-cursos a').css({ 'background':'url(http://www.ihbraga.com/images/hover_esq.png) left bottom no-repeat', 'line-height':'90%' , 'color':'#00845F'  });
            $('li.li-cursos #menuRightCorner').css({ 'background':'url(http://www.ihbraga.com/images/hover_dir.png) left bottom no-repeat' });
            
            resetSubs();
            
            $('ul#ul-cursos').slideDown(droplinemenu.animateduration.over);
            $('ul#ul-cursos').css({ 'z-index':'10000', 'white-space':'nowrap' });
            $('ul#ul-cursos li:first-child a').css({ 'color':'#FFC425', });
        }
        
        
        // ---------------------------- CURSOS / TEENS&YOUNGADULTS ----------------------------
        // ------------------------------------------------------------------------------
		if(loc=="http://www.ihbraga.com/cursos/teens&youngadults/" || loc=="http://ihbraga.com/cursos/teens&youngadults/") 
        { 
            //ANIMATION 
            $('li.li-cursos a').css({ 'background':'url(http://www.ihbraga.com/images/hover_esq.png) left bottom no-repeat', 'line-height':'90%' , 'color':'#00845F'  });
            $('li.li-cursos #menuRightCorner').css({ 'background':'url(http://www.ihbraga.com/images/hover_dir.png) left bottom no-repeat' });
            
            resetSubs();
            
            $('ul#ul-cursos').slideDown(droplinemenu.animateduration.over);
            $('ul#ul-cursos').css({ 'z-index':'10000', 'white-space':'nowrap' });
            $('ul#ul-cursos li:nth-child(2) a').css({ 'color':'#FFC425', });
        }
        
        // ---------------------------- CURSOS / KIDS&JUNIOR ----------------------------
        // ------------------------------------------------------------------------------
		if(loc=="http://www.ihbraga.com/cursos/adults&empresas/" || loc=="http://ihbraga.com/cursos/adults&empresas/") 
        { 
            //ANIMATION 
            $('li.li-cursos a').css({ 'background':'url(http://www.ihbraga.com/images/hover_esq.png) left bottom no-repeat', 'line-height':'90%' , 'color':'#00845F'  });
            $('li.li-cursos #menuRightCorner').css({ 'background':'url(http://www.ihbraga.com/images/hover_dir.png) left bottom no-repeat' });
            
            resetSubs();
            
            $('ul#ul-cursos').slideDown(droplinemenu.animateduration.over);
            $('ul#ul-cursos').css({ 'z-index':'10000', 'white-space':'nowrap' });
            $('ul#ul-cursos li:last-child a').css({ 'color':'#FFC425', });
        }
        
        // ---------------------------- CAMBRIDGE / CENTRO ----------------------------
        // ----------------------------------------------------------------------------
		if(loc=="http://www.ihbraga.com/cambridge/" || loc=="http://ihbraga.com/cambridge/" ||
           loc=="http://www.ihbraga.com/cambridge/centro/" || loc=="http://ihbraga.com/cambridge/centro/") 
        { 
            //ANIMATION 
            $('li.li-cambridge a').css({ 'background':'url(http://www.ihbraga.com/images/hover_esq.png) left bottom no-repeat', 'line-height':'90%' , 'color':'#FDB913'  });
            $('li.li-cambridge #menuRightCorner').css({ 'background':'url(http://www.ihbraga.com/images/hover_dir.png) left bottom no-repeat' });
            
            resetSubs();
            
            $('ul#ul-cambridge').slideDown(droplinemenu.animateduration.over);
            $('ul#ul-cambridge').css({ 'z-index':'10000', 'white-space':'nowrap' });
            $('ul#ul-cambridge li:first-child a').css({ 'color':'#FFC425', });
        }
        
        // ---------------------------- CAMBRIDGE / CRIANÇAS ----------------------------
        // ------------------------------------------------------------------------------
		if(loc=="http://www.ihbraga.com/cambridge/criancas/" || loc=="http://ihbraga.com/cambridge/criancas/")
        { 
            //ANIMATION 
            $('li.li-cambridge a').css({ 'background':'url(http://www.ihbraga.com/images/hover_esq.png) left bottom no-repeat', 'line-height':'90%' , 'color':'#FDB913'  });
            $('li.li-cambridge #menuRightCorner').css({ 'background':'url(http://www.ihbraga.com/images/hover_dir.png) left bottom no-repeat' });
            
            resetSubs();
            
            $('ul#ul-cambridge').slideDown(droplinemenu.animateduration.over);
            $('ul#ul-cambridge').css({ 'z-index':'10000', 'white-space':'nowrap' });
            $('ul#ul-cambridge li:nth-child(2) a').css({ 'color':'#FFC425', });
        }
        
        // ---------------------------- CAMBRIDGE / GERAL ----------------------------
        // ---------------------------------------------------------------------------
		if(loc=="http://www.ihbraga.com/cambridge/geral/" || loc=="http://ihbraga.com/cambridge/geral/")
        { 
            //ANIMATION 
            $('li.li-cambridge a').css({ 'background':'url(http://www.ihbraga.com/images/hover_esq.png) left bottom no-repeat', 'line-height':'90%' , 'color':'#FDB913'  });
            $('li.li-cambridge #menuRightCorner').css({ 'background':'url(http://www.ihbraga.com/images/hover_dir.png) left bottom no-repeat' });
            
            resetSubs();
            
            $('ul#ul-cambridge').slideDown(droplinemenu.animateduration.over);
            $('ul#ul-cambridge').css({ 'z-index':'10000', 'white-space':'nowrap' });
            $('ul#ul-cambridge li:nth-child(3) a').css({ 'color':'#FFC425', }); 
        }
        
        // ---------------------------- CAMBRIDGE / PROFISSIONAIS ----------------------------
        // -----------------------------------------------------------------------------------
		if(loc=="http://www.ihbraga.com/cambridge/profissionais/" || loc=="http://ihbraga.com/cambridge/profissionais/")
        { 
            //ANIMATION 
            $('li.li-cambridge a').css({ 'background':'url(http://www.ihbraga.com/images/hover_esq.png) left bottom no-repeat', 'line-height':'90%' , 'color':'#FDB913'  });
            $('li.li-cambridge #menuRightCorner').css({ 'background':'url(http://www.ihbraga.com/images/hover_dir.png) left bottom no-repeat' });
            
            resetSubs();
            
            $('ul#ul-cambridge').slideDown(droplinemenu.animateduration.over);
            $('ul#ul-cambridge').css({ 'z-index':'10000', 'white-space':'nowrap' });
            $('ul#ul-cambridge li:last-child a').css({ 'color':'#FFC425', });
        }
        
        // ---------------------------- VERAO / INTENSIVOS ----------------------------
        // ----------------------------------------------------------------------------
		if(loc=="http://www.ihbraga.com/verao/" || loc=="http://ihbraga.com/verao/" ||
           loc=="http://www.ihbraga.com/verao/intensivos/" || loc=="http://ihbraga.com/verao/intensivos/") 
        { 
            //ANIMATION 
            $('li.li-verao a').css({ 'background':'url(http://www.ihbraga.com/images/hover_esq.png) left bottom no-repeat', 'line-height':'90%' , 'color':'#5E004E'  });
            $('li.li-verao #menuRightCorner').css({ 'background':'url(http://www.ihbraga.com/images/hover_dir.png) left bottom no-repeat' });
            
            resetSubs();
            
            $('ul#ul-verao').slideDown(droplinemenu.animateduration.over);
            $('ul#ul-verao').css({ 'z-index':'10000', 'white-space':'nowrap' });
            $('ul#ul-verao li:first-child a').css({ 'color':'#FFC425', }); 
        }
        
        // ---------------------------- VERAO / INTENSIVOS ----------------------------
        // ----------------------------------------------------------------------------
		if(loc=="http://www.ihbraga.com/verao/estrangeiro/" || loc=="http://ihbraga.com/verao/estrangeiro/") 
        { 
            //ANIMATION 
            $('li.li-verao a').css({ 'background':'url(http://www.ihbraga.com/images/hover_esq.png) left bottom no-repeat', 'line-height':'90%' , 'color':'#5E004E'  });
            $('li.li-verao #menuRightCorner').css({ 'background':'url(http://www.ihbraga.com/images/hover_dir.png) left bottom no-repeat' });
            
            resetSubs();
            
            $('ul#ul-verao').slideDown(droplinemenu.animateduration.over);
            $('ul#ul-verao').css({ 'z-index':'10000', 'white-space':'nowrap' });
            $('ul#ul-verao li:last-child a').css({ 'color':'#FFC425', });
        }
        
        // ------------------------- CONTACTOS ----------------------------
        // ----------------------------------------------------------------
        if(loc=="http://www.ihbraga.com/contactos/" || loc=="http://ihbraga.com/contactos/") 
        { 
            //ANIMATION
            $('li.li-contactos a').css({ 'background':'url(http://www.ihbraga.com/images/hover_esq.png) left bottom no-repeat', 'line-height':'90%' , 'color':'#8DC63F' });
            $('li.li-contactos #menuRightCorner').css({ 'background':'url(http://www.ihbraga.com/images/hover_dir.png) left bottom no-repeat' });
            
            resetSubs();
        }
        
        // ------------------------- TESTEMUNHOS ----------------------------
        // ------------------------------------------------------------------
        if(loc=="http://www.ihbraga.com/testemunhos/" || loc=="http://ihbraga.com/testemunhos/") 
        { 
            //ANIMATION
            $('li.li-testemunhos a').css({ 'background':'url(http://www.ihbraga.com/images/hover_esq.png) left bottom no-repeat ', 'line-height':'90%' , 'color':'#00845F' });
            $('li.li-testemunhos #menu2RightCorner').css({ 'background':'url(http://www.ihbraga.com/images/hover_dir.png) left bottom no-repeat' });
            
            resetSubs();
        }
        
        // ------------------------- PARCEIROS ----------------------------
        // ----------------------------------------------------------------
        if(loc=="http://www.ihbraga.com/parceiros/" || loc=="http://ihbraga.com/parceiros/") 
        { 
            //ANIMATION
            $('li.li-parceiros a').css({ 'background':'url(http://www.ihbraga.com/images/hover_esq.png) left bottom no-repeat', 'line-height':'90%' , 'color':'#EF4123' });
            $('li.li-parceiros #menu2RightCorner').css({ 'background':'url(http://www.ihbraga.com/images/hover_dir.png) left bottom no-repeat' });
            
            resetSubs();
        }

        
        
		return false;
        } // end of checkPage
        
        
        function resetSubs()
        {
            // RESET LOOKS OF SUBMENUS
            $('#leftMenu ul li ul li a').css({ 'background':'none' , 'line-height':'150%' , 'color':'#fff'});
            
            $('#leftMenu ul li ul li a').hover( function() {
            
            
            if($(this).css('color') == "rgb(255, 255, 255)" || $(this).css('color') == "#fff" )
            {
                $(this).css({ 'color':'#FFC425', 'white-space':'pre'});
            }
            },
            function(){
            if($(this).css('white-space') == "pre")
            {
                $(this).css({ 'color':'#fff', 'white-space':'normal' });
            }
            });
        }

	}) //end document.ready
    
}
}




