// TIMER
RightNow = new Date();   
StartPoint = RightNow.getTime();    //time at start of test. getTime is no. of milliseconds elapsed from date object
var LengthOfTest = 720 //test length in seconds - 12 minutes
flag = false

function StartTheCount()
{
var RightNow2 = new Date();   
var CurrentTime = RightNow2.getTime();
var timeDifference = CurrentTime - StartPoint;
this.DifferenceInSeconds = timeDifference/1000;
return(this.DifferenceInSeconds);
}

function TheSeconds()
{
var SecCounts = StartTheCount();
SecCounts = LengthOfTest - SecCounts;
MinCounts = SecCounts/60;
var MinCountsString = " "+MinCounts; 
MinCountsString = MinCountsString.substring(0,MinCountsString.indexOf("."))+"  minutes";
SecCountsSecs = SecCounts % 60; //get modulus to find seconds left over
var SecCountsString = " "+SecCountsSecs; //turns it into a string
SecCountsString = SecCountsString.substring(0,SecCountsString.indexOf("."))+"  seconds"; //substring returns all characters of SecCounts up to decimal point
if (DifferenceInSeconds >= LengthOfTest)
	{
	GetScore();
	alert("End of Test. You can continue if you wish, but please note your score now.")
	}
else
	{
	window.document.form1.CountBox.value = (MinCountsString + SecCountsString);
	window.setTimeout('TheSeconds()',1000);
	}
if (flag == false) {window.document.form1.CountBox.value = ""}
}
//--------------------------------------------------------

var Verbal = new Array()
var num
for (num=-20; num<300; num++) //fills array with blanks.
{
	Verbal[num] = "";
}

//EXAMPLE QUESTIONS
Verbal [-19] = "EXAMPLE. What is the missing letter in this series:\r  a     c     e     ?     i"
Verbal [-17] = "           f"
Verbal [-16] = "           g"//Correct Answer
Verbal [-15] = "           h"
Verbal [-14] = "           j"
Verbal [-13] = "           k"

Verbal [-9] = "FINAL EXAMPLE. What is the missing letter in this series:\r  h     g     ?     e     d"
Verbal [-7] = "           a"
Verbal [-6] = "           b"
Verbal [-5] = "           c"
Verbal [-4] = "           f" //Correct Answer
Verbal [-3] = "           i"

//TEST QUESTIONS-----
Verbal [1] ="1) What is the missing letter in this series:\r  a     a     b     b     ?     c"
Verbal [3] = "           a"
Verbal [4] = "           b"
Verbal [5] = "           c" //Correct Answer
Verbal [6] = "           d"
Verbal [7] = "           e"

Verbal [11] =  "2) What is the missing letter in this series:\r  c     c     d     ?     e     f     g     g     h"
Verbal [13] = "           b"
Verbal [14] = "           c"
Verbal [15] = "           d"
Verbal [16] = "           e"//Correct Answer
Verbal [17] = "           f"

Verbal [21] ="3) What is the missing letter in this series:\r  a     z     b     ?     c     x"
Verbal [23] = "           b"
Verbal [24] = "           c"
Verbal [25] = "           w"
Verbal [26] = "           x"
Verbal [27] = "           y"//Correct Answer

Verbal [31] = "4) What is the missing letter in this series:\r  f     g     e     h     d     i     c     ?"
Verbal [33] = "           a"
Verbal [34] = "           b"
Verbal [35] = "           j"//Correct Answer
Verbal [36] = "           k"
Verbal [37] = "           l"

Verbal [41] = "5) What is the missing letter in this series:\r  r     q     p     r     q     p     ?"
Verbal [43] = "           o"
Verbal [44] = "           p"
Verbal [45] = "           q"
Verbal [46] = "           r"//Correct Answer
Verbal [47] = "           s"

Verbal [51] = "6) What is the missing letter in this series:\r  b     e     h     k     n     ?     t"
Verbal [53] = "           o"
Verbal [54] = "           p"
Verbal [55] = "           q"//Correct Answer
Verbal [56] = "           r"
Verbal [57] = "           s"

