function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}



function fk(p,j,i) {
var rfk=ka[p][j][i];
ifk=rfk.lastIndexOf("[");
if (ifk>0) 
rfk= rfk.substring(0,ifk);
return rfk;
} 

function finitjeu(p,j){
ascore=(ka[p][j].length-3)/2;
for (i=3;i<ka[p][j].length; i=i+2)
document.images[FormatStr(ka[p][j][0]+fk(p,j,i))].src="images/off.gif";
eval('document.'+ka[p][j][0]+'.vscore.value='+0);
eval('document.'+ka[p][j][0]+'.mscore.value='+ascore);
}
function filtremulti(srcod){
lg=srcod.length;
im=srcod.lastIndexOf("-i");
if (im<0) return srcod;
var srcres=srcod.substring(0,im-1);
idx=srcod.substring(im-1,im);
if ((idx<"0") || (idx>"9")) srcres=srcres+idx;
srcres=srcres+srcod.substring(im,lg);
return srcres;
}
function fscore(p,j){
var tot=0;
var nima="";
var srco="";
var srcobis="";
var srcd="";
for (i=3;i<ka[p][j].length; i=i+2){
srco=filtremulti(document.images[FormatStr(ka[p][j][0]+fk(p,j,i)+'-a')].src);
srcobis=srco;
srcobis1=srco;
srcobis2=srco;
srcobis3=srco;
ialt=ka[p][j][i].lastIndexOf("[");
if (ialt >0) {
ialtf=ka[p][j][i].lastIndexOf("]");
if (ialtf < 0) ialtf=ka[p][j][i].length;
var tdep=ka[p][j][i].substring(ialt+1,ialtf);
var dep=tdep.split(",");
ia=i+2*parseInt(dep[0]);
srcobis=document.images[FormatStr(ka[p][j][0]+fk(p,j,ia)+'-a')].src;
if (dep.length >1) {
ia=i+2*parseInt(dep[1]);
srcobis1=document.images[FormatStr(ka[p][j][0]+fk(p,j,ia)+'-a')].src;
}
if (dep.length >2) {

ia=i+2*parseInt(dep[2]);
srcobis2=document.images[FormatStr(ka[p][j][0]+fk(p,j,ia)+'-a')].src;
}
}
srcd=filtremulti(document.images[FormatStr(ka[p][j][0]+fk(p,j,i))].src);
srcdbis=document.images[FormatStr(ka[p][j][0]+fk(p,j,i))].src;
if((srco==srcd)||(srcobis==srcdbis)||(srcobis1==srcdbis)||(srcobis2==srcdbis)) tot++;
}
ascore=(ka[p][j].length-3)/2;

eval('document.'+ka[p][j][0]+'.vscore.value='+tot);
eval('document.'+ka[p][j][0]+'.mscore.value='+ascore);
}
function fsolution(p,j){
for (i=3;i<ka[p][j].length; i=i+2)
document.images[FormatStr(ka[p][j][0]+fk(p,j,i))].src=FormatStr('images/'+(ka[p][j][0]+'-'+fk(p,j,i))+'-i.jpg');
}
function FormatStr(Str){
    StrNewStr="";
    for(ix=0;ix<=Str.length;ix++){
      StrChar=Str.substring(ix,ix+1);
	  if((StrChar=="é")||(StrChar=="è")||(StrChar=="ê")) StrChar="e";
	  if((StrChar=="à")||(StrChar=="â")) StrChar="a";
	  if((StrChar=="î")||(StrChar=="ï")) StrChar="i";
	  if((StrChar=="û")||(StrChar=="ü")) StrChar="u";
	  
	  if((StrChar!=" ")&&(StrChar!="_")&&(StrChar!="'")) StrNewStr=StrNewStr+StrChar;}
return StrNewStr.toLowerCase();
}

function fref(p,j){
if (window.fenref) fenref.close();
var nomfen=FormatStr(ka[p][j][0]+ka[p][j][1]);
fenref=open('reference.htm',nomfen,'width=500,height=300,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no');
}
function mempage(pp){
parent.frames[2].document.param.nopage.value=pp;
}

function pagesuivante(pp){
parent.frames[2].document.param.nopage.value=pp+1;
location.href="kanji-jeu-p0.html";
}
function pageprecedente(pp){
parent.frames[2].document.param.nopage.value=pp-1;
location.href="kanji-jeu-p0.html";
}
function appelpage(pp,jj) {
var nompage= 'kanji-jeu-p0.html';
if(jj) nompage=nompage+'#'+ ka[pp][jj][0];
//parent.frames[2].document.param.nopage.value=pp;
return nompage;
}
function loto(Nb){
atirer="";
for (i=0;i<Nb;i++) atirer=atirer+i;
if(Nb>10) return atirer;
tirage=""
while (atirer.length>1) {
k=Math.floor(Math.random()*Nb);
tirage=tirage+atirer.substring(k,k+1);
m=atirer.length;
atirer=atirer.substring(0,k)+atirer.substring(k+1,m);
Nb=Nb-1;
}
tirage=tirage+atirer;
return tirage;
}



var srcimagechoisie="";
var pagechoisie="";
var kanjichoisi="";
function selectimage(pp,jj,ii){ 
 srcimagechoisie= FormatStr(ka[pp][jj][0]+fk(pp,jj,ii)+'-a');
 pagechoisie=pp;
 kanjichoisi=jj;
 for (ii=3;ii<ka[pp][jj].length;ii=ii+2){
 var na=FormatStr(ka[pp][jj][0]+fk(pp,jj,ii)+'-a');
 document.images[na].border=0;}
 document.images[srcimagechoisie].border=1;
   }
  
  function overimage(pp,jj,ii){ 
 var im= FormatStr(ka[pp][jj][0]+fk(pp,jj,ii)+'-a'); 
document.images[im].height=50;
document.images[im].vspace=0;
document.images[im].width=40;
document.images[im].hspace=0;

  }
  
    function outimage(pp,jj,ii){ 
 var ima= FormatStr(ka[pp][jj][0]+fk(pp,jj,ii)+'-a'); 
document.images[ima].height=40;
document.images[ima].vspace=5;
document.images[ima].width=30;
document.images[ima].hspace=5;
  }	
	
function affectimage(pp,jj,ii){
Ma=FormatStr(ka[pp][jj][0]+fk(pp,jj,ii));
 if (srcimagechoisie =="")
document.images[Ma].src="images/off.gif"
else
{document.images[Ma].src=document.images[srcimagechoisie].src;
document.images[srcimagechoisie].border=0;}
srcimagechoisie="";
pagechoisie="";
kanjichoisi="";

}

