var isIE = document.all;
var isFF = document.getElementById && !isIE;

var objet = null;
var modeobjet = "";
var ismoving = false;
var mouse_x;
var mouse_y;

var lastidobjet = null;

if (!isIE && ! isFF) alert("Votre navigateur n'est pas compatible avec les fonctionnalités de ce site");

document.getElementById("css").href = "css.php?res="+screen.width+"x"+screen.height
//alert("css.php?res="+screen.width+""+screen.height);

/***********************************************************************************************************
************************************************************************************************************
************************************************************************************************************
************************************************************************************************************
************************************************************************************************************
***********************************************************************************************************/

function selectdiv(E)
{
	var objetclique = (isFF ? E.target : event.srcElement);
	objet = null;
	
	if (objetclique.className == "nonbougeable") return true;
	
	if (objetclique.parentNode) 
		if (objetclique.parentNode.className == "bloc_info") 
			objetclique.parentNode.style.zIndex = zIndex(); 
	
	if (objetclique.parentNode.parentNode) 
		if (objetclique.parentNode.parentNode.className == "bloc_info") 
			objetclique.parentNode.parentNode.style.zIndex = zIndex(); 
	
	if (objetclique.parentNode.parentNode.parentNode) 
		if (objetclique.parentNode.parentNode.parentNode.className == "bloc_info") 
			objetclique.parentNode.parentNode.parentNode.style.zIndex = zIndex(); 

	/*if (objetclique.parentNode.parentNode.parentNode.parentNode) 
		if (objetclique.parentNode.parentNode.parentNode.parentNode.className == "bloc_info") 
			objetclique.parentNode.parentNode.parentNode.parentNode.style.zIndex = zIndex(); 
	*/
	

	
	if (objetclique.className=='bougeable' && !ismoving)
		{
			
			
			x = isFF ? E.clientX : event.clientX;
			y = isFF ? E.clientY : event.clientY;
			
			modeobjet = objetclique.name;
			
			objet = objetclique.parentNode;
			
			
			//objet.style.zIndex = zIndex(); // Pour mettre en premier plan
			
			objetX = (x-intpx(objet.style.left));
			objetY = (y-intpx(objet.style.top));
		}

	

	if (objetclique.parentNode.className=="bloc_info") menuter(objetclique.parentNode.id);
	
	return false;
}

function bougediv(E)
{
	mouse_x = isFF ? E.clientX : event.clientX;
	mouse_y = isFF ? E.clientY : event.clientY;
	if (objet) 
		{
			ismoving = true;
			x = isFF ? E.clientX : event.clientX;
			y = isFF ? E.clientY : event.clientY;
			
			if (modeobjet=="bouge")
				{
					objet.style.left = x - objetX;
					objet.style.top = y - objetY;
				}
			else if (modeobjet=="retaillage")
				{
					//debug (x + " " + y + " : " + objet.style.left + " " + objet.style.top);
					
					objet.style.width = (x - intpx(objet.style.left))<300 ? 300 : (x - intpx(objet.style.left)) ;
					objet.style.height = (y - intpx(objet.style.top)) <270 ? 270 : (y - intpx(objet.style.top));
					
					resizeBloc(objet);
				}
		}
		
	if (objet) return false; else return true;
}

function lachediv()
{
	objet = null;
	modeobjet = "";
	ismoving = false;
}

document.onmousedown = selectdiv
document.onmousemove = bougediv
document.onmouseup   = lachediv

/***********************************************************************************************************
************************************************************************************************************
************************************************************************************************************
************************************************************************************************************
************************************************************************************************************
***********************************************************************************************************/
clickadmin = 0;
// Préchargement des images

var ampoule_out = new Image(); ampoule_out.src = "imgs/ampoule_out.png";
var ampoule_over = new Image(); ampoule_over.src = "imgs/ampoule_over.png";

var menu1 = new Image(); menu1.src = "imgs/mn1.png";
var menu1b = new Image(); menu1b.src = "imgs/mn1_over.png";

var menu2 = new Image(); menu2.src = "imgs/mn2.png";
var menu2b = new Image(); menu2b.src = "imgs/mn2_over.png";

var menu3 = new Image(); menu3.src = "imgs/mn3.png";
var menu3b = new Image(); menu3b.src = "imgs/mn3_over.png";

var menu4 = new Image(); menu4.src = "imgs/mn4.png";
var menu4b = new Image(); menu4b.src = "imgs/mn4_over.png";

var menu5 = new Image(); menu5.src = "imgs/mn5.png";
var menu5b = new Image(); menu5b.src = "imgs/mn5_over.png";

var menu6 = new Image(); menu6.src = "imgs/mn6.png";
var menu6b = new Image(); menu6b.src = "imgs/mn6_over.png";

var menu7 = new Image(); menu7.src = "imgs/mn7.png";
var menu7b = new Image(); menu7b.src = "imgs/mn7_over.png";


