// Questions here

/*
var testTitle = "Indices";
var questionDuration = 21;

var questions = new Array();
questions[0] = new Array("Write *2<sup>3</sup> &times; 2<sup>4</sup>* as a single term in index form.","2<sup>7</sup>");
questions[1] = new Array("Write *4<sup>2</sup> &times; 4<sup>7</sup>* as a single term in index form.","4<sup>9</sup>");
questions[2] = new Array("Write *<i>x</i><sup>4</sup> &divide; <i>x</i><sup>7</sup>* as a single term in index form.","<i>x</i><sup>&minus;3</sup>");
questions[3] = new Array("Work out the value of *2<sup>5</sup>*.","32");
questions[4] = new Array("Work out the value of *7<sup>0</sup>*.","1");
*/


var testTitle = "Tables Test";
var questionDuration = 6;

var questions = new Array();

var oneFlag = false;

for ( a = 0; a <= 9; a++ ) {
  questions[a] = new Array();
  var repeatFlag = false;
  while ( repeatFlag == false ) {
    var temp1 = Math.floor(Math.random()*12) + 1;
    if ( temp1 == 1 && oneFlag == true ) {
      temp1 = temp1 + Math.floor(Math.random()*12);
      }
    else if ( temp1 == 1 && oneFlag == false ) {
      oneFlag = true;
      }
    var temp2 = Math.floor(Math.random()*12) + 1;
    if ( temp2 == 1 && oneFlag == true ) {
      temp2 = temp2 + Math.floor(Math.random()*11) + 1;
      }
    else if ( temp2 == 1 && oneFlag == false ) {
      oneFlag = true;
      }
    var tempString = "Work out *" + temp1 + " &times; " + temp2 + "*";
    var repeatFlag1 = false;
    for ( v = 0; v <= a; v++ ) {
      if ( tempString == questions[v][0] ) {
        repeatFlag1 = true;
        }
      }
    if ( repeatFlag1 == false ) {
      repeatFlag = true;
      }
    }
  questions[a][0] = tempString;
  questions[a][1] = temp1 * temp2;
  }



/*
var testTitle = "Standard Form";
var questionDuration = 31;

var questions = new Array();
questions[0] = new Array("Which of the following shows *<nobr>1<span style='font-size: 12pt;'> </span>530<span style='font-size: 12pt;'> </span>000</nobr>* in standard form?<br />&nbsp;A. 15.3 &times; 10<sup>5</sup><br />&nbsp;B. 1.53 &times; 10<sup>6</sup><br />&nbsp;C. 15.3 &times; 10<sup>&minus;5</sup><br />&nbsp;D. 1.53 &times; 10<sup>&minus;5</sup>","1.53 &times; 10<sup>6</sup> \(Answer B\)");
questions[1] = new Array("Which of the following shows *0.00104* in standard form?<br />&nbsp;A. 1.04 &times; 10<sup>2</sup><br />&nbsp;B. 1.04 &times; 10<sup>3</sup><br />&nbsp;C. 1.04 &times; 10<sup>&minus;2</sup><br />&nbsp;D. 1.04 &times; 10<sup>&minus;3</sup>","1.04 &times; 10<sup>&minus;3</sup> \(Answer D\)");
questions[2] = new Array("Which of the following shows *0.00000728* in standard form?<br />&nbsp;A. 728 &times; 10<sup>&minus;6</sup><br />&nbsp;B. 7.28 &times; 10<sup>&minus;6</sup><br />&nbsp;C. 7.2 &times; 10<sup>&minus;6</sup><br />&nbsp;D. 72.8 &times; 10<sup>&minus;6</sup>","7.28 &times; 10<sup>&minus;6</sup> \(Answer B\)");
questions[3] = new Array("Which of the following shows *<nobr>4272</nobr>* in standard form?<br />&nbsp;A. 4.27 &times; 10<sup>3</sup><br />&nbsp;B. 4.272 &times; 10<sup>&minus;3</sup><br />&nbsp;C. 4.272 &times; 10<sup>3</sup><br />&nbsp;D. 4.27 &times; 10<sup>&minus;3</sup>","4.272 &times; 10<sup>3</sup> \(Answer C\)");
questions[4] = new Array("Which ordinary number is the same as *<nobr>4.1 &times; 10<sup>&minus;2</sup>*?</nobr><br />&nbsp;A. 0.041<br />&nbsp;B. 0.0041<br />&nbsp;C. 410<br />&nbsp;D. 4100","0.041 \(Answer A\)");
questions[5] = new Array("Which ordinary number is the same as *<nobr>6.93 &times; 10<sup>4</sup>*?</nobr><br />&nbsp;A. 0.000693<br />&nbsp;B. 0.00693<br />&nbsp;C. 6930<br />&nbsp;D. 69300","69300 \(Answer D\)");
*/
/*
var testTitle = "Algebraic skills";
var questionDuration = 41;


var questions = new Array();
questions[0] = new Array("Solve correct to 2 d.p.<br />*<table><tr><td align='center'><i>x</i></td><td rowspan='2'> = 4.6</td></tr><tr><td align='center' style='border-top: solid 3px blue'>2.1</td></tr></table>*","<i>x</i> = 9.66");
questions[1] = new Array("Solve correct to 2 d.p.<br />*<table><tr><td align='center'>13</td><td rowspan='2'> = 0.9</td></tr><tr><td align='center' style='border-top: solid 3px blue'><i>x</i></td></tr></table>*","<i>x</i> = 14.44444... = 14.44 (2 d.p.)");
questions[2] = new Array("Solve correct to 2 d.p.<br />*<table><tr><td align='center'>16.1</td><td rowspan='2'> = 0.21</td></tr><tr><td align='center' style='border-top: solid 3px blue'><i>x</i></td></tr></table>*","<i>x</i> = 76.66666... = 76.67 (2 d.p.)");
questions[3] = new Array("Solve correct to 2 d.p.<br />*<table><tr><td align='center'><i>x</i></td><td rowspan='2'> = 0.37</td></tr><tr><td align='center' style='border-top: solid 3px blue'>29</td></tr></table>*","<i>x</i> = 10.73");

*/

