var n=8; //nombre d'exercices dans ce niveau
var PTNA=0 ;
var PTNCA=0 ;
var TNCA=0 ;
var minimum=6;//minimum d'exo requis pour evaluation
var started=false;
var log=" ";
var ref="tracker2a";
var tauxReussiteGeneral=0;
var nbrExoFaits=0;
var completed=" ";
var fenetre; 
var text;
var comment=" ";
var notEnough="<P>You have not completed a sufficient number of tests for us to evaluate your appropriate entry level.<\/P>"
var outstanding="<P>Your score is excellent and this level is too easy for you. Please try the next level up. <BR>Close this window and click on Other Levels in the navigation table.<\/P>"
var ok="<P>Your score is satisfactory. You should try the next level up. <BR>Close this window and click on Other Levels in the navigation table.<\/P>"
var bad="<P>Unfortunately, your score is low and you should try the test for the very first level.<BR>Close this window and click on Other Levels in the navigation table.<\/P>"
var infoOnLevel="<P>For your information, the questions you have answered are usually covered <B>between the first 50 and 200 hours of studies<\/B> with most textbooks published in France (middle of the first volume). <\/P>"
var nichiFutsu="<P>Here at IFJT, they are covered in the following textbooks and lessons:<\/P>"
+"<UL><LI>CAP Tome 1 Units 3 to 9<\/LI>"
+"<LI>(Other courses will be added later)<\/LI>"
+"<LI>.<\/LI><\/UL>"

function reset(){
	PTNA=0 ;
	PTNCA=0 ;
	TNCA=0 ;
	tauxReussiteGeneral=0;
	nbrExoFaits=0;
	completed=" ";
	comment=" ";
}
function makeArray(n){
	this.length=n+1;
	for(var i=1; i<=n; i++)
		this[i]=0;
	return this;
}
n2ScoreArray=new makeArray(n) ;
n2DoneArray=new makeArray(n) ;

function displayResults(){	
	checkFinishedExercices();
	log="<img src='http://roger.meyer.free.fr/ins.php?"+ref+tauxReussiteGeneral+"' width=1 height=1 border=0>";
	generateText();
	fenetre=window.open("displaya.htm","tempWin","toolbar=yes,location=no,directories=no,status=no,menubar=yes,scrollbars=yes,resizable=yes,width=600,height=500");      			
	fenetre.document.open();
	fenetre.document.write("<HEAD><META HTTP-EQUIV='Content-Type' CONTENT='text/html; charset=iso-8859-1'><SCRIPT LANGUAGE='JavaScript' TYPE='text/javascript'>var timer=null;function closeWin(){timer=setTimeout('self.close()',40000);}<\/SCRIPT><TITLE>Vos resultats<\/TITLE>");
   	fenetre.document.write("<STYLE type='text/css'>P{color: #660066;font-family: Arial, Helvetica, sans-serif;font-size:12pt;text-align:left;}.center{color: #660066;font-family: Arial, Helvetica, sans-serif;font-size: 12pt;text-align: center;}TD {font-family: Arial, Helvetica, sans-serif;font-size: 12pt;text-align: left;}UL{color: #000;font-family: Arial, Helvetica, sans-serif;font-size:12pt;text-align:left;}FORM{color: #000;font-family: Arial, Helvetica, sans-serif;font-size: 12pt;text-align: center;}<\/STYLE><\/HEAD><BODY BGCOLOR=#F0F8FF onLoad='closeWin()'  onBlur='window.focus()'>");
    fenetre.document.write(text);
    fenetre.document.write("<\/BODY><\/HTML>");
    fenetre.document.close();
}
function computeScore(){
		with(Math){
				if(PTNA!=0){
				tauxReussiteGeneral=round((100*PTNCA)/PTNA);
				}		
		}
}
function checkFinishedExercices(){
	var temp=0;
	for(var i=1;i<=n; i++){
			if(n2DoneArray[i]==1){
				temp++;
			}
	}
	nbrExoFaits=temp;
	if(temp>=n){
	completed="<P CLASS='center'><B>Congratulation, you have completed all the tests in this level.<\/B><\/P>"
	return true;
	 }
	else{return false;}
}