var menu8 = new Image(); menu8.src = "imgs/mn8.png";
var menu8b = new Image(); menu8b.src = "imgs/mn8_over.png";

var menu9 = new Image(); menu9.src = "imgs/mn9.png";
var menu9b = new Image(); menu9b.src = "imgs/mn9_over.png";

var menu10 = new Image(); menu10.src = "imgs/mn10.png";
var menu10b = new Image(); menu10b.src = "imgs/mn10_over.png";

var logo = new Image(); logo.src = "imgs/logo.png";
var logob = new Image(); logob.src = "imgs/logob.png";

var question = new Image(); question.src = "imgs/question.png";
var questionb = new Image(); questionb.src = "imgs/questionb.png";

var bouton_1_on = new Image(); bouton_1_on.src = "imgs/bouton_1_on.png";
var bouton_1_off = new Image(); bouton_1_off.src = "imgs/bouton_1_off.png";

var bouton_2_on = new Image(); bouton_2_on.src = "imgs/bouton_2_on.png";
var bouton_2_off = new Image(); bouton_2_off.src = "imgs/bouton_2_off.png";

var bouton_3_on = new Image(); bouton_3_on.src = "imgs/bouton_3_on.png";
var bouton_3_off = new Image(); bouton_3_off.src = "imgs/bouton_3_off.png";

var bouton_4_on = new Image(); bouton_4_on.src = "imgs/bouton_4_on.png";
var bouton_4_off = new Image(); bouton_4_off.src = "imgs/bouton_4_off.png";

var bouton_5_on = new Image(); bouton_5_on.src = "imgs/bouton_5_on.png";
var bouton_5_off = new Image(); bouton_5_off.src = "imgs/bouton_5_off.png";

var bouton_9_on = new Image(); bouton_9_on.src = "imgs/bouton_9_on.png";
var bouton_9_off = new Image(); bouton_9_off.src = "imgs/bouton_9_off.png";

var bouton_10_on = new Image(); bouton_10_on.src = "imgs/bouton_10_on.png";
var bouton_10_off = new Image(); bouton_10_off.src = "imgs/bouton_10_off.png";

var rubrique_cij77 = new Image(); rubrique_cij77.src = "imgs/rubrique_cij77.png";
var rubrique_cij77_over = new Image(); rubrique_cij77_over.src = "imgs/rubrique_cij77_over.png";

var rubrique_ij77 = new Image(); rubrique_ij77.src = "imgs/rubrique_ij77.png";
var rubrique_ij77_over = new Image(); rubrique_ij77_over.src = "imgs/rubrique_ij77_over.png";

var rubrique_publication = new Image(); rubrique_publication.src = "imgs/rubrique_publication.png";
var rubrique_publication_over = new Image(); rubrique_publication_over.src = "imgs/rubrique_publication_over.png";

var rubrique_espacepro = new Image(); rubrique_espacepro.src = "imgs/rubrique_espacepro.png";
var rubrique_espacepro_over = new Image(); rubrique_espacepro_over.src = "imgs/rubrique_espacepro_over.png";

var rubrique_sante = new Image(); rubrique_sante.src = "imgs/rubrique_sante.png";
var rubrique_sante_over = new Image(); rubrique_sante_over.src = "imgs/rubrique_sante_over.png";

var blocnote = new Image(); blocnote.src = "imgs/blocnote.png";
var blocnote_open = new Image(); blocnote_open.src = "imgs/blocnote_open.png";

var newsletter_on = new Image(); newsletter_on.src = "imgs/newsletter_on.png";
var newsletter_off = new Image(); newsletter_off.src = "imgs/newsletter_off.png";

var rss_over = new Image(); rss_over.src = "imgs/rss_over.png";
var rss_out = new Image(); rss_out.src = "imgs/rss_out.png";




/***********************************************************************************************************
************************************************************************************************************
************************************************************************************************************
************************************************************************************************************
************************************************************************************************************
***********************************************************************************************************/


curseurzindex = 10;
function zIndex() { return (++curseurzindex); }

blocid = 0;

