var cdhMobile=false;
var bananas_random=[
"Déclaration of the united states of bananas",
"Déclaration de la république démocratique du Comptoir",
"Si vous l\'aviez raté, ne le ratez pas encore",
"Le Comptoir vous saurait gré de bien vouloir consulter les machins au dessus",
"Décréation de Comptoir dénuée de tout pipotron abusif",
"N\'a de conviction que celui qui n\'a rien approfondi",
"Mangez beaucoup d\'ail, il rajeunit l\'organisme et écarte les importuns",
"Etre dans le vent : une ambition de feuille morte",
"Parce que ce n\'est pas faux qu\'il soit nécessaire de mettre son doigt dans le coq.",
"Nous vous demandons de vous arréter.",
"Il vaut mieux se taire et passer pour un con plutôt que de parler et ne laisser aucun doute sur le sujet",
"Tu veux du bacon ?",
"L\'ignorant affirme, le savant doute, le sage réfléchit",
"Bachi Bouzouk ! Moule à gaufres ! Anacoluthe ! Pitécanthrope de Java !",
"Peu importe ce qu’on pourra vous dire, les mots et les idées peuvent changer le monde",
"Une vodka-Martini. Mélangée au shaker, pas à la cuillère.",
"Allo McFly, y\'a personne au bout du fil ! Faut réfléchir McFLy !",
"Magnéto, Serge!",
"Moi j\’ai appris à lire, ben je souhaite ça à personne",
"On cause hardware, on tient pas un stand de crêpes"
]

function home_title(text,className,href,rss,rsstext) {
	pos=text.indexOf(" ")
	if (pos>0) text="<b class=home_title>"+text.substring(0,pos)+"</b>"+text.substring(pos)
	document.write("<div class=home_"+className+"_title><a href="+href+">"+text+"</a>")
	if (rss.length>0) document.write("<a title='Flux rss "+rsstext+"' target=_blank href="+rss+"><img src=/images/0.gif class=home_news_rss></a>")
	document.write("</div>")
}
day=new Array("dimanche")
day[1]="lundi";
day[2]="mardi";
day[3]="mercredi";
day[4]="jeudi";
day[5]="vendredi";
day[6]="samedi";
day[7]="dimanche";
var month=new Array("");
month[1]="janvier";
month[2]="février";
month[3]="mars";
month[4]="avril";
month[5]="mai";
month[6]="juin";
month[7]="juillet";
month[8]="août";
month[9]="septembre";
month[10]="octobre";
month[11]="novembre";
month[12]="décembre";
month[0]="décembre";
function home_date(text) {
	var dat=text.split(' ')
	document.write("<div class=home_calendar>"+day[dat[0]]+", "+dat[1]+" "+month[dat[2]]+" "+dat[3]+"</div>")
}
function home_topics_top(id) {
	document.getElementById("home_topics_top").style.display=""
	document.getElementById("home_topics_last").style.display="none"
	document.getElementById("home_topics_comm").style.display="none"
	document.getElementById("home_topics_title").className="home_topics_top"
}
function home_topics_last(id) {
	document.getElementById("home_topics_last").style.display=""
	document.getElementById("home_topics_top").style.display="none"
	document.getElementById("home_topics_comm").style.display="none"
	document.getElementById("home_topics_title").className="home_topics_last"
}
function home_topics_comm(id) {
	document.getElementById("home_topics_comm").style.display=""
	document.getElementById("home_topics_last").style.display="none"
	document.getElementById("home_topics_top").style.display="none"
	document.getElementById("home_topics_title").className="home_topics_comm"
}
function home_news_open(id,type) {
	if(document.body.className.indexOf('mobile')<0) {
		if(top.document.getElementById("text_"+id)) top.document.getElementById("text_"+id).style.display="block"
		if (news_over>0) if (news_over!=id) {
			document.getElementById("home_news_"+news_over).className="home_news"
			if(document.getElementById("bot_"+news_over)) document.getElementById("bot_"+news_over).style.backgroundColor="white"
		}
		news_over=0
		if (type=="/articles/") document.getElementById("home_news_"+id).className="home_articles_over_cat"
		else document.getElementById("home_news_"+id).className="home_news_over"
		if(document.getElementById("bot_"+id)) document.getElementById("bot_"+id).style.backgroundColor="#EDEDED"
	}
}
function home_news_over(id,type) {
	if(document.body.className.indexOf('mobile')<0) {
		if (news_over>0) if (news_over!=id) {
			document.getElementById("home_news_"+news_over).className="home_news"
			document.getElementById("bot_"+news_over).style.backgroundColor="white"
		}
		news_over=0
		if (type=="/articles/") document.getElementById("home_news_"+id).className="home_articles_over_cat"
		else document.getElementById("home_news_"+id).className="home_news_over"
		document.getElementById("bot_"+id).style.backgroundColor="#EDEDED"
	}
}
function home_news_close(id) {
	if(top.document.getElementById("text_"+id)) top.document.getElementById("text_"+id).style.display="none"
	news_over=id
	setTimeout("home_news_hide()",200)
}
function home_news_out(id) {
	news_over=id
	setTimeout("home_news_hide()",200)
}
function home_news_hide() {
	if (news_over>0) {
		document.getElementById("home_news_"+news_over).className="home_news"
		if(document.getElementById("bot_"+news_over)) document.getElementById("bot_"+news_over).style.backgroundColor="white"
	}
}
function home_articles_up(id) {
	if (document.getElementById("home_articles_move_"+id).value>0) {
		height_content=document.getElementById("home_articles_content_"+id).clientHeight+5
		height_actual=document.getElementById("home_articles_"+id).clientHeight
		if (height_actual<height_content) {
			document.getElementById("home_articles_"+id).style.height=Math.min(height_content,height_actual+15)+"px"
			setTimeout("home_articles_up("+id+")",10)
		} else {
			document.getElementById("home_articles_"+id).style.height=height_content+"px"
			document.getElementById("home_articles_move_"+id).value=0
		}
	}
}
function home_articles_down(id) {
	if (document.getElementById("home_articles_move_"+id).value<0) {
		height_actual=document.getElementById("home_articles_"+id).clientHeight
		if (height_actual>128) {
			document.getElementById("home_articles_"+id).style.height=Math.max(128,height_actual-45)+"px"
			setTimeout("home_articles_down("+id+")",10)
		} else {
			document.getElementById("home_articles_"+id).style.height="128px"
			document.getElementById("home_articles_move_"+id).value=0
		}
	}
}
function home_articles_over(id) {
	document.getElementById("home_articles_move_"+id).value=1
	document.getElementById("home_articles_"+id).className="home_articles_over"
	document.getElementById("home_articles_dot_"+id).style.display="none"
	home_articles_up(id)
}
function home_articles_out(id) {
	document.getElementById("home_articles_move_"+id).value=-1
	setTimeout("home_articles_hide("+id+")",20)
}
function home_articles_hide(id) {
	home_articles_down(id)
	if (document.getElementById("home_articles_move_"+id).value<0) {
		document.getElementById("home_articles_"+id).className="home_articles"
		document.getElementById("home_articles_dot_"+id).style.display=""
	}
}
function tip_it(which,TTitle,TContent) {
	if(document.body.className.indexOf('mobile')<0) {
		if (which) {
			mouse_X_origin=0
			mouse_Y_origin=0
			tip_active=1
			document.getElementById('ToolTip').style.visibility="visible"
			document.getElementById('ToolTip').innerHTML=TContent
			document.getElementById('ToolTip').style.left=1
			update_tip_pos()
		} else {
			tip_active=0
			mouse_X_origin=0
			mouse_Y_origin=0
			document.getElementById('ToolTip').style.visibility="hidden"
			document.getElementById('ToolTip').style.left=0
		}
	}
}
var mouse_X_origin=0
var mouse_Y_origin=0
function getMouseXY(e) {
	if (ie) {
		mouse_X=event.clientX
		scrOfY=0
		if (typeof(window.pageYOffset)=='number') scrOfY=window.pageYOffset
		else if (document.body&&(document.body.scrollLeft || document.body.scrollTop)) scrOfY=document.body.scrollTop
		else if (document.documentElement&&(document.documentElement.scrollLeft || document.documentElement.scrollTop)) scrOfY=document.documentElement.scrollTop
		mouse_Y=event.clientY+scrOfY
	} else {
		mouse_X=e.pageX
		mouse_Y=e.pageY
	}
	if (mouse_X<0) {
		mouse_X=0
	}
	if (mouse_Y<0) {
		mouse_Y=0
	}
	if (tip_active) {
		update_tip_pos()
	}
}
function update_tip_pos() {
	if (document.getElementById('ToolTip').style.left.replace('px','')==0) {
	if (mouse_X_origin==0) mouse_X_origin=mouse_X
	else if (Math.abs(mouse_X_origin-mouse_X)>15) tip_it(0,"","")
	if (mouse_Y_origin==0) mouse_Y_origin=mouse_Y
	else if (Math.abs(mouse_Y_origin-mouse_Y)>15) tip_it(0,"","")
	document.getElementById('ToolTip').style.left=(mouse_X-70)+'px'
	document.getElementById('ToolTip').style.top=(mouse_Y+20)+'px'
	}
}