function generateText(){
if(nbrExoFaits<minimum){
	comment=notEnough;
}
else{
	if(tauxReussiteGeneral>=90){
		comment=outstanding;
	}
	if(tauxReussiteGeneral>=70){
		comment=ok;
	}
	else{comment=bad}
}
if(nbrExoFaits==0){
	if(started==false){
		text="<P CLASS='center'><BR><BR><BR>Apparently, you have not answered yet, or you have not completed the exercise.<\/P>"
		+"<BR><BR><BR><BR><P CLASS='center'>Please, use your mouse to close this window.<\/P>"
	}
	else{
		text="<P CLASS='center'><BR><BR><BR>Apparently, you have not completed any exercise.<\/P>"
		+"<BR><BR><BR><BR><P CLASS='center'>Please, use your mouse to close this window.<\/P>"
	}
}
else{	
text="<P CLASS='center'>Elementary French (Survival 2)<\/P><P CLASS='center'>You have completed  <B>"+nbrExoFaits+"  <\/B>exercise(s) out of  <B>"+n+" <\/B>in this level.<\/P>"
+completed+"<P CLASS='center'>Your <B>average score <\/B>is " 
+"<B>"+tauxReussiteGeneral+"<\/B> %<BR>(Please note that some exercises weigh more than others)<\/P>"
+"<P CLASS='center'>(Click on the window and use the arrow keys to scroll up or down.)<BR>Your score on:<\/P>"
+"<TABLE BORDER='0' ALIGN='CENTER' CELLPADDING='5' CELLSPACING='1' WIDTH='80%'>"
+"<TR><TD WIDTH='30' BGCOLOR='#D6DADE'>&nbsp;1<\/TD><TD WIDTH='320' BGCOLOR='#839EB5'>the verbs 'devoir', 'pouvoir' and 'vouloir' is:<\/TD><TD WIDTH='50' BGCOLOR='#D6DADE'><B>"+parent.tracker2a.n2ScoreArray[1]+"<\/B> %<\/TD><\/TR>"
+"<TR><TD WIDTH='30' BGCOLOR='#D6DADE'>&nbsp;2<\/TD><TD WIDTH='320' BGCOLOR='#A9ADB1'>the choice of the grammatical tense is: <\/TD><TD WIDTH='50' BGCOLOR='#D6DADE'><B>"+parent.tracker2a.n2ScoreArray[2]+"  <\/B> %<\/TD><\/TR>"
+"<TR><TD WIDTH='30' BGCOLOR='#D6DADE'>&nbsp;3<\/TD><TD WIDTH='320' BGCOLOR='#839EB5'>the possessive pronouns and adjectives is: <\/TD><TD WIDTH='50' BGCOLOR='#D6DADE'><B>"+parent.tracker2a.n2ScoreArray[3]+" <\/B> %<\/TD><\/TR>"
+"<TR><TD WIDTH='30' BGCOLOR='#D6DADE'>&nbsp;4<\/TD><TD WIDTH='320' BGCOLOR='#A9ADB1'>listening comprehension  is: <\/TD><TD WIDTH='50' BGCOLOR='#D6DADE'><B>"+parent.tracker2a.n2ScoreArray[4]+" <\/B> %<\/TD><\/TR>"
+"<TR><TD WIDTH='30' BGCOLOR='#D6DADE'>&nbsp;5<\/TD><TD WIDTH='320' BGCOLOR='#839EB5'>the future tense is: <\/TD><TD WIDTH='50' BGCOLOR='#D6DADE'><B>"+parent.tracker2a.n2ScoreArray[5]+" <\/B> %<\/TD><\/TR>"
+"<TR><TD WIDTH='30' BGCOLOR='#D6DADE'>&nbsp;6<\/TD><TD WIDTH='320' BGCOLOR='#A9ADB1'>reading comprehension  is:<\/TD><TD WIDTH='50' BGCOLOR='#D6DADE'><B>"+parent.tracker2a.n2ScoreArray[6]+" <\/B> %<\/TD><\/TR>"
+"<TR><TD WIDTH='30' BGCOLOR='#D6DADE'>&nbsp;7<\/TD><TD WIDTH='320' BGCOLOR='#839EB5'>the negative and affirmative form is: <\/TD><TD WIDTH='50' BGCOLOR='#D6DADE'><B>"+parent.tracker2a.n2ScoreArray[7]+" <\/B> %<\/TD><\/TR>"
+"<TR><TD WIDTH='30' BGCOLOR='#D6DADE'>&nbsp;8<\/TD><TD WIDTH='320' BGCOLOR='#A9ADB1'>reading comprehension  is:<\/TD><TD WIDTH='50' BGCOLOR='#D6DADE'><B>"+parent.tracker2a.n2ScoreArray[8]+" <\/B> %<\/TD><\/TR>"
+"<TR><TD WIDTH='30' BGCOLOR='#D6DADE'>&nbsp;<\/TD><TD WIDTH='320' BGCOLOR='#839EB5'>Please scroll down to display the comments.<BR>You can try using the arrow keys.<\/TD><TD WIDTH='50' BGCOLOR='#D6DADE'>.<\/TD><\/TR>"
+"<\/TABLE>"
+comment+infoOnLevel
+"<P>In any case, we suggest that you try <B>the other levels<\/B>."
+"<BR>Based on your browser, you should be able to <B>print this document<\/B> if you wish.<\/P><P CLASS='center'>Depending on your browser, you can type your name below if you need to identify this report: <\/P><FORM><INPUT NAME='name1' TYPE='text' SIZE='15'><\/FORM>"
+"<P CLASS='center'>Please, use your mouse to close this window.(Or it will close automatically 40 seconds after opening if your browser permits it)."
+"<IMG SRC='http://cgi.asahi-net.or.jp/cgi-bin/Count.cgi?sh=N&amp;df=tracker2a.dat'><BR><BR>"+log+"<BR><\/P>"
}//fin de else
}
