var oldt = 0;

$(document).ready(function(){
	if ($(".diaporama").length>0) {
		$(".diaporama").parent().find("script").remove();
		$(".diaporama").find("img").attr("style", "");
		$(".diaporama").attr("style", "");
		$(".diaporama").wrapInner("<ul>");
		$(".diaporama img").wrap("<li>");
		$(".diaporama").wrap("<div class=\"diaporama_container\"></div>");
		//$(".diaporama_container").prepend("<div class=\"btn_prev\"></div><div class=\"btn_suiv\"></div>");
		$(".diaporama").before("<div style=\"overflow:hidden;margin:0 auto;width:605px;left:50px;height:33px;top:-40px;position:absolute;\"><div class=\"nav_diaporama\" style=\"position:absolute;left:0px;top:0px;white-space:nowrap;\"></div></div>");
		var cpt=1;
		$(".diaporama img").each(function() {
			var url = $(this).attr("src");
			url=url.replace("/media/", "/media/thumbnails/");
			$(".nav_diaporama").append("<a href=\"\" rel=\""+cpt+"\" class=\"customLink\"><img src=\""+url+"\" width=\"90\" height=\"33\"  /></a>");
			cpt++;
		});
		$(".firstLevel").children().first().addClass("firstItem");
		$(".firstLevel").children().last().addClass("lastItem");
		var nbimg = $(".diaporama img").length;
		var sudoSlider = $(".diaporama").sudoSlider({
			auto:true,
			fade:true,
			prevHtml: '<div class="btn_prev"></div>',
			nextHtml: '<div class="btn_suiv"></div>',
			prevNext:true,
			continuous:true,
			customLink:'a.customLink',
			beforeAniFunc: function(t){
			 var scroll = -t+2;
			 if (scroll >= -1) scroll = 0;
			 if (scroll < -1) scroll = scroll+1;
			 if (t>=nbimg-2) scroll=-nbimg+6;
			 
			 //if (scroll > -4) scroll = -3;
			 scroll = scroll * $('.customLink').eq(0).outerWidth(true);

			 var diff = Math.sqrt(Math.abs(oldt-t));
			 var speed = parseInt(diff*800);

			 $('.nav_diaporama').animate(
				{ marginLeft: scroll },
				{
				   queue:false,
				   duration:speed
				}
			 );
			 oldt = t;
		  }
		});
	}
	
	$(".bloc_logo a").hover(function(){
		$(this).animate({
			marginTop:"-5px"
		},200);
	}, function() {
		$(this).animate({
			marginTop:"0px"
		},200);
	});
	
	swfobject.embedSWF("/modeles/fr/Modele1/images/interface/anim_bandeau.swf", "img_logo", "944", "225", "9.0.0", "expressInstall.swf", {}, {bgcolor:"#000000"}, {});
	
});
(function($) {
	$.fn.cycle = function(options, arg2) {
		return false;
	};
})(jQuery);

function accueil_site() {
	location.href="/";
}