var comm_timer=[]
function home_comm_hide(id){
	comm_timer[id]=setTimeout(function(){
	document.getElementById('bull'+id).parentNode.style.display="none"
	},150);
}
function home_comm_show(id) {
	if(document.body.className.indexOf('mobile')<0) {
		window.clearTimeout(comm_timer[id])
		divs=document.getElementsByClassName('bull1');
		for(let i=0;i<divs.length;i++){
			if(divs[i].getElementsByTagName('div')[0].id.replace('bull','')*1!=id) {
				divs[i].style.display="none";
			}
		}
		iframe_src("frame_comm","/modules/mod_home/bull_ragots.php?id="+id)
	}
}
function action_comm() {
	tip_it(1,"Ragots",document.getElementById('ragots').value)
}
function dbl(num) {
	if (num<10) return "0"+num
	else return num
}

function coupe_text(taille_min, taille_max, text)
{
	pos = taille_max;
	var tab_car = [" ",".", "!", "?", ";", ":", ",", "(", ")", "[", "]", "-"];
	var ajoute_trois_points = true;
	for (var car = 0; car < tab_car.length; car++ ) // Pour chaque caractere on regarde le plus court
	{
		// Si le caractere existe et donne une phrase plus petite
		if (text.indexOf(tab_car[car], taille_min) != -1 && text.indexOf(tab_car[car], taille_min) < pos) {
			pos = text.indexOf(tab_car[car], taille_min);
			if (tab_car[car] != ".") {
				ajoute_trois_points = true;
			} else {
				ajoute_trois_points = false;
			}
		}
	}
	var ajoute_trois_points = false;
	if (ajoute_trois_points)
		return text.substring(0, pos) + "...";
	else
		return text.substring(0, pos + 1);
}

function decimalToHexString(number){
  if (number < 0)
  {
    number = 0xFFFFFFFF + number + 1;
  }

  return number.toString(16).toUpperCase()+number.toString(16).toUpperCase()+number.toString(16).toUpperCase();
}
function $_GET(param) {
	var vars = {};
	window.location.href.replace( location.hash, '' ).replace(
		/[?&]+([^=&]+)=?([^&]*)?/gi, // regexp
		function( m, key, value ) { // callback
			vars[key] = value !== undefined ? value : '';
		}
	);

	if ( param ) {
		return vars[param] ? vars[param] : null;
	}
	return vars;
}