Verbal [61] = "7) What is the missing letter in this series:\r  y     e     w     g     u     i     ?"
Verbal [63] = "           s"//Correct Answer
Verbal [64] = "           t"
Verbal [65] = "           r"
Verbal [66] = "           k"
Verbal [67] = "           l"

Verbal [71] = "8) What is the missing letter in this series:\r  x     ?     p     l     h"
Verbal [73] = "           r"
Verbal [74] = "           s"
Verbal [75] = "           q"
Verbal [76] = "           o"
Verbal [77] = "           t"//Correct Answer

Verbal [81] = "9) What is the missing letter in this series:\r  c     c     d     f     i     ?"
Verbal [83] = "           j"
Verbal [84] = "           k"
Verbal [85] = "           l"
Verbal [86] = "           m"//Correct Answer
Verbal [87] = "           n"

Verbal [91] = "10) What is the missing letter in this series:\r  j     g     d     k     ?     e     l"
Verbal [93] = "           h" //Correct Answer
Verbal [94] = "           f"
Verbal [95] = "           i"
Verbal [96] = "           m"
Verbal [97] = "           g"

Verbal [101] = "11) What is the missing letter in this series:\r  a     b     d     h     ?"
Verbal [103] = "           l"
Verbal [104] = "           m"
Verbal [105] = "           n"
Verbal [106] = "           o"
Verbal [107] = "           p"//Correct Answer square numbers

Verbal [111] = "12) What is the missing letter in this series:\r  b     g     d     i     ?     k     h"
Verbal [113] = "           j"
Verbal [114] = "           e"
Verbal [115] = "           c"
Verbal [116] = "           f"//Correct Answer
Verbal [117] = "           g"

Verbal [121] = "13) What is the missing letter in this series:\r  a     d     i     ?"
Verbal [123] = "           p" //Correct Answer
Verbal [124] = "           n"
Verbal [125] = "           o"
Verbal [126] = "           l"
Verbal [127] = "           m"

Verbal [131] = "14) What is the missing letter in this series:\r  g     ?     d     i     j     d     k     l     d"
Verbal [133] = "           f"
Verbal [134] = "           e"
Verbal [135] = "           c"
Verbal [136] = "           h"//Correct Answer
Verbal [137] = "           d"

Verbal [141] = "15) What is the missing letter in this series:\r  p     q     q     ?     s     s     t     u"
Verbal [143] = "           r" //Correct Answer
Verbal [144] = "           t"
Verbal [145] = "           s"
Verbal [146] = "           u"
Verbal [147] = "           q"

Verbal [151] = "16) What is the missing letter in this series:\r  g     g     k     k     o     o     ?"
Verbal [153] = "           q"
Verbal [154] = "           s"//Correct Answer
Verbal [155] = "           r"
Verbal [156] = "           o"
Verbal [157] = "           t"

Verbal [161] = "17) What is the missing letter in this series:\r  y     e     u     i     q     m     ?"
Verbal [163] = "           m"//Correct Answer +4 -4
Verbal [164] = "           n"
Verbal [165] = "           j"
Verbal [166] = "           k"
Verbal [167] = "           o"

Verbal [171] = "18) What is the missing letter in this series:\r  v     s     p     w     t     q     ?"
Verbal [173] = "           r"
Verbal [174] = "           u"
Verbal [175] = "           x"//Correct Answer
Verbal [176] = "           v"
Verbal [177] = "           y"

Verbal [181] = "19) What is the missing letter in this series:\r  a     b     k     c     d     k     e     ?"
Verbal [183] = "           f"//Correct Answer
Verbal [184] = "           g"
Verbal [185] = "           k"
Verbal [186] = "           e"
Verbal [187] = "           h"

Verbal [191] = "20) What is the missing letter in this series:\r  q     r     k     s     t     i     u     v      ?"
Verbal [193] = "           v"
Verbal [194] = "           y"
Verbal [195] = "           h"
Verbal [196] = "           x"
Verbal [197] = "           g"//Correct Answer

