function getHTTPObject()
{
	var xhr_object = null;
	if(window.XMLHttpRequest) // Firefox 
		xhr_object = new XMLHttpRequest(); 
	else if(window.ActiveXObject) // Internet Explorer 
		xhr_object = new ActiveXObject("Microsoft.XMLHTTP"); 
	return xhr_object;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function enHome(lien,erreur,obj)
{
	if ((navigator.appName.indexOf("Microsoft",0)>=0) && (parseInt(navigator.appVersion)>=4))
	{
		obj.style.behavior='url(#default#homepage)';
		obj.setHomePage(lien);
	}
	else alert(erreur);
}

function enfavori(lien,intitut,erreur)
{
	if ((navigator.appName.indexOf("Microsoft",0)>=0) && (parseInt(navigator.appVersion)>=4))
	{
		window.external.addfavorite(lien,intitut);
	}
	else alert(erreur);
}

hdnTimeout="";
function afficheMsgErr(msg)
{
	if (hdnTimeout>'') clearTimeout(hdnTimeout);
	var zone=MM_findObj("zoneTextErr");
	zone.innerHTML=msg;
	if (msg!="&nbsp;") hdnTimeout=setTimeout("afficheMsgErr('&nbsp;')",1500);
}

function grise(nom2)
{
	var nom="greyopacity";
	var nom3="lightbox";
	el = MM_findObj(nom);
	el2 = MM_findObj(nom2);
	el3 = MM_findObj(nom3);
	objHauteur=MM_findObj("principal");
	
	var hauteur=objHauteur.offsetHeight+12;
	var autre=window.screen.height;
	if (hauteur<autre) hauteur=autre;
	el.style.height=hauteur+"px";
	
	var largeur=window.screen.width-23;
	var autre=objHauteur.offsetWidth+120;
	if (largeur<autre) largeur=autre;
	el.style.width=largeur+"px";
	el3.innerHTML=el2.innerHTML;
	showDiv(nom);
	showDiv(nom3);
}

function degrise(nom2)
{
	var nom="greyopacity";
	el = MM_findObj(nom);
	hideDiv(nom);
	hideDiv("lightbox");
}

function showHideDiv(nom)
{
	el = MM_findObj(nom);
	if (el.style.display == 'none') el.style.display='';
	else el.style.display='none';
}

function showDiv(nom)
{
	el = MM_findObj(nom);
	el.style.display='';
}

function hideDiv(nom)
{
	el = MM_findObj(nom);
	el.style.display='none';
}

function detectEnter(evt)
{
	 var charCode = (evt.which) ? evt.which : event.keyCode;
	 if (charCode == 13) return true;
	 else return false;	
}

function detectSaisie(evt,nameObjGrille,idCell)
{
	var charCode = (evt.which) ? evt.which : event.keyCode;
	eval("var objRetour="+nameObjGrille+";");
	if (charCode>48 && charCode<58) objRetour.setValue(idCell,charCode-48);
	else objRetour.setValue(idCell,".");
	return false;
}

function getLocalTime()
{
	dateLocal=new Date();
	decalageHoraireMinute=dateLocal.getTimezoneOffset();
	param="decalageMinute="+decalageHoraireMinute;
	
	var xmlhttp = getHTTPObject();
	xmlhttp.open("POST", "localTime.php", true);
	
	xmlhttp.onreadystatechange = function()
	{ 
		if(xmlhttp.readyState == 4) 
		{
			monDivVid=MM_findObj("zoneDateIntro");
			retourAJAX=xmlhttp.responseText;
				
			tabParametres=retourAJAX.split("|");
			for (idParam in tabParametres)
			{
				valeurs=tabParametres[idParam].split("=");
				if (valeurs.length>1)
				{
					aevaluer=valeurs[0]+"='"+valeurs[1]+"';";
					eval(aevaluer);
				}
			}
					
			monDivVid.innerHTML=dateLocale+" -";
			if (datedujour=="") datedujour=dateLocale;
			setTimeout("getLocalTime();",60000);
		}
	}
		
	xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xmlhttp.send(param);	
}

function previsu(objForm)
{
	param+="idmsg="+objForm.elements["reference"].value;
	// objForm.elements["monmsg"].value;
	objForm.elements["monmsg"].value="";
	var divOut="tempDiv";
	monDivVid=MM_findObj(divOut);
	monDivVid.innerHTML='';
	grise(divOut);
	
}

function affiche(module,objForm)
{
	var param="";
	var fctgrise=false;
	var majident=false;

	if (module=="sendadm" || module=="sendami")
	{
		var fic="sendMsg.php";
		param+="model="+module;
		if (objForm!='')
		{
			param+="&monmsg="+encodeURIComponent(objForm.elements["monmsg"].value);
			param+="&prov="+objForm.elements["provenance"].value;
			param+="&dest="+objForm.elements["destinataire"].value;
			param+="&titre="+encodeURIComponent(objForm.elements["titre"].value);
			param+="&code="+objForm.elements["codesecur"].value;
			param+="&snd="+objForm.elements["snd"].value;
		}
		divOut="tempDiv";
		fctgrise=true;		
	}

	if (module=="modiftxt" || module=="supprtxt")
	{
		var fic="updateMsg.php";
		param+="idmsg="+objForm.elements["reference"].value;
		param+="&monmsg="+encodeURIComponent(objForm.elements["monmsg"].value);
		objForm.elements["monmsg"].value="";
		if (module=="modiftxt") param+="&act=modif";
		else param+="&act=suppr";
		divOut="tempDiv";
		fctgrise=false;
	}
	
	if (module=="enregistrement-2")
	{
		var fic="enregistrementMsg.php";
		if (objForm!="")
		{
			param+="monmsg="+encodeURIComponent(objForm.elements["monmsg"].value);
			objForm.elements["monmsg"].value="";
		}
		divOut="tempDiv";
		fctgrise=false;
	}

	if (module=="classement")
	{
		var fic="classement.php";
		param+="page="+objForm;
		divOut="tempDiv";
		fctgrise=true;
	}

	if (module=="liste-persos")
	{
		var fic="listePerso.php";
		param+="page="+objForm;
		divOut="tempDiv";
		fctgrise=true;
	}

	if (module=="enregistrement")
	{
		var fic="enregistrementTmp.php";
		param+="chrono="+eltContext.chrono_secondes;
		divOut="tempDiv";
		fctgrise=true;
	}

	if (module=="connexion" || module=="connexion2")
	{
		var fic="connexion.php";
		if (module=="connexion2") param+="waitSave=1";
		divOut="tempDiv";
		fctgrise=true;
	}

	if (module=="multiconnexion")
	{
		var fic="multiconnexion.php";
		if (objForm!="") param+="chx="+objForm;
		divOut="tempDiv";
		fctgrise=true;
	}
	
	if (module=="identifMulti")
	{
		var fic="multiconnexion.php";
		param+="chx="+objForm;
		divOut="tempDiv";
		fctgrise=false;
	}
	
	if (module=="deconnexion")
	{
		var fic="connexion.php";
		param="valid3=deconn";
		divOut="tempDiv";
		fctgrise=false;
	}

	if (module=="inscription")
	{
		var fic="inscription.php";
		divOut="tempDiv";
		fctgrise=true;
	}
	
	if (module=="nouveau")
	{
		var listeChamps=new Array("identif","emel","passmot","passmotver","codesecur");
		var fic="inscription.php";
		param="valid=ok";
		for (idChamp in listeChamps) param+="&"+listeChamps[idChamp]+"="+encodeURIComponent(objForm.elements[listeChamps[idChamp]].value);
		divOut="tempDiv";
		fctgrise=true;
	}
	
	if (module=="identifSimple")
	{
		var fic="connexion.php";
		param="valid1=ok";
		param+="&identif="+objForm.elements["identif"].value;
		divOut="tempDiv";
		fctgrise=false;
	}
	
	if (module=="identifPlus")
	{
		var listeChamps=new Array("emel","passmot");
		var fic="connexion.php";
		param="valid2=ok";
		for (idChamp in listeChamps) param+="&"+listeChamps[idChamp]+"="+objForm.elements[listeChamps[idChamp]].value;
		if (objForm.elements["valauto"].checked) param+="&valauto=1";
		divOut="tempDiv";
		fctgrise=false;
	}

	if (fic!=undefined && fic>"")
	{
		var xmlhttp = getHTTPObject();
		xmlhttp.open("POST", fic, true);
	
		xmlhttp.onreadystatechange = function()
		{ 
			if(xmlhttp.readyState == 4) 
			{
				//alert(xmlhttp.responseText);
				monDivVid=MM_findObj(divOut);
				retourAJAX=xmlhttp.responseText;
				tabEltRetour=retourAJAX.split("|||");
				
				if (!fctgrise) degrise();
				
				if (tabEltRetour[1] > " ")
				{
					tabParametres=tabEltRetour[1].split("|");
					for (idParam in tabParametres)
					{
						valeurs=tabParametres[idParam].split("=");
						if (valeurs.length>1)
						{
							aevaluer=valeurs[0]+"='"+valeurs[1]+"';";
							eval(aevaluer);
						}
					}
					
					if (fic=="enregistrementMsg.php" || fic=="updateMsg.php")
					{
						chargeMsgs();
						if (tabParametres[0]=="nook") affiche('connexion2','');
					}
					if (fic=="enregistrementTmp.php") chargeTmps();
					if (fic=="connexion.php") idconnect(nom_connect,mode_connect,txt_mode_connect,true);
					if (fic=="multiconnexion.php" && tabParametres[0]!="nook") idconnect(nom_connect,1,txt_mode_connect,true);
				}
				else fctgrise=true;
				
				if (fctgrise && retourAJAX!='session_out')
				{
					monDivVid.innerHTML=tabEltRetour[0];
					grise(divOut);
				}
				else
				{
					degrise();
					reconnect();
				}
			}
		}
		
		xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		xmlhttp.send(param);
	}
}

function idconnect(nom,mode,txtMod,connex)
{
	getLocalTime();
	var elt1=MM_findObj("identifiant");
	var elt2=MM_findObj("lienConnect");
	elt1.innerHTML=nom;
	if (mode==1) elt2.innerHTML='<a href="javascript:affiche(\'deconnexion\',\'\');" class="lienLight">'+txtMod+'</a>';
	else elt2.innerHTML='<a href="javascript:affiche(\'connexion\',\'\');" class="lienLight">'+txtMod+'</a>';
	if (connex)
	{
		chargeTmps();
		chargeMsgs();
	}
}

function double2once(val1,val2)
{
	var sortie=val2*9+val1;
	return sortie;
}

function once2double(val)
{
	var sortie=new Array();
	sortie[0]=val%9;
	sortie[1]=Math.floor(val/9);
	return sortie;
}


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

//							Class ContextObj

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


function ContextObj(nameObj,idZoneChrono)
{
	this.nameObj=nameObj;

	this.tabGrilles=new Array();
	this.objGrille="";
	this.idCase="";
	this.idAnnot="";
	
	this.idZoneChrono=idZoneChrono;
	this.chrono_secondes=0;
	this.hdlerTimeout="";
	this.modePause=true;
	this.typeGrille=0;
}

ContextObj.prototype.playChrono = ContextObj_playChrono;
ContextObj.prototype.attachGrille = ContextObj_attachGrille;
ContextObj.prototype.incrementeChrono = ContextObj_incrementeChrono;
ContextObj.prototype.affichChrono = ContextObj_affichChrono;
ContextObj.prototype.stopChrono = ContextObj_stopChrono;
ContextObj.prototype.pointeCell = ContextObj_pointeCell;
ContextObj.prototype.depointeCell = ContextObj_depointeCell;
ContextObj.prototype.clicDroit = ContextObj_clicDroit;
ContextObj.prototype.changeAnnot = ContextObj_changeAnnot;
ContextObj.prototype.changeColor = ContextObj_changeColor;
ContextObj.prototype.finGrille = ContextObj_finGrille;
ContextObj.prototype.noChrono = ContextObj_noChrono;
ContextObj.prototype.changeClic3 = ContextObj_changeClic3;
ContextObj.prototype.changeCodeCouleurAnnot = ContextObj_changeCodeCouleurAnnot;

function ContextObj_changeCodeCouleurAnnot(idColor)
{
	for (idGrille in this.tabGrilles)
	{
		var objTemp=eval(this.tabGrilles[idGrille]["grille"]);
		objTemp.codeCouleurAnnot=idColor;
	}
}

function ContextObj_changeClic3()
{
	for (idGrille in this.tabGrilles)
	{
		var objTemp=eval(this.tabGrilles[idGrille]["grille"]);
		objTemp.clic3=!objTemp.clic3;
	}
}

function ContextObj_attachGrille(lagrille,idPage)
{
	var lidTabGrilles=this.tabGrilles.length;
	this.tabGrilles[lidTabGrilles]=new Array();
	this.tabGrilles[lidTabGrilles]["grille"]=lagrille;
	this.typeGrille=idPage;
}

function ContextObj_finGrille(reference)
{
	var objTemp=eval(reference);
	window.clearTimeout(this.hdlerTimeout);
	this.objGrille="";
	this.idCase="";
	this.idAnnot="";
	objTemp.finGrille();
	
	var refTab=-1;
	for (var valeur in this.tabGrilles) if (this.tabGrilles[valeur]["grille"]==reference) refTab=valeur;
	if (refTab!=-1 && this.typeGrille!=2) affiche('enregistrement',this.tabGrilles[refTab]);
}

function ContextObj_changeColor()
{
	if (!this.modePause) for (idGrille in this.tabGrilles)
	{
		var objTemp=eval(this.tabGrilles[idGrille]["grille"]);
		objTemp.modeColor=!objTemp.modeColor;
		objTemp.play(1);
	}
}

function ContextObj_changeAnnot()
{
	if (!this.modePause) for (idGrille in this.tabGrilles)
	{
		var objTemp=eval(this.tabGrilles[idGrille]["grille"]);
		objTemp.modeAnnot=!objTemp.modeAnnot;
		objTemp.play(1);
	}
}

function ContextObj_playChrono()
{
	if (this.modePause) this.hdlerTimeout=window.setTimeout(this.nameObj+".incrementeChrono()",1000);
	if (this.modePause)
	{
		this.modePause=false;
		for (idGrille in this.tabGrilles)
		{
			var objTemp=eval(this.tabGrilles[idGrille]["grille"]);
			objTemp.play(0);
		}
	}
}

function ContextObj_incrementeChrono()
{
	this.hdlerTimeout=window.setTimeout(this.nameObj+".incrementeChrono()",1000);
	this.chrono_secondes++;
	this.affichChrono();
}

function ContextObj_affichChrono()
{
	var secondes=this.chrono_secondes;
	var zoneChrono=MM_findObj(this.idZoneChrono);
	var sec=secondes%60;
	var totMinute=Math.floor(secondes/60);
	var min=totMinute%60;
	var totHeure=Math.floor(totMinute/60);
	
	var chaineChrono="";
	
	if (totHeure>0) chaineChrono+=totHeure+" : ";
	if (min<10) chaineChrono+="0";
	chaineChrono+=min+" : ";
	if (sec<10) chaineChrono+="0";
	chaineChrono+=sec;
	
	zoneChrono.innerHTML=chaineChrono;	
}

function ContextObj_stopChrono()
{
	this.modePause=true;
	for (idGrille in this.tabGrilles)
	{
		var objTemp=eval(this.tabGrilles[idGrille]["grille"]);
		objTemp.pause();
	}
	
	window.clearTimeout(this.hdlerTimeout);
}

function ContextObj_noChrono()
{
	MM_findObj("zoneChrono").innerHTML="-";
	MM_findObj("optSpecNav").innerHTML="";
	MM_findObj("zonePause").innerHTML="";
	eltContext.chrono_secondes=0;
	window.clearTimeout(this.hdlerTimeout);
}

function ContextObj_pointeCell(nameGrille,idCase,idAnnot)
{
	this.objGrille=nameGrille;
	this.idCase=idCase;
	this.idAnnot=idAnnot;
}

function ContextObj_depointeCell()
{
	this.objGrille="";
	this.idCase="";
}

function ContextObj_clicDroit()
{
	if (this.objGrille>'')
	{
		var action;
		if (this.idAnnot>0)
		{
			action=this.objGrille+".setValue("+this.idCase+","+this.idAnnot+");";
		}
		else
		{
			eval("var test=("+this.objGrille+".cellule["+this.idCase+"].valeur!='.');");
			if (test)
			{
				 action=this.objGrille+".cellule["+this.idCase+"].valeur='.';"+this.objGrille+".cellule["+this.idCase+"].etat=5;";
			}
			else action=this.objGrille+".cellule["+this.idCase+"].etat=6;";
		}

		eval(action);
		eval(this.objGrille+".majCell("+this.idCase+");");
	}
}


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

//							Class Couleur

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


function Couleur(vide,annot,valeurNoCol,valeurColor,saisieNoCol,saisieColor,annotColor)
{
	this.vide=vide.split("|");
	this.annot=annot; // x1
	this.valeurNoCol=valeurNoCol;
	this.valeurColor=valeurColor.split("|"); // x9
	this.saisieNoCol=saisieNoCol;
	this.saisieColor=saisieColor.split("|"); // x9
	this.annotColor=annotColor.split("|"); // x8
}

Couleur.prototype.getStyleValeur = Couleur_getStyleValeur;
Couleur.prototype.getStyleSaisie = Couleur_getStyleSaisie;
Couleur.prototype.getStyleVide = Couleur_getStyleVide;
Couleur.prototype.getStyleAnnot = Couleur_getStyleAnnot;
Couleur.prototype.getColorAnnot = Couleur_getColorAnnot;

function Couleur_getColorAnnot(codeCouleur)
{
	var sortie=this.annotColor[codeCouleur];
	return sortie;
}

function Couleur_getStyleValeur(valeur,modeCouleur)
{
	var sortie;
	if (modeCouleur) sortie=this.valeurColor[valeur-1];
	else sortie=this.valeurNoCol;
	return sortie;
}

function Couleur_getStyleSaisie(valeur,modeCouleur)
{
	var sortie;
	if (modeCouleur) sortie=this.saisieColor[valeur-1];
	else sortie=this.saisieNoCol;
	return sortie;
}

function Couleur_getStyleVide(modeCouleur)
{
	var sortie;
	if (modeCouleur) sortie=this.vide[1];
	else sortie=this.vide[0];
	return sortie;
}

function Couleur_getStyleAnnot(valeur,codeCouleur)
{
	var sortie;
	if (valeur==0) sortie=this.annot;
	else sortie=this.getColorAnnot(codeCouleur);
	return sortie;
}



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

//							Class Theme

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


function Theme(image,tabLarg,tabHaut,tabEcartLarg,tabEcartHaut,posX,posY,fonts)
{
	this.image=image;
	this.largeurs=new Array();
	this.hauteurs=new Array();
	this.fonts=fonts.split("|"); // 0=>valeurs, 1=>saisie, 2=>annot
	this.largeurs=tabLarg.split(",");
	this.hauteurs=tabHaut.split(",");
	this.ecartLarg=tabEcartLarg.split(",");
	this.ecartHaut=tabEcartHaut.split(",");
	this.largeur=0;
	this.hauteur=0;
	for (i=0; i<9; i++)
	{
		this.largeurs[i]=parseInt(this.largeurs[i]);
		this.hauteurs[i]=parseInt(this.hauteurs[i]);
		if (this.ecartLarg[i]!=undefined && this.ecartLarg[i]>"") this.ecartLarg[i]=parseInt(this.ecartLarg[i]);
		else this.ecartLarg[i]=0;
		if (this.ecartHaut[i]!=undefined && this.ecartHaut[i]>"") this.ecartHaut[i]=parseInt(this.ecartHaut[i]);
		else this.ecartHaut[i]=0;
		this.largeur+=this.largeurs[i]+this.ecartLarg[i];
		this.hauteur+=this.hauteurs[i]+this.ecartHaut[i];
	}
	this.decalX=posX;
	this.decalY=posY;
}

Theme.prototype.getWH = Theme_getWH;
Theme.prototype.getEcartWH = Theme_getEcartWH;

function Theme_getWH(id)
{
	var refXY=once2double(id);
	var sortie=new Array();
	sortie[0]=this.largeurs[refXY[0]];
	sortie[1]=this.hauteurs[refXY[1]];
	return sortie;
}

function Theme_getEcartWH(id)
{
	var refXY=once2double(id);
	var sortie=new Array();
	sortie[0]=this.ecartLarg[refXY[0]];
	sortie[1]=this.ecartHaut[refXY[1]];
	return sortie;
}


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

//							Class Grille

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


function Grille(theme,couleur,chaineGrille,cible,idGrille,idContext)
{
	this.theme=theme;
	this.couleurs=couleur;
	this.modeColor=false;
	this.modeAnnot=false;
	this.clic3=false;
	this.reference=idGrille;
	this.referenceContext=idContext;
	this.zoneHTML=cible;
	this.etatFin=false;
	this.codeCouleurAnnot=0;

	this.cellule=new Array();
	for (i=0; i<81; i++)
	{
		this.cellule[i]=new Object();
		this.cellule[i].valeur=chaineGrille.charAt(i);
		this.cellule[i].annotation=new Array();
		for (j=1; j<=9; j++)
		{
			this.cellule[i].annotation[j]=new Object();
			this.cellule[i].annotation[j].valeur=0;
			this.cellule[i].annotation[j].codeCouleur=this.codeCouleurAnnot;
		}
		// etat :	1 => val ss couleur
		//			2 => val avec couleur
		//			3 => saisie ss couleur
		//			4 => saisie avec couleur
		//			5 => vide
		//			6 => Annot
		if (this.cellule[i].valeur==".") this.cellule[i].etat=5;
		else this.cellule[i].etat=1;
	}
}

Grille.prototype.show = Grille_show;
Grille.prototype.play = Grille_play;
Grille.prototype.pause = Grille_pause;
Grille.prototype.majCell = Grille_majCell;
Grille.prototype.getCellID = Grille_getCellID;
Grille.prototype.getSaisieID = Grille_getSaisieID;
Grille.prototype.setValue = Grille_setValue;
Grille.prototype.setAnnot = Grille_setAnnot;
Grille.prototype.showPLAY = Grille_showPLAY;
Grille.prototype.finGrille = Grille_finGrille;
Grille.prototype.getBase = Grille_getBase;
Grille.prototype.getSaisie = Grille_getSaisie;
Grille.prototype.setBase = Grille_setBase;
Grille.prototype.setSaisie = Grille_setSaisie;
Grille.prototype.getChaine = Grille_getChaine;
Grille.prototype.setChaine = Grille_setChaine;
Grille.prototype.clicCellAnnot = Grille_clicCellAnnot;
function Grille_getChaine()
{
	var maChaine="";
	for (i=0; i<81; i++)
	{
		if (maChaine.length>0) maChaine+=";";
		if (this.cellule[i].etat==1 || this.cellule[i].etat==2) maChaine+="#"+this.cellule[i].valeur;
		if (this.cellule[i].etat==3 || this.cellule[i].etat==4) maChaine+=this.cellule[i].valeur;
		if (this.cellule[i].etat>4)
		{
			maChaine+="0";
			var annot="";
			for (k=1;k<10;k++)
			{
				var specialAnnot="";
				if (this.cellule[i].annotation[k].codeCouleur>0) specialAnnot="C"+this.cellule[i].annotation[k].codeCouleur;
				if (this.cellule[i].annotation[k].valeur==1) annot+=specialAnnot+k;
				if (this.cellule[i].annotation[k].valeur==2) annot+=specialAnnot+"X"+k;
			}
			if (annot!="") maChaine+="|"+annot;
		}
	}
	return maChaine;	
}

function Grille_setChaine(nouvChaine)
{
	var tabDesElts=nouvChaine.split(";");
	this.modeAnnot=false;
	for (i=0; i<81; i++)
	{
		var valCell=tabDesElts[i];
		this.cellule[i].valeur=".";
		for (j=1; j<=9; j++) this.cellule[i].annotation[j].valeur=0;
		if (valCell.charAt(0)!="0" && valCell.charAt(0)!="#") this.cellule[i].valeur=valCell.charAt(0);
		if (valCell.charAt(0)=="#") this.cellule[i].valeur=valCell.charAt(1);
		if (valCell.charAt(0)=="0" && valCell.length>2)
		{
			this.modeAnnot=true;
			var specialAnnot=0;
			var specialClic3=false;
			for (k=2;k<valCell.length;k++)
			{
				if (valCell.charAt(k)=="C")
				{
					k++;
					specialAnnot=valCell.charAt(k);
				}
				else if (valCell.charAt(k)=="X") specialClic3=true;
				else
				{
					this.setAnnot(i,valCell.charAt(k),specialAnnot,specialClic3);
					specialAnnot=0;
					specialClic3=false;
				}
			}
		}
	}
	
	this.play(1);
}

function Grille_getBase()
{
	var maChaine="";
	for (i=0; i<81; i++)
	{
		if (this.cellule[i].etat==1 || this.cellule[i].etat==2) maChaine+=this.cellule[i].valeur;
		else maChaine+=".";
	}
	return maChaine;
}

function Grille_setBase(chaine)
{
	for (i=0; i<81; i++)
	{
		if (chaine.charAt(i)!=".")
		{
			this.cellule[i].valeur=chaine.charAt(i);
			if (this.modeColor) this.cellule[i].etat=2;
			else this.cellule[i].etat=1;
		}
	}
}

function Grille_getSaisie()
{
	var maChaine="";
	for (i=0; i<81; i++)
	{
		if (this.cellule[i].etat==3 || this.cellule[i].etat==4) maChaine+=this.cellule[i].valeur;
		else maChaine+=".";
	}
	return maChaine;
}

function Grille_setSaisie(chaine)
{
	for (i=0; i<81; i++)
	{
		if (chaine.charAt(i)!=".")
		{
			this.cellule[i].valeur=chaine.charAt(i);
			if (this.modeColor) this.cellule[i].etat=4;
			else this.cellule[i].etat=3;
		}
	}
}

function Grille_setValue(idCell,value)
{
	var total=true;
	if (value!=".")
	{
		var lcube,ccube;
		var monbool=false;

		var coord=once2double(idCell);
		lcube=Math.floor(coord[1]/3);
		ccube=Math.floor(coord[0]/3);
		for (var i=0;i<9;i++)
		{
			maLig=coord[1]*9+i;
			if (maLig!=idCell) if (this.cellule[maLig].valeur==value) monbool=true;
			maCol=i*9+coord[0];
			if (maCol!=idCell) if (this.cellule[maCol].valeur==value) monbool=true;
			monCube=9*(lcube*3+Math.floor(i/3))+((ccube*3)+(i%3));
			if (monCube!=idCell) if (this.cellule[monCube].valeur==value) monbool=true;
		}

		if (monbool)
		{
			afficheMsgErr(value+" ne convient pas dans cette case actuellement");
		}
		else this.cellule[idCell].valeur=value;

		for (j=0; j<81; j++)
		{
			if (this.cellule[j].valeur==".") total=false;
		}
	}
	else total=false;
	
	if (value=="." || this.cellule[idCell].valeur==".")
	{
		this.cellule[idCell].valeur=".";
		if (this.modeAnnot) this.cellule[idCell].etat=6;
		else this.cellule[idCell].etat=5;
	}
	else if (this.modeColor) this.cellule[idCell].etat=4;
	else this.cellule[idCell].etat=3;
	this.majCell(idCell);
	
	if (total) eval(this.referenceContext).finGrille(this.reference);
}

function Grille_setAnnot(idCell,value,codeCouleur,clic3)
{
	this.cellule[i].valeur=".";
	//if (this.cellule[i].annotation[value]==1) this.cellule[i].annotation[value]=0;
	this.cellule[i].annotation[value].codeCouleur=codeCouleur;
	if (clic3) this.cellule[i].annotation[value].valeur=2;
	else this.cellule[i].annotation[value].valeur=1;
	this.majCell(idCell);
}

function Grille_getCellID(id)
{
	return "zC"+this.reference+"_"+id;
}

function Grille_getSaisieID(id)
{
	return "inp_"+this.reference+"_"+id;
}

function Grille_show(withpause)
{
	var laCible=MM_findObj(this.zoneHTML);
	var sortie="<div style='position:absolute;top:0px;left:0px;'><img src='"+this.theme.image+"' /></div>";
	sortie+="<div style='position:absolute;top:"+this.theme.decalY+"px;left:"+this.theme.decalX+"px;width:"+this.theme.largeur+"px;height:"+this.theme.hauteur+"px;'>";
	for (var i=0; i<81; i++)
	{
		var infos=this.theme.getWH(i);
		var tabEcrtCel=this.theme.getEcartWH(i);
		sortie+="<div id='"+this.getCellID(i)+"' style='position:relative;float:left;width:"+(tabEcrtCel[0]+infos[0])+"px;height:"+(tabEcrtCel[1]+infos[1])+"px;'></div>";
	}
	sortie+="</div>";
	if (withpause) this.showPLAY(true);
	laCible.innerHTML=sortie;
}

function Grille_play(force)
{
	if (!this.etatFin || force==1)
	{
		if (force!=1) this.showPLAY(false);
		for (var i=0; i<81; i++)
		{
			if (this.cellule[i].etat==1 || this.cellule[i].etat==2)
			{
				if (this.modeColor) this.cellule[i].etat=2;
				else this.cellule[i].etat=1;
			}
			else if (this.cellule[i].valeur==".")
			{
				if (this.modeAnnot) this.cellule[i].etat=6;	
				else this.cellule[i].etat=5;	
			}
			else
			{
				if (this.modeColor) this.cellule[i].etat=4;
				else this.cellule[i].etat=3;
			}
	
			this.majCell(i);
		}
	}
}

function Grille_showPLAY(boolAffic)
{
	var objPlay=MM_findObj(this.zoneHTML+"Play");
	var msgPlay='';
	var laCible=MM_findObj(this.zoneHTML);	
	
	if (boolAffic)
	{
		laCible.style.MozOpacity = 0.45;
		laCible.style.opacity = 0.45;
		msgPlay='<div style="position:relative;float:left;padding-left:'+this.theme.decalX+'px;padding-top:'+this.theme.decalY+'px;">';
		msgPlay+='<div style="position:relative;float:left;height:'+this.theme.hauteur+'px;width:'+this.theme.largeur+'px;line-height:'+this.theme.hauteur+'px;text-align:center;">';
		msgPlay+='<a href="javascript:'+this.referenceContext+'.playChrono();" style="font-family:Times;font-size:80px;color:#396DA0;font-weight:bold;text-decoration:none;">G<span style="font-size:60px;">O</span></a></div></div>';
	}
	else
	{
		laCible.style.MozOpacity = 1;
		laCible.style.opacity = 1;
	}
	
	objPlay.innerHTML=msgPlay;
}

function Grille_finGrille()
{
	var objFin=MM_findObj(this.zoneHTML+"Play");
	this.etatFin=true;
	var opacity="background-color:#FFF;filter:alpha(opacity=15);opacity:.15;-moz-opacity:.15;";
	var msgFin='<div style="position:relative;float:left;padding-left:'+this.theme.decalX+'px;padding-top:'+this.theme.decalY+'px;">';
	msgFin+='<div style="position:relative;float:left;height:'+this.theme.hauteur+'px;width:'+this.theme.largeur+'px;line-height:'+this.theme.hauteur+'px;text-align:center;'+opacity+'">&nbsp;</div></div>';
	objFin.innerHTML=msgFin;
}

function Grille_pause()
{
	if (!this.etatFin)
	{
		for (var i=0; i<81; i++)
		{
			var laCell=MM_findObj(this.getCellID(i));
			laCell.innerHTML="";
		}
		this.showPLAY(true);
	}
}

function Grille_majCell(id)
{
	var infos=this.theme.getWH(id);
	var laCell=MM_findObj(this.getCellID(id));
	
	var complementOption="";
	var valeurElt="";

	var laVal=this.cellule[id].valeur!="."?this.cellule[id].valeur:" ";
	var largeur=infos[0];
	var hauteur=infos[1];

	var nameIdSaisie=this.getSaisieID(id);
	var focusCellSaisie="";
	var saisieElt="";
	if (this.referenceContext!="")
	{
		focusCellSaisie="onMouseOver='"+this.referenceContext+".pointeCell(\""+this.reference+"\","+id+",0);MM_findObj(\""+nameIdSaisie+"\").focus();' onMouseOut='"+this.referenceContext+".depointeCell();' ";
		saisieElt="onKeyPress='javascript:detectSaisie(event,\""+this.reference+"\","+id+");'";
	}
	
	if (this.cellule[id].etat==1)
	{
		complementOption=this.couleurs.getStyleValeur(laVal,false)+this.theme.fonts[0];
		valeurElt="<div style='position:relative;float:left;line-height:"+hauteur+"px;width:"+largeur+"px;height:"+hauteur+"px;text-align:center;cursor:default;"+complementOption+"'>"+laVal+"</div>";
	}
	if (this.cellule[id].etat==2)
	{
		complementOption=this.couleurs.getStyleValeur(laVal,true)+this.theme.fonts[0];
		valeurElt="<div style='position:relative;float:left;line-height:"+hauteur+"px;width:"+largeur+"px;height:"+hauteur+"px;text-align:center;cursor:default;"+complementOption+"'>"+laVal+"</div>";
	}
	if (this.cellule[id].etat==3)
	{
		complementOption=this.couleurs.getStyleSaisie(laVal,false)+this.theme.fonts[1];
		valeurElt="<div "+focusCellSaisie+" style='position:relative;float:left;width:"+largeur+"px;height:"+hauteur+"px;"+this.couleurs.getStyleSaisie(laVal,false)+"'><div style='position:relative;float:left;padding-top:0px;'><textarea "+saisieElt+" id='"+nameIdSaisie+"' style='overflow:hidden;margin:0px;border:0px;width:"+(largeur-4)+"px;height:"+(hauteur-4)+"px;line-height:"+(hauteur-4)+"px;text-align:center;"+complementOption+"'>"+laVal+"</textarea></div></div>";
	}
	if (this.cellule[id].etat==4)
	{
		complementOption=this.couleurs.getStyleSaisie(laVal,true)+this.theme.fonts[1];
		valeurElt="<div "+focusCellSaisie+" style='position:relative;float:left;width:"+largeur+"px;height:"+hauteur+"px;"+this.couleurs.getStyleSaisie(laVal,true)+"'><div style='position:relative;float:left;padding-top:0px;'><textarea "+saisieElt+" id='"+nameIdSaisie+"' style='overflow:hidden;margin:0px;border:0px;width:"+(largeur-4)+"px;height:"+(hauteur-4)+"px;line-height:"+(hauteur-4)+"px;text-align:center;"+complementOption+"'>"+laVal+"</textarea></div></div>";
	}
	if (this.cellule[id].etat==5)
	{
		complementOption=this.couleurs.getStyleVide(this.modeColor)+this.theme.fonts[1];
		valeurElt="<div "+focusCellSaisie+" style='position:relative;float:left;width:"+largeur+"px;height:"+hauteur+"px;"+this.couleurs.getStyleVide(this.modeColor)+"'><div style='position:relative;float:left;padding-top:0px;'><textarea "+saisieElt+" id='"+nameIdSaisie+"' style='overflow:hidden;margin:0px;border:0px;width:"+(largeur-4)+"px;height:"+(hauteur-4)+"px;line-height:"+(hauteur-4)+"px;text-align:center;"+complementOption+"'>"+laVal+"</textarea></div></div>";
	}
	if (this.cellule[id].etat==6)
	{
		valeurElt="";
		ptitHauteur=Math.floor(hauteur/3);
		ptitLargeur=Math.floor(largeur/3);
		for (a=1; a<=9; a++)
		{
			var focusCellAnnot="";
			if (this.referenceContext!="") focusCellAnnot="onMouseOver='"+this.referenceContext+".pointeCell(\""+this.reference+"\","+id+","+a+");' onMouseOut='"+this.referenceContext+".depointeCell();' ";
			if ((Math.ceil(a/3))==2) haut=hauteur-(2*ptitHauteur);
			else haut=ptitHauteur;
			if ((a%3)==2) larg=largeur-(2*ptitLargeur);
			else larg=ptitLargeur;
			complementOption=this.couleurs.getStyleAnnot(this.cellule[id].annotation[a].valeur,this.cellule[id].annotation[a].codeCouleur)+this.theme.fonts[2];
			valeurAffiche=a;
			if (this.cellule[id].annotation[a].valeur==2) valeurAffiche="X";
			if ((a%3)==1) valeurElt+="<div style='position:relative;float:left;'>";
			valeurElt+="<div "+focusCellAnnot+" onClick='javascript:"+this.reference+".clicCellAnnot("+id+","+a+");' style='position:relative;float:left;line-height:"+haut+"px;width:"+larg+"px;height:"+haut+"px;text-align:center;cursor:pointer;"+complementOption+"'>"+valeurAffiche+"</div>";
			if ((a%3)==0) valeurElt+="</div>";
		}
	}
	laCell.innerHTML=valeurElt;
}

function Grille_clicCellAnnot(cell,annot)
{
	this.cellule[cell].annotation[annot].codeCouleur=this.codeCouleurAnnot;
	this.cellule[cell].annotation[annot].valeur++;
	if (this.cellule[cell].annotation[annot].valeur==3 || (this.cellule[cell].annotation[annot].valeur==2 && !this.clic3)) this.cellule[cell].annotation[annot].valeur=0;
	this.majCell(cell);
}


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

//				Initialisations variables

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

eltContext=new ContextObj("eltContext","zoneChrono");
idpopon="";
mouseX=0;
mouseY=0;
lang="";
idGrille=0;
grillep=0;
datedujour="";

function posSouris(e)
{
	if(document.layers)
	{
		mouseX=e.x;
		mouseY=e.y;
	}
	else
	{
		mouseX=e.clientX;
		mouseY=e.clientY;
	}

    if( document.documentElement && document.documentElement.clientWidth)
      DocRef = document.documentElement;
    else
      DocRef = document.body;

    mouseX += DocRef.scrollLeft;
    mouseY += DocRef.scrollTop;	
}

function chargeGrilleSoum(divGrille,chaine)
{
	var tabLarg="32,32,32,32,32,32,32,32,32";
	var tabHaut=tabLarg;
	var tabEcartLarg="5,5,10,6,6,10,5,5";
	var tabEcartHaut=tabEcartLarg;
	var coinSupGaucheX=31;
	var coinSupGaucheY=29;
	var paddingSaisie=3;
	var fonts="font-family:Times New Roman;font-size:18px;font-weight:bold; | font-family:Times New Roman;font-size:16px;font-weight:bold; | font-family:Arial; font-size:12px; font-weight:bold;";
	var monTheme=new Theme("img/sudoku-grid.gif",tabLarg,tabHaut,tabEcartLarg,tabEcartHaut,coinSupGaucheX,coinSupGaucheY,fonts,paddingSaisie);

	var vide="color:#999999;background-color:#F5F5F5;|color:#999999;background-color:#D6D6D6;";
	var annotations="color:#CDD0D6;background-color:#FBFBFB;";
	var valeurSsColor="color:#990000;background-color:#E6E6E6;";
	var saisieSsColor="color:#000099;background-color:#F5F5F5;";
	var valeurColor="color:#B28D00;background-color:#FFD100;|color:#009241;background-color:#00EA8F;|color:#C54BC8;background-color:#FF80FF;|color:#FFB483;background-color:#E00000;|color:#0089AB;background-color:#00C8EC;|color:#6CDB5B;background-color:#008A00;|color:#7CC2FF;background-color:#006CA4;|color:#D27DA1;background-color:#A30048;|color:#FFD578;background-color:#FF6600;";
	var saisieColor="color:#444444;background-color:#FFD100;|color:#444444;background-color:#00EA8F;|color:#444444;background-color:#FF80FF;|color:#EEEEEE;background-color:#E00000;|color:#444444;background-color:#00C8EC;|color:#EEEEEE;background-color:#008A00;|color:#EEEEEE;background-color:#006CA4;|color:#EEEEEE;background-color:#A30048;|color:#EEEEEE;background-color:#FF6600;";
	var annotationsCouleur="color:#1A2945;background-color:#FBFBFB;|color:#5A8A2C;background-color:#CCFF99;|color:#313C94;background-color:#9999FF;|color:#333333;background-color:#FFCCCC;|color:#9A9B37;background-color:#FFFF99;|color:#FFD49D;background-color:#CC9966;|color:#CBFF94;background-color:#99CC66;|color:#E8B0FF;background-color:#9966CC;";
	var mesCouleurs=new Couleur(vide,annotations,valeurSsColor,valeurColor,saisieSsColor,saisieColor,annotationsCouleur);

	var idZoneGrille=divGrille;
	var nameObjGrille=divGrille+"Name";
	var chaineBase=".................................................................................";
	eval(nameObjGrille+"=new Grille(monTheme,mesCouleurs,chaineBase,idZoneGrille,nameObjGrille,'eltContext');");
	eltContext.attachGrille(nameObjGrille,3);
	eval(nameObjGrille+".setSaisie('"+chaine+"');");
	eval(nameObjGrille+".show(1);");
	eval(nameObjGrille+".play(0);");
}

function chargeGrillePres(divGrille,chaine,chaineComplete)
{
	var tabLarg="32,32,32,32,32,32,32,32,32";
	var tabHaut=tabLarg;
	var tabEcartLarg="5,5,10,6,6,10,5,5";
	var tabEcartHaut=tabEcartLarg;
	var coinSupGaucheX=31;
	var coinSupGaucheY=29;
	var paddingSaisie=3;
	var fonts="font-family:Times New Roman;font-size:18px;font-weight:bold; | font-family:Times New Roman;font-size:16px;font-weight:bold; | font-family:Arial; font-size:12px; font-weight:bold;";
	var monTheme=new Theme("img/sudoku-grid.gif",tabLarg,tabHaut,tabEcartLarg,tabEcartHaut,coinSupGaucheX,coinSupGaucheY,fonts,paddingSaisie);

	var vide="color:#999999;background-color:#F5F5F5;|color:#999999;background-color:#D6D6D6;";
	var annotations="color:#CDD0D6;background-color:#FBFBFB;";
	var valeurSsColor="color:#990000;background-color:#E6E6E6;";
	var saisieSsColor="color:#000099;background-color:#F5F5F5;";
	var valeurColor="color:#B28D00;background-color:#FFD100;|color:#009241;background-color:#00EA8F;|color:#C54BC8;background-color:#FF80FF;|color:#FFB483;background-color:#E00000;|color:#0089AB;background-color:#00C8EC;|color:#6CDB5B;background-color:#008A00;|color:#7CC2FF;background-color:#006CA4;|color:#D27DA1;background-color:#A30048;|color:#FFD578;background-color:#FF6600;";
	var saisieColor="color:#444444;background-color:#FFD100;|color:#444444;background-color:#00EA8F;|color:#444444;background-color:#FF80FF;|color:#EEEEEE;background-color:#E00000;|color:#444444;background-color:#00C8EC;|color:#EEEEEE;background-color:#008A00;|color:#EEEEEE;background-color:#006CA4;|color:#EEEEEE;background-color:#A30048;|color:#EEEEEE;background-color:#FF6600;";
	var annotationsCouleur="color:#1A2945;background-color:#FBFBFB;|color:#5A8A2C;background-color:#CCFF99;|color:#313C94;background-color:#9999FF;|color:#333333;background-color:#FFCCCC;|color:#9A9B37;background-color:#FFFF99;|color:#FFD49D;background-color:#CC9966;|color:#CBFF94;background-color:#99CC66;|color:#E8B0FF;background-color:#9966CC;";
	var mesCouleurs=new Couleur(vide,annotations,valeurSsColor,valeurColor,saisieSsColor,saisieColor,annotationsCouleur);

	var idZoneGrille=divGrille;
	var nameObjGrille=divGrille+"Name";
	eval(nameObjGrille+"=new Grille(monTheme,mesCouleurs,chaine,idZoneGrille,nameObjGrille,'');");
	eval(nameObjGrille+".show(0);");
	eval(nameObjGrille+".modeColor=true;");	
	eval(nameObjGrille+".etatFin=true;");	
	eval(nameObjGrille+".setChaine('"+chaineComplete+"');");
}

function chargeGrille(nameObjContext,menuType,level,infos,separateur,divGrille)
{
	dateLocal=new Date();
	decalageHoraireMinute=dateLocal.getTimezoneOffset();
	id_page=menuType;
	
	var tabLarg="32,32,32,32,32,32,32,32,32";
	var tabHaut=tabLarg;
	var tabEcartLarg="5,5,10,6,6,10,5,5";
	var tabEcartHaut=tabEcartLarg;
	var coinSupGaucheX=31;
	var coinSupGaucheY=29;
	var paddingSaisie=3;
	var fonts="font-family:Times New Roman;font-size:18px;font-weight:bold; | font-family:Times New Roman;font-size:16px;font-weight:bold; | font-family:Arial; font-size:12px; font-weight:bold;";
	var monTheme=new Theme("img/sudoku-grid.gif",tabLarg,tabHaut,tabEcartLarg,tabEcartHaut,coinSupGaucheX,coinSupGaucheY,fonts,paddingSaisie);

	var vide="color:#999999;background-color:#F5F5F5;|color:#999999;background-color:#D6D6D6;";
	var annotations="color:#CDD0D6;background-color:#FBFBFB;";
	var valeurSsColor="color:#990000;background-color:#E6E6E6;";
	var saisieSsColor="color:#000099;background-color:#F5F5F5;";
	var valeurColor="color:#B28D00;background-color:#FFD100;|color:#009241;background-color:#00EA8F;|color:#C54BC8;background-color:#FF80FF;|color:#FFB483;background-color:#E00000;|color:#0089AB;background-color:#00C8EC;|color:#6CDB5B;background-color:#008A00;|color:#7CC2FF;background-color:#006CA4;|color:#D27DA1;background-color:#A30048;|color:#FFD578;background-color:#FF6600;";
	var saisieColor="color:#444444;background-color:#FFD100;|color:#444444;background-color:#00EA8F;|color:#444444;background-color:#FF80FF;|color:#EEEEEE;background-color:#E00000;|color:#444444;background-color:#00C8EC;|color:#EEEEEE;background-color:#008A00;|color:#EEEEEE;background-color:#006CA4;|color:#EEEEEE;background-color:#A30048;|color:#EEEEEE;background-color:#FF6600;";
	var annotationsCouleur="color:#1A2945;background-color:#FBFBFB;|color:#5A8A2C;background-color:#CCFF99;|color:#313C94;background-color:#9999FF;|color:#333333;background-color:#FFCCCC;|color:#9A9B37;background-color:#FFFF99;|color:#FFD49D;background-color:#CC9966;|color:#CBFF94;background-color:#99CC66;|color:#E8B0FF;background-color:#9966CC;";
	var mesCouleurs=new Couleur(vide,annotations,valeurSsColor,valeurColor,saisieSsColor,saisieColor,annotationsCouleur);
	
	var param='decalageMinute='+decalageHoraireMinute;
	param+='&typeMenu='+menuType;
	param+='&niveau='+level;
	param+='&autres='+infos;
	param+='&nomDiv='+divGrille;
	
	var xmlhttp = getHTTPObject();
	xmlhttp.open("POST", "loadData.php", true);
	
	xmlhttp.onreadystatechange = function()
	{ 
		if(xmlhttp.readyState == 4)
		{
			retourAJAX=xmlhttp.responseText;
			tabEltRetour=retourAJAX.split(separateur);

			if (tabEltRetour[0]!="nogrid")
			{
				var chaine=tabEltRetour[0];
				idGrille=tabEltRetour[1];
				grillep=tabEltRetour[2];
				var idZoneGrille=tabEltRetour[3];
				var nameObjGrille=tabEltRetour[3]+"Name";
				eval(nameObjGrille+"=new Grille(monTheme,mesCouleurs,chaine,idZoneGrille,nameObjGrille,nameObjContext);");
				eltContext.attachGrille(nameObjGrille,id_page);
				eval(nameObjGrille+".show(1);");
				chargeTmps();
				chargeMsgs();
			}
			else
			{
				var objGrid=MM_findObj("groupDwld");
				if (objGrid!=null) objGrid.style.display='none';
				var objGrid2=MM_findObj("zonNogrid");
				if (objGrid2!=null) objGrid2.style.display='';				
			}
		}
	}
	
	xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xmlhttp.send(param);
}

function chargeGrillePrint(nameDivGrille,chaineBase,chaineSaisie,mode)
{
	if (mode==2)
	{
		var tabLarg="26,26,26,26,26,26,26,26,26";
		var tabHaut=tabLarg;
		var tabEcartLarg="3,3,5,3,3,5,3,3";
		var tabEcartHaut=tabEcartLarg;
		var coinSupGaucheX=5;
		var coinSupGaucheY=5;
		var paddingSaisie=3;
		var fonts="font-family:Arial;font-size:15px;font-weight:bold; | font-family:Arial;font-size:15px;font-weight:bold; | font-family:Geneva; font-size:11px; font-weight:bold;";
		var monTheme=new Theme("img/fond-ptite-grille.gif",tabLarg,tabHaut,tabEcartLarg,tabEcartHaut,coinSupGaucheX,coinSupGaucheY,fonts,paddingSaisie);
	
		var vide="color:#999999;background-color:#F5F5F5;|color:#999999;background-color:#D6D6D6;";
		var annotations="color:#CDD0D6;background-color:#FBFBFB;";
		var valeurSsColor="color:#990000;background-color:#E6E6E6;";
		var saisieSsColor="color:#000099;background-color:#F5F5F5;";
		var valeurColor="color:#B28D00;background-color:#FFD100;|color:#009241;background-color:#00EA8F;|color:#C54BC8;background-color:#FF80FF;|color:#FFB483;background-color:#E00000;|color:#0089AB;background-color:#00C8EC;|color:#6CDB5B;background-color:#008A00;|color:#7CC2FF;background-color:#006CA4;|color:#D27DA1;background-color:#A30048;|color:#FFD578;background-color:#FF6600;";
		var saisieColor="color:#000000;background-color:#FFD100;|color:#000000;background-color:#00EA8F;|color:#000000;background-color:#FF80FF;|color:#000000;background-color:#E00000;|color:#000000;background-color:#00C8EC;|color:#000000;background-color:#008A00;|color:#000000;background-color:#006CA4;|color:#000000;background-color:#A30048;|color:#000000;background-color:#FF6600;";
		var annotationsCouleur="color:#1A2945;background-color:#FBFBFB;|color:#5A8A2C;background-color:#CCFF99;|color:#313C94;background-color:#9999FF;|color:#333333;background-color:#FFCCCC;|color:#9A9B37;background-color:#FFFF99;|color:#FFD49D;background-color:#CC9966;|color:#CBFF94;background-color:#99CC66;|color:#E8B0FF;background-color:#9966CC;";
		var mesCouleurs=new Couleur(vide,annotations,valeurSsColor,valeurColor,saisieSsColor,saisieColor,annotationsCouleur);
	}
	else
	{
		var tabLarg="33,35,34,35,34,35,34,35,33";
		var tabHaut=tabLarg;
		var tabEcartLarg="3,3,8,3,3,8,3,3";
		var tabEcartHaut=tabEcartLarg;
		var coinSupGaucheX=30;
		var coinSupGaucheY=28;
		var paddingSaisie=3;
		var fonts="font-family:Arial;font-size:15px;font-weight:bold; | font-family:Arial;font-size:15px;font-weight:bold; | font-family:Geneva; font-size:11px; font-weight:bold;";
		var monTheme=new Theme("img/sudoku-grid.gif",tabLarg,tabHaut,tabEcartLarg,tabEcartHaut,coinSupGaucheX,coinSupGaucheY,fonts,paddingSaisie);
	
		var vide="color:#999999;background-color:#F5F5F5;|color:#999999;background-color:#D6D6D6;";
		var annotations="color:#CDD0D6;background-color:#FBFBFB;";
		var valeurSsColor="color:#990000;background-color:#E6E6E6;";
		var saisieSsColor="color:#000099;background-color:#F5F5F5;";
		var valeurColor="color:#B28D00;background-color:#FFD100;|color:#009241;background-color:#00EA8F;|color:#C54BC8;background-color:#FF80FF;|color:#FFB483;background-color:#E00000;|color:#0089AB;background-color:#00C8EC;|color:#6CDB5B;background-color:#008A00;|color:#7CC2FF;background-color:#006CA4;|color:#D27DA1;background-color:#A30048;|color:#FFD578;background-color:#FF6600;";
		var saisieColor="color:#000000;background-color:#FFD100;|color:#000000;background-color:#00EA8F;|color:#000000;background-color:#FF80FF;|color:#000000;background-color:#E00000;|color:#000000;background-color:#00C8EC;|color:#000000;background-color:#008A00;|color:#000000;background-color:#006CA4;|color:#000000;background-color:#A30048;|color:#000000;background-color:#FF6600;";
		var annotationsCouleur="color:#1A2945;background-color:#FBFBFB;|color:#5A8A2C;background-color:#CCFF99;|color:#313C94;background-color:#9999FF;|color:#333333;background-color:#FFCCCC;|color:#9A9B37;background-color:#FFFF99;|color:#FFD49D;background-color:#CC9966;|color:#CBFF94;background-color:#99CC66;|color:#E8B0FF;background-color:#9966CC;";
		var mesCouleurs=new Couleur(vide,annotations,valeurSsColor,valeurColor,saisieSsColor,saisieColor,annotationsCouleur);
	}
	
	nameObjGrille=nameDivGrille+"Name";
	eval(nameObjGrille+"=new Grille(monTheme,mesCouleurs,chaineBase,nameDivGrille,nameObjGrille,'');");
	eval(nameObjGrille+".setSaisie(chaineSaisie);");
	eval(nameObjGrille+".show(0);");
	eval(nameObjGrille+".modeColor=false;");	
	eval(nameObjGrille+".etatFin=true;");	
	eval(nameObjGrille+".play(1);");		
}

function prePrint(mode,infos)
{
	window.open("specprint.php?mode="+mode+"&infos="+infos,"printpage","directories=no,location=no,menubar=yes,resizable=yes,scrollbars=yes,status=no,toolsbar=no,width=800,height=800");
}

function chargeTmps()
{	
	if (MM_findObj("zoneTmps")!=null)
	{
		var xmlhttp = getHTTPObject();
		xmlhttp.open("POST", "loadChronos.php", true);
		var data="nodata=0";
		
		xmlhttp.onreadystatechange = function()
		{ 
			if(xmlhttp.readyState == 4)
			{
				separateur="|||";
				retourAJAX=xmlhttp.responseText;
				tabEltRetour=retourAJAX.split(separateur);
				var mesmoyennes="";
				var lestemps="";
				if (retourAJAX!=separateur) mesmoyennes=tabEltRetour[0];
				if (retourAJAX!=separateur) lestemps=tabEltRetour[1];
				MM_findObj("zoneMoy").innerHTML=mesmoyennes;
				MM_findObj("zoneTmps").innerHTML=lestemps;
			}
		}
		
		xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		xmlhttp.send(data);
	}
}

function chargeMsgs()
{	
	if (MM_findObj("zoneMsg")!=null)
	{
		dateLocal=new Date();
		decalageHoraireMinute=dateLocal.getTimezoneOffset();
		param="decalageMinute="+decalageHoraireMinute;
		
		var xmlhttp = getHTTPObject();
		xmlhttp.open("POST", "loadMessages.php", true);
		
		xmlhttp.onreadystatechange = function()
		{ 
			if(xmlhttp.readyState == 4)
			{
				retourAJAX=xmlhttp.responseText;
				var tabRetour=retourAJAX.split("|||");
				if (tabRetour.length>0) MM_findObj("zoneMsg").innerHTML=tabRetour[0];
				
				if (tabRetour.length>1)
				{
					var complJavascript=tabRetour[1].split("/");
					for (uneSeriPar in complJavascript)
					{
						var malisteparam=complJavascript[uneSeriPar].split(",");
						chargeGrillePres(malisteparam[0],malisteparam[1],malisteparam[2]);
					}
				}
			}
		}
		
		xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		xmlhttp.send(param);
	}
}

function chargeCalend(decalMois,niveau)
{
	dateLocal=new Date();
	decalageHoraireMinute=dateLocal.getTimezoneOffset();
	param="decalageMinute="+decalageHoraireMinute+"&decalageMois="+decalMois+"&niveau="+niveau;
	
	var xmlhttp = getHTTPObject();
	xmlhttp.open("POST", "loadCalend.php", true);
	
	xmlhttp.onreadystatechange = function()
	{ 
		if(xmlhttp.readyState == 4)
		{
			retourAJAX=xmlhttp.responseText;
			if (retourAJAX > "") MM_findObj("zoneCalend").innerHTML=retourAJAX;
		}
	}
	
	xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xmlhttp.send(param);	
}

function getPrincipalGrille()
{
	monObj=eval(eltContext.tabGrilles[0]["grille"]);
	return monObj;
}

function affChronos()
{
	var monObj=MM_findObj("zoneChrono");
	if (monObj.style.display=='none') monObj.style.display='';
	else monObj.style.display='none';
}

function chargeLstMsg()
{
	var xmlhttp = getHTTPObject();
	xmlhttp.open("POST", "loadLstMsg.php", true);
	
	decalageHoraireMinute=dateLocal.getTimezoneOffset();
	param="decalageMinute="+decalageHoraireMinute;
	
	xmlhttp.onreadystatechange = function()
	{ 
		if(xmlhttp.readyState == 4)
		{
			retourAJAX=xmlhttp.responseText;
			MM_findObj("zonLstMsg").innerHTML=retourAJAX;
		}
	}
	
	xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xmlhttp.send(param);
	
	setTimeout("chargeLstMsg()",7000);
}

function nothing() {}

function popon(id)
{
	var recepteur=MM_findObj("boxpopon");
	if (idpopon!=id)
	{
		idpopon=id;
		var emetteur=MM_findObj(id);
		recepteur.innerHTML=emetteur.innerHTML;
		showDiv("boxpopon");
		recepteur.style.top=(mouseY+15)+"px";
		recepteur.style.left=(mouseX+15)+"px";
		setTimeout("ajusteDivContext()",10);
	}
}

function ajusteDivContext()
{
	var recepteur=MM_findObj("boxpopon");
	recepteur.style.top=(mouseY-14-recepteur.offsetHeight)+"px";
	recepteur.style.left=(mouseX-25)+"px";	
}

function popout(id)
{
	var recepteur=MM_findObj("boxpopon");
	recepteur.innerHTML="";
	hideDiv("boxpopon");
	idpopon="";
}

function reconnect()
{
	var xmlhttp = getHTTPObject();
	xmlhttp.open("POST", "reconnect.php", true);

	param="lang="+lang+"&idGrille="+idGrille+"&grillep="+grillep;
	
	xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xmlhttp.send(param);
}

function nextgrid(sens,typepage,reference)
{
	var xmlhttp = getHTTPObject();
	xmlhttp.open("POST", "navgrille.php", true);

	decalageHoraireMinute=dateLocal.getTimezoneOffset();

	param="sens="+sens+"&typepage="+typepage+"&reference="+reference+"&decalageMinute="+decalageHoraireMinute;
	
	xmlhttp.onreadystatechange = function()
	{ 
		if(xmlhttp.readyState == 4)
		{
			retourAJAX=xmlhttp.responseText;
			if (retourAJAX!="none") document.location=retourAJAX;
		}
	}
	
	xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xmlhttp.send(param);
}

function opclse(namesct,nameimg)
{
	var sect=MM_findObj(namesct);
	if (sect.style.display=="none")
	{
		MM_findObj(nameimg).src="img/open-sect.gif";
		sect.style.display="";
	}
	else
	{
		MM_findObj(nameimg).src="img/close-sect.gif";
		sect.style.display="none";
	}
}

function solver(nameForm,cmtErr)
{
	if (!eltContext.modePause)
	{
		var xmlhttp = getHTTPObject();
		xmlhttp.open("POST", "solver.php", true);
	
		var objForm=MM_findObj(nameForm);
		var objGrille=getPrincipalGrille();
		var machaine=objGrille.getChaine();
		
		var modeRadio=objForm.elements["mode"];
		var mode=2;
		
		for (var i=0; i<modeRadio.length;i++) if (modeRadio[i].checked) mode=modeRadio[i].value;
	
		param="chaine="+machaine+"&mode="+mode;
		
		xmlhttp.onreadystatechange = function()
		{ 
			if(xmlhttp.readyState == 4)
			{
				retourAJAX=xmlhttp.responseText;
				var tabEltRetour=retourAJAX.split("|||");
			
				if (tabEltRetour[0]!="erreur")
				{				
					eltContext.noChrono();
					var objGrille=getPrincipalGrille();
					objGrille.setChaine(tabEltRetour[0]);
				}
				else afficheMsgErr(cmtErr);
			}
		}
		
		xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		xmlhttp.send(param);
	}
}


nbCapture=0;
lstCaptures=new Array();

function capturer()
{
	if (!eltContext.modePause)
	{
		var obj=MM_findObj("zonCapt");
		var maGrille=getPrincipalGrille();
		var ligne=maGrille.getChaine();
		lstCaptures[nbCapture++]=ligne;
		obj.innerHTML='<div class="posCapture"><a href="javascript:replacer('+(nbCapture-1)+');"><div class="uneCapture">'+(nbCapture)+'</div></a></div>'+obj.innerHTML;
	
		if (MM_findObj("zonInsrtCapt")!=null)
		{
			var objCapt=MM_findObj("zonInsrtCapt");
			var eltsCapt=objCapt.innerHTML;
			eltsCapt+='<div class="posCubCapture"><div class="cubCaptureInsrt"><a href="javascript:integrTxt('+(nbCapture-1)+');" class="lnkInrtCptur">'+nbCapture+'</a></div></div>';
			objCapt.innerHTML=eltsCapt;
		}
	}
}

function replacer(numero)
{
	if (!eltContext.modePause)
	{
		var maGrille=getPrincipalGrille();
		maGrille.setChaine(lstCaptures[numero]);
	}
}

function integrTxt(numero)
{
	var monform=MM_findObj("cmmnt");
	var montext=" [g] "+lstCaptures[numero]+" [/g] ";

	with(document.cmmnt)
	{
		if (monmsg.createTextRange) 
		{
			var text;
			monmsg.focus(monmsg.caretPos);
			if (document.selection!=undefined) monmsg.caretPos = document.selection.createRange().duplicate();

			if(monmsg.caretPos.text.length>0)
			{
				var sel = monmsg.caretPos.text;
				var fin = '';
				while(sel.substring(sel.length-1, sel.length)==' ')
				{
					sel = sel.substring(0, sel.length-1)
					fin += ' ';
				}
				monmsg.caretPos.text = montext + fin;
			}
			else monmsg.caretPos.text = montext;
		}
		else monmsg.value += montext;
	}
}

function popperso()
{
	decalageHoraireMinute=dateLocal.getTimezoneOffset();
	window.open("soumPerso.php?decalageMinute="+decalageHoraireMinute,"perso","directories=no,location=no,menubar=no,resizable=no,scrollbars=yes,status=no,toolbar=no,width=500,height=600");
}

function extractETsoum(monform)
{
	var magrille=getPrincipalGrille();
	var masaisie=magrille.getSaisie();
	monform.elements["chaine"].value=masaisie;
	monform.submit();
}

function chmntOptClic3(etat)
{
	eltContext.changeClic3();
}

function chmntColor(id)
{
	for (i=0;i<8;i++)
	{
		objColorAnnot=MM_findObj("contourCouleurAnnot"+i);
		if (i==id) objColorAnnot.style.border="2px solid #333";
		else objColorAnnot.style.border="2px solid #EEE";
	}
	eltContext.changeCodeCouleurAnnot(id);
}