function action_news(div,hr,section) {
	var news_id=document.getElementById('news_id').value.split('<')
	var news_title=document.getElementById('news_title').value.split('<')
	var news_alias=document.getElementById('news_alias').value.split('<')
	var news_text=document.getElementById('news_text').value.split('<')
	var news_date=document.getElementById('news_date').value.split('<')
	var news_author=document.getElementById('news_author').value.split('<')
	var news_ragots=document.getElementById('news_ragots').value.split('<')
	var news_thumb=document.getElementById('news_thumb').value.split('<')
	var cat_title=document.getElementById('cat_title').value.split('<')
	var cat_alias=document.getElementById('cat_alias').value.split('<')
	var section_id=document.getElementById('section_id').value.split('<')
	var HTML=new Array()
	var now=new Date()
	var yesterday=new Date(now.getTime()-86400000)
	var old=0
	var sunday_on=0
	var news_first_count=0
	var news_first_hit=0
	var color_start=32;
	var color_end=80;
	var color_now=color_start;
	var color_add;

	var device=  document.body.className.indexOf('mobile')

	if (device==0) { // Take the user to a different screen here. }
		var plateforme='mobile';
	} else  {var plateforme='desktop';}


	for (i=0;i<news_id.length;i++) {
	if (section_id[i]==0) {
		news_first_count++;
	}
	}
	color_add=(color_end-color_start)/news_first_count;

	for (i=0;i<news_id.length;i++) {
		num=new Date(news_date[i]*1000)
		if((div=="news")&&(sunday_on<2)){
			nday=num.getDay()
			if((sunday_on==1)||(((now.getDay()==0)&&(now.getHours()>=8))||(now.getDay()>0))){
			if((sunday_on==1)||(now.getTime()-num.getTime()<3600*24*6*1000)){
				if(section_id[i]!=0) {
					if(nday<=1) sunday_on=1
					if((now.getDay()==0)&&(nday==6)) sunday_on=1
				}
				if(sunday_on==1){
					if(((nday==0)&&(num.getHours()<8))||(nday==6)){
					sunday_on=2
					// if(section_id[i]==1 && i>0) HTML.push('<img align=right src=/images/0.gif class=home_hr><br><br>')
					//if(section_id[i]==1 && i>0) HTML.push('<br>')
				HTML.push('<div id=sunday_top></div>')
				//if((nday==0)||(i==0)) HTML.push('<img align=right src=/images/0.gif class=home_hr><br><br>')
					old=5678;
		}}}}}

		if ((section_id[i]==1)&&(section_id[i]>0)&&(hr==0)) {
			// if (old>0) if (num.getDate()!=old) HTML.push('<img align=right src=/images/0.gif class=home_hr><br><br>')
			// if (old>0) if (num.getDate()!=old) HTML.push('<br>')
			old=num.getDate()
		}
		if (Math.abs(section_id[i])>1) {
			type='/articles/'
			texttitle='Tous les articles'
		} else {
			type='/actus/'
			texttitle='Toutes les actus'

		}
		
		thumb_width=230;
		news_height=110;
		thumb_height=100; 
		if (section_id[i]==0) { thumb_width=230; thumb_height=62; }
		else{
			if (Math.abs(section_id[i])!=1) { thumb_width=325; thumb_height=100; } else thumb_width=230;
		}








		if(plateforme=='desktop'){

		if(section_id[i]==1 && news_text[i].length<2){
			thumb_width=230; thumb_height=62; news_height=62;
			HTML.push('<table class="home_news_quick')
			}
		else HTML.push('<table class="home_news');

		if (section_id[i]==3 || section_id[i]==5 || section_id[i]==6) { bull_css="_art"; } else { bull_css=""; };
		if (section_id[i]==0) {
			HTML.push('_first'+bull_css)
			news_height=60;
			if(section_id[i+1]!=0){
				HTML.push(' home_news_first_last')
				HTML.push(' cat_'+cat_alias[i].split('-').join('_'));
			} else {
				HTML.push(' cat_'+cat_alias[i].split('-').join('_'));
			}
			HTML.push('"')
		}
		else if (section_id[i]<0) {
			HTML.push(bull_css+' cat_'+cat_alias[i].split('-').join('_'));
			HTML.push('" id=home_news_',news_id[i],' onmouseover=home_news_open(',news_id[i],',"'+type+'") onmouseout=home_news_close(',news_id[i],')')
		}
		else {
			HTML.push(bull_css+' cat_'+cat_alias[i].split('-').join('_'));
			HTML.push('" id=home_news_',news_id[i],' onmouseout=tip_it(0,"","");')
		}
		
		if (cat_alias[i]=="bons-plans-du-comptoir") type="/"
		if (section_id[i]==5) type="/reference/";
		if (cat_alias[i]=="concours") type="/"
		if (section_id[i]==0) {
			HTML.push(' style="background-image: linear-gradient(to bottom, #'+decimalToHexString(color_now)+', #'+decimalToHexString(color_add+color_now)+')"');
			color_now+=color_add;
		}
		HTML.push(' cellpadding=0 cellspacing=0>')
		//if (section_id[i]==0) HTML.push('<tr><td height=5> </tr>')
		//bull_css="";
		
		
		HTML.push('<tr><td rowspan=3 valign=middle><div class=bull1 style=display:none><div onmouseover=home_comm_show(',news_id[i],');  onmouseout=home_comm_hide(',news_id[i],'); class=home_comm id=bull',news_id[i],'> </div></div>');
		HTML.push('<div');
		if (news_ragots[i]>0) HTML.push(' onmouseover=home_comm_show(',news_id[i],') onmouseout=home_comm_hide(',news_id[i],')');
		HTML.push('	class="bull_ragots',bull_css,' bull_',cat_alias[i],'">');
		
		
		if(Math.round((new Date()).getTime()/1000)-news_date[i]<0) {
		// pas encore publié
		noragot=[""];
		}
		else if(Math.round((new Date()).getTime()/1000)-news_date[i]<6000*3) {
		// publié depuis moins de 6h
		noragot=["<img src=/images/ragot-load.gif>","<img src=/images/ragot-load-2.gif>","<img src=/images/ragot-load-3.gif>"];
		} else {
			//noragot=["no<br>ragotz","pinut's","la<br>bulle","CQFD","ragots<br>vacants","glory<br>hole","c\'est qui bob ?"];
			noragot=[""];
		}
		
		// ragots fermés
		if (news_ragots[i]<0) noragot=["nope","no<br>way","RBdC","atone"];
		
		if (news_ragots[i]>0) {
			HTML.push('<a href=',type,cat_alias[i],'/',news_id[i],'-',news_alias[i],'.html#ragots>',news_ragots[i],'</a>');
		} else {
			HTML.push('<a href=',type,cat_alias[i],'/',news_id[i],'-',news_alias[i],'.html#ragots><font>',noragot[Math.round(Math.random()*(noragot.length-1))],'</font>')
		}

		
		HTML.push('</div>');

		if (news_date[i]*1000>now.getTime()) HTML.push('<div class=news1 style=width:',thumb_width,'px;>');
		//else if(section==1) HTML.push('<div class=news2 style=width:',thumb_width,'px;height:',news_height,'px><table style=border-spacing:0>');
		else if(section==1) HTML.push('<div class=news2 style=width:',thumb_width,'px;>');
		else HTML.push('<div class=news3 style=width:',thumb_width,'px>');

		if (news_thumb[i]>0) {
			HTML.push('<a href=',type,cat_alias[i],'/',news_id[i],'-',news_alias[i],'.html>')
			if(news_text[i].length<2){
				HTML.push('<div style=width:'+thumb_width+'px;height:'+thumb_height+'px;background-image:url(/images/thumbs/actus/',news_id[i],'.jpg);margin-top:-5px;background-size:cover;></div>')
			} else {
				HTML.push('<img width='+thumb_width+' id=img_'+news_id[i]+' alt="',news_title[i],'" src=/images/thumbs/')
				if(Math.abs(section_id[i])==1) HTML.push('actus')
				else if(Math.abs(section_id[i])==0) HTML.push('alaune')
				else HTML.push('tests')
				HTML.push('/',news_id[i],'.jpg')
				if (section_id[i]==0) HTML.push(' style=margin-top:-10px;position;absolute; class=first')
				HTML.push('>')
			}
		HTML.push('</a>')
		}
		else if(
				news_date[i]*1000<=now.getTime()) HTML.push('<tr><td><a href=',type,cat_alias[i],'/',news_id[i],'-',news_alias[i],'.html><img width='+thumb_width+' src=/images/thumbs/video.gif alt=video></a>'
				)
		HTML.push('</div>');
		
		if (section_id[i]==0) HTML.push('<td colspan=2 valign=top style=padding-top:10px class=home_news><h2 class=title><a class=home_news ');
		else if(section_id[i]==1 && news_text[i].length<2) HTML.push('<td colspan=2 valign=top style=vertical-align:middle class=home_news><h2 class=title><a class=home_news ');
		else HTML.push('<td colspan=2 valign=middle class=home_news><h2 class=title><a class=home_news ');
		if (news_date[i]*1000>now.getTime()) HTML.push('style=color:var(--accentohcon) ')
		HTML.push('href=',type,cat_alias[i],'/',news_id[i],'-',news_alias[i],'.html>')
		if ((news_title[i].indexOf(" • ")==0)&&(section_id[i]==0)) HTML.push('<b class=componentheading style=padding:0px;font-size:100%;>Oy&eacute;Oy&eacute;</b> • ')
		if (news_title[i].indexOf(" • ")>0) {
			HTML.push('<b class=componentheading style=padding:0px;font-size:100%;>',news_title[i].substr(0,news_title[i].indexOf(" • ")),'</b> • ')
			news_title[i]=news_title[i].substr(3+news_title[i].indexOf(" • "))
		}
		HTML.push(news_title[i],'</a>')
		if (Math.abs(section_id[i])==1) HTML.push(' <a class=home_cat title="',texttitle,' de cette catégorie" href=',type,cat_alias[i],'.html>',cat_title[i],'</a></h4></td>')
		
		if ((num.getDate()==now.getDate())&&(num.getMonth()==now.getMonth())&&(num.getFullYear()==now.getFullYear())) today="aujourd'hui"
		else if ((num.getDate()==yesterday.getDate())&&(num.getMonth()==yesterday.getMonth())&&(num.getFullYear()==yesterday.getFullYear())) today="hier"
		else {
			today=/*day[num.getDay()]+'&nbsp;'+*/dbl(num.getDate())+'&nbsp;'+month[num.getMonth()+1]
			if (num.getFullYear()<now.getFullYear()) today += " "+num.getFullYear()
		}
		HTML.push('</td></tr>');
		
		if((news_text[i].length>10)||(section_id[i]<=0)){

			text=coupe_text(138, 195, news_text[i]); //text=news_text[i].substring(0,180);
			if(text!=news_text[i]) text+='…'
			if(section_id[i]>1) {
				// plus de substring
				text=news_text[i];
				//text=news_text[i].substring(0,250)
				if(text.indexOf('|')>0) text='<h3>'+text.substring(0,text.indexOf('|'))+'</h3>'
				else {
					text='<h3>'+text+'</h3>'
				}
			}
			text=text.replace('|','')
			text=text.replace('[del]','<del>')
			text=text.replace('[/del]','</del>')
						
			if(section_id[i]==1 && news_text[i].length<2){
				HTML.push('<tr><td colspan=2>')
					HTML.push('<div style=height:36px; class="home_content_')
					if (section_id[i]==1) HTML.push('news'); else HTML.push('articles')
					HTML.push('">')
					if (section_id[i]>1) HTML.push('<span class="home_author"><a class=home_cat style=color:var(--accentohcon-yallah); title="',texttitle,' de cette catégorie" href=',type,cat_alias[i],'.html>',cat_title[i],'</a>&nbsp;<strong>/</strong>&nbsp;',today,'</span>')
					else {
						HTML.push('<a href=',type,cat_alias[i],'/',news_id[i],'-',news_alias[i],'.html>')
						// HTML.push('<font style=font-size:1.22em;line-height:1.12em;overflow:hidden>',text,' ',today,'</font>')
						// HTML.push(' à <font color="D61043">',dbl(num.getHours()),'h',dbl(num.getMinutes()))
						HTML.push('</span></a>')
						
					}
					HTML.push('</b></span>')
					HTML.push('</div></td>')
			}else if(section_id[i]>0) {
				HTML.push('<tr><td colspan=2>')
				if (section_id[i]==1) HTML.push('<div class="home_content_news'); else HTML.push('<div class="home_content_articles')
				HTML.push('">')
				if (section_id[i]>1) HTML.push('<span class="home_author"><a style=color:var(--accentohcon-yallah); title="',texttitle,' de cette catégorie" href=',type,cat_alias[i],'.html>',cat_title[i],'</a></span><br>',text)
				else {
					HTML.push('<a href=',type,cat_alias[i],'/',news_id[i],'-',news_alias[i],'.html>')
					HTML.push(text,' &nbsp;<span class="home_content_date"><strong>/</strong></font>&nbsp;',today)
					HTML.push('&nbsp;•&nbsp;',dbl(num.getHours()),':',dbl(num.getMinutes()))
					HTML.push('</span></span></a>')
					
				}
				HTML.push('</div></td>')
			}
			if (section_id[i]<0) {
				HTML.push('<tr><td colspan=2>')
				HTML.push('<div id=text_',news_id[i],' style=display:none; class=home_content_')
				if (Math.abs(section_id[i])==1) HTML.push('news'); else HTML.push('articles')
				HTML.push('>');
				if (Math.abs(section_id[i])>1)
				HTML.push('<a href=',type,cat_alias[i],'/',news_id[i],'-',news_alias[i],'.html>')
			
				if (Math.abs(section_id[i])==1 && news_text[i].length<2){HTML.push(text,' <span class=odette>',news_author[i],'&nbsp;<font style=color:var(--accentohcon)>&nbsp;',today,'&nbsp;',dbl(num.getHours()),dbl(num.getMinutes()),'<font style=color:var(--cooling)>-Coorte</font>')}
				else {HTML.push(text,' <span class=odette>',news_author[i],'&nbsp;<font style=color:var(--accentohcon)>&nbsp;',today,'&nbsp;',dbl(num.getHours()),dbl(num.getMinutes()))}
				HTML.push('</span></font></span></a></div></td>')
				// HTML.push('<font style=font-size:1.22em;line-height:1.12em;overflow:hidden>',text,'</font> <span class=home_author>',news_author[i],' ',today)
			}

			HTML.push('</tr>')
		}
		HTML.push('</table>')
		if (section_id[i]==0) {
			if(section_id[i+1]!=0){
				HTML.push('<div class="home_news_first_last_hr"><span>'+bananas_random[Math.floor(Math.random()*bananas_random.length)]+'</span></div>')
			}
		}

		}

		if(plateforme=='mobile'){



			if(section_id[i]==1 && news_text[i].length<2){
				thumb_width=230; thumb_height=60; news_height=60;
				HTML.push('<div class="container_home_news_quick')
			}
			else HTML.push('<div class="container_home_news');
			if (section_id[i]==3 || section_id[i]==5 || section_id[i]==6) { bull_css="_art"; } else { bull_css=""; };

		/*	if(news_title[i].substr(0,news_title[i].indexOf(" • "))=="Test")
			{HTML.push(' home_news_test')}*/

			if (section_id[i]==0) {
				HTML.push('_first'+bull_css)
				news_height=60;
				if(section_id[i+1]!=0){
					HTML.push(' home_news_first_last')
					HTML.push(' cat_'+cat_alias[i].split('-').join('_'));
				} else {
					HTML.push(' cat_'+cat_alias[i].split('-').join('_'));
				}
				HTML.push('"')
			}
			else if (section_id[i]<0) {
				HTML.push(bull_css+' cat_'+cat_alias[i].split('-').join('_'));
				HTML.push('" id=home_news_',news_id[i],' onmouseover=home_news_open(',news_id[i],',"'+type+'") onmouseout=home_news_close(',news_id[i],')')
			}
			else {
				HTML.push(bull_css+' cat_'+cat_alias[i].split('-').join('_'));
				HTML.push('" id=home_news_',news_id[i])
			}

			if (cat_alias[i]=="bons-plans-du-comptoir") type="/"
			if (cat_alias[i]=="reference") type="/"
			if (cat_alias[i]=="concours") type="/"
			if (section_id[i]==0) {
				HTML.push(' style="background-image: linear-gradient(to bottom, #'+decimalToHexString(color_now)+', #'+decimalToHexString(color_add+color_now)+')"');
				color_now+=color_add;
			}

			HTML.push('>');

			if (news_date[i]*1000>now.getTime()) HTML.push('<div class=ligne-news1 ><div class="left-news" >');
			else if(section==1) HTML.push('<div class=ligne-news2 ><div class="left-news"  >');
			else HTML.push('<div class=ligne-news3 ><div  class="left-news"  ');

			if (news_thumb[i]>0) {

				HTML.push('<div class="left-image">');
				HTML.push('<div >');




				if(bull_css!='_art') {
					HTML.push('<div');
					if (news_ragots[i] > 0) HTML.push('');
					HTML.push('	class="bull_ragots', bull_css, ' bull_', cat_alias[i], '">');
					if (Math.round((new Date()).getTime() / 1000) - news_date[i] < 0) {
						// pas encore publié
						noragot = [""];
					} else if (Math.round((new Date()).getTime() / 1000) - news_date[i] < 6000 * 3) {
						// publié depuis moins de 5h
						noragot = ["<img src=/images/ragot-load.gif>", "<img src=/images/ragot-load-2.gif>", "<img src=/images/ragot-load-3.gif>"];
					} else {
						//noragot = ["no<br>ragotz", "echo<br>echo","billet<br>muet","nil<br>speak", "la<br>bulle", "CQFD", "ragots<br>vacants", "glory<br>hole", "c\'est qui bob ?"];
						noragot=[""];
					}
					// ragots fermés
					if (news_ragots[i] < 0) noragot = ["nope", "no<br>way", "RBdC", "atone"];
					if (news_ragots[i] > 0) {
						HTML.push('<span>', news_ragots[i], '</a>');
					} else {
						HTML.push('<font>', noragot[Math.round(Math.random() * (noragot.length - 1))], '</font>')
					}

					HTML.push('</div></div>');
				}


				HTML.push('<a href=',type,cat_alias[i],'/',news_id[i],'-',news_alias[i],'.html style="position:relative">')
					HTML.push('<img width='+thumb_width+' id=img_'+news_id[i]+' loading="lazy" alt="',news_title[i],'" src=/images/thumbs/')
					if(Math.abs(section_id[i])==1) HTML.push('actus')
					else if(Math.abs(section_id[i])==0) HTML.push('alaune')
					else HTML.push('tests')
					HTML.push('/',news_id[i],'.jpg')
					if (section_id[i]==0) HTML.push(' style=margin-top:-10px; class=first')
					HTML.push('>')

				HTML.push('</a></div>')
			} else if(news_date[i]*1000<=now.getTime()) HTML.push('<div ><a href=',type,cat_alias[i],'/',news_id[i],'-',news_alias[i],'.html><img width='+thumb_width+' src=/images/thumbs/video.gif alt=video></a></div>')
			else HTML.push('</div>')
			HTML.push('</div>');

			if (section_id[i]==0) HTML.push('<div class="center-news" ><h2 class=title><a class=home_news ');
			else if(section_id[i]==1 && news_text[i].length<2) HTML.push('<div class="center-news" ><h2 class=title><a class=home_news data-n="1"');
			else HTML.push('<div class="center-news"><h2 class=title><a class=home_news data-n="2"');
			if (news_date[i]*1000>now.getTime()) HTML.push('style=color:color:var(--accentohcon) ')
			HTML.push('href=',type,cat_alias[i],'/',news_id[i],'-',news_alias[i],'.html>')
			if ((news_title[i].indexOf(" • ")==0)&&(section_id[i]==0)) HTML.push('<b class=componentheading style=padding:0px;font-size:100%;>Oy&eacute;Oy&eacute;</b> • ')
			if (news_title[i].indexOf(" • ")>0) {
				HTML.push('<b class=componentheading style=padding:0px;font-size:100%;>',news_title[i].substr(0,news_title[i].indexOf(" • ")),'</b> • ')
				news_title[i]=news_title[i].substr(3+news_title[i].indexOf(" • "))
			}
			HTML.push(news_title[i])
			if (Math.abs(section_id[i])==1) HTML.push('&nbsp;<span class="home_cat" >',cat_title[i],'</span>')
			HTML.push('</a>')
			if ((num.getDate()==now.getDate())&&(num.getMonth()==now.getMonth())&&(num.getFullYear()==now.getFullYear())) today="aujourd'hui"
			else if ((num.getDate()==yesterday.getDate())&&(num.getMonth()==yesterday.getMonth())&&(num.getFullYear()==yesterday.getFullYear())) today="hier"
			else {
				today=/*day[num.getDay()]+'&nbsp;'+*/dbl(num.getDate())+'&nbsp;'+month[num.getMonth()+1]
				if (num.getFullYear()<now.getFullYear()) today += " "+num.getFullYear()
			}
			if(bull_css=='_art') {
				HTML.push('<div');
				if (news_ragots[i] > 0) HTML.push('');
				HTML.push('	class="bull_ragots', bull_css, ' bull_', cat_alias[i], '">');
				if (Math.round((new Date()).getTime() / 1000) - news_date[i] < 0) {
					// pas encore publié
					noragot = [""];
				} else if (Math.round((new Date()).getTime() / 1000) - news_date[i] < 6000 * 3) {
					// publié depuis moins de 6h
					noragot = ["<img src=/images/ragot-load.gif>", "<img src=/images/ragot-load-2.gif>", "<img src=/images/ragot-load-3.gif>"];
				} else {
					//noragot = ["no<br>ragotz", "echo<br>echo","billet<br>muet","nil<br>speak", "la<br>bulle", "CQFD", "ragots<br>vacants", "glory<br>hole", "c\'est qui bob ?"];
					noragot=[""];
				}
				// ragots fermés
				if (news_ragots[i] < 0) noragot = ["nope", "no<br>way", "RBdC", "atone","que<br>dalle"];
				if (news_ragots[i] > 0) {
					HTML.push('<span>', news_ragots[i], '</span>');
				} else {
					HTML.push('<font>', noragot[Math.round(Math.random() * (noragot.length - 1))], '</font>')
				}

				HTML.push('</div>');

			}



			if((news_text[i].length>10)||(section_id[i]<=0)){

				text=coupe_text(138, 195, news_text[i]); //text=news_text[i].substring(0,180);
				if(text!=news_text[i]) text+='…'
				if(section_id[i]>1) {
					// plus de substring
					text=news_text[i];
					//text=news_text[i].substring(0,250)
					if(text.indexOf('|')>0) text='<h3>'+text.substring(0,text.indexOf('|'))+'</h3>'
					else {
						text='<h3>'+text+'</h3>'
					}
				}
				text=text.replace('|','')
				text=text.replace('[del]','<del>')
				text=text.replace('[/del]','</del>')

				if(section_id[i]==1 && news_text[i].length<2){
					HTML.push('<div class="center-news">')
					HTML.push('<div style=height:36px; class="home_content_')
					if (section_id[i]==1) HTML.push('news'); else HTML.push('articles')
					HTML.push('"><div class="interne">')

					if (section_id[i]>1) HTML.push('<span class="home_author"><span class=home_cat style=color:var(--accentohcon-yallah); title="',texttitle,' de cette catégorie">',cat_title[i],'</span>&nbsp;<strong>/</strong>&nbsp;',today,'</span>')

					HTML.push('</b></span>')

				}else if(section_id[i]>0) {

					if (section_id[i]==1) HTML.push('<div class="home_content_news'); else HTML.push('<div class="home_content_articles')
					HTML.push('"><div class="interne">')
					HTML.push('<a href=',type,cat_alias[i],'/',news_id[i],'-',news_alias[i],'.html style="position:relative">')
					if (section_id[i]>1) HTML.push(text,'<span class="news-today">'+cat_title[i]+'</span>')
					else {

						HTML.push(text,' &nbsp;<span class="home_content_date"><strong>/</strong>&nbsp;',today)
						HTML.push('&nbsp;•&nbsp;',dbl(num.getHours()),':',dbl(num.getMinutes()))
						HTML.push('</span></span>')

					}
					HTML.push('</a></div></div></div></div>')
				}
				if (section_id[i]<0) {
					HTML.push('<div class="center-news">')
					HTML.push('<div id=text_',news_id[i],' style=display:none; class=home_content_')
					if (Math.abs(section_id[i])==1) HTML.push('news'); else HTML.push('articles')
					HTML.push('>');
					if (Math.abs(section_id[i])>1)
						HTML.push('<a href=',type,cat_alias[i],'/',news_id[i],'-',news_alias[i],'.html>')

					if (Math.abs(section_id[i])==1 && news_text[i].length<2){HTML.push(text,' <span class=odette>',news_author[i],'&nbsp;<font style=color:var(--accentohcon)>&nbsp;',today,'&nbsp;',dbl(num.getHours()),dbl(num.getMinutes()),'<font style=color:var(--cooling)>-Coorte</font>')}
					else {HTML.push(text,' <span class=odette>',news_author[i],'&nbsp;<font style=color:var(--accentohcon)>&nbsp;',today,'&nbsp;',dbl(num.getHours()),dbl(num.getMinutes()))}
					HTML.push('</span></font></span></a></div></div>')
					// HTML.push('<font style=font-size:1.22em;line-height:1.12em;overflow:hidden>',text,'</font> <span class=home_author>',news_author[i],' ',today)
				}


			}
			HTML.push('</div>');
			HTML.push('</div>');
			HTML.push('</div>')
			HTML.push('</div>');
			if (section_id[i]==0) {
				if(section_id[i+1]!=0){
					HTML.push('<div class="home_news_first_last_hr container_home_news_first_last_hr"><div class="custommarquee test"><span class="custommarqueeinside test">'+bananas_random[Math.floor(Math.random()*bananas_random.length)]+'</span></div></div>')
				}
			}


		}
	}



	obj='div_'+type
	// faut que ça vide si y'a rien
	if (news_id[0]>0) {
		document.getElementById('div_'+div).innerHTML=HTML.join("")
		document.getElementById('div_'+div).style.display=''
	}
	else {
		document.getElementById('div_'+div).innerHTML='Rien, nada, que pouic';
		document.getElementById('div_'+div).style.display=''
	}
	setTimeout("loading_stop()",500)
	if(div=="news") {
		if(window.location.pathname.length<4) {
			if(plateforme=='desktop') sunday_display();
			if(plateforme=='mobile') sunday_display_mobile();
		}
	}

}

