/* TEST D'ANGLAIS */
  function EslTest(){
    var correctAnswers = 0;
    var questionNumber = 0;
    var questionsArray = new Array();
    var answersArray = new Array();
    var levelArray = new Array();
    var questionTitle = document.getElementById("esl_questionTitle");
    var questionDefinition = document.getElementById("esl_questionDefinition");
    var questionOptions = document.getElementById("esl_questionOptions");
    var questionButton = document.getElementById("esl_questionButton");


    var displayQuestion = function(){
      var questionOptionsText = "";
      questionTitle.innerHTML = 'Question ' + (questionNumber + 1);
      questionDefinition.innerHTML = questionsArray[questionNumber][0];
      for (var questionOption=1; questionOption<=4; questionOption++){
        questionOptionsText += "\n" + '<input type="radio" id="esl_radioOption' + questionOption + '" name="esl_radioOption"';
        if (questionOption==1){
          questionOptionsText += ' checked="checked"';
        }
        questionOptionsText += ' /> <label for="esl_radioOption' + questionOption + '">' + questionsArray[questionNumber][questionOption] + '</label><br />';
      }
      questionOptions.innerHTML = questionOptionsText + "\n";
    }


    this.buttonStart_onclick = function(){
      questionButton.innerHTML = '<input type="button" name="esl_buttonAnswer" id="esl_buttonAnswer" value="Answer Question" onclick="return esl_test.buttonAnswer_onclick()"/>';
      displayQuestion();
    }


    this.buttonAnswer_onclick = function(){
      checkAnswer();
      if(questionNumber < answersArray.length - 1){
        questionNumber++;
        displayQuestion();
      }else{
        questionTitle.innerHTML = 'Quiz Results and Answers';
        for (var i=0; i < levelArray.length; i++){
          if (correctAnswers >= levelArray[i]['lower'] && correctAnswers <= levelArray[i]['upper']){
            var level = levelArray[i]['case'];
            break;
          }
        }
        questionDefinition.innerHTML = correctAnswers + ' out of ' + answersArray.length +  ' questions answered correctly! <strong>' + level + '</strong>';
        var answersText = "";
        for (var answerCounter=0; answerCounter < answersArray.length; answerCounter++){
          answersText += "\n" + '<p>Question ' + (answerCounter+1) + ': ' + questionsArray[answerCounter][0] + '<br />Answer: ' + questionsArray[answerCounter][answersArray[answerCounter]] + '</p>';
        }
        questionOptions.innerHTML = answersText + "\n";
        questionButton.innerHTML = '';
      }
    }


    var checkAnswer = function(){
      var radioOptionArray = document.getElementById('eslQuizForm').elements['esl_radioOption'];
      for (var questionOption=0; questionOption<=3; questionOption++){
        if (radioOptionArray[questionOption].checked == true){
          questionOption++;
          break;
        }
      }
      if (questionOption == answersArray[questionNumber]){
        correctAnswers++;
      }
    }

    // ****************************************************************************

    var initialiseArray = function(){
      var i = 0;
      
      questionsArray[i] = new Array();
		questionsArray[i][0] = 'Please select the best word to complete the following sentence:<br />I come ________ England.';
		questionsArray[i][1] = 'to';
		questionsArray[i][2] = 'from';
		questionsArray[i][3] = 'at';
		questionsArray[i][4] = 'in';
		answersArray[i] = 2;
		i++;
		questionsArray[i] = new Array();
		questionsArray[i][0] = "Please select the best word to complete the following sentence:<br />There aren't ________ people here.";
		questionsArray[i][1] = 'much';
		questionsArray[i][2] = 'many';
		questionsArray[i][3] = 'a lot';
		questionsArray[i][4] = 'some';
		answersArray[i] = 2;
		i++;
		questionsArray[i] = new Array();
		questionsArray[i][0] = 'Please select the best word to complete the following sentence:<br />Tim ________ work tomorrow.';
		questionsArray[i][1] = "isn't going";
		questionsArray[i][2] = "isn't";
		questionsArray[i][3] = "isn't going to";
		questionsArray[i][4] = "isn't to";
		answersArray[i] = 3;
		i++;
		questionsArray[i] = new Array();
		questionsArray[i][0] = "Please select the best word to complete the following sentence:<br />I'd like ________ information, please.";
		questionsArray[i][1] = 'an';
		questionsArray[i][2] = 'some';
		questionsArray[i][3] = 'piece';
		questionsArray[i][4] = 'a piece';
		answersArray[i] = 2;
		i++;
		questionsArray[i] = new Array();
		questionsArray[i][0] = 'Please select the best word to complete the following sentence:<br />________ to school yesterday?';
		questionsArray[i][1] = 'Do you walk';
		questionsArray[i][2] = 'Did you walked';
		questionsArray[i][3] = 'Did you walk';
		questionsArray[i][4] = 'Have you walked';
		answersArray[i] = 3;
		i++;
		questionsArray[i] = new Array();
		questionsArray[i][0] = 'Please select the best word to complete the following sentence:<br />I went to the shop ________ some chocolate.';
		questionsArray[i][1] = 'for buying';
		questionsArray[i][2] = 'for buy';
		questionsArray[i][3] = 'to buy';
		questionsArray[i][4] = 'buy';
		answersArray[i] = 3;
		i++;
		questionsArray[i] = new Array();
		questionsArray[i][0] = "Please select the best word to complete the following sentence:<br />'I don't like coffee.' '________ do I.'";
		questionsArray[i][1] = 'So';
		questionsArray[i][2] = 'Neither';
		questionsArray[i][3] = 'Either';
		questionsArray[i][4] = 'No';
		answersArray[i] = 2;
		i++;
		questionsArray[i] = new Array();
		questionsArray[i][0] = "Please select the best word to complete the following sentence:<br />'Have you visited London?' '________'";
		questionsArray[i][1] = 'Not yet';
		questionsArray[i][2] = 'Ever';
		questionsArray[i][3] = 'Already';
		questionsArray[i][4] = 'Not';
		answersArray[i] = 1;
		i++;
		questionsArray[i] = new Array();
		questionsArray[i][0] = "Please select the best word to complete the following sentence:<br />Is Jo ________ Chris?";
		questionsArray[i][1] = "taller that";
		questionsArray[i][2] = "taller";
		questionsArray[i][3] = "as tall as";
		questionsArray[i][4] = "more tall";
		answersArray[i] = 3;
		i++;
		questionsArray[i] = new Array();
		questionsArray[i][0] = "Please select the best word to complete the following sentence:<br />You should ________ your homework.";
		questionsArray[i][1] = "make";
		questionsArray[i][2] = "do";
		questionsArray[i][3] = "work";
		questionsArray[i][4] = "give";
		answersArray[i] = 2;
		i++;
		questionsArray[i] = new Array();
		questionsArray[i][0] = "Please select the best word to complete the following sentence:<br />\'Where\'s the ________ post office, please?\'";
		questionsArray[i][1] = "most near";
		questionsArray[i][2] = "near";
		questionsArray[i][3] = "more near";
		questionsArray[i][4] = "nearest";
		answersArray[i] = 4;
		i++;
		questionsArray[i] = new Array();
		questionsArray[i][0] = "Please select the best word to complete the following sentence:<br />Would you mind ________ the window?";
		questionsArray[i][1] = "closing";
		questionsArray[i][2] = "close";
		questionsArray[i][3] = "to close";
		questionsArray[i][4] = "closed";
		answersArray[i] = 1;
		i++;
		questionsArray[i] = new Array();
		questionsArray[i][0] = "Please select the best word to complete the following sentence:<br />He\'s interested ________ learning Spanish.";
		questionsArray[i][1] = "on";
		questionsArray[i][2] = "to";
		questionsArray[i][3] = "in";
		questionsArray[i][4] = "for";
		answersArray[i] = 3;
		i++;
		questionsArray[i] = new Array();
		questionsArray[i][0] = "Please select the best word to complete the following sentence:<br />How long ________ English?";
		questionsArray[i][1] = "do you learn";
		questionsArray[i][2] = "are you learning";
		questionsArray[i][3] = "have you been learning";
		questionsArray[i][4] = "you learn";
		answersArray[i] = 3;
		i++;
		questionsArray[i] = new Array();
		questionsArray[i][0] = "Please select the best word to complete the following sentence:<br />His office is on the second ________ of the building.";
		questionsArray[i][1] = "floor";
		questionsArray[i][2] = "level";
		questionsArray[i][3] = "ground";
		questionsArray[i][4] = "stage";
		answersArray[i] = 1;
		i++;
		questionsArray[i] = new Array();
		questionsArray[i][0] = "Please select the best word to complete the following sentence:<br />The doctor gave me a ________ for some medicine yesterday.";
		questionsArray[i][1] = "note";
		questionsArray[i][2] = "receipt";
		questionsArray[i][3] = "prescription";
		questionsArray[i][4] = "recipe";
		answersArray[i] = 3;
		i++;
		questionsArray[i] = new Array();
		questionsArray[i][0] = "Please select the best word to complete the following sentence:<br />Can you tell me when ________ ?";
		questionsArray[i][1] = "the train leaves";
		questionsArray[i][2] = "does the train leave";
		questionsArray[i][3] = "leaves the train";
		questionsArray[i][4] = "does leave the train";
		answersArray[i] = 1;
		i++;
		questionsArray[i] = new Array();
		questionsArray[i][0] = "Please select the best word to complete the following sentence:<br />I ________ a reply to my letter in the next few days.";
		questionsArray[i][1] = "hope";
		questionsArray[i][2] = "expect";
		questionsArray[i][3] = "wait for";
		questionsArray[i][4] = "get";
		answersArray[i] = 2;
		i++;
		questionsArray[i] = new Array();
		questionsArray[i][0] = "Please select the best word to complete the following sentence:<br />When Simon ________ back tonight, he\'ll cook dinner.";
		questionsArray[i][1] = "comes";
		questionsArray[i][2] = "will come";
		questionsArray[i][3] = "come";
		questionsArray[i][4] = "shall come";
		answersArray[i] = 1;
		i++;
		questionsArray[i] = new Array();
		questionsArray[i][0] = "Please select the best word to complete the following sentence:<br />We arrived ________ England two days ago.";
		questionsArray[i][1] = "to";
		questionsArray[i][2] = "in";
		questionsArray[i][3] = "on";
		questionsArray[i][4] = "at";
		answersArray[i] = 2;
		i++;
		questionsArray[i] = new Array();
		questionsArray[i][0] = "Please select the best word to complete the following sentence:<br />\'Why are you so hungry?\' \'Oh, I ________ breakfast this morning.\'";
		questionsArray[i][1] = "hadn\'t";
		questionsArray[i][2] = "didn\'t";
		questionsArray[i][3] = "didn\'t have";
		questionsArray[i][4] = "haven\'t";
		answersArray[i] = 3;
		i++;
		questionsArray[i] = new Array();
		questionsArray[i][0] = "Please select the best word to complete the following sentence:<br />You ________ better see a doctor.";
		questionsArray[i][1] = "did";
		questionsArray[i][2] = "would";
		questionsArray[i][3] = "should";
		questionsArray[i][4] = "had";
		answersArray[i] = 4;
		i++;
		questionsArray[i] = new Array();
		questionsArray[i][0] = "Please select the best word to complete the following sentence:<br />You should ________ swimming.";
		questionsArray[i][1] = "start up";
		questionsArray[i][2] = "get off";
		questionsArray[i][3] = "take up";
		questionsArray[i][4] = "take off";
		answersArray[i] = 3;
		i++;
		questionsArray[i] = new Array();
		questionsArray[i][0] = "Please select the best word to complete the following sentence:<br />\'Did you speak to Juliet?\' \'No, I\'ve ________ seen her.";
		questionsArray[i][1] = "nearly";
		questionsArray[i][2] = "hardly";
		questionsArray[i][3] = "often";
		questionsArray[i][4] = "always";
		answersArray[i] = 2;
		i++;
		questionsArray[i] = new Array();
		questionsArray[i][0] = "Please select the best word to complete the following sentence:<br />He told me that he ________ in Spain the previous year.";
		questionsArray[i][1] = "has been working";
		questionsArray[i][2] = "had been working";
		questionsArray[i][3] = "has worked";
		questionsArray[i][4] = "had been worked";
		answersArray[i] = 2;
		i++;
		questionsArray[i] = new Array();
		questionsArray[i][0] = "Please select the best word to complete the following sentence:<br />She looks ________ she\'s going to be sick.";
		questionsArray[i][1] = "as if";
		questionsArray[i][2] = "as";
		questionsArray[i][3] = "likes";
		questionsArray[i][4] = "if";
		answersArray[i] = 1;
		i++;
		questionsArray[i] = new Array();
		questionsArray[i][0] = "Please select the best word to complete the following sentence:<br />The best way to learn a language is ________ a little every day.";
		questionsArray[i][1] = "speak";
		questionsArray[i][2] = "in speaking";
		questionsArray[i][3] = "to speaking";
		questionsArray[i][4] = "by speaking";
		answersArray[i] = 4;
		i++;
		questionsArray[i] = new Array();
		questionsArray[i][0] = "Please select the best word to complete the following sentence:<br />She ________ me to go to school.";
		questionsArray[i][1] = "said";
		questionsArray[i][2] = "told";
		questionsArray[i][3] = "suggested";
		questionsArray[i][4] = "made";
		answersArray[i] = 2;
		i++;
		questionsArray[i] = new Array();
		questionsArray[i][0] = "Please select the best word to complete the following sentence:<br />I want to be a teacher when I ________ .";
		questionsArray[i][1] = "grow";
		questionsArray[i][2] = "age";
		questionsArray[i][3] = "grow up";
		questionsArray[i][4] = "am more years";
		answersArray[i] = 3;
		i++;
		questionsArray[i] = new Array();
		questionsArray[i][0] = "Please select the best word to complete the following sentence:<br />I\'m fed up ________ this exercise.";
		questionsArray[i][1] = "with doing";
		questionsArray[i][2] = "to do";
		questionsArray[i][3] = "to doing";
		questionsArray[i][4] = "for doing";
		answersArray[i] = 1;
		i++;
		questionsArray[i] = new Array();
		questionsArray[i][0] = "Please select the best word to complete the following sentence:<br />It ________ my brother.";
		questionsArray[i][1] = "is ages that I didn\'t see";
		questionsArray[i][2] = "is ages since I saw";
		questionsArray[i][3] = "was ages that I haven\'t seen";
		questionsArray[i][4] = "was ages since I saw";
		answersArray[i] = 2;
		i++;
		questionsArray[i] = new Array();
		questionsArray[i][0] = "Please select the best word to complete the following sentence:<br />She has been ________ of murdering her husband.";
		questionsArray[i][1] = "charged";
		questionsArray[i][2] = "accused";
		questionsArray[i][3] = "arrested";
		questionsArray[i][4] = "blamed";
		answersArray[i] = 2;
		i++;
		questionsArray[i] = new Array();
		questionsArray[i][0] = "Please select the best word to complete the following sentence:<br />You aren\'t allowed to use your mobile so ________ .";
		questionsArray[i][1] = "it\'s no point to leave it on";
		questionsArray[i][2] = "it\'s no point in leaving it on";
		questionsArray[i][3] = "there\'s no point in leaving it on";
		questionsArray[i][4] = "there\'s no point to leave it on";
		answersArray[i] = 3;
		i++;
		questionsArray[i] = new Array();
		questionsArray[i][0] = "Please select the best word to complete the following sentence:<br />You ________ the cleaning. I would have done it tonight.";
		questionsArray[i][1] = "needn\'t have done";
		questionsArray[i][2] = "couldn\'t have done";
		questionsArray[i][3] = "can\'t have done";
		questionsArray[i][4] = "wouldn\'t have done";
		answersArray[i] = 1;
		i++;
		questionsArray[i] = new Array();
		questionsArray[i][0] = "Please select the best word to complete the following sentence:<br />They have put speed bumps on the road to ________ accidents.";
		questionsArray[i][1] = "avoid";
		questionsArray[i][2] = "prohibit";
		questionsArray[i][3] = "prevent";
		questionsArray[i][4] = "forbid";
		answersArray[i] = 3;
		i++;
		questionsArray[i] = new Array();
		questionsArray[i][0] = "Please select the best word to complete the following sentence:<br />We would never have had the accident if you ________ so fast.";
		questionsArray[i][1] = "wouldn\'t been driving";
		questionsArray[i][2] = "hadn\'t been driving";
		questionsArray[i][3] = "had driven";
		questionsArray[i][4] = "wouldn\'t drive";
		answersArray[i] = 2;
		i++;
		questionsArray[i] = new Array();
		questionsArray[i][0] = "Please select the best word to complete the following sentence:<br />The tree ________ by lightning.";
		questionsArray[i][1] = "was flashed";
		questionsArray[i][2] = "struck";
		questionsArray[i][3] = "was struck";
		questionsArray[i][4] = "flashed";
		answersArray[i] = 3;
		i++;
		questionsArray[i] = new Array();
		questionsArray[i][0] = "Please select the best word to complete the following sentence:<br />If only I ________ richer.";
		questionsArray[i][1] = "am";
		questionsArray[i][2] = "were";
		questionsArray[i][3] = "would be";
		questionsArray[i][4] = "will be";
		answersArray[i] = 2;
		i++;
		questionsArray[i] = new Array();
		questionsArray[i][0] = "Please select the best word to complete the following sentence:<br /> ________ the better team, we lost the match.";
		questionsArray[i][1] = "Despite of being";
		questionsArray[i][2] = "Despite";
		questionsArray[i][3] = "Despite being";
		questionsArray[i][4] = "Although";
		answersArray[i] = 3;
		i++;
		questionsArray[i] = new Array();
		questionsArray[i][0] = "Please select the best word to complete the following sentence:<br />By this time next year, I ________ all my exams.";
		questionsArray[i][1] = "will have taken";
		questionsArray[i][2] = "will take";
		questionsArray[i][3] = "take";
		questionsArray[i][4] = "have taken";
		answersArray[i] = 1;

		 var n = 0;
		 levelArray[n] = new Array();
		 levelArray[n]['lower'] = 0;
		 levelArray[n]['upper'] = 8;
		 levelArray[n]['case'] = 'Your level is approximately <a href="http://www.esl-languages.com/en/study-abroad/adults/levels-and-progression/index.htm">Elementary (A1)</a>';
		 n++;
		 levelArray[n] = new Array();
		 levelArray[n]['lower'] = levelArray[n-1]['upper'] + 1;
		 levelArray[n]['upper'] = 18;
		 levelArray[n]['case'] = 'Your level is approximately <a href="http://www.esl-languages.com/en/study-abroad/adults/levels-and-progression/index.htm">Pre-Intermediate (A1-A2)</a>';
		 n++;
		 levelArray[n] = new Array();
		 levelArray[n]['lower'] = levelArray[n-1]['upper'] + 1;
		 levelArray[n]['upper'] = 28;
		 levelArray[n]['case'] = 'Your level is approximately <a href="http://www.esl-languages.com/en/study-abroad/adults/levels-and-progression/index.htm">Intermediate (A2-B1)</a>';
		 n++;
		 levelArray[n] = new Array();
		 levelArray[n]['lower'] = levelArray[n-1]['upper'] + 1;
		 levelArray[n]['upper'] = 34;
		 levelArray[n]['case'] = 'Your level is approximately <a href="http://www.esl-languages.com/en/study-abroad/adults/levels-and-progression/index.htm">Upper-Intermediate (B1)</a>';
		 n++;
		 levelArray[n] = new Array();
		 levelArray[n]['lower'] = levelArray[n-1]['upper'] + 1;
		 levelArray[n]['upper'] = 40;
		 levelArray[n]['case'] = 'Your level is approximately <a href="http://www.esl-languages.com/en/study-abroad/adults/levels-and-progression/index.htm">Advanced (B2)</a>';
    }();

  }
