/* ------------------------------------------------------------------------
	Class: MediaBox
	Author: Stéphane PERES(http://www.npc-media.com)
	Version: 1.6
------------------------------------------------------------------------- */

// Lien valid W3C
function innerHTMLcopy(source, target){
	$("#target").html = $("#source").html
}
function lien(monLien){
	window.open(monLien, '_blank');
	return false;
}

// Opacité sur les images
$(function(){
	$("#block img").css("opacity",1);
	   $("#block img").mouseover(function(){
			$(this).stop().fadeTo(500,0.7);
	});
	$("#block img").mouseout(function(){
			$(this).stop().fadeTo(500,1);
	});
	$("#block2 img").css("opacity",1);
	   $("#block2 img").mouseover(function(){
			$(this).stop().fadeTo(500,0.7);
	});
	$("#block2 img").mouseout(function(){
			$(this).stop().fadeTo(500,1);
	});
	$("#jeu_batonnat img").css("opacity",0.8);
	   $("#jeu_batonnat img").mouseover(function(){
			$(this).stop().fadeTo(500,1);
	});
	$("#jeu_batonnat img").mouseout(function(){
			$(this).stop().fadeTo(500,0.8);
	});
});

// Bloc info
$(function() {
    $('#activator').click(function(){
		$('#overlay').fadeIn('fast',function(){
			$('#box').animate({'top':'200px'},500);
        });
    });
    $('#boxclose').click(function(){
		$('#box').animate({'top':'-600px'},500,function(){
            $('#overlay').fadeOut('fast');
        });
    });
});

// Défilement des pages avec effet
$(function() {
	ascenseur.init('.liste h2','.liste ul');
	$('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 = {
	init : function(btn,acacher){			
		$(acacher).hide();
		$(btn).click(function(){
			$(acacher).slideToggle(500);
			return false;
		});
	},
}

// DesignInfoBulle
$(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-20,
            opacity:0
        });
        bulle.animate({
            top:posTop-10,
            opacity:0.99
        });
    });
    
    $("a").mouseout(function(){
        var bulle = $(".infobulle:last");
        $(this).attr("title",bulle.text());
        bulle.animate(
            {
                top:bulle.offset().top+10,
                opacity:0
            },
            500,
            "linear",
            function(){
                bulle.remove();  
            }
        );
    });
});