function showImage(image) {
	image.src = image.dataset.src;
	image.classList.remove(lazyClass);
}

function action_articles() {
	var article_id=document.getElementById('article_id').value.split('<')
	var article_title=document.getElementById('article_title').value.split('<')
	var article_alias=document.getElementById('article_alias').value.split('<')
	var article_text=document.getElementById('article_text').value.split('<')
	var article_thumb=document.getElementById('article_thumb').value.split('<')
	var article_cat_title=document.getElementById('article_cat_title').value.split('<')
	var article_cat_alias=document.getElementById('article_cat_alias').value.split('<')
	var article_section_id=document.getElementById('article_section_id').value.split('<')

	var HTML=new Array()
	for (i=0;i<article_id.length;i++) {
		HTML.push('<div class=home_articles_new>');
		HTML.push('<div class="home_articles_title1 back_',article_cat_alias[i],'"><a href="/');
		if(article_section_id[i]>1) HTML.push('articles'); else HTML.push('actus');
		
		//if (!window.location.search.contains('bite'))
		//	HTML.push('/',article_cat_alias[i],'/',article_id[i],'-',article_alias[i],'.html"><h4 class=cdh>',article_title[i],'</h4>');
		//else
		HTML.push('/',article_cat_alias[i],'/',article_id[i],'-',article_alias[i],'.html"><h2 class=cdh><span class="custommarquee"><span class="custommarqueeinside">',article_title[i],'</span></span></h2>');
			
		//HTML.push('<div class=home_articles_title2><span><span class="custommarquee"><span class="custommarqueeinside">',article_text[i].substring(0,article_text[i].indexOf("|") == -1?undefined:article_text[i].indexOf("|")),'</span></span></span> <img align=right style="filter: blur(0);" src=/images/0.gif class=plus17></div>');
		HTML.push('</a></div>');
		HTML.push('<div class=home_articles_img><a href="/');
		if(article_section_id[i]>1) HTML.push('articles'); else HTML.push('actus');
		HTML.push('/',article_cat_alias[i],'/',article_id[i],'-',article_alias[i],'.html"><img alt="',article_title[i],'" src=/images/thumbs/alaune/',article_id[i],'.jpg></a></div>');
		HTML.push('</div>');
	}
	if (article_id[0]>0) {
		document.getElementById('div_articles').innerHTML=HTML.join("");
		document.getElementById('div_articles').style.display='';
		
		document.querySelectorAll('#div_articles .custommarquee').forEach(customMarquee);
	}
}
function loading_stop() {
	document.getElementById('loading').style.backgroundImage='url("/images/0.gif")'
}
function news_page(p,pub) {
	document.getElementById('loading').style.backgroundImage='url("/templates/pac_pho/images/loading.gif")'
	document.getElementById('li_1').className=""
	document.getElementById('li_2').className=""
	document.getElementById('li_3').className=""
	document.getElementById('li_4').className=""
	document.getElementById('li_5').className=""
	document.getElementById('li_'+p).className="active"
	iframe_src("frame_news",'/modules/mod_home/news_start.php?page='+p)
	if (pub>0) {
		sunday_launch=true
		sunday_reveal()
}}
function news_page_admin(p,pub) {
	news_page(p,pub)
	if (p>1) document.getElementById('div_admin').style.display="none"
	else document.getElementById('div_admin').style.display=""
}
function reload_pub() {
	var iframe=top.document.getElementsByTagName("iframe")
	for (i=0;i<iframe.length;i++) {
		pos=iframe[i].id.indexOf("framepub")
		if (pos>=0) top.document.getElementById('reloadpub'+iframe[i].id.substr(8)).click()
	}
	news_over=0
}

