function addmailing(email, lang){
	if(validMail(email.value)){
		killAjax();
		ret = function() {
			if(ajaxOk()){
				document.getElementById('liste').innerHTML = objAjax.responseText;
			}
		}
		callAjax('/script/ajax.php?what=mailing&courriel='+email.value+'&lang='+lang,ret,null);
	}
	else{
		email.focus();
		email.select();
		alert('Veuillez entrer une adresse de courriel valide.');
	}
}

function addcomment(lang, post){
	if(validForm(post)){
		killAjax();
		ret = function(){
			if(ajaxOk()){
				document.getElementById('comment_form').innerHTML = objAjax.responseText;
			}
		}
		callAjax('/script/ajax.php?what=comment&lang='+lang,ret,null,post);
	}
}

// Dropdown menu ...
var currMenu = null;
function mainmenu(sender,classe){
	sender = document.getElementById(sender);
	if(sender){
		sender = (sender.tagName=="UL") ? sender : sender.childNodes[0];
		sender = (sender && sender.tagName=="UL") ? sender : sender.nextSibling;
		if(sender){
			if(sender.tagName=="UL"){
				if(classe!=""){
					var uls = sender.getElementsByTagName("UL");
					for(i=0;i<uls.length;i++){
						if(uls[i].className==classe) currMenu = uls[i].parentNode;
					}
					if(currMenu) currMenu.className+=" shover";
				}
				var lis = sender.getElementsByTagName("LI");
				for(i=0;i<lis.length;i++){
					if(lis[i].className!="vide"){
						lis[i].onmouseover=function() {
							if(currMenu) currMenu.className=currMenu.className.replace("shover", "");
							this.className+=" shover";
							//if(document.all) this.style.zIndex=100;
						}
						lis[i].onmouseout=function() {
							this.className=this.className.replace("shover", "");
							if(currMenu) if(currMenu.className.indexOf("shover")==-1) currMenu.className+=" shover";
							//if(document.all) this.style.zIndex=1;
						}
					}
				}
			}else{
				alert("Le sender n\'est pas un UL");
			}
		}
	}
}

$(function(){
	$("a[rel^=ajax]").fancybox({
		'hideOnContentClick': false
	});
	//if(document.all) document.getElementById("contenu").innerHTML = "s lskajg lkdsfj glj sdlfkgjlksd fgj lsdfj glkj sdflgj lksdg lksdjf gklj sdfklgj lkdjsf glkj sdlfkgj lksdj fgjkl " + document.getElementById("contenu").innerHTML;
});

/*var mousewent = null;
var mouset = null;
function mainmenuJQ2(s){
	$('ul li.parent ul').hide();
	$(function(){
		$('ul li.parent a').hover(function(){
			if(mousewent){
				if(document.all) document.getElementById("contenu").innerHTML = mousewent + " " + document.getElementById("contenu").innerHTML;
				clearTimeout(mousewent);
				mousewent = null;
			}
			
			$(this).parent().addClass("shover");
			$(this).parent().children('ul').slideDown(s);
		},function(){
			if(mousewent){
				if(document.all) document.getElementById("contenu").innerHTML = mousewent + " " + document.getElementById("contenu").innerHTML;
				clearTimeout(mousewent);
				mousewent = null;
			}
			mouset = this;
			mousewent = setTimeout(function(){
				$(mouset).parent().children('ul').slideUp(s,function(){mainmenuJQhide2(this)});
			},1000);
		});
		
		$('ul li.parent ul').hover(function(){
			if(mousewent){
				if(document.all) document.getElementById("contenu").innerHTML = mousewent + " " + document.getElementById("contenu").innerHTML;
				clearTimeout(mousewent);
				mousewent = null;
			}
			
			$(this).parent().addClass("shover");
			$(this).show();
		},function(){
			if(mousewent){
				if(document.all) document.getElementById("contenu").innerHTML = mousewent + " " + document.getElementById("contenu").innerHTML;
				clearTimeout(mousewent);
				mousewent = null;
			}
			mouset = this;
			mousewent = setTimeout(function(){
				$(mouset).slideUp(s,function(){mainmenuJQhide2(this)});
			},1000);
		});
	});
}*/