function rajouteBloc(xx,yy,dx,dy,url,ident, menu)
{
	
	if (xx==-1) xx = 80;
	if (yy==-1) yy = 45;
	if (dx=="max" || dx==-1) dx = screen.width - xx - 100;
	if (dy=="max" || dy==-1) dy = screen.height - yy - 180;
	
	
	
	if (ident!='') blocidindex = ident; 
	else blocidindex = blocid;
	//debug ("<br /> __--" + xx + " " + yy + " " + dx + " " + dx + " " + ident);
	
	if (!document.getElementById("bloc_"+blocidindex))
	{
		str = "<div id='bloc_"+blocidindex+"' class='bloc_info' style='position:absolute;background:url(imgs/fondblocnote.png);border:solid 2px #404040;top:"+yy+"px;z-Index:"+zIndex()+";left:"+xx+"px;width:"+dx+"px;height:"+dy+"px;overflow:none;'>"
//			+"	<img style='position:absolute;background:url(imgs/fondblocnote.png);' id='bloc_"+blocidindex+"_fond' class='bougeable' style='position:absolute;top:0px;left:0px;width:400px;height:200px;' />"
				
			+"	<img src='imgs/pointi.png' style='position:absolute;top:-5px;left:-25px;height:25px;width:25px;' alt='Rajouter dans vos favoris' id='pointi'  onmouseover='this.src=\"imgs/\"+this.id+\"_over.png\";' onmouseout='this.src=\"imgs/\"+this.id+\".png\";'  onclick=\"return true;window.external.AddFavorite('http://127.0.0.1/cij77ij/index.php?url="+url+"&ident="+ident+"', 'Centre Information Jeunesse "+url+"');\"  />"
			
			+"	<img src='imgs/i.png' id='bloc_"+blocidindex+"_i' class='bougeable' name='bouge' style='position:absolute;cursor:move;top:30px;left:-25px;width:25px;' />"
	
			+"	<img src='imgs/fermeture_out.png' id='bloc_"+blocidindex+"_x' style='position:absolute;top:5px;left:180px;width15px;height:15px;' onmouseover='this.src=\"imgs/fermeture_over.png\";' onmouseout='this.src=\"imgs/fermeture_out.png\";' onclick='document.getElementById(\"blocconteneur\").removeChild(document.getElementById(\"bloc_"+blocidindex+"\"));' alt=\"Fermer cette fenêtre\" />"
					
			if (menu==1)
			{
			str 	+= "	<div id='bloc_"+blocidindex+"_jl' style='position:absolute;top:25px;left:200px;' >"
					
				+"		<img id='bloc_"+blocidindex+"_jh' src='imgs/j.png' style='position:absolute;top:0px;left:0px;width:25px;height:160px;' />"

				+"		<img src='imgs/boutonprint_out.gif' id='bloc_"+blocidindex+"_print' class='nonbougeable' style='position:relative;cursor:pointer;top:0px;left:-5px;height:50px;width:50px;' onmouseover='this.src=\"imgs/boutonprint_over.gif\";loupeto(this.id, 80, 80);' onmouseout='this.src=\"imgs/boutonprint_out.gif\";loupeto(this.id, 50, 50);' onclick=\"imprimeinfo('bloc_"+blocidindex+"_contenu');\" alt='Imprimer cet article'/>"
				// +"		<img src='imgs/boutonblocnote_out.gif' id='bloc_"+blocidindex+"bn' class='nonbougeable' style='position:relative;cursor:pointer;top:0px;left:-5px;height:50px;width:50px;' onmouseover='this.src=\"imgs/boutonblocnote_over.gif\";loupeto(this.id, 80, 80);' onmouseout='this.src=\"imgs/boutonblocnote_out.gif\";loupeto(this.id, 50, 50);' onclick='noter(\""+blocidindex+"\");' alt='Copier dans son bloc notes' />"
				+"		<img src='imgs/boutonmail_out.gif' id='bloc_"+blocidindex+"_mail' class='nonbougeable' style='position:relative;cursor:pointer;top:0px;left:-5px;height:50px;width:50px;' onmouseover='this.src=\"imgs/boutonmail_over.gif\";loupeto(this.id, 80, 80);' onmouseout='this.src=\"imgs/boutonmail_out.gif\";loupeto(this.id, 50, 50);' onclick='mailer(\"bloc_"+blocidindex+"_contenu\");' alt='Envoyer vers un Email' />"
	
				+"	</div>"
			}
			str +="	<div id='bloc_"+blocidindex+"_contenu' class='bougeable' style='position:absolute;top:5px;left:10px;width:170px;height:170px;overflow:auto;'>Veuillez patienter quelques instants le chargement dynamique<br /></div>"
			
			+"	<img id='bloc_"+blocidindex+"_pj' src='imgs/pointj.png' class='bougeable' name ='retaillage' style='position:absolute;top:187px;left:187px;height:25px;width:25px;cursor:se-resize;' />"
			
			+"</div>"
		
		
		document.getElementById("blocconteneur").innerHTML += str;
	}
	else
	{
		document.getElementById("bloc_"+blocidindex).style.display = "block";
		document.getElementById("bloc_"+blocidindex).style.zIndex = zIndex();
	}

	

	menuter("bloc_"+blocidindex);
	
	resizeBloc(document.getElementById("bloc_"+blocidindex));
	bloc_attente('bloc_'+blocidindex+'_contenu');
	if (url != '') req(url, 'idbloc=bloc_'+blocidindex+'_contenu'); 
	
	blocid++;
}