function check() {
	h=1800
	c=Math.round(Math.random()*h+h)*1000
	setTimeout("resize_pub()",c)
}
function section_page(p,tri,day,week,trim,section,pub) {
	document.getElementById('loading').style.backgroundImage='url("/templates/pac_pho/images/loading.gif")'
	iframe_src("frame_news",'/modules/mod_home/section_page.php?page='+p+'&tri='+tri+'&day='+day+'&week='+week+'&trim='+trim+'&section='+section)
}

function section_page2(p,tri,day,week,trim,section,pub,month) {
	document.getElementById('loading').style.backgroundImage='url("/templates/pac_pho/images/loading.gif")'
	iframe_src("frame_news",'/modules/mod_home/section_page.php?month='+month+'&page='+p+'&tri='+tri+'&day='+day+'&week='+week+'&trim='+trim+'&section='+section)
	}


function cat_page(p,month,day,week,section,catid,pub,trim = 0) {
	document.getElementById('loading').style.backgroundImage='url("/templates/pac_pho/images/loading.gif")';
	document.getElementById('frame_news').src=session('/modules/mod_home/cat_page.php?page='+p+'&month='+month+'&day='+day+'&week='+week+'&trim='+trim+'&section='+section+'&catid='+catid);
	}

function session(url) {
	s=""+Math.random()
	if (url.indexOf("?")>0) return (url+"&s="+s.substring(2,12))
	else return (url+"?s="+s.substring(2,12))
}
function iframe_src(id,url) {
	document.getElementById(id).src=session(url)
	url=""
}

