nbCasesCochees=0;nbCases=50;nbIndice=0;nbCasesCochees_etoile=0;nbCases_etoile=9;nbIndice_etoile=0;function makeArray(a){this.length=a;return this}var griTab=new makeArray(nbCases);var griTab_etoile=new makeArray(nbCases_etoile);function Case(a){this.etat=a}function changerCase(b,a){if(griTab[a].etat==0){nbIndice++;grilleOn(b,a);nbCasesCochees++}else{grilleOff(b,a);nbIndice--;nbCasesCochees--}}function changerCase_Etoile(b,a){if(griTab_etoile[a].etat==0){nbIndice_etoile++;grilleOn_Etoile(b,a);nbCasesCochees_etoile++}else{grilleOff_Etoile(b,a);nbIndice_etoile--;nbCasesCochees_etoile--}}function grilleOn(a,b){x_pos=(b-1)*22;a.style.backgroundPosition="-"+x_pos+"px -27px";griTab[b].etat=nbIndice}function grilleOn_Etoile(a,b){x_pos=(b-1)*45;a.style.backgroundPosition="-"+x_pos+"px -42px";griTab_etoile[b].etat=nbIndice_etoile}function grilleOff(a,c){var b;x_pos=(c-1)*22;a.style.backgroundPosition="-"+x_pos+"px 0px";b=griTab[c].etat;griTab[c].etat=0;for(i=1;i<=nbCases;i++){if(griTab[i].etat>=b){griTab[i].etat--}}}function grilleOff_Etoile(a,c){var b;x_pos=(c-1)*45;a.style.backgroundPosition="-"+x_pos+"px 0px";b=griTab_etoile[c].etat;griTab_etoile[c].etat=0;for(i=1;i<=nbCases_etoile;i++){if(griTab_etoile[i].etat>=b){griTab_etoile[i].etat--}}}function recupererNumCochees(){liste="";selection=new makeArray(nbCases);for(i=1;i<=nbCases;i++){selection[i]=0}for(i=1;i<=nbCases;i++){if(griTab[i].etat!=0){selection[griTab[i].etat]=i}}for(i=1;i<=nbCases;i++){if(selection[i]!=0){liste+=selection[i]+","}}return liste}function recupererNumCochees_Etoile(){liste_etoile="";selection_etoile=new makeArray(nbCases_etoile);for(i=1;i<=nbCases_etoile;i++){selection_etoile[i]=0}for(i=1;i<=nbCases_etoile;i++){if(griTab_etoile[i].etat!=0){selection_etoile[griTab_etoile[i].etat]=i}}for(i=1;i<=nbCases_etoile;i++){if(selection_etoile[i]!=0){liste_etoile+=selection_etoile[i]+","}}return liste_etoile}function effacer(){nbCasesCochees=0;nbCasesCochees_etoile=0}function initGrille(){for(i=1;i<=nbCases;i++){griTab[i]=new Case(0)}}function initGrille_Etoile(){for(i=1;i<=nbCases_etoile;i++){griTab_etoile[i]=new Case(0)}}function afficheGrille(){document.write('<table border="0" cellspacing="1">');for(i=0;i<9;i++){document.write("<tr>");for(j=0;j<6;j++){numero=(((i*6)+j)+1);if(numero>nbCases){break}x_pos=(numero-1)*22;document.write('<td valign="middle" align="center" width="22" height="27">');document.write('<a title="'+numero+'" href="#" onClick="changerCase(this, '+numero+'); return false;" class="NumeroGrille" style="background-position:-'+x_pos+'px 0px;"></a>');document.write("</td>")}document.write("</tr>")}document.write("</table>")}function afficheGrille_Etoile(){document.write('<table border="0" cellspacing="1">');for(i=0;i<3;i++){document.write("<tr>");for(j=0;j<3;j++){numero=(((i*3)+j)+1);x_pos=(numero-1)*45;document.write('<td valign="middle" align="center" width="45" height="42">');document.write('<a title="'+numero+'" href="#" onClick="changerCase_Etoile(this, '+numero+'); return false;" class="EtoileGrille" style="background-position:-'+x_pos+'px 0px;"></a>');document.write("</td>")}document.write("</tr>")}document.write("</table>")};