function BlocNote()
{
		
	blocidindex = "note";
	
	if (!document.getElementById("bloc_note"))
	{
		str = "<div id='bloc_note' class='bloc_info' style='position:absolute;background:url(imgs/fondblocnote.png);border:solid 1px #A0A0A0;top:100px;z-Index:"+zIndex()+";left:200px;width:400px;height:400px;overflow:none;'>"
				
			+"	<img src='imgs/i.png' id='bloc_note_i' class='bougeable' name='bouge' style='position:absolute;cursor:move;top:30px;left:-25px;width:25px;' />"
	
			+"	<img src='imgs/fermeture_out.png' id='bloc_note_x' style='position:absolute;top:5px;left:175px;width15px;height:15px;' onmouseover='this.src=\"imgs/fermeture_over.png\";' onmouseout='this.src=\"imgs/fermeture_out.png\";' onclick='document.getElementById(\"bloc_note\").style.display=\"none\";' />"
					
			+"	<div id='bloc_note_jl' style='position:absolute;top:25px;left:400px;' >"

			+"		<img src='imgs/boutonprint_out.png' class='nonbougeable' style='position:absolute;cursor:pointer;top:0px;left:-10px;' onmouseover='this.src=\"imgs/boutonprint_over.png\";' onmouseout='this.src=\"imgs/boutonprint_out.png\";' onclick='imprimeinfo(\"bloc_note_contenu\");' alt='Imprimer cet article'/>"

			+"		<img src='imgs/boutonmail_out.png'  style='position:absolute;cursor:pointer;top:40px;left:-10px;' onmouseover='this.src=\"imgs/boutonmail_over.png\";' onmouseout='this.src=\"imgs/boutonmail_out.png\";'  onclick='mailer(\"bloc_note_contenu\");' />"

			+"	</div>"
			
			+"	<div id='bloc_note_contenu' style='position:absolute;top:20px;left:10px;width:170px;height:170px;overflow:auto;'>Vous avez téléchargé cette (ces) information(s) :<br /></div>"
			+"	<img id='bloc_"+blocidindex+"_pj' src='imgs/pointj.png' class='bougeable' name ='retaillage' style='position:absolute;top:187px;left:187px;height:25px;width:25px;cursor:se-resize;' />"
			
			+"</div>"
		
		document.getElementById("blocconteneur").innerHTML += str;
	}
	else
	{
		document.getElementById("bloc_"+blocidindex).style.display = "block";
		document.getElementById("bloc_"+blocidindex).style.zIndex = zIndex();
	}
	
	menuter("bloc_"+blocidindex);
	
	resizeBloc(document.getElementById("bloc_"+blocidindex));
	
	//req("blocnote.php", 'idbloc=bloc_'+blocidindex+'_contenu'); 
	
	blocid++;
	
}

function bloc_attente(idb)
{
	if (document.getElementById(idb))
		document.getElementById(idb).innerHTML = "<div style=''><img src='imgs/sablier.gif' /></div>";
}

function menuter(id)
{
	if (document.getElementById(lastidobjet+"_jl")) document.getElementById(lastidobjet+"_jl").style.display="none";
	lastidobjet = id;
	if (document.getElementById(lastidobjet+"_jl")) document.getElementById(lastidobjet+"_jl").style.display="block";
	
}

function noter(blocidindex)
{
	//alert(document.getElementById("bloc_"+blocidindex+"_contenu").innerHTML);
	if (!document.getElementById("bloc_note")) BlocNote();
	document.getElementById("bloc_note_contenu").innerHTML	+= document.getElementById("bloc_"+blocidindex+"_contenu").innerHTML + "<br /><hr width=70% align=center><br />";
	req('stat.php','action=bloc note&detail='+escape(geby('bloc_'+blocidindex+'_contenu').innerHTML));
	animeblocnote(0);
}

function mailer(blocindex)
{
	// Ouverture de la procédure d'envoi du mail
	rajouteBloc( -1, -1, -1, -1, '', "mail", 0 );
	req( 'mail.php', 'idbloc=mail&mode=construire&contenu='+escape(geby(blocindex).innerHTML) );
	
}

var t = Array;

function loupeto(idm, wf, hf)
{
	// on récupère la taille courante
	wi = intpx(geby(idm).style.width);
	hi = intpx(geby(idm).style.height);
	ecartw = (wf - wi) / 10;
	ecarth = (hf - hi) / 10;
	
	try {clearInterval(t[idm]);} catch(e)	{}
	loupeto2(idm, ecartw, ecarth, wf, hf, 10);
}

function loupeto2(idm, ecartw, ecarth, wf, hf, etape)
{
	if (geby(idm) && etape >= 1) 
	{
		
		etape = etape -1;
		

		wi = (wf-ecartw*etape);
		hi = (hf-ecarth*etape);
		geby(idm).style.width =  parseInt(wi)+"px";
		geby(idm).style.height = parseInt(hi)+"px";
		
		
		t[idm] = setTimeout("loupeto2('"+idm+"',"+ecartw+","+ecarth+","+wf+","+hf+","+etape+")",20);
		//alert('test');
	}
}


