jQuery(window).load(function() {
    try {
        /* used for the tow boxes  themarportals / recent dossiers list  */
        var themaportalsBoxHeight = jQuery('div.themaportals_list_wrapper').height();
        var actualDossierBoxHeight = jQuery('div.recent_list_dossier_wrapper').height();
        if (themaportalsBoxHeight > actualDossierBoxHeight) {
            var diff = themaportalsBoxHeight-actualDossierBoxHeight;
            jQuery('div.recent_list_dossier_wrapper div.inner_border_wrapper div:last').css({paddingBottom: diff +'px'});  
        } else {
            var diff = actualDossierBoxHeight-themaportalsBoxHeight;
            jQuery('div.themaportals_list_wrapper div.inner_border_wrapper li.last').css({paddingBottom: (diff+2) +'px'});  
        }
        jQuery('div.themaportals_list_wrapper div.inner_border_wrapper ul').children().hover(function() {
            jQuery(this).addClass('hover').click(function() {
                location.href = jQuery('> a', jQuery(this)).attr('href');
            });
        }, function() {
            jQuery(this).removeClass('hover'); 
        });
    } catch (error) {
        // prevent error message
    }
});

jQuery(document).ready(function() {
	try {
	    var topNavDivOverFlow = false;
	    if (jQuery('table#top_nav_div_left').offsetHeight >= (jQuery('div#top_nav_div td > ul > li').first().offsetHeight * 1.25))
	            topNavDivOverFlow = true;
	    if (topNavDivOverFlow) {
	        var topNavDivNeededWidth = 0;
	        jQuery('#top_nav_div td > ul > li').each(function(item){
	            topNavDivNeededWidth += item.getWidth() + 1;
	        });
	        jQuery('table#top_nav_div_left').setStyle({width : topNavDivNeededWidth + 'px'});
	        jQuery('div#top_nav_div').setStyle({width : topNavDivNeededWidth + 'px'});
	    }
	} catch (error) {}
	// activate the top menu
	jQuery('div#top_nav_div ul').superfish({
        delay:       1000,                            // one second delay on mouseout 
        animation:   {opacity:'show',height:'show'},  // fade-in and slide-down animation 
        speed:       'fast',                          // faster animation speed 
        autoArrows:  false,                           // disable generation of arrow mark-up 
        dropShadows: true  
    });
});



function fixHeightHomepageCategoryBox()
{
	fixHeightCategoryBoxElements(false);
}

function fixHeightCategoryBoxElements(secBoxHover)
{    
	jQuery('div.category_list_horizontale div.first_box').bind('mouseover', function() {
		jQuery(this).addClass('first_box_hover');
		if (secBoxHover) {
            jQuery(this).next().addClass('sec_box_hover');                
        }
	});
	jQuery('div.category_list_horizontale div.first_box').bind('mouseout', function() {
		jQuery(this).removeClass('first_box_hover');
		if (secBoxHover) {
            jQuery(this).next().removeClass('sec_box_hover');                
        }
	});
	jQuery('div.category_list_horizontale').each(function() {
	    var maxHeightFirstBox = 0;
	    var maxHeightSecBox = 0;
        jQuery(this).children().each(function() {
            if (jQuery('div.first_box', jQuery(this)).height() > maxHeightFirstBox)
                maxHeightFirstBox = jQuery('div.first_box', jQuery(this)).height();
            if (jQuery('div.sec_box ul', jQuery(this)).height() > maxHeightSecBox)
                maxHeightSecBox = jQuery('div.sec_box ul', jQuery(this)).height();
        });
        jQuery('div.first_box', jQuery(this)).css({height: maxHeightFirstBox+'px'});
        jQuery('div.sec_box ul', jQuery(this)).css({height: maxHeightSecBox+'px'});
    });
}
