	
function Imprime() {
  if (navigator.appVersion.indexOf("Mac",0)>0) {
     alert("Sur Macintosh.Utilisez la combinaison de touches \"Pomme-P\"\npour imprimer cette page");
        }
else {
    window.print();
  }
}


function precede()
{
if(precedent!=0) {var temp=num_grille-1; document.getElementById('avant').href='pyramide'+temp+'.htm'; document.getElementById('avant').innerHTML='&lt;&nbsp;Pr&eacute;c&eacute;dent';}	
}

function suit()
{
if(suivant!=0) {var temp=num_grille+1; document.getElementById('apres').href='pyramide'+temp+'.htm'; document.getElementById('apres').innerHTML='Suivant&nbsp;&gt;';}	
}

function valide()
{
for(i=0;i<n*(n+1)/2; i++) {var temp=new String(); temp+='a'+i; 
			if(document.getElementById(temp).value!='' && texte.charAt(i)!=document.getElementById(temp).value) {document.getElementById(temp).value=''; }
		   }
}


function controle()
{
var compte=0;
for(i=0;i<n*(n+1)/2; i++) {	var temp=new String(); temp+='a'+i; 
			if(document.getElementById(temp).value!='' && texte.charAt(i)==document.getElementById(temp).value) {compte+=1; }
		    }
if (compte==n*(n+1)/2) {document.getElementById('felicite').style.visibility='visible';}
}

function montre(a)
{
document.getElementById(a).style.visibility='visible';
}

function cache(a)
{
document.getElementById(a).style.visibility='hidden';
}



function donne_mot()
{
if (position==-1){return;}
var t=position*(position+1)/2;
for (i=t; i<t+position+1; i++) {var temp=new String(); temp+='a'+i; document.getElementById(temp).value=texte.charAt(i);}
}

function efface_mot()
{
if (position==-1){return;}
var t=position*(position+1)/2;
for (i=t; i<t+position+1; i++) {var temp=new String(); temp+='a'+i; document.getElementById(temp).value='';}
}


function sol()
{
for (i=0;i<n*(n+1)/2;i++) {var temp=new String(); temp+='a'+i; document.getElementById(temp).value=texte.charAt(i);}
}

function efface()
{
for (i=0;i<n*(n+1)/2;i++) {var temp=new String(); temp+='a'+i; document.getElementById(temp).value=''; document.getElementById('indice').innerHTML='Cliquez sur une des lettres pour avoir la d&eacute;finition correspondante'; position=-1; cache('felicite');}
}

function suivant(a)
{
document.getElementById('a2').value='1';
}

function donne_def()
{
document.getElementById('indice').innerHTML=definitions[position];
}

function ouvre()
{
for (i=0; i<n; i++){	
			window.document.write("<table border=\"0\" height=\"25px\" width=\"");
			window.document.write(25*(i+3));
			window.document.write("px\" cellspacing=\"0\" cellpadding=\"0\"><tr><td width=\"25\" bordercolor=\"#FFFFFF\" style=\"border-top: 0px solid #FFFFFF; border-bottom: 0px solid #FFFFFF; border-left: 0px solid #FFFFFF; border-right: 0px solid #FFFFFF;padding-left: 0px; padding-right: 0px; padding-top: 0px; padding-bottom: 0px\">&nbsp;</td>");
			for (j=0; j<i+1; j++) {
						window.document.write("<td align=\"center\" width=\"25\" bordercolor=\"#FFFFFF\" style=\"border-top: 1px solid #FFFFFF; border-left: 1px solid #FFFFFF; border-right: 0px solid #FFFFFF;padding-left: 0px; padding-right: 0px; padding-top: 0px; padding-bottom: 0px\">");
						window.document.write("<input type=\"text\" maxlength='1' id=\"a");
						window.document.write(i*(i+1)/2+j);
						window.document.write("\" size=\"1\" style=\"height:24px; width:24px; text-align:center;color: #FFFFFF; border-style: solid; border-width: 0;  padding-top: 3px; padding-bottom:3px; background-color: #404550\"  onFocus=\"javascript: position=");
						window.document.write(i);
						window.document.write("; donne_def();\" onKeyup=\"javascript:this.value=this.value.toUpperCase();");
						if (i*(i+1)/2+j!=n*(n+1)/2-1){window.document.write("document.getElementById('a");
									      window.document.write((i*(i+1)/2+j+1)%(n*(n+1)/2));
									      window.document.write("').focus();"); }
						window.document.write(" controle();\"></td>");
						}
			window.document.write("<td width=\"25\" bordercolor=\"#FFFFFF\" style=\"border-top: 0px solid #FFFFFF; border-bottom: 0px solid #FFFFFF; border-left: 1px solid #FFFFFF; border-right: 0px solid #FFFFFF;padding-left: 0px; padding-right: 0px; padding-top: 0px; padding-bottom: 0px\">&nbsp;</td></tr></table>");
		}
window.document.write("<table border=\"0\" height=\"25px\" width=\"");
window.document.write(25*(n)+ajustement);
window.document.write("\" cellspacing=\"0\" cellpadding=\"0\"><tr><td width=\"100%\" bordercolor=\"#FFFFFF\" style=\"border-top: 1px solid #FFFFFF; border-bottom: 0px solid #FFFFFF; border-left: 0px solid #FFFFFF; border-right: 0px solid #FFFFFF;padding-left: 0px; padding-right: 0px; padding-top: 0px; padding-bottom: 0px\">&nbsp;</td></tr></table>");
	
	
}