Verbal [201] = "21) What is the missing letter in this series:\r  c     j     q     x     e     ?     s"
Verbal [203] = "           j"
Verbal [204] = "           l"//Correct Answer
Verbal [205] = "           n"
Verbal [206] = "           g"
Verbal [207] = "           p"

Verbal [211] = "22) What is the missing letter in this series:\r  y     d     j     w     f     l     u     h     ?"
Verbal [213] = "           m"
Verbal [214] = "           o"
Verbal [215] = "           n"//Correct Answer
Verbal [216] = "           s"
Verbal [217] = "           j"

Verbal [221] = "23) What is the missing letter in this series:\r  m     o     n     n     o     m     p     ?"
Verbal [223] = "           l"//Correct Answer
Verbal [224] = "           p"
Verbal [225] = "           m"
Verbal [226] = "           n"
Verbal [227] = "           o"

Verbal [231] = "24) What is the missing letter in this series:\r  c     d     c     d     d     d     e      d      e     ?"
Verbal [233] = "           d"
Verbal [234] = "           e"
Verbal [235] = "           f"//Correct Answer
Verbal [236] = "           g"
Verbal [237] = "           h"

Verbal [241] = "25) What is the missing letter in this series:\r  a     b     b     d     c     f     d     ?"
Verbal [243] = "           e"
Verbal [244] = "           f"
Verbal [245] = "           g"
Verbal [246] = "           h"//Correct Answer
Verbal [247] = "           i"

Verbal [251] = "26) What is the missing letter in this series:\r  b     c     e     g     k     ?     q     s"
Verbal [253] = "           l"
Verbal [254] = "           m"//Correct Answer - prime numbers
Verbal [255] = "           n"
Verbal [256] = "           o"
Verbal [257] = "           p"

Verbal [261] = "27) What is the missing letter in this series:\r  m     n     n     o     o     ?     p     p     p"
Verbal [263] = "           r"
Verbal [264] = "           p"
Verbal [265] = "           q"
Verbal [266] = "           n"
Verbal [267] = "           o"//Correct Answer



var Ans = new Array()
num = -29 //when next quest button clicked advances to 1 at start of test
var checked1

function NextQuest()
{
if (num==-9) 
{
window.document.form1.Scorebox.value=""
flag = true;
RightNow = new Date();  
StartPoint = RightNow.getTime(); 
StartTheCount()
}
num=num+10

window.document.form1.nextquestbutton.value="Next Question"
//BOXFILL
BoxFill()
if (num==271)
	{
	num=num-10
	BoxFill()
	window.alert("That was the last question.  Either click on PREVIOUS QUESTION to attempt questions you may have missed out, or GET YOUR SCORE if you wish to finish.")
	}
}

function PrevQuest()
{
num=num-10
BoxFill()
if (num==1)
{
num=1;
window.document.form1.Questionbox.value=(Verbal[num]);
}
if (num==-9)
	{
	num=1;
	BoxFill()
	window.alert("That was the first question.")
	}
if (num==-29)
	{
	num=-19;
	BoxFill()
	window.alert("That was the first example.")
	}
}

function BoxFill() //Fills in boxes and radio buttons
{
window.document.form1.Questionbox.value=Verbal[num]; // puts quesions into correct box
window.document.form1.Answerbox1.value=Verbal[num+2];
window.document.form1.Answerbox2.value=Verbal[num+3];
window.document.form1.Answerbox3.value=Verbal[num+4];
window.document.form1.Answerbox4.value=Verbal[num+5];
window.document.form1.Answerbox5.value=Verbal[num+6];

window.document.form1.question_1[0].checked=false //clears radio buttons 
window.document.form1.question_1[1].checked=false 
window.document.form1.question_1[2].checked=false
window.document.form1.question_1[3].checked=false
window.document.form1.question_1[4].checked=false

if (Ans[num]==1) {window.document.form1.question_1[0].checked=true} //checks radio button if already answered
if (Ans[num]==2) {window.document.form1.question_1[1].checked=true}
if (Ans[num]==3) {window.document.form1.question_1[2].checked=true}
if (Ans[num]==4) {window.document.form1.question_1[3].checked=true}
if (Ans[num]==5) {window.document.form1.question_1[4].checked=true}
}