function driver_os_2020(id) {
	try{
	document.getElementById('os_0').style.display='none'
	document.getElementById('os_1').style.display='none'
	document.getElementById('os_2').style.display='none'
	document.getElementById('os_3').style.display='none'
	document.getElementById('os_4').style.display='none'
	document.getElementById('os2_0').style.display='none'
	document.getElementById('os2_1').style.display='none'
	document.getElementById('os2_2').style.display='none'
	if(id<5) document.getElementById('os_'+id).style.display='block'
	if(id<3) document.getElementById('os2_'+id).style.display='block'
	document.getElementById('text_os_'+id).className='opacity_on'
	document.getElementById('title_os_0').className='Xwin10x64_off'
	document.getElementById('title_os_1').className='Win11_off'
	document.getElementById('title_os_2').className='Linux_off'
	document.getElementById('text_os_0').className='opacity_off'
	document.getElementById('text_os_1').className='opacity_off'
	document.getElementById('text_os_2').className='opacity_off'
	document.getElementById('text_os_3').className='opacity_off'
	document.getElementById('text_os_4').className='opacity_off'
	document.getElementById('biosfirm').className='Fbios_off'

	var classos
	switch (id) {
		case 0:
			classos="Xwin10x64_on"
			break
		case 1:
			classos="Win11_on"
			break
		case 2:
			classos="Linux_on"
			break

	}
	if(id<3)document.getElementById('title_os_'+id).className=classos

	document.getElementById('text_os_'+id).className="opacity_on"

	if(id==3 || id==4){
		document.getElementById('biosfirm').className="Fbios_on"
	}
	}catch(e){}
}

if (navigator.userAgentData) {
navigator.userAgentData.getHighEntropyValues(["platformVersion"])
	.then(ua => {
		if (navigator.userAgentData.platform === "Windows") {
			const majorPlatformVersion = parseInt(ua.platformVersion.split('.')[0]);
			if (majorPlatformVersion >= 13) {
				console.log("Vous êtes beta testeur Windows 11");
			}
			else if (majorPlatformVersion > 0) {
				console.log("Un rebel sous Windows 10");

			}
			else {
				console.log("Un vieux Windows");
			}
		}
		else {
			console.log("Zêtes quelque part mais pas sous Windows");
		}
	});

}


function replace_all(text,search,replace) {
	loop=0
	while (text.indexOf(search,0)>=0) {
		loop++
		text=text.replace(search,replace)
		if (loop>100) break
	}
	return (text)
}
function metascore(id,colorval,score){
	var circle=new ProgressBar.Circle('#progress'+id,{color:'#'+colorval,strokeWidth:5,trailColor:'#e2e2e2',trailWidth:2,duration:2500,easing:'bouncePast'});
	circle.animate(score);
}

function home_date(dd){
var now=new Date()
	var yesterday=new Date(now.getTime()-86400000)
	num=new Date(dd*1000)
	if ((num.getDate()==now.getDate())&&(num.getMonth()==now.getMonth())&&(num.getFullYear()==now.getFullYear())) today="aujourd'hui"
		else if ((num.getDate()==yesterday.getDate())&&(num.getMonth()==yesterday.getMonth())&&(num.getFullYear()==yesterday.getFullYear())) today="hier"
		else {
			today=day[num.getDay()]+' '+dbl(num.getDate())+' '+month[num.getMonth()+1]
			if (num.getFullYear()<now.getFullYear()) today += " "+num.getFullYear()
		}
	document.write(today+' à '+dbl(num.getHours())+'h'+dbl(num.getMinutes()))
}

function cdp_receivemsg(event) {
   if(event.data === "hide-cdp") {
      document.getElementById("cdp_ean").style.display = "none";
      document.getElementById("cdp_more").style.display = "none";
	  document.getElementById("cdp_search").style.borderTopColor="transparent";
	  if(document.getElementById("cdp_noresult").className!="start") document.getElementById("cdp_noresult").style.display = "";
   }
}

	
function cdp_more(){
	document.getElementById("cdp_ean").height=550;
	document.getElementById("cdp_more").style.display="none";
	document.getElementById("cdp_less").style.display="";
}
function cdp_less(){
	document.getElementById("cdp_ean").height=380;
	document.getElementById("cdp_more").style.display="";
	document.getElementById("cdp_less").style.display="none";
}
function cdp_search(e) {
	var event = window.event ? window.event : e;
	if(event.keyCode==13 && document.getElementById("cdp_search").value.length>3){
		cdp_less();
		document.getElementById("cdp_ean").style.display = "";
		document.getElementById("cdp_more").style.display = "";
		document.getElementById("cdp_search").style.borderTopColor="#353535";
		document.getElementById("cdp_noresult").style.display = "none";
		document.getElementById("cdp_noresult").className="";	document.getElementById("cdp_ean").src="https://api.gamerprices.com/comparator/product/cdh?search="+document.getElementById("cdp_search").value+"&template=side&limit=3";
	} else if(document.getElementById("cdp_search").value.length==0) document.getElementById("cdp_ean").src="https://api.gamerprices.com/comparator/product/cdh?search="+cdp_ean+"&template="+cdp_type+"&limit=3";
}



function img_comparison(images,titles){
	html='<p><iframe src="/images/comparison/?';
	for(i=0;i<Math.min(images.length,titles.length);i++){
		if(i>0) html+='&';
		html+='i'+(i+1)+'='+images[i];
		html+='&t'+(i+1)+'='+titles[i];
	}
	html+='" width="720" height="';
	if(Math.min(images.length,titles.length)==1) height=396;
	else {
		height=425+23*Math.min(images.length,titles.length);
	}
	html+=height+'" scrolling="no" allowtransparency="no"></iframe></p>';
	document.write(html);
}

window.addEventListener("message", function(message){
	if (["https://graphs.comptoir.co", "https://dev.comptoir.co"].includes(message.origin)) {
		if (message.data && typeof message.data == 'object' && message.data.resizeIframe && message.data.src) {
			document.querySelector('iframe[src="'+message.data.src+'"]').animate([{height: message.data.resizeIframe}], {duration: 300, fill: 'forwards', delay: 0})
		}
	}
}, false);