function impr_pyramide()
{
var romain=new Array('I','II','III','IV','V','VI','VII','VIII','IX','X','XI','XII','XIII','IVX','XV','XVI','XVII','XVIII','IXX','XX');
aju=ajustement;
ajustement=0;
impr=open("","imprimer","scrollbars=yes,toolbar=yes,menubar=yes,status=yes,resizable=yes,top=50,left=50,width=800,height=450");
impr.document.writeln("<html><head><script language=\"javascript\" src=\"pyramide.js\"></script><title>Pyramide</title></head>");
impr.document.writeln("<body onload=\"javascript:Imprime();\">");
impr.document.writeln("<font face=\"Arial\"><h3>Pyramide N&deg;"+num_grille+"</h3>");
impr.document.writeln("<p>&nbsp;</p>");
impr.document.writeln("<p>&nbsp;</p></font>");
impr.document.writeln("<table border=\"0\"><tr><td valign=\"top\" align=\"center\">");	
for (i=0; i<n; i++){	
			impr.document.write("<table border=\"0\" height=\"27px\" width=\"");
			impr.document.write(27*(i+3));
			impr.document.writeln("px\" cellspacing=\"0\" cellpadding=\"0\"><tr><td width=\"25\" bordercolor=\"#ffffff\" style=\"border: 1px solid #ffffff;\">&nbsp;</td>");
			for (j=0; j<i+1; j++) {
						impr.document.writeln("<td align=\"center\" width=\"25\" bordercolor=\"#FFFFFF\" style=\"border-left: 1px solid #000000;border-top: 1px solid #000000;\">&nbsp;</td>");
						}
			impr.document.writeln("<td width=\"27\" bordercolor=\"#FFFFFF\" style=\"border-top: 0px solid #FFFFFF; border-bottom: 0px solid #FFFFFF; border-left: 1px solid #000000; border-right: 0px solid #FFFFFF;padding-left: 0px; padding-right: 0px; padding-top: 0px; padding-bottom: 0px\">&nbsp;</td></tr></table>");
		}
impr.document.write("<table border=\"0\" height=\"27px\" width=\"");
impr.document.write(27*(n)+ajustement);
impr.document.writeln("\" cellspacing=\"0\" cellpadding=\"0\"><tr><td width=\"100%\" bordercolor=\"#FFFFFF\" style=\"border-top: 1px solid #000000; border-bottom: 0px solid #FFFFFF; border-left: 0px solid #FFFFFF; border-right: 0px solid #FFFFFF;padding-left: 0px; padding-right: 0px; padding-top: 0px; padding-bottom: 0px\">&nbsp;</td></tr></table>");
impr.document.writeln("</td><td valign=\"top\">");
for (i=0; i<n; i++){	
			impr.document.writeln("<table border=\"0\" height=\"27px\" cellspacing=\"0\" cellpadding=\"0\"><tr><td valign=\"middle\" bordercolor=\"#ffffff\" style=\"border: 1px solid #ffffff;\"><p style=\"font-size:13px; margin-left:40; font-style: normal; font-family:Arial, Tahoma, Geneva;\"><b>"+romain[i]+".</b>&nbsp;&nbsp;"+definitions[i]+"</p></td>");
		}
impr.document.writeln("</body></html>");
impr.document.close(); 
ajustement=aju;
}		
		
