

<!--

//array of questions

var whichquest;					//indicates current question	

var optans= new Array(20);		//holds all the answers

var correct= new Array(5);		//holds a number indicating correct answers

var quest= new Array(5);		//holds all the questions

var timerID = null;				//a check value for the timer

var countdown;					//holds value for the timer

var pos;						//holds current position of footballer;

var finished=false;				//a check for whether quiz is finished;

var picq1 = new Image();		//arrays for the images

var picq2 = new Image();

var picq3 = new Image();

var picq4 = new Image();

var picq5 = new Image();

var startimg = new Image();		// variable to re-load startbutton image

//QUESTIONS AND ANSWERS GO BELOW HERE

//for question 1

picq1.src="http://www.chinadaily.com.cn/image_lt/bbc_content_images/blank_image.gif";

quest[0]="1. If somebody says, 'Good afternoon', you say?";



correct[0]=2;

optans[0]="Good morning";

optans[1]="Good evening";

optans[2]="Good afternoon";

optans[3]="Good night";



//for question 2

picq2.src="http://www.chinadaily.com.cn/image_lt/bbc_content_images/blank_image.gif";

quest[1]="2. What is the correct spelling of the word below?";



correct[1]=0;

optans[4]="alright";

optans[5]="allright";

optans[6]="alrite";

optans[7]="aright";



//for question 3

picq3.src="http://www.chinadaily.com.cn/image_lt/bbc_content_images/blank_image.gif";

quest[2]="3. Which sentence is correct?";



correct[2]=1;

optans[8]="How you?";

optans[9]="How are you?";

optans[10]="How you are?";

optans[11]="How you are doing?";



//for question 4

picq4.src="http://www.chinadaily.com.cn/image_lt/bbc_content_images/blank_image.gif";

quest[3]="4.What is the correct answer to the question, 'How are you?'";



correct[3]=0;

optans[12]="Very well";

optans[13]="I well";

optans[14]="Very bad";

optans[15]="Very alright";



 

//for question 5

picq5.src="http://www.chinadaily.com.cn/image_lt/bbc_content_images/blank_image.gif";

quest[4]="5. Which sentence is NOT correct?";



correct[4]=2;

optans[16]="I'm fine, thanks";

optans[17]="I'm very well, thanks";

optans[18]="I'm hi, thanks";

optans[19]="I'm not bad";





// TIMER SCRIPT



//this function stops the clock - if clock isn't stopped, timer sometimes gets confused

function stopclock (){

 	clearTimeout(timerID);		//stop latest call to fundtion showtime

	finished=false;				//quiz is finished

}





//this function displays the countdown clock & checking the results

function showtime () {

	document.countme.src="http://www.chinadaily.com.cn/image_lt/bbc_content_images/countdown" + countdown + ".gif";		//changes the clock image



	if (countdown==0) 	{		//if timer has reached 0 then stop the quiz and display appropriate image

		document.images.pos5.src="http://www.chinadaily.com.cn/image_lt/bbc_content_images/out_of_time.gif";

		finished=false;								//quiz finished so disables clicking on answers   

 		return;

						}

   	else    {

		timerID = setTimeout("showtime()",1000); 	//recalls this function after 1 second

		countdown--;								//reduces the timer value by 1

			}

}



//this function lists the question and possible answers

function listquests (num) {

var mult;

mult=num+1;

mult2=num*4;



//displays appropriate picture to go with quiz question

if (mult==1) {

	document.images.somepics.src=picq1.src; }

if (mult==2) {

	document.images.somepics.src=picq2.src; }

if (mult==3) {

	document.images.somepics.src=picq3.src; }

if (mult==4) {

	document.images.somepics.src=picq4.src; }

if (mult==5) {

	document.images.somepics.src=picq5.src; }



	document.quiz.questions[0].value=quest[num];  	//displays question



for (i=1; i<=4; i++) {							//displays four answers and sets them all to false

	document.quiz.questions[i].value=optans[(i-1)+mult2];

    document.quiz.answer[i-1].checked=false;

}

}



//this function checks which answer user has clicked and responds appropriately

