if(navigator.cookieEnabled && $.cookie("age_legal")!='ok')
	document.location.href="/accueil.php";
$(document).ready(function(){
	//MENU//
	$("#menu a.actif").parents("#menu li").addClass("actif").css("color","red");
	var ouvrables=$("#menu li:has(ul)");
	ouvrables.each(function(){
		var $this=$(this);
		var ul=$("ul",this);
		if(!$this.is(".actif"))
			ul.hide();
		$(">div",this).click(function(){
			ul.slideToggle();
			$("ul",ouvrables).not(ul).slideUp();
		});
	});
	//MENU//
	
	//TITRE//
	(function(){
		var h1=$("#page h1").eq(0);
		var txt=h1.text();
		var sep=" > ";
		var posSep=txt.lastIndexOf(sep);
		if(posSep>=0)
			h1.html("<span class='chemin'>"+txt.substring(0,posSep)+" &gt; </span>"+txt.substring(posSep+sep.length));	
	})();
	//TITRE//
	
	//LYS H//
	$("h2").prepend("<img src='images/puce-txt.png' class='puce'>");
	//LYS H//
	
	$(".gallerie.intitulee a:has(img)").each(function(){
		var a=$(this);
		var img=$(">img",this);
		var a2=a.clone().empty();
		var div=$("<div class='img_titre'></div>");
		a.after(div);
		div.append(this);
		div.append(a2);
		var div2=$("<div>")
		var title=$.trim(img.attr("title"));
		if(title=="")
			title=this.title;
		a2.text(title).wrap(div2);
		div2.width(img.width());
	});
	
	$(".illustration.groupe").each(function(){
		var imgs=$(">a",this).removeAttr("src").attr("rel","group").fancybox();
		if(imgs.length<=1)
			return;
		var first=imgs.eq(0);
		var btn_diaporama=$("<a class='btn_diaporama'></a>").attr("href",first.attr("href"));
		var img_diaporama=$("<img src='images/diaporama.png'>");
		btn_diaporama.append(img_diaporama);
		$(">*",this).not(first).hide();
		$(this).prepend(btn_diaporama);
		btn_diaporama.focus(function(){first.focus();}).click(function(){first.click();return false;});
		img_diaporama.ifixpng();
	});
	$("a:has(img)").filter('[href$=".png"],[href$=".jpg"]').not($(".illustration.groupe>a")).fancybox();
	
	//CORRECTIONS BUGS MSIE
	$("#block_marque>img,.bouteille>img").ifixpng();
	if($.browser.msie && $.browser.version<8)
	{
		$("div[id]").filter(function(){return $(this).css("float")!="none";}).css("display","inline");
		$("#page ul").each(function(){
		//$(this).wrap("<table class='table_li'><tr><td></td></tr></table>");
		
			var ul=$(this);				
			var table=$("<table class='table_li'></table>");
			$(">li",this).each(function(){
				var $this=$(this);
				var tr=$("<tr><td class='puce_li'><div class='puce_ie'></div></td><td class='cont_li'></td></tr>");
				var cont_li=$(".cont_li",tr);
				cont_li.append($this.contents());
				table.append(tr);
			});
			ul.after(table);
			ul.remove();
		});
	}
});