/*

var t = Array;
function loupeto(idm, w, h )
{
	// on récupère la taille courante
	w1 = intpx(geby(idm).style.width);
	h1 = intpx(geby(idm).style.height);
	
	for (i = 0; i <10; i++)
	{
		t[idm+i] = setTimeout("loupeto2('"+idm+"',"+(w1*(10-i)+w*i)/10+","+(h1*(10-i)+h*i)/10+")", i*20);
	}
	
	
}


function loupeto2(idm, w, h)
{
	//alert(idm);
	geby(idm).style.width =  parseInt(w)+"px";
	geby(idm).style.height = parseInt(h)+"px";

}
*/
function animeblocnote(num)
{
	if (num==15)
	{
	}
	else 
	{
		document.getElementById("blocnote").src = "imgs/blocnote"+(num%2==0?"":"_open")+".png";
		setTimeout('animeblocnote('+(num+1)+')',200);
	}
}


function resizeBloc(bloc)
{
	// on récupère la taille courante du bloc
		idbloc = bloc.id;

		dx = intpx(bloc.style.width);
		dy = intpx(bloc.style.height);
		
		//debug(idbloc+" "+dx+" "+dy);	
		
		if (dx<75) dx = 75;
		if (dy<75) dy = 75;
	
	// Image du fond
		if (document.getElementById(idbloc+"_fond"))
		{
			document.getElementById(idbloc+"_fond").style.width = dx;
			document.getElementById(idbloc+"_fond").style.height = dy;
		}
	
	// Image du I
		if (document.getElementById(idbloc+"_i"))
		{
			document.getElementById(idbloc+"_i").style.height = dy - 30;
		}
	
	// Image du - et X
		if (document.getElementById(idbloc+"_x")) 
		{
			//document.getElementById(idbloc+"_m").style.left = dx - 40;
		 	document.getElementById(idbloc+"_x").style.left = dx - 20;
		}
	
	// Image du J
		if (document.getElementById(idbloc+"_jh"))
		{
			document.getElementById(idbloc+"_jh").style.height = dy - 40;
			document.getElementById(idbloc+"_jl").style.left = dx - 10;
		}
	
	// Image du point J
		if (document.getElementById(idbloc+"_pj")) 
		{
			document.getElementById(idbloc+"_pj").style.left = dx - 10;
			document.getElementById(idbloc+"_pj").style.top = dy - 13;
		}
		
	// Image du contenu
		if (document.getElementById(idbloc+"_contenu")) 
		{
			document.getElementById(idbloc+"_contenu").style.width = dx-30;
			document.getElementById(idbloc+"_contenu").style.height = dy-10;
		}
}


/***********************************************************************************************************
************************************************************************************************************
************************************************************************************************************
************************************************************************************************************
************************************************************************************************************
***********************************************************************************************************/
var sto;
function req(url, donnee)
{
	sto = "url : "+url+" --- données : "+donnee+"\n";
	requete = null;
	if(window.XMLHttpRequest) // FF   
		requete = new XMLHttpRequest();   
	else 
	if(window.ActiveXObject) // IE   
		requete = new ActiveXObject("Microsoft.XMLHTTP");   
	else 
		 alert("Pb de compatibilité du navigateur sur httpRequest...");
	
  	if (requete != null)
  	{
  		requete.open("POST", url, true);
  		requete.onreadystatechange = retourreq;
  	 	requete.setRequestHeader("Content-type", "application/x-www-form-urlencoded; charset=iso-8859-1"); 
  		requete.send("strangersite=Attentionjevoussurveille&"+donnee);
	}	
	sto = "url : "+url+" --- données : "+"strangersite=Attentionjevoussurveille&"+donnee+"\n";	
}

function retourreq()
{
	if (requete.readyState == 4)
	{
		try
		{
			eval(requete.responseText);
		}
		catch(error)
		{
			alert(sto+requete.responseText);
		}
	}
}

function mise_en_attente(idb)
{
	if (document.getElementById(idb)) document.getElementById(idb).innerHTML = "<div align=center></div>";
}

function informer_bloc(str, idb)
{
	var motif = new RegExp("(codestranger_123456789987654321_strangercode)"); 
	while(str.indexOf("codestranger_123456789987654321_strangercode")!=-1)
		str = str.replace(motif,"\r\n");

	if (!document.getElementById(idb) && document.getElementById("bloc_"+idb+"_contenu")) idb = "bloc_"+idb+"_contenu";
	
	if (document.getElementById(idb))
	{
		 document.getElementById(idb).innerHTML = '';
		 document.getElementById(idb).innerHTML = unescape(str);
	}
	else 
		alert("JS : "+idb+" n existe pas et ne peut pas mettre "+str);
}

function intpx(str)
{
	pospx = str.indexOf("px");
	if (pospx==-1) pospx = str.length;
	return(parseInt(str.substring(0, pospx)));
}