function mainmenuJQhide2(sender){
	$(sender).hide();
	$(sender).parent().removeClass("shover");
	mousewent = null;
}

jQuery.fn.adnDeonCMEB = function() {
	var o = $(this[0]);
	var timeName = $(this).selector;
	
	var params = arguments[0] || {};
		if(!params.tag) params.tag = "h4";
		if(!params.separator) params.separator = "hr";
		if(!params.container) params.container = "#"+$(o).attr("id");
		if(!params.expanderClass) params.expanderClass = "adnDeonExpander";
		if(!params.containerClass) params.containerClass = "adnDeonHolder";
		if(!params.separatorClass) params.separatorClass = "adnDeonSep";
		if(!params.anchorName) params.anchorName = "blocInformation";
		//params.collapsible
		//params.scrollToExpander
		//params.autoExpand
		//params.autoSpeed
		//params.hoverStopAuto
		//params.separatorShow
		if(!params.slideUpSpeed) params.slideUpSpeed = 600;
		if(!params.slideDownSpeed) params.slideDownSpeed = 800;
		
		if(params.autoSpeed){
			if(!params.autoExpand) params.autoExpand="first";
			params.collapsible = null;
		}
	
	if($(""+params.container+" div."+params.containerClass+"").length==0){
		$(""+params.container+" "+params.tag+", "+params.container+" "+params.separator+"").each(function(index){
			$(this).addClass(""+params.expanderClass+"");
			$(this).attr("id",params.anchorName+"_"+index);
			if($(this).is(""+params.separator+"")){
				$(this).nextAll().wrapAll('<div class="'+params.separatorClass+'" />');
			}else{
				$(this).nextAll().wrapAll('<div class="'+params.containerClass+'" />');
			}
		});
		 
		var expanders = $(""+params.container+" "+params.tag+", "+params.container+" "+params.separator+"").remove();
		var containers = $(""+params.container+" div."+params.containerClass+", "+params.container+" div."+params.separatorClass+"").remove();
		 
		//alert(expanders.length + " " + containers.length);
		
		$(expanders).each(function(index){
			$(""+params.container+"").append(this);
			$(""+params.container+"").append($(containers).eq(index));
		});
		 
		$(""+params.container+" div."+params.containerClass+"").hide();
		if(!params.separatorShow) $(""+params.container+" "+params.separator+"").hide();
		
		function expandMe(sender){
			if(sender==null){
				var monItem = $(""+params.container+" "+params.tag+"."+params.expanderClass+"_O");
				var expandIndex = $(""+params.container+" "+params.tag+"").index(monItem);
				expandIndex++;
				if(expandIndex>=$(""+params.container+" "+params.tag+"").length) expandIndex=0;
				sender = $(""+params.container+" "+params.tag+"").eq(expandIndex);
			}
			if($(sender).next("div."+params.containerClass+"").is(":hidden")){
				$(""+params.container+" "+params.tag+"").removeClass(""+params.expanderClass+"_O");
				$(""+params.container+" div."+params.containerClass+"").slideUp(params.slideUpSpeed);
				$(sender).addClass(""+params.expanderClass+"_O");
				$(sender).next("div."+params.containerClass+"").slideDown(params.slideDownSpeed,function(){
					var thePrev = this;
					if(params.scrollToExpander==true) window.location = "#"+$(thePrev).prev(""+params.tag+"").attr("id");
				});
			}else{
				if(params.collapsible){
					$(""+params.container+" "+params.tag+"").removeClass(""+params.expanderClass+"_O");
					$(""+params.container+" div."+params.containerClass+"").slideUp(params.slideUpSpeed);
				}
			}
		}
		
		$(""+params.container+" "+params.tag+"").bind("click",function(index){
			expandMe(this);
		});
		
		if(params.autoSpeed && !params.autoExpand) params.autoExpand="first";
		
		if(params.autoExpand){
			var expandIndex = 0;
			if(params.autoExpand=="first"){
				expandIndex = 0;
			}else{
				if(params.autoExpand=="last"){
					expandIndex = $(""+params.container+" "+params.tag+"").length-1;
				}else{
					expandIndex=params.autoExpand;
				}
			}
			
			expandMe($(""+params.container+" "+params.tag+"").eq(expandIndex));
			
			if(params.autoExpand2){
				expandMe($(""+params.container+" "+params.tag+"").eq(params.autoExpand2));
			}
			
			if(params.autoSpeed){
				/*$(expanders).each(function(index){
					alert($(this));
				});*/
				clearInterval(adnInterval[timeName]);
				adnInterval[timeName] = setInterval(function(){
					expandMe(null);
				}, params.autoSpeed);
				
				if(params.hoverStopAuto){
					$(o).mouseenter(function(){
						clearInterval(adnInterval[timeName]);
						adnInterval[timeName] = null;
					});
					$(o).mouseleave(function(){
						if(!adnInterval[timeName]){
							clearInterval(adnInterval[timeName]);
							adnInterval[timeName] = setInterval(function(){
								expandMe(null);
							}, params.autoSpeed);
						};
					});
				}
			}
			
			/* POTENTIELLEMENT DECRIPITED $(""+params.container+" "+params.tag+"").eq(expandIndex).addClass(""+params.expanderClass+"_O");
			$(""+params.container+" div."+params.containerClass+"").eq(expandIndex).slideDown();*/
		}
	}
}

