// Tous les javascripts droits d'auteurs 2003 Serge Lamarche à sergewebservice@yahoo.ca
// All javascripts copyrights 2003 Serge Lamarche at sergewebservice@yahoo.ca
// a5

var textfr1 = new Array(); var textfr2 = new Array(); 
var texten1 = new Array(); var texten2 = new Array(); 

textfr1=["SVP, il faut entrer des nombres\n plus grands que quatre\n mais pas trop grands !\n\n ","Profondeur maximum de 35 carreaux \n et surface max de 175 sur Opera."];
textfr2=["Jeu de type labyrinthe généré par javascript"];
textfr2.push("Appuyer ici pour le départ!","Réinitialiser.","Pointage: ","Explications du jeu: ","En cliquant sur un carreau vous en faites monter (ou redescendre) deux qui s'avoisinent. A cause de connections défectueuses, les carreaux qui lèvent (ou descendent) en appuyant, répondent selon une motif aléatoire. Notez que ce motif reste inchangé même après une réinitialisation. Vous devez recharger la page et regénérer le labyrinthe pour changer le motif.","Les souris ne sautent pas les carreaux élevés et ne vont pas en diagonale. (Elles sont aussi plus lentes dans les coins et les endroits étroits.) Vous pouvez ainsi la (ou les) diriger vers la cage pour un ramassage sécuritaire. Les souris sont précieuses et doivent rester vivantes pour tests et résultats futurs. Elles ne sont pas méchantes mais mieux vaut éviter cette maladie.","Vous avez environ une demi-heure. Plus bas votre pointage, meilleur vous êtes.","Commentaires? Ecrire à sergewebservice@yahoo.ca","Commentaires?","feedback.html?labyrinthe-ec","Organigramme","organigramme.html") 

texten1=["Please, enter numbers\n greater than four\n but not too big !\n","Maximum depth 35 tiles \n and max surface 175 on Opera."];
texten2=["Labyrinth-type game generated by javascript"];
texten2.push("Click here to start !","Reinitialize.","Score: ","Game explanations: ","When clicking on a tile you make two neighbouring go up (or down). Because of defective connections, the tiles who lift (or descend) while clicking, respond according to a random pattern. Note that this pattern remain unchanged even after a reinitialization. You must reload the page and regenerate the labyrinth to change the pattern.","The mice do not jump over lifted tiles and do not go in diagonal. (They are also slower in corners and tight places.) You can, like this, direct it (or them) to the cage for a safe recuperation. The mice are precious and must stay alive for further tests and results. They are not mean but better avoid this disease.","You have about half an hour. Small scores are better.","Comments? Write to sergewebservice@yahoo.ca","Comments?","feedback.html?labyrinth-ec","Site Map","organigramme.html") 


function labyrinthe2(langue) {  //a3;
if (langue=="en") {inserer=texten1}; if (langue=="fr") {inserer=textfr1};
nx =document.forms["jeu"].elements["x"].value;
ny =document.forms["jeu"].elements["y"].value;
if((isNaN(nx+ny)==isNaN("hgtrkt"))||(nx<5)||(ny<5)||(200<nx*ny)) {
alert(inserer[0]) ;return;};
if ((-1 != navigator.userAgent.search(/Opera/))&&((ny>35)||(175<nx*ny))) {
alert(inserer[1]);return;};
if (document.createTextNode) { table2(ny,nx,langue); } else return; }

function dir1() { return((2*Math.round(Math.random()))-1) } ;

function chgimGecko(e) { if (!e) e = window.event; 
if (e.srcElement) { chgimg(e.srcElement.coorda); chgimg(e.srcElement.coordb); }
else if (this.coorda) { chgimg(this.coorda); chgimg(this.coordb); } 
else if (e.target) { chgimg(e.target.coorda); chgimg(e.target.coordb); } compte(); }
function casseGecko(e) { if (!e) e = window.event; 
if (e.srcElement) casse(e.srcElement.id); 
else if (this.id) casse(this.id); 
else if (e.target) casse(e.target.id); compte(); }
function sourisGecko(e) { souris(ny,nx); }
function reinitGecko(e) { reinit(ny,nx); }