function imprimeinfo(idb)
{
	req('stat.php','action=imprimer&detail='+escape(geby('bloc_'+blocidindex+'_contenu').innerHTML));
	cij77popup = window.open("", "cij77" + idb, "toolbar=no,scrollbars=no,resizable=yes");
	
	
	cij77popup.document.write(document.getElementById(idb).innerHTML);
	cij77popup.document.write("");
	
	cij77popup.document.close();
	
	window.cij77popup.print();
	//cij77popup.close();
}

function previsualiser(idb)
{
	//req('stat.php','action=imprimer&detail='+escape(geby('bloc_'+blocidindex+'_contenu').innerHTML));
	cij77popup = window.open("", "previsualisationcij" + idb, "toolbar=no,scrollbars=yes,resizable=yes");
	
	cij77popup.document.write("<html>");
	cij77popup.document.write("<head>");
	cij77popup.document.write("<link id='css' href='css.php' rel='stylesheet' type='text/css'>");
	//cij77popup.document.write("<script type='text/javascript' src='js.js'></script>");
	
	cij77popup.document.write("</head>");
	cij77popup.document.write("<body background='imgs/fondblocnote.png'>");
	
	cij77popup.document.write(document.getElementById(idb).value);
	cij77popup.document.write("</body>");
	cij77popup.document.write("</html>");
	cij77popup.document.write("");
	
	cij77popup.document.close();
	

}

function autoclose(t, idb)
{
	setTimeout("ferme('"+idb+"')",t);
}

function ferme(idb)
{
	if (document.getElementById(idb)) document.getElementById(idb).style.display="none";
else alert(idb);
}


function geby(objet)
{
	return document.getElementById(objet);
}

function $(objet)
{
	return document.getElementById(objet);
}

function exploreformulaire(t)
{
	var txt = "";
	var n = t.childNodes.length;

	if (t.nodeName=="INPUT" || t.nodeName=="SELECT" || t.nodeName=="TEXTAREA") 
	{
		var nomvariable = "";
		if (t.id != "") nomvariable = t.id;
		if (t.name != "") nomvariable = t.name;
		
		var valeurvariable = "";
		if (nomvariable != "" && t.value !="") valeurvariable = escape(t.value);
		
		var chaine = "";
		if (nomvariable != "")
			chaine = "&" + nomvariable + "=" + valeurvariable;
		
		txt = chaine;
		
	}
	
	
	for (var i=0; i<n; i++)
		{
			 //txt = txt + "aller" + level+ ":"+i+"/"+n;
			 txt = txt + exploreformulaire(t.childNodes[i]);
			 //txt = txt + "retour" + level+ ":"+i+"/"+n;
			 
			 
		}
	

	return(txt);
}



function swapdisplay(idb)
{

	if (geby(idb).style.display)
		{
			if (geby(idb).style.display=="none")
				geby(idb).style.display="block";
			else
				geby(idb).style.display="none";
		}
	
}

cumul=null;
function echangenews(idn)
{
	if (cumul==null) cumul=idn;
	else 
	{
		tt = geby("titre_"+cumul).value; geby("titre_"+cumul).value = geby("titre_"+idn).value; geby("titre_"+idn).value = tt;
		tt = geby("description_"+cumul).value; geby("description_"+cumul).value = geby("description_"+idn).value; geby("description_"+idn).value = tt;
		tt = geby("lien_"+cumul).value; geby("lien_"+cumul).value = geby("lien_"+idn).value; geby("lien_"+idn).value = tt;
		geby("radio_news_"+cumul).checked='';
		geby("radio_news_"+idn).checked='';
		
		cumul=null;
	}
}

function echangesr(idn)
{
	if (cumul==null) cumul=idn;
	else 
	{
		divsr = geby("bloc_listsr_"+idn).innerHTML;
		geby("bloc_listsr_"+idn).innerHTML = geby("bloc_listsr_"+cumul).innerHTML;
		geby("bloc_listsr_"+cumul).innerHTML = divsr;
		
		numord = geby("ordresr_"+idn).value;
		geby("ordresr_"+idn).value = geby("ordresr_"+cumul).value;
		geby("ordresr_"+cumul).value = numord;
		
		geby("sr"+cumul).checked='';
		geby("sr"+idn).checked='';
		
		cumul=null;
	}
}

function swap(a, b)
{
	n=a;
	a=b;
	b=n;
}

function montre(id)
{
	if (geby(id)) geby(id).style.display="block";
}
function cache(id)
{
	if (geby(id)) geby(id).style.display="none";
}



function fond(id,color)
{
	if (geby(id)) geby(id).style.backgroundColor=color;
}



function debug(str)
{
	document.getElementById("debugueur").innerHTML = "<br />Debug : "+str + document.getElementById("debugueur").innerHTML;
}

