
(function($) {
    $.scrollToElement = function( $element, speed ) {

        speed = speed || 750;

        $("html, body").animate({
            scrollTop: $element.offset().top,
            scrollLeft: $element.offset().left
        }, speed);
        return $element;
    };

    $.fn.scrollTo = function( speed ) {
        speed = speed || "normal";
        return $.scrollToElement( this, speed );
    };
})(jQuery);

$(document).ready(function(){
	$("#header ul li").hover(function(){
	   $(this).children("span").fadeIn("600");
	 },function(){
	   $(this).children("span").fadeOut("600");
	 });
	
	
	$(".bk-projet").hover(function(){
	   $(this).children(".present-projet").stop().animate({bottom:'-1px'},{queue:false,duration:160});
	$(this).children('.img-hover').fadeIn('500');
	 },function(){
	   $(this).children(".present-projet").stop().animate({bottom:'-20px'},{queue:false,duration:160});
		$(this).children(".img-hover").fadeOut("fast");
	 });
	
	
	
	$(".bk-projet.link-externe").click(function(){
		var link = $(this).find("a");
		var linkLocation = $(link).attr("href");
		window.open(linkLocation);
		return false;
	});	
	
	$(".bk-projet.link-interne").click(function(){
    	window.location=$(this).find("a").attr("href");return false;
	});
	
	$('.bk-projet.showvid').click(function () { 
		$("#header").scrollTo(500);
		var myId = $(this).attr('id');
		var myVideo = ('videos/'+myId+'.flv');
		changeMovie(myVideo);
		return false;
	});	
	
	var myPlayvids = ('<img src="images/play-vids.png" class="picto-vids" />');
	$(".showvid").hover(function(){
		$(this).append(myPlayvids);
		$('.picto-vids').css('opacity', 0);
		$('.picto-vids').fadeTo("fast", 1);
		
	 },function(){
		$('.picto-vids').fadeTo("fast", 0);
		$('.picto-vids').remove();
	 });

	$(".#header h1").click(function(){
		window.location=$(this).find("a").attr("href");return false;
	});

});