function table2(nbligne,nbcol,language) { 
if (language=="en") {inserer=texten2}; if (language=="fr") {inserer=textfr2};
var labo=document.getElementById("lab2"); 

var titre = document.createElement("h1");  titre.setAttribute("class","jeu"); 
var texte = document.createTextNode(inserer[0]); 
titre.appendChild(texte); labo.appendChild(titre); 

var paragraphe = document.createElement("p"); paragraphe.setAttribute("class","jeu"); 
var lien = document.createElement("a"); //-----
texte = document.createTextNode(inserer[1]); 
//======paragraphe.appendChild(texte); 
lien.appendChild(texte); //-----
texte = "javascript:sourisGecko()"; lien.setAttribute("href",texte); //----
lien.setAttribute("class","jeu"); paragraphe.appendChild(lien); //----
//=========paragraphe.addEventListener("click",sourisGecko,true); 
labo.appendChild(paragraphe); 

paragraphe = document.createElement("p");  paragraphe.setAttribute("class","jeu"); 
lien = document.createElement("a"); //-----
texte = document.createTextNode(inserer[2]); 
//======paragraphe.appendChild(texte); 
lien.appendChild(texte); //-----
texte = "javascript:reinitGecko()"; lien.setAttribute("href",texte); //----
lien.setAttribute("class","jeu"); paragraphe.appendChild(lien); //----
//=========paragraphe.addEventListener("click",sourisGecko,true); 
labo.appendChild(paragraphe); 

paragraphe = document.createElement("p");  paragraphe.setAttribute("class","jeu"); 
var formulaire = document.createElement("form"); 
formulaire.setAttribute("method","post"); formulaire.setAttribute("id","result"); 
formulaire.setAttribute("action",""); texte = document.createTextNode(inserer[3]); 
var entree = document.createElement("input"); entree.setAttribute("id","score"); entree.setAttribute("type","text"); 
entree.setAttribute("size","4"); entree.style.padding="0px 10px"; entree.setAttribute("value","0"); 
formulaire.appendChild(texte); formulaire.appendChild(entree); paragraphe.appendChild(formulaire); 
labo.appendChild(paragraphe); 


var plancher = document.createElement("table");
var tplancher = document.createElement("tbody");
for(ligne=1;ligne<=nbligne;ligne++) {
ligneplancher=document.createElement("tr"); ligneplancher.setAttribute("align","center");
for(col=1;col<=nbcol;col++) {
carreau=document.createElement("td");
lecarreau=document.createElement("img"); lecarreau.id="a"+col+"b"+ligne ; 

diry1=diry2=ligne ; dirx1=dirx2=col ;
if (dir1()<0) { diry1+= ((ligne==1) ? 1 : ((ligne==nbligne) ? -1 : dir1())) } 
else { dirx1+= ((col==1) ? 1 : ((col==nbcol) ? -1 : dir1())) } ;
if (dir1()<0) { diry2+= ((ligne==1) ? 1 : ((ligne==nbligne) ? -1 : dir1())) } 
else { dirx2+= ((col==1) ? 1 : ((col==nbcol) ? -1 : dir1())) } ;
if ((dirx1==dirx2)&&(diry1==diry2)) { diry2=ligne ; dirx2=col ; } ;


lecarreau.coorda='a'+dirx1+'b'+diry1 ; lecarreau.coordb='a'+dirx2+'b'+diry2 ; 
lecarreau.setAttribute("width","25px"); lecarreau.setAttribute("height","25px"); 
lecarreau.src="images-jeu/jeu.gif" ; 
if (lecarreau.addEventListener) { lecarreau.addEventListener("mousedown",chgimGecko,true); lecarreau.addEventListener("dblclick",casseGecko,true); }
else if (lecarreau.attachEvent) { lecarreau.attachEvent("onmousedown",chgimGecko); 
lecarreau.attachEvent("ondblclick",casseGecko); }
carreau.appendChild(lecarreau);
ligneplancher.appendChild(carreau);
 }
tplancher.appendChild(ligneplancher);
 }
plancher.appendChild(tplancher); plancher.style.background="lightblue"; 
plancher.setAttribute("align","center"); plancher.setAttribute("cellspacing","2");
plancher.setAttribute("border","0"); plancher.setAttribute("cellpadding","0");
labo.style.visibility="visible"; labo.appendChild(plancher); document.forms["jeu"].style.visibility="hidden";

paragraphe = document.createElement("p"); var sauteli = document.createElement("br"); 
texte = document.createTextNode(inserer[4]);  paragraphe.setAttribute("class","jeu"); 
paragraphe.appendChild(texte); paragraphe.appendChild(sauteli); labo.appendChild(paragraphe); 

paragraphe = document.createElement("p");  paragraphe.setAttribute("class","jeu"); 
texte = document.createTextNode(inserer[5]); 
paragraphe.appendChild(texte); labo.appendChild(paragraphe); 

paragraphe = document.createElement("p");  paragraphe.setAttribute("class","jeu"); 
texte = document.createTextNode(inserer[6]); 
paragraphe.appendChild(texte); 
texte = document.createTextNode(inserer[7]); 
paragraphe.appendChild(sauteli); paragraphe.appendChild(texte); 
labo.appendChild(paragraphe); 

paragraphe = document.createElement("p");   paragraphe.setAttribute("class","jeu"); 
texte = document.createTextNode(inserer[8]); 
paragraphe.appendChild(texte); labo.appendChild(paragraphe); 
var regle = document.createElement("hr"); regle.style.margin="30px 25%"; 
document.getElementsByTagName("body").item(0).style.background="#e6e6fa"; 
regle.setAttribute("width","50%"); labo.appendChild(regle); 
for (var i=0; i<labo.childNodes.length; i++) labo.childNodes.item(i).style.fontFamily="comic sans ms, arial, helvetica"; titre.style.marginLeft="5%"; 
var noeud = document.getElementById("infobas").cloneNode(true); labo.appendChild(noeud); 
paragraphe = document.createElement("p");  paragraphe.setAttribute("class","evalpage"); 
texte = document.createTextNode(inserer[9]); 
lien = document.createElement("a"); lien.setAttribute("href",inserer[10]); 
lien.setAttribute("id","rating"); lien.appendChild(texte); 
paragraphe.appendChild(lien); labo.appendChild(paragraphe); 
paragraphe = document.createElement("p");  paragraphe.setAttribute("class","evalpage"); 
texte = document.createTextNode(inserer[11]); 
lien = document.createElement("a"); lien.setAttribute("href",inserer[12]); 
lien.setAttribute("id","rating"); lien.appendChild(texte); 
paragraphe.appendChild(lien); labo.appendChild(paragraphe); 
}