function checkanswers() {

if (!finished) {						//stops users clicking on possible responses after quiz finished

	return;

}

mult2=(whichquest)*4;

ans=correct[whichquest];					//locates which is the correct radio button to have clicked



if (document.quiz.answer[ans].checked) {  	//has the user selected the right answer?

	if (pos==1) {						  	//if yes, move the 'footballer' forward

		document.images.pos1.src="http://www.chinadaily.com.cn/image_lt/bbc_content_images/blank_game_frame95x60.gif";

		document.images.pos2.src="http://www.chinadaily.com.cn/image_lt/bbc_content_images/swimmer_frame_2.gif";

	}

	if (pos==2) {

		document.images.pos2.src="http://www.chinadaily.com.cn/image_lt/bbc_content_images/blank_game_frame95x60.gif";

		document.images.pos3.src="http://www.chinadaily.com.cn/image_lt/bbc_content_images/swimmer_frame_3.gif";

    }         

	if (pos==3) {						//if this is the third correct answer the user has won

		document.images.pos3.src="http://www.chinadaily.com.cn/image_lt/bbc_content_images/blank_game_frame95x60.gif";

		document.images.pos4.src="http://www.chinadaily.com.cn/image_lt/bbc_content_images/swimmer_frame_4.gif";

		document.images.pos5.src="http://www.chinadaily.com.cn/image_lt/bbc_content_images/win.gif";

		stopclock();					//stops the timer and so ends the quiz

		return;

		

	} 

	pos++;   

}

else 	{					//if the answer was wrong, don't change anything unless

	wrong++;

	if (wrong==3) {			//two questions wrong so displays approriate images

		if (pos==1) {		//the images to change depend upon whether the 'footballer' is currently

		document.images.pos1.src="http://www.chinadaily.com.cn/image_lt/bbc_content_images/swimmer_frame_1.gif";

					}

		if (pos==2) {

			document.images.pos2.src="http://www.chinadaily.com.cn/image_lt/bbc_content_images/swimmer_frame_2.gif";

					}

		if (pos==3){

			document.images.pos3.src="http://www.chinadaily.com.cn/image_lt/bbc_content_images/swimmer_frame_3.gif";

					}

	document.images.pos4.src="http://www.chinadaily.com.cn/image_lt/bbc_content_images/blank_game_frame95x60.gif";

	document.images.pos5.src="http://www.chinadaily.com.cn/image_lt/bbc_content_images/lose.gif";

	stopclock();						//stops the timer and so ends the quiz

	return;

		}

}



if (whichquest<5)       {		//if game not over, check if all the questions have been attempted

	whichquest++;				//moves to the next question

	listquests(whichquest);		//if they haven't then display the next set of questions

}

else  {							//all questions have been answered quiz ends with appropriate answer

	

	if (pos==1) {

		document.images.pos1.src="http://www.chinadaily.com.cn/image_lt/bbc_content_images/dribble_sad.jpg";

				}

	if (pos==2) {

		document.images.pos2.src="http://www.chinadaily.com.cn/image_lt/bbc_content_images/dribble_sad.jpg";

				}

	if (pos==3)	{

		document.images.pos3.src="http://www.chinadaily.com.cn/image_lt/bbc_content_images/dribble_sad.jpg";

				}

	document.images.pos4.src="http://www.chinadaily.com.cn/image_lt/bbc_content_images/goalie_saved.jpg";

	document.images.pos5.src="http://www.chinadaily.com.cn/image_lt/bbc_content_images/lose.gif";

    stopclock();				//stops the timer and so ends the quiz



					}

}



//this function sets up all the variables and then starts the quiz

function startit() 				

{

whichquest=0;					//indicates the current question

countdown=30;					//the countdown timer - 30 seconds for this game

pos=1;							//holds the current position of the 'footballer'

wrong=0;						//number of questions currently got wrong



document.images.pos1.src="http://www.chinadaily.com.cn/image_lt/bbc_content_images/swimmer_frame_1.gif";	//resets all the graphics of the game

document.images.pos2.src="http://www.chinadaily.com.cn/image_lt/bbc_content_images/blank_game_frame95x60.gif";

document.images.pos3.src="http://www.chinadaily.com.cn/image_lt/bbc_content_images/blank_game_frame95x60.gif";

document.images.pos4.src="http://www.chinadaily.com.cn/image_lt/bbc_content_images/blank_game_frame95x60.gif";

document.images.pos5.src="http://www.chinadaily.com.cn/image_lt/bbc_content_images/clear.gif";



stopclock();					//stops the timer - if not included. timer sometimes speeds up

finished=true;					//check whether all questions answered and so quiz over

listquests(0);					//displays the first quesion and answer

showtime();						//displays and starts the timer

}



//-->