function fermesousmenus()
{
	try{clearTimeout(closer_toto_0);  } catch(e) {}; geby("toto_0").style.display="none";
	try{clearTimeout(closer_toto_60); } catch(e) {}; geby("toto_60").style.display="none";
	try{clearTimeout(closer_toto_120);} catch(e) {}; geby("toto_120").style.display="none";
	try{clearTimeout(closer_toto_180);} catch(e) {}; geby("toto_180").style.display="none";
	try{clearTimeout(closer_toto_210);} catch(e) {}; geby("toto_210").style.display="none";
	try{clearTimeout(closer_toto_240);} catch(e) {}; geby("toto_240").style.display="none";
	try{clearTimeout(closer_toto_cij);} catch(e) {}; geby("toto_cij").style.display="none";
	//try{clearTimeout(closer_toto_doc);} catch(e) {}; geby("toto_doc").style.display="none";
	
}



var defilement;
var vdefil = +1;


function animdefil()
{
	taillevue = geby("blocpdefilnews").style.height;
	taillevue = 100;
	tailletotale = geby("blocpdefilnews").scrollHeight;
	pos = geby("blocpdefilnews").scrollTop;
	
	if ( (pos + taillevue) >= (tailletotale)) vdefil = - vdefil;
	if ( (pos ) <= 0) vdefil = - vdefil;
		
	geby("blocpdefilnews").scrollTop += vdefil;
}


//var defilement2;
//var vdefil2 = +1;

/*function startdefil2()
{
	defilement2 = setInterval("animdefil2()", 65);
	geby("blocpdefilnews2").style.overflow = 'auto';
}

function stopdefil2()
{
	clearInterval(defilement2);
	geby("blocpdefilnews2").style.overflow = 'auto';
}



function animdefil2()
{
	taillevue = geby("blocpdefilnews2").style.height;
	taillevue = 100;
	tailletotale = geby("blocpdefilnews2").scrollHeight;
	pos = geby("blocpdefilnews2").scrollTop;
	
	if ( (pos + taillevue) >= (tailletotale)) vdefil2 = - vdefil2;
	if ( (pos ) <= 0) vdefil2 = - vdefil2;
		
	geby("blocpdefilnews2").scrollTop += vdefil2;
}
*/



bn1 = 0;
bn1ing = false;
function nextbn1()
{
	//On efface le bn courant
		i=0;
		while(geby("bn"+i)) 	geby("bn"+(i++)).style.display="none";
	
	
	if (geby("bn"+(bn1+1))) bn1=bn1+1; else bn1=0;
	
	// On change la couleur (et le dernier de la couleur redémarre le défilement suivant
	geby("bn"+bn1).style.color="#ffffff";
	geby("bn"+bn1).style.display="block";
	bn1ing = true;
	nextbn1color("bn"+bn1, 10);
}

bn2 = 0;
bn2ing = false;
function nextbn2()
{
	//On efface le bn courant
		i=0;
		while(geby("bnd"+i)) 	geby("bnd"+(i++)).style.display="none";
	
	
	if (geby("bnd"+(bn2+1))) bn2=bn2+1; else bn2=0;
	
	// On change la couleur (et le dernier de la couleur redémarre le défilement suivant
	
	geby("bnd"+bn2).style.color="#ffffff";
	geby("bnd"+bn2).style.display="block";
	bn2ing = true;
	nextbn2color("bnd"+bn2, 10);
}

function nextbn1color(idbn,etape)
{
	if (etape>0)
	{
		if(etape==10) geby(idbn).style.color="#ffffff";
		if(etape==9) geby(idbn).style.color="#ffffff";
		if(etape==8) geby(idbn).style.color="#eeeeee";
		if(etape==7) geby(idbn).style.color="#eeeeee";
		if(etape==6) geby(idbn).style.color="#cccccc";
		if(etape==5) geby(idbn).style.color="#bbbbbb";
		if(etape==4) geby(idbn).style.color="#999999";
		if(etape==3) geby(idbn).style.color="#666666";
		if(etape==2) geby(idbn).style.color="#222222";
		if(etape==1) geby(idbn).style.color="#000000";
		
		timerbn1color = setTimeout("nextbn1color('"+idbn+"',"+(etape-1)+")",50);
	}
	else
	{
		geby(idbn).style.display="block";
		bn1ing = false;
		startdefil();
		
	}
}
function nextbn2color(idbn,etape)
{
	if (etape>0)
	{
		if(etape==10) geby(idbn).style.color="#ffffff";
		if(etape==9) geby(idbn).style.color="#ffffff";
		if(etape==8) geby(idbn).style.color="#eeeeee";
		if(etape==7) geby(idbn).style.color="#eeeeee";
		if(etape==6) geby(idbn).style.color="#cccccc";
		if(etape==5) geby(idbn).style.color="#bbbbbb";
		if(etape==4) geby(idbn).style.color="#999999";
		if(etape==3) geby(idbn).style.color="#666666";
		if(etape==2) geby(idbn).style.color="#222222";
		if(etape==1) geby(idbn).style.color="#000000";
		
		timerbn2color = setTimeout("nextbn2color('"+idbn+"',"+(etape-1)+")",50);
	}
	else
	{
		geby(idbn).style.display="block";
		bn2ing = false;
		startdefil2();
		
	}
}