function customMarquee(item) {
	let item2 = item.querySelector('.custommarqueeinside');
	if (!item2)
		return;
	
	let w1 = item.offsetWidth - parseFloat(window.getComputedStyle(item).paddingLeft) - parseFloat(window.getComputedStyle(item).paddingRight);
	let w2 = item2.offsetWidth - parseFloat(window.getComputedStyle(item2).paddingLeft) - parseFloat(window.getComputedStyle(item2).paddingRight);
	if (w1 < w2) {
		try{item.animate([
			{ offset: 0, 	transform: 'translateX(0px)' },
			{ offset: 2000 / (10000 / 600 * w2), 	transform: 'translateX(0px)' },// reste 2 secondes sans bouger à gauche
			{ offset: 0.5, 	transform: 'translateX('+(w1 - w2)+'px)' }, // scrolle jusqu'à droite
			{ offset: (0.5 + 2000 / (10000 / 600 * w2)), 	transform: 'translateX('+(w1 - w2)+'px)' }, // attend 2 seconde sans bouger
			{ offset: 1, 	transform: 'translateX(0px)' }, // reviens tout à gauche
		  ], {
		  duration: 10000 / 600 * w2, // la durée est en fonction de la longueur du texte
		  iterations: Infinity,
		  easing: 'cubic-bezier(0.52, 0, 0.9, 1)',
		});}catch(e){}
	}
}

window.addEventListener('load', function() {
    document.querySelectorAll('.custommarquee').forEach(customMarquee)
})


setTimeout(function() {
	var element = document.getElementById('reclaaaame lb');
	if(element){
		var h =  element.offsetHeight;
			if(h==0) {
			console.log("pinut\'s !")
		}
		else { console.log("une belle hauteur : "+h) }

		var modal = document.getElementById("modaldon");
		var btn = document.getElementById("doncdh");
		var span = document.getElementsByClassName("close")[0];

		if (btn) {
			btn.onclick = function() {
				modal.style.display = "block";
			}
		}

		if (modal) {
			span.onclick = function() {
				modal.style.display = "none";
			}
		}
		window.onclick = function(event) {
			if (event.target == modal) {
				modal.style.display = "none";
			}
		}

		let iframe = document.querySelector("#child-iframe");

		window.addEventListener('message', function(e) {
			// message that was passed from iframe page
			let message = e.data;

			iframe.style.height = message.height + 'px';
			iframe.style.width = message.width + 'px';
		} , false);
	}

},3000);


