
/**
 * @section		create global var ieIE 6, 7 & 8
 */
var isIE = false;
var manageIsIE = {
    init: function () {
        if (jQuery.browser.msie) {
            isIE = true;
            if(parseInt(jQuery.browser.version) == 6) {
                isIE = 6;
            } else if (parseInt(jQuery.browser.version) == 7) {
                isIE = 7;
            } else if (parseInt(jQuery.browser.version) == 8) {
                isIE = 8;
            }
        }
    }
};

var carouselWrapper, myCarousel;
jQuery(document).ready(function() { 
    // Arrondis	////////////////////////////////////////////////////////////////////////////////////////////

                                
    if (!$.browser.msie) {
        DD_roundies.addRule('#nav li span, .miseEnAvant, .miseEnAvant p a, a.contact, a.plan, a.bleu, a.bleu-clair, a.orange, a.vert, a.gris, #sousNavPage .SNcontent ul#sousNav li a, .content button', '5px', true);

        DD_roundies.addRule('#nav li a.niv1', '5px 5px 3px 3px', true);
        $('.imgRollover').mouseover(function() {
            $(this).stop().fadeTo(200, 0.6);
        }).mouseout(function(){
            $(this).stop().fadeTo(200, 1);
        });
    }
    else
    {
        $('.imgRollover').mouseover(function() {
            $(this).stop().fadeTo(200, 0.6);
        }).mouseout(function(){
            $(this).stop().fadeTo(200, 1);
        });
        DD_roundies.addRule('#nav li a.niv1', '5px 5px 3px 3px', true);
        //Ligne qui fait planter IE 7 :
        DD_roundies.addRule('#nav li span, .miseEnAvant, .miseEnAvant p a, a.contact, a.plan, a.bleu, a.bleu-clair, a.orange, a.vert, a.gris, #sousNavPage .SNcontent ul#sousNav li a', '5px', true);
    ////////////
    }
        
    var homeCarrousel = jQuery('#ecamActu').bxSlider({
        auto: true,
        infiniteLoop: false,
        autoControls: true,
        hideControlOnEnd: true,
        pager: true,
        controls: true,
        onFirstSlide: function(){
            homeCarrousel.goToFirstSlide();
            homeCarrousel.stopShow();
        }
    });
		
    $("a.fancybox").fancybox({
        'titleShow'		: false,
        'transitionIn'	: 'elastic',
        'transitionOut'	: 'elastic',
        'margin' : 0,
        'padding' : 0
    });
		
    $("a.inline").fancybox({
        'hideOnContentClick': false,
        'transitionIn'	: 'elastic',
        'transitionOut'	: 'elastic',
        'margin' : 0,
        'padding' : 0,
        swf : {
            wmode: 'transparent'
        }
    });
		
    jQuery('#searchBox').hide();

    jQuery('#searchBtn').hover(function(){
        /*if ($('#searchBox').is(':visible')){
			jQuery('#searchBox').fadeOut("fast");
				jQuery('#searchBtn').css("color","#AFAFAF");
			return false;
		}else {*/
        jQuery('#searchBox').fadeIn("fast");
        jQuery('#searchBtn').css("color","#ffffff");
				
        return false;
			
    //}
    });
	




    //jQuery('body').bind('hover', function(e) {
    jQuery('body').mouseover(function(e) {
        // si searchbox visible
        if (jQuery('#searchBox').is(':visible') && jQuery(e.target).attr('id')!='searchBox' && jQuery(e.target).parents('#searchBox').html()==null){
            jQuery('#searchBox').fadeOut("fast");
            jQuery('#searchBtn').css("color","#AFAFAF");
        }
    });
	
    // click sur le body : masque searchbox si visible
    /*jQuery('body').bind('click', function(e) {
		if ($('#searchBox').is(':visible')){
			jQuery('#searchBox').fadeOut("fast");
			jQuery('#searchBtn').css("color","#AFAFAF");
		}
	});
	// ne pas propager le click si celui-ci est effectue sur la search box
	jQuery('#searchBox').bind('click', function(e) {
		return false;
	});*/
    // soumettre le form lors du click sur bouton ok (si recherche non vide)
    /*jQuery('#searchBox input.submit').bind('click', function(e) {
		if (jQuery('#searchForm input.text').val().length>0) {
			jQuery('#searchForm').submit();
		}
	});*/
	
	
    // Menu du header (mouse over/out sur <li>)
    jQuery('#header #navigation ul#nav>li').mouseover(function(){
        // masque form de recherche si visible
        if (jQuery('#searchBox').is(':visible')) {
            jQuery('#searchBox').fadeOut("fast");
            jQuery('#searchBtn').css("color","#AFAFAF");
        }
        // masque tous les autres sous menus
        jQuery('#header #navigation ul#nav>li.hover').removeClass('hover');
        // affiche le sous menu courant
        jQuery(this).addClass('hover');
    }).mouseout(function(){
        // masque le sous menu courant
        jQuery(this).removeClass('hover');
    });

    // __________________ CARROUSEL INTERIEUR __________ //
    carouselWrapper = jQuery('#carrouselInterieur');

    var preloadImg = new Array;
    var preloaded = 0;
    var totPreload = jQuery('#carrouselInterieur li a img').length;

    jQuery('#carrouselInterieur li a img').each(function() {
        var elmt = jQuery(this);
        preloadImg.push(elmt.attr('src'));
    });

	/*
    jQuery('li a', carouselWrapper).hover(function() {
        var title = $(this).attr('title');
        if(title == '')
        {
            title = 'Document sans nom';
        }
        $(this).append('<h4>'+title+'</h4>');
    }, function() {
        $(this).find('h4').remove();
    });
    */

    jQuery('body').bind('loaded', function() {
        
        if(preloaded == totPreload) {
            myCarousel = carouselWrapper.Carousel({
                itemWidth: 220,
                itemHeight: 212,
                itemMinWidth: 80,
                items: 'a',
                reflections: 0,
                rotationSpeed: 5
            });
        }
    });

    jQuery.each(preloadImg,function(e) {
        jQuery(new Image()).load(function() {
            preloaded++;
            jQuery('body').trigger('loaded');
        }).attr('src',this);
    });
    $('#carrouselInterieur .fancyboxCarrousel').fancybox({
        'titleShow'	: $('img',this).attr('title'),
        'transitionIn'	: 'elastic',
        'transitionOut'	: 'elastic',
        'margin' : 0,
        'padding' : 0,
        onComplete: function() {
            // stop le carrousel 3D
            myCarousel.stop();
            jQuery.fancybox.resize();
        },
        onClosed: function() {
            // relance le carrousel 3D
            myCarousel.start();
        }
    });
 

});


function addToFavorites(url_site)
{
    if (window.sidebar)
    {
        window.sidebar.addPanel("ECAM Strasbourg Europe",url_site,"");
    }
    else if( navigator.appName == 'Microsoft Internet Explorer' )
    {
        window.external.AddFavorite(url_site,"ECAM Strasbourg Europe");
    }
    else
    {
        //Texte � pr�voir en multi-langues
        alert('Votre navigateur ne prend pas en compte cette fonctionnalit�');
    }
}
	