function startdefil()
{
	if (!bn1ing) timerbn1 = setTimeout("nextbn1()", 3000);
}
function startdefil2()
{
	if (!bn2ing) timerbn2 = setTimeout("nextbn2()", 3000);
}

function stopdefil()
{
	 try{clearInterval(timerbn1)}catch(e){};
}
function stopdefil2()
{
	 try{clearInterval(timerbn2)}catch(e){};
}


function flashouilleimg(idimg,t,etat,x1,y1,x2,y2)
{
	if (etat)
	{
		geby(idimg).style.width = x1;
		geby(idimg).style.height = y1;
		tt = false;
		
	}	
	else
	{
		geby(idimg).style.width = x2;
		geby(idimg).style.height = y2;
		tt = true;
		
	}
	
	
	
	if (t>0) setTimeout("flashouilleimg('"+idimg+"',"+(t)+","+(tt)+","+x1+","+y1+","+x2+","+y2+")",500/t);
}

function flashouillegras(iddiv,t,etat)
{
	if (etat)
	{
		geby(iddiv).style.fontWeight = "700";
		tt = false;
		
	}	
	else
	{
		geby(iddiv).style.fontWeight = "100";
		tt = true;
		
	}
	
	
	
	if (t>0) setTimeout("flashouillegras('"+iddiv+"',"+(t)+","+(tt)+")",500/t);
}

/**********************************************************************************************/

idtxtare = "";

function ta_titre(idta)
{
	idtxtare = idta;
	ta_encadre('<div class=titre>','</div>');
	
}

function ta_soustitre(idta)
{
	idtxtare = idta;
	ta_encadre('<div class=soustitre>','</div>');
	
}
function ta_puce(idta)
{
	idtxtare = idta;
	ta_encadre('\n<b><IMG height=20 hspace=2 src="../images/puce.gif" width=20 align=absMiddle vspace=2 border=0><FONT COLOR=#B40000>\n','\n</font></b>\n<br>\n<br>\n');
	
}
function ta_gras(idta)
{
	idtxtare = idta;
	ta_encadre('<b>','</b>');
	
}

function ta_italique(idta)
{
	idtxtare = idta;
	ta_encadre('<i>','</i>');
	
}

function ta_souligne(idta)
{
	idtxtare = idta;
	ta_encadre('<u>','</u>');
	
}

function ta_taille(idta, taille)
{
	idtxtare = idta;
	ta_encadre('<font size='+taille+'>','</font>');
	
}

function ta_lien(idta)
{
	idtxtare = idta;
	lien = prompt('Entre le lien', 'http://');
	titre = prompt('Entre le titre du lien', lien);
	
	ta_encadre('\n<a href=\''+lien+'\' target=_new>\n'+titre,'\n</a>\n');
	
}

function ta_commentaire(idta)
{
	idtxtare = idta;

	
	ta_encadre('\n<!--\n','\n-->\n');
	
}

function open_close(idta)
{
	idtxtare = idta;
	num = Math.floor(Math.random()*1000000000);
	
	ta_encadre('\n<div style=\"cursor:pointer;\" onclick=\"swapdisplay(\'sousbloc_'+num+'\');\">\n(Mettre un titre)\n</div>', '\n<div id=\'sousbloc_'+num+'\' style=\"display:none;\">\n(Mettre un texte)\n</div>\n\n');

}

function ta_encadre(deb,fin)
{
	if (idtxtare != "")
	{
		txt = geby(idtxtare);
		if (document.selection)
		{
			txt.focus();
			selec = document.selection.createRange();
			selec.text = deb + selec.text + fin ;
			txt.focus();
		}
		else if (txt.selectionStart)
		{
			tx = txt.selectionStart;
			ty = txt.selectionEnd;
			
			txtslct = txt.value.substring(tx, ty); // On récupère la chaine et on découpe...
			txt.value = txt.value.substring(0, tx) + deb + txtslct + fin + txt.value.substring(ty);
			txt.selectionStart = tx;
			txt.selectionEnd = ty + deb.length + fin.length;
			txt.focus();
			
		}
	}
}


/**********************************************************************************************/



function maj(idb)
{
	var motif = new RegExp("(codestranger_123456789987654321_strangercode)"); 
	while(geby(idb).value.indexOf("codestranger_123456789987654321_strangercode")!=-1)
		geby(idb).value = geby(idb).value.replace(motif,"\r\n");
}

/**********************************************************************************************/

function affiche_rubrique(idn)
{
	rajouteBloc(-1,-1,-1,-1,"rubrique.php?idrubrique="+idn, "principal", 1);
}

function affiche_publication(idn)
{
	rajouteBloc(-1,-1,-1,-1,"publication.php", "principal", 1);
}

function affiche_doc(idp)
{
	rajouteBloc(-1,-1,-1,-1,"publication.php?idp="+idp, "principal", 1);
}