document.addEventListener("DOMContentLoaded", function(){
    /*
    * jQuery tableHover plugin - modified to not use jquery
    * Version: 0.1.4
    *
    * Copyright (c) 2007 Roman Weich
    * http://p.sohei.org
    *
	*/
	
    (function()
    {
        /**
         * Calculates the actual cellIndex value of all cells in the table and stores it in the realCell property of each cell.
         * Thats done because the cellIndex value isn't correct when colspans or rowspans are used.
         * Originally created by Matt Kruse for his table library - Big Thanks! (see http://www.javascripttoolbox.com/)
         * @param {element} table	The table element.
         */
        var fixCellIndexes = function(table) 
        {
            var rows = table.rows;
            var len = rows.length;
            var matrix = [];
            for ( var i = 0; i < len; i++ )
            {
                var cells = rows[i].cells;
                var clen = cells.length;
                for ( var j = 0; j < clen; j++ )
                {
                    var c = cells[j];
                    var rowSpan = c.rowSpan || 1;
                    var colSpan = c.colSpan || 1;
                    var firstAvailCol = -1;
                    if ( !matrix[i] )
                    { 
                        matrix[i] = []; 
                    }
                    var m = matrix[i];
                    // Find first available column in the first row
                    while ( m[++firstAvailCol] ) {}
                    c.realIndex = firstAvailCol;
                    for ( var k = i; k < i + rowSpan; k++ )
                    {
                        if ( !matrix[k] )
                        { 
                            matrix[k] = []; 
                        }
                        var matrixrow = matrix[k];
                        for ( var l = firstAvailCol; l < firstAvailCol + colSpan; l++ )
                        {
                            matrixrow[l] = 1;
                        }
                    }
                }
            }
        };

        /**
         * Sets the rowIndex of each row in the table. 
         * Opera seems to get that wrong using document order instead of logical order on the tfoot-tbody part.
         * @param {element} table	The table element.
         */
        var fixRowIndexes = function(tbl) 
        {
            var v = 0, i, k, r = ( tbl.tHead ) ? tbl.tHead.rows : 0;
            if ( r )
            {
                for ( i = 0; i < r.length; i++ )
                {
                    r[i].realRIndex = v++;
                }
            }
            for ( k = 0; k < tbl.tBodies.length; k++ )
            {
                r = tbl.tBodies[k].rows;
                if ( r )
                {
                    for ( i = 0; i < r.length; i++ )
                    {
                        r[i].realRIndex = v++;
                    }
                }
            }
            r = ( tbl.tFoot ) ? tbl.tFoot.rows : 0;
            if ( r )
            {
                for ( i = 0; i < r.length; i++ )
                {
                    r[i].realRIndex = v++;
                }
            }
        };

        /**
         * Highlights table rows and/or columns on mouse over.
         * Fixes the highlight of the currently highlighted rows/columns on click.
         * Works on tables with rowspans and colspans.
         *
         * @param {map} options			An object for optional settings (options described below).
         *
         * @option {boolean} allowHead		Allow highlighting when hovering over the table header.
         *							Default value: true
        * @option {boolean} allowBody		Allow highlighting when hovering over the table body.
        *							Default value: true
        * @option {boolean} allowFoot		Allow highlighting when hovering over the table footer.
        *							Default value: true
        *
        * @option {boolean} headRows		If true the rows in the table header will be highlighted when hovering over them.
        *							Default value: false
        * @option {boolean} bodyRows		If true the rows in the table body will be highlighted when hovering over them.
        *							Default value: true
        * @option {boolean} footRows		If true the rows in the table footer will be highlighted when hovering over them.
        *							Default value: false
        * @option {boolean} spanRows		When hovering over a cell spanning over more than one row, highlight all spanned rows.
        *							Default value: true
        *
        * @option {boolean} headCols		If true the cells in the table header (matching the currently hovered column) will be highlighted.
        *							Default value: false
        * @option {boolean} bodyCols		If true the cells in the table body (matching the currently hovered column) will be highlighted.
        *							Default value: true
        * @option {boolean} footCols		If true the cells in the table footer (matching the currently hovered column) will be highlighted.
        *							Default value: false
        * @option {boolean} spanCols		When hovering over a cell spanning over more than one column, highlight all spanned columns.
        *							Default value: true
        * @option {array} ignoreCols		An array of numbers. Each column with the matching column index won't be included in the highlighting process.
        *							Index starting at 1!
        *							Default value: [] (empty array)
        *
        * @option {boolean} headCells		Set a special highlight class to the cell the mouse pointer is currently pointing at (inside the table header only).
        *							Default value: false
        * @option {boolean} bodyCells		Set a special highlight class to the cell the mouse pointer is currently pointing at (inside the table body only).
        *							Default value: true
        * @option {boolean} footCells		Set a special highlight class to the cell the mouse pointer is currently pointing at (inside the table footer only).
        *							Default value: false
        *
        * @option {string} rowClass			The css class set to the currently highlighted row.
        *							Default value: 'hover'
        * @option {string} colClass			The css class set to the currently highlighted column.
        *							Default value: '' (empty string)
        * @option {string} cellClass			The css class set to the currently highlighted cell.
        *							Default value: '' (empty string)
        * @option {string} clickClass		The css class set to the currently highlighted row and column on mouse click.
        *							Default value: '' (empty string)
        *
        * @example $('#table').tableHover({});
        * @desc Add simple row highlighting to #table with default settings.
        *
        * @example $('#table').tableHover({rowClass: "someclass", colClass: "someotherclass"});
        * @desc Add row and columnhighlighting to #table and set the specified css classes to the highlighted cells.
        *
        * @example $('#table').tableHover({clickClass: "someclickclass"});
        * @desc Add simple row highlighting to #table and set the specified css class on the cells when clicked.
        *
        * @example $('#table').tableHover({allowBody: false, allowFoot: false, allowHead: true, colClass: "someclass"});
        * @desc Add column highlighting on #table only highlighting the cells when hovering over the table header.
        *
        * @example $('#table').tableHover({bodyCols: false, footCols: false, headCols: true, colClass: "someclass"});
        * @desc Add column highlighting on #table only for the cells in the header.
        *
        * @type jQuery
        *
        * @name tableHover
        * @cat Plugins/tableHover
        * @author Roman Weich (http://p.sohei.org)
        */
        tableHover = function(tbl, options)
        {
            var settings = {...{
                    allowHead : true,
                    allowBody : true,
                    allowFoot : true,

                    headRows : false,
                    bodyRows : true,
                    footRows : false,
                    spanRows : true,

                    headCols : false,
                    bodyCols : true,
                    footCols : false,
                    spanCols : true,
                    ignoreCols : [],

                    headCells : false,
                    bodyCells : true,
                    footCells : false,
                    //css classes,,
                    rowClass : 'hover',
                    colClass : '',
                    cellClass : '',
                    clickClass : ''
                }, ...options};

            
                var colIndex = [], rowIndex = [], r, rCnt = 0, lastClick = [-1, -1];

                tbl.tBodies = [...tbl.querySelectorAll('tbody')];

                if ( !tbl.tBodies || !tbl.tBodies.length )
                {
                    return;
                }

                /**
                 * Adds all rows and each of their cells to the row and column indexes.
                 * @param {array} rows		An array of table row elements to add.
                 * @param {string} nodeName	Defines whether the rows are in the header, body or footer of the table.
                 */
                var addToIndex = function(rows, nodeName)
                {
                    var c, row, rowI, cI, rI, s;
                    //loop through the rows
                    for ( rowI = 0; rowI < rows.length; rowI++, rCnt++ )
                    {
                        row = rows[rowI];
                        //each cell
                        for ( cI = 0; cI < row.cells.length; cI++ )
                        {
                            c = row.cells[cI];
                            //add to rowindex
                            if ( (nodeName == 'TBODY' && settings.bodyRows) 
                                || (nodeName == 'TFOOT' && settings.footRows) 
                                || (nodeName == 'THEAD' && settings.headRows) )
                            {
                                s = c.rowSpan;
                                while ( --s >= 0 )
                                {
                                    rowIndex[rCnt + s].push(c);
                                }
                            }
                            //add do colindex
                            if ( (nodeName == 'TBODY' && settings.bodyCols)
                                    || (nodeName == 'THEAD' && settings.headCols) 
                                    || (nodeName == 'TFOOT' && settings.footCols) )
                            {
                                s = c.colSpan;
                                while ( --s >= 0 )
                                {
                                    rI = c.realIndex + s;
                                    //if ( $.inArray(rI + 1, settings.ignoreCols) > -1 )
                                    if ( settings.ignoreCols.includes(rI +1) )
                                    {
                                        break;//dont highlight the columns in the ignoreCols array
                                    }
                                    if ( !colIndex[rI] )
                                    {
                                        colIndex[rI] = [];
                                    }
                                    colIndex[rI].push(c);
                                }
                            }
                            //allow hover for the cell?
                            if ( (nodeName == 'TBODY' && settings.allowBody) 
                                    || (nodeName == 'THEAD' && settings.allowHead) 
                                    || (nodeName == 'TFOOT' && settings.allowFoot) )
                            {
                                c.thover = true;
                            }
                        }
                    }
                };

                /**
                 * Mouseover event handling. Set the highlight to the rows/cells.
                 */
                var over = function(e)
                {
                    var p = e.target;
                    while ( p != this && p.thover !== true )
                    {
                        p = p.parentNode;
                    }
                    if ( p.thover === true )
                    {
                        highlight(p, true);
                    }
                };

                /**
                 * Mouseout event handling. Remove the highlight from the rows/cells.
                 */
                var out = function(e)
                {
                    var p = e.target;
                    while ( p != this && p.thover !== true )
                    {
                        p = p.parentNode;
                    }
                    if ( p.thover === true )
                    {
                        highlight(p, false);
                    }
                };
                
                /**
                 * Mousedown event handling. Sets or removes the clickClass css style to the currently highlighted rows/cells.
                 */
                /*var click = function(e)
                {
                    var t = e.target;
                    while ( t && t != tbl && !t.thover ) //search the real target
                        t = t.parentNode;
                    if ( t.thover && settings.clickClass != '' )
                    {
                        var x = t.realIndex, y = t.parentNode.realRIndex, s = '';
                        //unclick
                        $('td.' + settings.clickClass + ', th.' + settings.clickClass, tbl).removeClass(settings.clickClass);
                        if ( x != lastClick[0] || y != lastClick[1] )
                        {
                            //click..
                            if ( settings.rowClass != '' )
                            {
                                s += ',.' + settings.rowClass;
                            }
                            if ( settings.colClass != '' )
                            {
                                s += ',.' + settings.colClass;
                            }
                            if ( settings.cellClass != '' )
                            {
                                s += ',.' + settings.cellClass;
                            }
                            if ( s != '' )
                            {
                                $('td, th', tbl).filter(s.substring(1)).addClass(settings.clickClass);
                            }
                            lastClick = [x, y];
                        }
                        else
                        {
                            lastClick = [-1, -1];
                        }
                    }
                };*/
                
                /**
                 * Adds or removes the highlight to/from the columns and rows.
                 * @param {element} cell	The cell with the mouseover/mouseout event.
                 * @param {boolean} on		Defines whether the style will be set or removed.
                 */
                var highlight = function(cell, on)
                {
                    let tableHoverHover;
                    if ( on ) //create dummy funcs - dont want to test for on==true all the time
                    {
                        //$.fn.tableHoverHover = $.fn.addClass;
                        tableHoverHover = 'add';
                    }
                    else
                    {
                        //$.fn.tableHoverHover = $.fn.removeClass;
                        tableHoverHover = 'remove';
                    }
                    //highlight columns
                    var h = colIndex[cell.realIndex] || [], rH = [], i = 0, rI, nn;
                    if ( settings.colClass != '' )
                    {
                        while ( settings.spanCols && ++i < cell.colSpan && colIndex[cell.realIndex + i] )
                        {
                            h = h.concat(colIndex[cell.realIndex + i]);
                        }
                        //$(h).tableHoverHover(settings.colClass);
                        h.map(e => e.classList[tableHoverHover](settings.colClass));
                    }
                    //highlight rows
                    if ( settings.rowClass != '' )
                    {
                        rI = cell.parentNode.realRIndex;
                        if ( rowIndex[rI] )
                        {
                            rH = rH.concat(rowIndex[rI]);
                        }
                        i = 0;
                        while ( settings.spanRows && ++i < cell.rowSpan )
                        {
                            if ( rowIndex[rI + i] )
                            {
                                rH = rH.concat(rowIndex[rI + i]);
                            }
                        }
                        //$(rH).tableHoverHover(settings.rowClass);
                        //h[tableHoverHover](settings.rowClass);
                        rH.map(e => e.classList[tableHoverHover](settings.rowClass));
                    }
                    //highlight cell
                    if ( settings.cellClass != '' )
                    {
                        nn = cell.parentNode.parentNode.nodeName.toUpperCase();
                        if ( (nn == 'TBODY' && settings.bodyCells)
                                || (nn == 'THEAD' && settings.headCells)
                                || (nn == 'TFOOT' && settings.footCells) )
                        {
                            //$(cell).tableHoverHover(settings.cellClass);
                            cell.classList[tableHoverHover](settings.cellClass);
                        }
                    }
                };

                fixCellIndexes(tbl);
                fixRowIndexes(tbl);

                //init rowIndex
                for ( r = 0; r < tbl.rows.length; r++ )
                {
                    rowIndex[r] = [];
                }
                //add header cells to index
                if ( tbl.tHead )
                {
                    addToIndex(tbl.tHead.rows, 'THEAD');
                }
                //create index - loop through the bodies
                for ( r = 0; r < tbl.tBodies.length; r++ )
                {
                    addToIndex(tbl.tBodies[r].rows, 'TBODY');
                }
                //add footer cells to index
                if ( tbl.tFoot )
                {
                    addToIndex(tbl.tFoot.rows, 'TFOOT');
                }
                //$(this).bind('mouseover', over).bind('mouseout', out).click(click);
                tbl.addEventListener('mouseover', over);
                tbl.addEventListener('mouseout', out);
                
        };


        [...document.querySelectorAll('table.cdh, table.cdh2, table.cdh3')].forEach(table => tableHover(table, {}))

    })();
});

function quarter_select(obj){
	if(document.querySelector('td#select')) document.querySelector('td#select').id="";
	obj.parentNode.id="select";
}


document.addEventListener("DOMContentLoaded", function() {
    var elements = document.querySelectorAll('.prout img, .prout iframe, #div_news img, #div_news iframe, .ANPM img, .home_articles_img img');
    elements.forEach(function(element) {
        element.setAttribute('loading', 'lazy');
    });
});