var curimgcaroussel = 1;
function swapTitleHome(i){
	if(i==1){
		document.getElementById("cmebTitre").style.backgroundPosition = "-1px 0";
		document.getElementById("imgCMEB").style.backgroundPosition = "0 0";

		document.getElementById("p1").style.display = "block";
		document.getElementById("p2").style.display = "none";
		document.getElementById("p3").style.display = "none";
		document.getElementById("p4").style.display = "none";	
		curimgcaroussel=1;
		}
		
	if(i==2){
		document.getElementById("cmebTitre").style.backgroundPosition = "-186px 0";
		document.getElementById("imgCMEB").style.backgroundPosition = "-363px 0";

		document.getElementById("p1").style.display = "none";
		document.getElementById("p2").style.display = "block";
		document.getElementById("p3").style.display = "none";
		document.getElementById("p4").style.display = "none";
		curimgcaroussel=2;
		}
		
	if(i==3){
		document.getElementById("cmebTitre").style.backgroundPosition = "-371px 0";
		document.getElementById("imgCMEB").style.backgroundPosition = "-726px 0";
		
		document.getElementById("p1").style.display = "none";
		document.getElementById("p2").style.display = "none";
		document.getElementById("p3").style.display = "block";
		document.getElementById("p4").style.display = "none";
		curimgcaroussel=3;
		
		}
	if(i==4){
		document.getElementById("cmebTitre").style.backgroundPosition = "-556px 0";
		document.getElementById("imgCMEB").style.backgroundPosition = "-1089px 0";
		
		document.getElementById("p1").style.display = "none";
		document.getElementById("p2").style.display = "none";
		document.getElementById("p3").style.display = "none";
		document.getElementById("p4").style.display = "block";
		curimgcaroussel=4;
		
		}
		$(".miniCMEB a").each(function(){$(this).css("backgroundPosition","0 -55px")});
		$(".miniCMEB a").eq(curimgcaroussel-1).css("backgroundPosition","0 0");
		
	}
var timerhndl;	

startCaroussel = function(){timerhndl = setInterval("smcaroussel()",7000)};
stopcaroussel = function(){clearInterval(timerhndl);};
smcaroussel = function(){
	curimgcaroussel++;
	if(curimgcaroussel>4){curimgcaroussel=1;}
	swapTitleHome(curimgcaroussel);
	//$(".miniCMEB a").each(function(){$(this).css("backgroundPosition","0 -55px")});
	//$(".miniCMEB a").eq(curimgcaroussel-1).css("backgroundPosition","0 0");
};

$(document).ready(function(){
	/*BEGIN*/
	$("#videoTattoo").click(function(e){
		e.preventDefault();
		alert('J\'ai cliqué');
		//_gaq.push(['_trackEvent', 'Click To Facebook', 'Teaser Facebook general', 'Visite vers la page accueil de FB']);
	});
	/*END*/
});

