/** jQuery ready **/
$(function() {
    
    /* ouvre les liens ayant l'attribut "rel" = "external" dans une nouvelle fenêtre */
    $('a[rel="external"]').live('click', function() {
        window.open($(this).attr('href'));
        return false;
    });
    
    /* ajout du "i" majuscule dans le menu de navigation principale */
    var nbItemsToAppend = ($('#main-nav ul').children('li').length - 2);
    $('#main-nav ul').children('li:lt('+(nbItemsToAppend)+')').append('I');
    
    /* ajout du "i" majuscule dans le menu de navigation de bas de page */
    $('#footer-nav').children('li:not(:last)').append('I');
    
    /* alignement vertical des blocs pour la homepage en mode vertical */
    if ($('#content').hasClass('vertical')) {
        var flashHeight = $('#homepage-flash').height(),
            tagsHeight = $('#homepage-tags').height(),
            videoHeight = $('#homepage-video').height();
            videoInnerHeight = $('#homepage-video').innerHeight(),
            margins = 0;
        if (videoHeight == 0) {
            margins = (flashHeight - tagsHeight - videoHeight);
        } else {
            margins = (flashHeight - tagsHeight - videoInnerHeight);
        }
        $('#homepage-tags').css('margin-top', (margins/2)+'px');
    }
    
    $(".tag2 a").colorbox({iframe:true, innerWidth:998, innerHeight:560});
    
});


/****************************************************************************************/
/**************************** Survol IE >> afficher le sous menu  ***********************/
/***************************************************************************************/
sfHover = function() {
	if(document.getElementById("choixlangue")){

		var sfElschoixlangue = document.getElementById("choixlangue").getElementsByTagName("LI");
		if(sfElschoixlangue){
			for (var i=0; i<sfElschoixlangue.length; i++) {
				sfElschoixlangue[i].onmouseover=function() {
					this.className+=" sfhover";
					this.style.zIndex = "+999";
				}
				sfElschoixlangue[i].onmouseout=function() {
					this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
				}
			}
		}
	}

	if(document.getElementById("footer")){
		var sfEls = document.getElementById("footer").getElementsByTagName("LI");
		if(sfEls){
			for (var i=0; i<sfEls.length; i++) {
				sfEls[i].onmouseover=function() {
					this.className+=" sfhover";
					this.style.zIndex = "+999";
				}
				sfEls[i].onmouseout=function() {
					this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
				}
			}
		}
	}
}

if (window.attachEvent) window.attachEvent("onload", sfHover);