function ShowAnswer()
{
//EXAMPLES
if (num==-19) 
{
if (window.document.form1.question_1[0].checked==true){window.document.form1.Scorebox.value="WRONG. The answer is g" }
if (window.document.form1.question_1[1].checked==true){window.document.form1.Scorebox.value="CORRECT! The answer is g" }
if (window.document.form1.question_1[2].checked==true){window.document.form1.Scorebox.value="WRONG. The answer is g" }
if (window.document.form1.question_1[3].checked==true){window.document.form1.Scorebox.value="WRONG. The answer is g" }
if (window.document.form1.question_1[4].checked==true){window.document.form1.Scorebox.value="WRONG. The answer is g" }
}
if (num==-9) 
{
if (window.document.form1.question_1[0].checked==true){window.document.form1.Scorebox.value="WRONG. The answer is f" }
if (window.document.form1.question_1[1].checked==true){window.document.form1.Scorebox.value="WRONG. The answer is f" }
if (window.document.form1.question_1[2].checked==true){window.document.form1.Scorebox.value="WRONG. The answer is f"}
if (window.document.form1.question_1[3].checked==true){window.document.form1.Scorebox.value="CORRECT! The answer is f" }
if (window.document.form1.question_1[4].checked==true){window.document.form1.Scorebox.value="WRONG. The answer is f" }
}

if (num==1) {window.document.form1.Scorebox.value=""}
window.document.form1.nextquestbutton.value="Next Question"
for (i=0;i<window.document.form1.question_1.length;i++)
	{if (window.document.form1.question_1[i].checked==true)
checked1=i}
Ans[num]=checked1+1 //radio boxes have values 0-2 therefore must add 1 to give correct answer number
}

function GetScore()  // Could be put into theSeconds Function
{
var	totalscore = 0
	if (Ans[1]==3) {totalscore=totalscore+1}
	if (Ans[11]==4) {totalscore=totalscore+1}
	if (Ans[21]==5) {totalscore=totalscore+1}
	if (Ans[31]==3) {totalscore=totalscore+1}
	if (Ans[41]==4) {totalscore=totalscore+1}
	if (Ans[51]==3) {totalscore=totalscore+1}
	if (Ans[61]==1) {totalscore=totalscore+1}
	if (Ans[71]==5) {totalscore=totalscore+1}
	if (Ans[81]==4) {totalscore=totalscore+1}
	if (Ans[91]==1) {totalscore=totalscore+1}
	if (Ans[101]==5) {totalscore=totalscore+1}
	if (Ans[111]==4) {totalscore=totalscore+1}
	if (Ans[121]==1) {totalscore=totalscore+1}
	if (Ans[131]==4) {totalscore=totalscore+1}
	if (Ans[141]==1) {totalscore=totalscore+1}
	if (Ans[151]==2) {totalscore=totalscore+1}
	if (Ans[161]==1) {totalscore=totalscore+1} //question 17
	if (Ans[171]==3) {totalscore=totalscore+1}
	if (Ans[181]==1) {totalscore=totalscore+1}
	if (Ans[191]==5) {totalscore=totalscore+1}
	if (Ans[201]==2) {totalscore=totalscore+1}
	if (Ans[211]==3) {totalscore=totalscore+1}
	if (Ans[221]==1) {totalscore=totalscore+1}
	if (Ans[231]==3) {totalscore=totalscore+1}
	if (Ans[241]==4) {totalscore=totalscore+1}
	if (Ans[251]==2) {totalscore=totalscore+1}
	if (Ans[261]==5) {totalscore=totalscore+1}
	window.document.form1.Scorebox.value=" Your score is "+totalscore;
}