/* ------------------------------------------------------------------------
	Class: MediaBox
	Author: Stéphane PERES(http://www.npc-media.com)
	Version: 1.5
------------------------------------------------------------------------- */

// Liens avec TARGET _BLANK pour validation W3C
function innerHTMLcopy(source, target){
	$("#target").html = $("#source").html
}

function lien(monLien){
	window.open(monLien, '_blank');
	return false;
}

// DesignInfoBulle  |  Design de la balise "title"
$(function(){
    
    $("a").mouseover(function(){
        if($(this).attr("title")=="") return false;
        
        $("body").append('<span class="infobulle"></span>');
        var bulle = $(".infobulle:last");
        bulle.append($(this).attr("title"));
        $(this).attr("title","");
        var posTop = $(this).offset().top-$(this).height();
        var posLeft = $(this).offset().left+$(this).width()/2-bulle.width()/2;
        bulle.css({
            left:posLeft,
            top:posTop+30,
            opacity:0
        });
        bulle.animate({
            top:posTop+40,
            opacity:0.99
        });
    });
    
    $("a").mouseout(function(){
        var bulle = $(".infobulle:last");
        $(this).attr("title",bulle.text());
        bulle.animate(
            {
                top:bulle.offset().top+45,
                opacity:0
            },
            500,
            "linear",
            function(){
                bulle.remove();  
            }
        );
    });
});

// Effet de rollover avec CSS
$(function(){
		// Rubrique "Demande d'informations"
	    $("#espace_information img").css("opacity",0.5);
           $("#espace_information img").mouseover(function(){
				$(this).stop().fadeTo(500,1);
	    });
	    $("#espace_information img").mouseout(function(){
				$(this).stop().fadeTo(500,0.5);
	    });
		
		// Rubrique "Nos domaines d'activité"
	    $("#block_ac_domaines img").css("opacity",1); // Opacity 1 correspond à un alpha 0%
           $("#block_ac_domaines img").mouseover(function(){
				$(this).stop().fadeTo(500,0.6); // Alpha à 60 %
	    });
	    $("#block_ac_domaines img").mouseout(function(){
				$(this).stop().fadeTo(500,1);
	    });
		
		// Rubrique "Actualités"
	    $("#block_ac_actualites img").css("opacity",1);
           $("#block_ac_actualites img").mouseover(function(){
				$(this).stop().fadeTo(500,0.8);
	    });
	    $("#block_ac_actualites img").mouseout(function(){
				$(this).stop().fadeTo(500,1);
	    });
		
		// Rubrique "Block images"
	    $("#block_sup img").css("opacity",1);
           $("#block_sup img").mouseover(function(){
				$(this).stop().fadeTo(500,0.6);
	    });
	    $("#block_sup img").mouseout(function(){
				$(this).stop().fadeTo(500,1);
	    });
		
		// Contact
	    $("#icone_google_maps img").css("opacity",0.5);
           $("#icone_google_maps img").mouseover(function(){
				$(this).stop().fadeTo(500,1);
	    });
	    $("#icone_google_maps img").mouseout(function(){
				$(this).stop().fadeTo(500,0.5);
	    });
});

// Accordeon FDE
/*
	Permet d'afficher un menu au format accordeon.
	@btn		Bouton qui déclencheront les accordeons
	@wrapper	Element suivant le bouton à cacher
*/

$(function() {
	// Fonctionne pour toutes les balises H2 et UL du div en question
	ascenseur.init('.fde h2','.fde ul');
	
	// fluid scroll
	$('a[href^=#]').click(function() {
		cible=$(this).attr('href');
		if($(cible).length>=1){
			hauteur=$(cible).offset().top;
		}
		else{
			hauteur=$("a[name="+cible.substr(1,cible.length-1)+"]").offset().top;
		}
		$('html,body').animate({scrollTop: hauteur}, 1000);
		return false;
	});
});

ascenseur = {
	// Initialisation des comportements
	init : function(btn,acacher){			
		$(acacher).hide(); // Par défaut on cache le contenu
		$(btn).click(function(){
			$(acacher).slideToggle(500); // Aprés le click, l'animation d'une demi seconde est déclenchée
			return false;
		});
	},
}