var testIntro = "<p>There are " + questions.length + " questions in this tables test.</p><p>You will only have " + (questionDuration - 1) + " seconds for each question.</p><p>Good luck!</p>";



///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// CODE FOR TIMINGS BELOW
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////


var secs;
var k = 0;
var tempObj;

function cd() {
  var insertQuestion = document.getElementById("questionSpace");
  var tempQuestion = questions[k][0].substring( 0, questions[k][0].indexOf("*")) + questions[k][0].substring( questions[k][0].indexOf("*") + 1, questions[k][0].lastIndexOf("*")) + questions[k][0].substring( questions[k][0].lastIndexOf("*") + 1);
  insertQuestion.innerHTML = "<small>Question " + (k + 1) + ".</small><br />" + tempQuestion;
  secs = questionDuration;
  redo();
  }

function dis(secs) {
  var disp;
  disp = " ";
  disp += secs;
  return(disp);
  }

function initialise() {
  var tempObj = document.getElementById("startButton");
  tempObj.style.visibility = "hidden";
  cd();
  }

function showAnswers() {
  var answerText = document.getElementById("questionSpace");
  var tempText = "";
  for ( b = 0; b < questions.length; b++ ) {
    var questionPart = questions[b][0].substring( questions[b][0].indexOf("*") + 1, questions[b][0].lastIndexOf("*"));
    tempText += "<br />" + ( b + 1 ) + ". " + questionPart + " Answer: <span style='color: red;'>" + questions[b][1] + "</span><br />";
    }
  answerText.innerHTML = tempText;
  }

function redo() {
  secs--;
  document.cd.disp.value = dis(secs);
  if(secs == 0) {
    k += 1;
    if ( k < questions.length ) {
      var insertQuestion = document.getElementById("questionSpace");
      var tempQuestion = questions[k][0].substring( 0, questions[k][0].indexOf("*")) + questions[k][0].substring( questions[k][0].indexOf("*") + 1, questions[k][0].lastIndexOf("*")) + questions[k][0].substring( questions[k][0].lastIndexOf("*") + 1);
      insertQuestion.innerHTML = "<small>Question " + (k + 1) + ".</small><br />" + tempQuestion;
      secs = questionDuration;
      redo();
      }
    else {
      var insertQuestion = document.getElementById("questionSpace");
      insertQuestion.innerHTML = "TEST COMPLETE<br /><form name='ans'><input type='button' onclick='javascript:showAnswers()' name='answers' value='Show answers' /></form>";
      document.ans.answers.focus();
      }
    }
  else {
    cd = setTimeout("redo()",1000);
    }
  }