/* INSTRUCTIONS */
/* 
OK! After you have read everything in the main (html) page (go read it if you haven't ) this is what you have to edit now. This .js file actually takes care of checking the answers and must be in the same directory as the main html file. I probably told you this already.
Make a copy of this page for BACKUP in case something goes wrong.
Configure each line as per the instructions given below it.
You may change the words inside the "quotes" if there are quotes.
If there aren't any quotes then it might be a numerical value which shouldn't be quoted at all (like the first one below). Note that you can't run this file directly. You'll have to preview your changes by running the main file. This is just an external file required for the functioning of the main file.
*/
var points_pq=4;
/*
points_pq - This is the amount of points to be given for each right question. The total will be calculated using this and the total number of questions.
*/
var time_pq=9;
/*
time_pq - This is the amount of seconds to be given for answering each question. The total will be calculated using this and the total number of questions

If set to 0 unlimited amount of time will be given and the quiz will end only if the user wants to end it by clicking the ANSWERS button
*/
var percent_pass=80;
/*
percent_pass - This is the minimum percentage required to pass the test.
*/
var over=false;
/*
Do NOT change this. However if you change the false to true, the quiz timer won't start counting.
*/
var go_to="http://golocalnet.net/Ttests/Ttest2.html";
/*
go_to - This is the URL of the page the browser should be redirected to after the quiz is over in QUOTES. If left blank the user will be taken back to the Quiz Page (i.e. page that started the quiz)
*/
var score=0;
/*
Do NOT change this.
*/
var answer=new Array();
/*
Now around 22-24 lines below find this line.....
***********ANSWERS***********

It's the answers, corresponding to the questions in the main page. So if option 2 is the answer to question 1, then you have 
answer[1]=2 
(in simple English Answer 1 is option 2) 
(don't use quotes because its a number. e.g. answer[1]="2" is WRONG)
Again, just like the questions, they start from 0. So answer[0] is the answer to question[0] in the main page
IMP: Also the total number of answers MUST BE equal to the number of questions (in the main html page) 
which is obvious.

OK! what happens if they are not equal? (just incase you want to know...)

if questions > answers 
If the answers are from 0 - 25 but questions from 0 - 25 the 24th and 25th questions won't be checked at all.

if answers > questions
If the answers are from 0 - 25 but questions from 0 - 25 errors will occur.
So thats it. Go ahead and change it (the answers) and then read further (i.e the finale).....
*/

/***********ANSWERS***********/
answer[0]=1;
answer[1]=2;
answer[2]=2;
answer[3]=1;
answer[4]=3;
answer[5]=2;
answer[6]=3;
answer[7]=1;
answer[8]=2;
answer[9]=1;
answer[10]=3;
answer[11]=1;
answer[12]=1;
answer[13]=1;
answer[14]=1;
answer[15]=3;
answer[16]=2;
answer[17]=3;
answer[18]=1;
answer[19]=2;
answer[20]=1;
answer[21]=3;
answer[22]=2;
answer[23]=1;
answer[24]=3;

/*
FINALE

Everything after these comments must be left as it is. Now you can test and upload it to your web site. As i told you earlier, both files in the same directory. 
If you think you have a nice set of questions, drop me a note at schubert_94_2000@yahoo.com telling me the URL of the qiuz page on your site. I'll be glad to take a look if i can.
If you find this script very useful and if you want to contribute , your'e welcome > E-mail me at schubert_94_2000@yahoo.com

MY URL: http://gp-3.cjb.net/ - dedicated to the best F1 SIMULATION in the world :)
Other Scripts I have made can be found at: http://javascripts.gp-3.cjb.net/ customizable as always :)
*/
var counter=time_pq*answer.length;
function ans()
	{
	var y=0;
	if(document.layers)
		{
		for(x=0;x<answer.length;x++)
			{
			if(quiz.document.forms[x].elements[answer[x]-1].checked==true)
				{
				score+=points_pq;
				}
			else
				{
				alert("Answer:"+(x+1)+" is WRONG. Its actually option number:"+[answer[x]]);
				y++;
				}
			}
		}
	else
		{
		for(x=0;x<answer.length;x++)
			{
			if(document.forms[x].elements[answer[x]-1].checked==true)
				{
				score+=points_pq;
				}
			else
				{
				location.href="#"+(x);
				alert("Answer:"+(x+1)+" is WRONG. Its actually option number:"+[answer[x]]);
				y++;
				}
			}
		}
	alert("You scored "+score+"/"+(points_pq*answer.length));
	percent=score*100/(points_pq*answer.length);
	if(percent<percent_pass)
		{
		alert("According to the "+percent_pass+"%, you have FAILED!!!");
		}
	else if(percent>=percent_pass)
		{
		if(percent=percent_pass)
			{
			alert("You secured "+percent_pass+"%. You JUST PASSED!");
			}
		else if(percent=100)
			{
			alert("You have secured 100%. Your'e Great!!!");
			}
		else
			{
			alert("According to the "+percent_pass+"% rule, you have PASSED the test!!!");
			}
		}
	over=true;
	score=0;
	window.status="The quiz has ended.";
	if(go_to.length!=0)
		{
		location.href=go_to;
		}
	else
		{
		history.go(-(y+1));
		}
	}
	
function count()
	{
	if(over==false)
		{
		if(counter>1)
			{
			counter--;
			if(document.layers)
				{
				quiz.window.status="TIME TO GO: "+counter+" seconds";
				}
			else
				{
				window.status="TIME TO GO: "+counter+" seconds";
				}
			}
		else
			{
			counter=0;
			window.status=counter;
			over=true;
			alert("OK! Time out.");
			if (document.layers)
				{
				
				}
			ans();	
			}
		}
	}