var sectionImgs;
var itembank;
var response1;
var response2;
var response3;
var response4;
var response5;
var response6;
var Info;
var Infotext;
	
var questionno 				= 0;
var sectionno 				= 999; 
var instructpage 			= 0;
var incorrectcount 			= 0;
var testnav 				= false;
var gtryagain 				= false;
var gfinish 				= false;
var objclearbutton			= null;
var objbackbutton			= null;
var objCorrect				= null;
var objIncorrect2			= null;
var objIncorrect			= null;
var objforwardbutton		= null;
var objfinishbutton			= null;	
var objinstructbutton		= null;
var objinstructbackbutton	= null;

function SetObjects()
{
	objclearbutton 		  = GetLayer('clearbutton');
	objbackbutton  		  = GetLayer('backbutton');
	objCorrect     		  = GetLayer('Correct');
	objIncorrect2  		  = GetLayer('Incorrect2');
	objIncorrect   		  = GetLayer('Incorrect');
	objforwardbutton 	  = GetLayer('forwardbutton');
	objfinishbutton 	  = GetLayer('finishbutton');
	objinstructbutton 	  = GetLayer('instructbutton');
	objinstructbackbutton = GetLayer('instructbackbutton');
}

function SetFirst(val){firsttime = val;}

function labeltextbits()
{
	Labeltext 	 = new Array;
	Labeltext[0] = "Cubiks online assessment: instructions and practice";
	Labeltext[1] = "Information about the assessment process";
	Labeltext[2] = "Practice online assessment";
	Labeltext[3] = "Practice verbal reasoning test";
	Labeltext[4] = "Further information";		
}

function labelSetUp(nPage)
{	
	if( nPage == 1 ){
		var labelcontent = '<table class="label" cellspacing="0" cellpadding="0" width="480" height="35">';			 
			labelcontent += '<tr height="35"><td width="15">&nbsp;</td>';
   			labelcontent += '<td width="465" class="label">';
			labelcontent += 'Cubiks online assessment: instructions and practice';
			labelcontent += '</td>';
			labelcontent += '</tr>';					
			labelcontent += '</table>';			
	
			SetLayerHtml('labellayer',labelcontent);
			ShowLayer	('labellayer');
	}	
	if( nPage >= 2 && nPage <= 6 ){

		var labelcontent = '<table class="label" cellspacing="0" cellpadding="0" width="480" height="35">';			 
			labelcontent += '<tr height="35"><td width="15">&nbsp;</td>';
   			labelcontent += '<td width="465" class="label">';
			labelcontent += 'Information about the assessment process';
			labelcontent += '</td>';
			labelcontent += '</tr>';					
			labelcontent += '</table>';			
	
			SetLayerHtml('labellayer',labelcontent);
			ShowLayer('labellayer');
	}
	if( nPage == 7 ){

		var labelcontent = '<table class="label" cellspacing="0" cellpadding="0" width="480" height="35">';			 
			labelcontent += '<tr height="35"><td width="15">&nbsp;</td>';
   			labelcontent += '<td width="465" class="label">';
			labelcontent += 'Practice online assessment';
			labelcontent += '</td>';
			labelcontent += '</tr>';					
			labelcontent += '</table>';			
	
			SetLayerHtml('labellayer',labelcontent);
			ShowLayer('labellayer');
	}
	if( nPage == 8 ){

		var labelcontent = '<table class="label" cellspacing="0" cellpadding="0" width="480" height="35">';			 
			labelcontent += '<tr height="35"><td width="15">&nbsp;</td>';
   			labelcontent += '<td width="465" class="label">';
			labelcontent += 'Practice verbal reasoning test';
			labelcontent += '</td>';
			labelcontent += '</tr>';					
			labelcontent += '</table>';			
	
			SetLayerHtml('labellayer',labelcontent);
			ShowLayer('labellayer');
	}
	if( nPage == 9 ){

		var labelcontent = '<table class="label" cellspacing="0" cellpadding="0" width="480" height="35">';			 
			labelcontent += '<tr height="35"><td width="15">&nbsp;</td>';
   			labelcontent += '<td width="465" class="label">';
			labelcontent += 'Further information';
			labelcontent += '</td>';
			labelcontent += '</tr>';					
			labelcontent += '</table>';			
	
			SetLayerHtml('labellayer',labelcontent);
			ShowLayer('labellayer');
	}
}

function OnInstructionPage( nPage )
{
   	var instructs;

	if( nPage == 1 ){
		instructs = '<table width="570"><tr><td>';
		instructs += '<p class="quot2"><b>Some verbal test practice</b></p>';
		instructs += '<p class="quotx">In this test of verbal reasoning you will be asked to read a series of passages of text followed by a number of statements.  Your task is to assess whether each of these statements are either “true”, “false” or “cannot say” in relation to the passage which precedes it.</p>';
		instructs += '<p class="quotx">While taking this practice test:</p>';
		instructs += '<ul><li><span class="quotx">You will need to work both quickly and accurately, so do not ponder on one question for too long.</span></li>'  
		instructs += '<li><span class="quotx">You should assess each statement only in relation to the passage that preceded it and not in relation to any knowledge you might have or any personal views you might hold.</span></li>';		
		instructs += '<li><span class="quotx">You will be given 2 chances to get the answer correct.  If you get it wrong twice, the correct answer and a ‘tip’ are given to help you assess your understanding of the type of questions asked.</span></li></ul>'	
		instructs += '<p class="quotx"><b>We suggest that you time yourself and try to complete the practice questions within 5 minutes.</b>  Timing yourself on the practice test replicates the real testing environment.  If you will be taking the test online, this has a time limit which is controlled by the computer.  If you will be taking the pencil/paper version of the test, you will be timed by your test administrator and advised when the time limit is reached.  In either testing circumstance, full instructions will be given to you before you take the test under timed conditions.</p>';	
		instructs += '<p class="quotx">Click on "Next" to see more instructions about the practice test.</p>';
		instructs += '</td></tr></table>';
				
		questionno = 0;	
	}
	if( nPage == 2 ){
		instructs = '<table width="570"><tr><td>';			
		instructs += '<p class="quot2"><b>Verbal reasoning practice test:</b></p>';
		instructs += '<p class="quotx">So, having read the passage, and the statements that follow it, you would;</p>';
		instructs += '<ul><li><span class="quotx">select option T if you think the statement is true in relation to the passage,</span></li>';
		instructs += '<li><span class="quotx">select option F if you think the statement is false in relation to the passage,</span></li>';		
	  	instructs += '<li><span class="quotx">select option CS if you cannot say whether the statement follows on or not from the passage.</span></li></ul>';
		instructs += '<p class="quotx">Once you have selected what you believe to be the correct answer, indicate this by either:</p>';
		instructs += '<ul><li><span class="quotx">clicking the left-hand mouse button when the pointer is over your selected answer;</span></li>';		
	  	instructs += '<li><span class="quotx">or selecting your answer letter (T, F, C, . . . ) on the keyboard.</span></li></ul>';
		instructs += '<p class="quotx">Your answer will be highlighted in red and a message box will be displayed indicating whether or not you have selected the correct response.</p>';		
	 	instructs += '<p class="quotx">Click on ‘Next’ to see the first of the 8 example practice questions.</p>';
		instructs += '</td></tr></table>';	
	}
	
	if( nPage == 3){
		instructs = ' ';
		SetVisibility( true );
		StartItemPages();
	}else {
		SetLayerHtml('InstructionPage',instructs);
		ShowLayer('InstructionPage');
  		instructpage = nPage;
		SetVisibility( false );   
	}	
	instructpage = nPage;
	labelSetUp(nPage);
}


function InstructNext(direction)
{
	OnInstructionPage( instructpage + direction );		
}

function keyDown(e)
{  	     
    var key_press = GetKeypressed(e)
	
    if( instructpage < 3 ){
	    if( key_press == 13 || key_press == 34 || key_press == 39){
			if(IsLayerVisible('instructbutton')){
				InstructNext(1);	
				return;
			}	
		}
		
	    if( key_press == 33 || key_press == 37){
			if(IsLayerVisible('instructbackbutton')){			
				InstructNext(-1);
				return;
			}
		}
	}					

    if( instructpage >= 3 ){  
	   if( key_press == 13 || key_press == 34 || key_press == 39){ //enter, pagedn or right arrow
			if(IsLayerVisible('forwardbutton')){
				MoveQuestion(1);				
				return;
			}

	   		if(IsLayerVisible('finishbutton')){
				ClearCorrect();
				return;
			}						
	   }
	   if( key_press == '67' || key_press == '70' || key_press == '84' || key_press == '99' || key_press == '102' || key_press == '116' ){ //C, F or T
				var ans;
				if( key_press == '67' || key_press == '99' )
							ans = 3;
				if( key_press == '70' || key_press == '102' )
							ans = 2;
				if( key_press == '84' || key_press == '116' )
							ans = 1;				
				SetAnswer(itemBank[questionno].itemindex, ans)
				return;
	   }
	   //if( key_press == 99 || key_press == 102 || key_press == 116 ){ //c, f or t
		//		SetAnswer(itemBank[questionno].itemindex, parseInt(key_press)-98)
		//		return;
	   //}
	}
	
    if( instructpage >= 3 && questionno == 7 ){  
	   if( key_press == 13 || key_press == 34 || key_press == 39){ //enter, pagedn or right arrow
			if(IsLayerVisible('finishbutton')){
				FinishQuestion();
				return;
			}			
	   }
	}  								
}

function StartQuestionnaire()
{   
 	onfocus="instructbutton.focus()"

	SetKeypressedFunc(keyDown);
	SetObjects();						
	questionSetup();
	InstructNext(1);
}

function DoResize()
{
	if( instructpage < 10 ){
		SetVisibility( false );
		OnInstructionPage(instructpage);
	}
	else {
		SetVisibility( true );
		MoveQuestion(0);
	}
}

function SetVisibility( state )
{
	if( state == true ){
		HideLayer('InstructionPage');
		HideLayer('instructbutton');
		HideLayer('instructbackbutton');					
		HideLayer('CubiksCurvelayer');
		HideLayer('labellayer');
		HideLayer('Correct');
		HideLayer('Incorrect');				
		ShowLayer('qlayer');
		ShowLayer('qtoplayer');
		ShowLayer('sectdisp');
		ShowLayer('numberon');
		ShowLayer('backbutton');
		HideLayer('clearbutton');
		HideLayer('forwardbutton');
		HideLayer('finishbutton');
		HideLayer('Finishpanel');				
	}else {
		ShowLayer('InstructionPage');     			
	
		if(instructpage!=9)
			ShowLayer('instructbutton');
	
		if(instructpage==9)
			HideLayer('instructbutton');
	
		if(instructpage!=1)
			ShowLayer('instructbackbutton');
	
		if(instructpage==1)
			HideLayer('instructbackbutton');												
	
		ShowLayer('labellayer');
		HideLayer('qlayer')
		HideLayer('qtoplayer');
		HideLayer('sectdisp');
		HideLayer('numberon');
		HideLayer('backbutton');
		HideLayer('forwardbutton');
		HideLayer('Finishpanel');
		HideLayer('Correct');
		HideLayer('Incorrect');
		HideLayer('clearbutton');		
	}
}

function navigationSetUp()
{
	nextNormal 		= "vimages/bnext.gif";
	nextOver 		= "vimages/rnext.gif";
	prevNormal 		= "vimages/bprev.gif";
	prevOver 		= "vimages/rprev.gif";
	finishNormal 		= "vimages/bfinish.gif";
	finishOver 		= "vimages/rfinish.gif";
	tryagainNormal 		= "vimages/btryagain.gif";
	tryagainOver 		= "vimages/rtryagain.gif";
	previousNormal 		= "vimages/bprev.gif";
	previousOver 		= "vimages/rprev.gif";
	clearNormal 		= "vimages/bclear.gif";
	clearOver 		= "vimages/rclear.gif";	
}


function popupInfo( correctletter, poptiptext )
{
		this.correctletter = correctletter;
		this.poptiptext	   = poptiptext;
}


function popupInfoSetUp()
{
	Info = new Array;	
	Info[0] = new popupInfo( "True","Tip: Gym charges change depending on where the gym is.");
	Info[1] = new popupInfo( "False","Tip: Read the first sentence carefully.");
	Info[2] = new popupInfo( "Cannot say","Tip: The cost of the gym can change.");
	Info[3] = new popupInfo( "False","Tip: Read the third sentence of the passage carefully.");	
	Info[4] = new popupInfo( "True","Tip: Check when the green breakout rooms can be booked.");	
	Info[5] = new popupInfo( "True","Tip: Read the fourth sentence of the passage carefully.");
	Info[6] = new popupInfo( "Cannot say","Tip: Does the paragraph say how many rooms of each type are available?");	
	Info[7] = new popupInfo( "False","Tip: Check the last sentence of the paragraph.");	
}


function textbits()
{
	Infotext = new Array;
	Infotext[0] = " is the correct response. Well done!"
	Infotext[1] = " is the correct response."
	Infotext[2] = "Please spend some time working through why answer "
	Infotext[3] = " is the correct one. Click 'Clear' to remove this message and when you fully understand why " 
	Infotext[4] = " is correct, click 'Next' to continue."
	Infotext[5] = "Please click on ‘Next’ to proceed to the next question."
	Infotext[6] = "Click 'Finish' to continue."
	Infotext[7] = "Please click on ‘Finish’ to proceed to the final page."
	Infotext[8] = " is correct, click 'Finish' to continue."				
}


function responseItem( tdwidth, tagid, response, answered, correct )
{
	this.tdwidth 		  = tdwidth;
	this.tagid 		  = tagid;
	this.response 		  = response;
	this.answered 		  = answered;
	this.correct 		  = correct;
}


function responseSetUp()
{
	response1 = new Array;
	response1[0] = new responseItem(80,1,"<b>T&nbsp;</b> True",false,true);
	response1[1] = new responseItem(80,2,"<b>F&nbsp;</b> False",false,false);
	response1[2] = new responseItem(100,3,"<b>C&nbsp;</b> Cannot Say",false,false);
	
	response2 = new Array;
	response2[0] = new responseItem(80,1,"<b>T&nbsp;</b> True",false,false);
	response2[1] = new responseItem(80,2,"<b>F&nbsp;</b> False",false,true);
	response2[2] = new responseItem(100,3,"<b>C&nbsp;</b> Cannot Say",false,false);
	
	response3 = new Array;
	response3[0] = new responseItem(80,1,"<b>T&nbsp;</b> True",false,false);
	response3[1] = new responseItem(80,2,"<b>F&nbsp;</b> False",false,false);
	response3[2] = new responseItem(100,3,"<b>C&nbsp;</b> Cannot Say",false,true);
	
	response4 = new Array;
	response4[0] = new responseItem(80,1,"<b>T&nbsp;</b> True",false,false);
	response4[1] = new responseItem(80,2,"<b>F&nbsp;</b> False",false,true);
	response4[2] = new responseItem(100,3,"<b>C&nbsp;</b> Cannot Say",false,false);
	
	response5 = new Array;
	response5[0] = new responseItem(80,1,"<b>T&nbsp;</b> True",false,true);
	response5[1] = new responseItem(80,2,"<b>F&nbsp;</b> False",false,false);
	response5[2] = new responseItem(100,3,"<b>C&nbsp;</b> Cannot Say",false,false);
	
	response6 = new Array;
	response6[0] = new responseItem(80,1,"<b>T&nbsp;</b> True",false,true);
	response6[1] = new responseItem(80,2,"<b>F&nbsp;</b> False",false,false);
	response6[2] = new responseItem(100,3,"<b>C&nbsp;</b> Cannot Say",false,false);
	
	response7 = new Array;
	response7[0] = new responseItem(80,1,"<b>T&nbsp;</b> True",false,false);
	response7[1] = new responseItem(80,2,"<b>F&nbsp;</b> False",false,false);
	response7[2] = new responseItem(100,3,"<b>C&nbsp;</b> Cannot Say",false,true);
	
	response8 = new Array;
	response8[0] = new responseItem(80,1,"<b>T&nbsp;</b> True",false,false);
	response8[1] = new responseItem(80,2,"<b>F&nbsp;</b> False",false,true);
	response8[2] = new responseItem(100,3,"<b>C&nbsp;</b> Cannot Say",false,false);								
}


function questionItem( itemindex, section, questiontxt, responsechoices, answer, flags )
{
	this.itemindex = itemindex;
    	this.section = section;
	this.questiontxt = questiontxt;
	this.responsechoices = responsechoices;
	this.answer = answer;
    	this.flags = flags;
}


function questionSetup()
{
	navigationSetUp();

//	sectionSetUp();

	responseSetUp();
	
	popupInfoSetUp();
	
	textbits();
	
	labeltextbits();

	itemBank = new Array;
 
itemBank[0] = new questionItem( 1,1,"1. The cost of the regular gym subscription fee is variable",response1,0,0);
	
itemBank[1] = new questionItem( 2,1,"2. The healthcare scheme is only available to a small number of employees.",response2,0,0);

itemBank[2] = new questionItem( 3,1,"3. The monthly cost of gym membership is more than $45.",response3,0,0);

itemBank[3] = new questionItem( 4,1,"4. The activation fee is payable annually.",response4,0,0);

itemBank[4] = new questionItem( 5,2,"5. It is not possible to book all the meeting rooms in advance.",response5,0,0);

itemBank[5] = new questionItem( 6,2,"6. It is necessary to give notice of a request for refreshments.",response6,0,0);

itemBank[6] = new questionItem( 7,2,"7. There are more rooms available for advance booking than rooms which can be used without notice.",response7,0,0);

itemBank[7] = new questionItem( 8,2,"8. Those who ask for last minute help with technology are attended to as fast as those who ordered their equipment in advance.",response8,0,0);
}


function Popup()
{	
	var quest = questionno;
	
	var Popupcontent = '<table class="quot2" border="1" cellpadding=10 cellspacing=0 bordercolor="#000000" width="499" height="70" bgcolor="#FDDBD9">';			 
		Popupcontent += '<tr height="70">';		
   		Popupcontent += '<td width="499" class="quot2">';
		Popupcontent += Info[quest].correctletter + Infotext[0];
		Popupcontent += '<p>';			
		Popupcontent += Infotext[5];
		Popupcontent += '</td>';
		Popupcontent += '</tr>';								
		Popupcontent += '</table>';			
	
		SetLayerHtml('Correct',Popupcontent);
		ShowLayer('Correct');
}

function PopupQuest5()
{	
	var quest = questionno;
	
	var Popupcontent = '<table class="quot2" border="1" cellpadding=10 cellspacing=0 bordercolor="#000000" width="499" height="70" bgcolor="#FDDBD9">';
		Popupcontent += '<tr height="70">';			 
   		Popupcontent += '<td width="499" class="quot2">';
		Popupcontent += Info[quest].correctletter + Infotext[0];
		Popupcontent += '<p class="quot2">';
		Popupcontent += Infotext[6];
		Popupcontent += '</td>';
		Popupcontent += '</tr>';								
		Popupcontent += '</table>';			
	
		SetLayerHtml('Correct',Popupcontent);
		ShowLayer('Correct');
}

function PopupIncorrect()
{	
	var questno = questionno
			
	var Popupincorrect = '<table class="quot2" border="1" cellpadding=10 cellspacing=0 bordercolor="#000000" width="499" height="100" bgcolor="#FDDBD9">';			 
		Popupincorrect += '<tr height="100">';
		Popupincorrect += '<td width="499" class="quot2">';			
		Popupincorrect += Info[questno].correctletter + Infotext[1];						 
		Popupincorrect += '<p>';			
		Popupincorrect += Infotext[2] + Info[questno].correctletter + Infotext[3] + Info[questno].correctletter + Infotext[4];
		Popupincorrect += '<p>';			
		Popupincorrect += Info[questno].poptiptext;
		Popupincorrect += '</td>';
		Popupincorrect += '</tr>';						
		Popupincorrect += '</table>';													

		SetLayerHtml('Incorrect2',Popupincorrect);
		ShowLayer('Incorrect2');
}

function PopupIncorrectQuest5()
{	
	var questno = questionno
			
	var Popupincorrect = '<table class="quot2" border="1" cellpadding=10 cellspacing=0 bordercolor="#000000" width="499" height="100" bgcolor="#FDDBD9">';			 
		Popupincorrect += '<tr height="100">';
		Popupincorrect += '<td width="499" class="quot2">';			
		Popupincorrect += Info[questno].correctletter + Infotext[1];			
		Popupincorrect += '<p>';			 			
		Popupincorrect += Infotext[2] + Info[questno].correctletter + Infotext[3] + Info[questno].correctletter + Infotext[8];
		Popupincorrect += '<p>';			
		Popupincorrect += Info[questno].poptiptext;
		Popupincorrect += '</td>';
		Popupincorrect += '</tr>';						
		Popupincorrect += '</table>';													

		SetLayerHtml('Incorrect2',Popupincorrect);
		ShowLayer('Incorrect2');
}

function StartItemPages()
{
// 	var d;
//  d = new Date();
  	testnav = true;
	MoveQuestion(0);
}

function PresentQuestion( questionindex )
{	
	var itemcontentQuest = '<div align="center"><center><table border="0" cellspacing="3" cellpadding="5" width="605"><tr align="left" valign="middle">'; 
	   	itemcontentQuest += '<td colspan="5" class="quote">'; 
		itemcontentQuest += itemBank[questionindex].questiontxt;
		itemcontentQuest += '</td></tr>';
		itemcontentQuest += '</table></center></div>';
		
		SetLayerHtml('qtoplayer',itemcontentQuest);
		ShowLayer('qtoplayer');

	var itemcontent = '<div align="center"><center><table border="0" cellspacing="3" cellpadding="5" width="450"><tr align="left" valign="middle">'; 
		itemcontent += '<tr align="left" valign="bottom">';
	for( var i = 0; i < 3; i++ ){
	
		var isresponseactive = (itemBank[questionindex].responsechoices[i].tagid > 0 )?true:false;

		itemcontent += '<td width="30">&nbsp;</td>';
		itemcontent += '<td width="' + itemBank[questionindex].responsechoices[i].tdwidth + '">';

		var isresponseactive = (itemBank[questionindex].responsechoices[i].tagid > 0 )?true:false;
		
		if( isresponseactive ){				
			itemcontent += '<a href="javascript:SetAnswer('				
			itemcontent += itemBank[questionindex].itemindex;
			itemcontent += ',';
			itemcontent += itemBank[questionindex].responsechoices[i].tagid;
			itemcontent += ')" ';
			
			if( itemBank[questionindex].responsechoices[i].answered == true ){
				if (!IsNS4())
					itemcontent += '><span class="answerbox"';
				else
					itemcontent += 'class="answerbox"';
				}															
				itemcontent += '>';
		}
			itemcontent += itemBank[questionindex].responsechoices[i].response;
			if( isresponseactive ){
				if (!IsNS4())
				 	itemcontent += '</span>';

				itemcontent += '</a>';
			}
			itemcontent += '</td>';
			itemcontent += '<td width="30">&nbsp;</td>';
	}
	itemcontent += '</tr></table></center></div>';
	
	SetSection( itemBank[questionindex].section );
	SetLayerHtml('qlayer',itemcontent);
	ShowLayer('qlayer');
	SetLayerPixLeft('qlayer',54)
	SetLayerPixTop('qlayer',414)  
	SetLayerPixLeft('qtoplayer',58)
	SetLayerPixTop('qtoplayer',364) 	
	
	for(i=0; i<3; i++){
		if(itemBank[7].responsechoices[i].answered == true && itemBank[questionindex].responsechoices[i].correct == false && gtryagain == true){
			HideLayer('finishbutton');
			HideLayer('forwardbutton');
		}	
		if(itemBank[questionno].responsechoices[i].answered == true && itemBank[questionindex].responsechoices[i].correct == false && gtryagain == true){
			HideLayer('Incorrect2');
			if(IsLayerHidden('Incorrect2'))
				ShowLayer('forwardbutton');	
		}	
	}
}	

function SetSection( sectionid )
{
	var section1Cont = '<table border="1" cellspacing="0" cellpadding="10" width="483" height="171" bgcolor="#EAE8E8">';
 	section1Cont += '<tr height="106">';
	section1Cont += '<td width="453">';
	section1Cont += '<span class="quotxjustify"><p>Memo to Administration Staff<p>Our healthcare scheme has benefits for all our employees.  One of these is reduced gym subscriptions.<p>To take advantage of this you will first need to pay a one-off activation fee of $45 to join the gym.  Then you will pay a monthly membership fee.  How much you pay each month depends on the location of the gym you choose to join and how many active lifestyle points you have accumulated whilst you have been a member of the healthcare scheme.</p></span>';
	section1Cont += '</td>';   
	section1Cont += '</tr>';						
	section1Cont += '</table>';

	var section2Cont = '<table border="1" cellspacing="0" cellpadding="10" width="483" height="171" bgcolor="#EAE8E8">';
	section2Cont += '<tr height="106">';
	section2Cont += '<td width="453">';
	section2Cont += '<span class="quotxjustify"><p>Memo from the Centre Manager<p>You are reminded that most meeting rooms must be booked in advance.  The Boardroom and the Serenity Suite rooms can be booked up to 25 days in advance.  The Green breakout rooms are only available for spontaneous meetings and cannot be booked.<p>Refreshments for your meeting can be ordered through our online booking system as long as at least two days notice is given.  There is a range of audiovisual and computer equipment available.  Again, these must be booked ahead through our online booking system.  Our technology technicans are happy to help with queries if you are not sure which equipment wil best suit your needs.  Please phone them well before your meeting.  When setting up equipment they will prioritise arrangements for those who gave the most advance notice.</p></span>';
	section2Cont += '</td>';   
	section2Cont += '</tr>';                                    
	section2Cont += '</table>';   
	
	
	if( itemBank[questionno].section == 1 ){	
		SetLayerHtml('sectdisp',section1Cont);
		ShowLayer('sectdisp');				
	}

	if( itemBank[questionno].section == 2 ){  
        	SetLayerHtml('sectdisp',section2Cont);
        	ShowLayer('sectdisp');                    
      }                 
			
}


function SwapNext( onover )
{
	if( document.images ){
            var obj;
			if( !IsNS4() )
				obj = document.images["gnext"];
			else  
				obj = document.forwardbutton.document.images["gnext"];
			
			obj.src = (onover == true)?nextOver:nextNormal;		
	}
}


function SwapClear( onover )
{
	if( document.images ){
            var obj;
			if( !IsNS4() )
				obj = document.images["gclear"];
			else  
				obj = document.backbutton.document.images["gclear"];
			
			obj.src = (onover == true)?clearOver:clearNormal;
	}
}


function SwapTryAgain( onover )
{
	if( document.images ){
            var obj;
			if( !IsNS4() )
				obj = document.images["gtryagain"];
			else  
				obj = document.backbutton.document.images["gtryagain"];
			
			obj.src = (onover == true)?tryagainOver:tryagainNormal;
	}
}


function SwapPrevious( onover )
{
	if( document.images ){
            var obj;
			if( !IsNS4() )
				obj = document.images["gprevious"];
			else  
				obj = document.backbutton.document.images["gprevious"];
			
			obj.src = (onover == true)?previousOver:previousNormal;
	}	
}


function SwapInstructPrev( onover )
{
	if( document.images ){
            var obj;
			if( !IsNS4() )
				obj = document.images["ginstback"];
			else  
				obj = document.instructbackbutton.document.images["ginstback"];
			
			obj.src = (onover == true)?prevOver:prevNormal;
	}
}


function SwapInstructNext( onover )
{
	if( document.images ){
            	var obj;
			if( !IsNS4() )
				obj = document.images["ginst"];
			else  
				obj = document.instructbutton.document.images["ginst"];
			
			obj.src = (onover == true)?"vimages/rnext.gif":"vimages/bnext.gif";		
	}
}


function SwapFinish( onover )
{
	if( document.images ){	
	var obj;
			if( !IsNS4() )
				obj = document.images["gfinish"];
			else  
				obj = document.finishbutton.document.images["gfinish"];
			
			obj.src = (onover == true)?finishOver:finishNormal;
	}
}
			

function MoveQuestion( direction )
{
	HideLayer('objforwardbutton');
	HideLayer('objbackbutton');	
	HideLayer('objCorrect');
	HideLayer('objIncorrect2');
		
	if( testnav == false )
		return;		

	var newquestionno = questionno + direction;
	if( newquestionno > (itemBank.length-1) )
		newquestionno = (itemBank.length-1);		
			
   	if( newquestionno < 0 )
		newquestionno = 0;
				
	if( newquestionno > 7 )
		FinishQuestion(); 

	if(IsLayerVisible('objclearbutton')) {
		HideLayer('objbackbutton');
		HideLayer('objclearbutton');
	}
	if(IsLayerVisible('objCorrect')) {
		HideLayer('objIncorrect2');
		HideLayer('objIncorrect');
		HideLayer('objCorrect');
		HideLayer('objbackbutton');			
	}
	if(IsLayerVisible('objIncorrect2')) {
		HideLayer('objIncorrect2');
		HideLayer('objIncorrect');
		HideLayer('objCorrect');
		HideLayer('objbackbutton');			
	}
																				
   	questionno = newquestionno;
	incorrectcount = 0;
   	PresentQuestion( questionno );
	SetNumberon( questionno+1 );
//	ClearCorrect();
	ClearBtns();
	gtryagain = false;			
}

function SetNumberon( number )
{
	var numbercontent = '<table class="label" cellspacing="0" cellpadding="0" width="670" height="35">';			 
		numbercontent += '<tr height="35"><td width="15">&nbsp;</td>';
		numbercontent += '<td width="645" class="label">';
		numbercontent += '<span class="title">Example practice question&nbsp;' + number + '&nbsp;of&nbsp;8</span>';
		numbercontent += '</td>';
		numbercontent += '</tr>';					
		numbercontent += '</table>';
			
	SetLayerHtml('numberon',numbercontent);
	ShowLayer('numberon');
}

function SetAnswer( questionid ,itemid )
{						
	if (incorrectcount >= 2 )
		return;

	if (IsLayerVisible('objbackbutton') || IsLayerVisible('objclearbutton'))
		return;
			
	if (IsLayerVisible('objforwardbutton') || IsLayerVisible('objfinishbutton'))
		return;	
			
	var iscorrect 	  = false;	
	var questionindex = questionid - 1;		
	
	itemBank[0].answered = 0;
		
	if( itemBank[questionindex].answer != itemid ){
		itemBank[questionindex].answer = itemid;
				
		for( var i = 0; i < 3; i++ ){				
			if(itemBank[questionindex].responsechoices[i].tagid == itemid){
			 	itemBank[questionindex].responsechoices[i].answered = true;
				iscorrect = itemBank[questionindex].responsechoices[i].correct;
			}else{
				itemBank[questionindex].responsechoices[i].answered = false;				
			}	
		}	
		PresentQuestion(questionindex);		
						
		if( iscorrect == true ){								
			ShowLayer('objCorrect');
			HideLayer('objbackbutton');
			HideLayer('objIncorrect');
			HideLayer('objIncorrect2');
								
			ShowLayer('objforwardbutton');
			incorrectcount = 2;							
			Popup();
			
			if (questionno == 7){
				ShowLayer('objfinishbutton');
				PopupQuest5();				
			}	
			else
				HideLayer('objfinishbutton');			
		}
		if( iscorrect == false ){				
			ShowLayer('objIncorrect');
			ShowLayer('objbackbutton');
			HideLayer('objIncorrect2');
			HideLayer('objclearbutton');	
			HideLayer('objforwardbutton');							
			HideLayer('objCorrect');

			if(gtryagain == false)
				incorrectcount = 2;																							
		}
		if( iscorrect == false && gtryagain == true ){							
			ShowLayer('objclearbutton');
			ShowLayer('objIncorrect2');
			HideLayer('objbackbutton');
			HideLayer('objIncorrect');
			HideLayer('objforwardbutton');							
			HideLayer('objCorrect');
							
			if(gtryagain == true)
				incorrectcount = 2;							

			PopupIncorrect();
			
			if (questionno == 7){
				PopupIncorrectQuest5();
			}	
			else
				HideLayer('objfinishbutton');			
		}									
	}
}

function CloseLayer()
{
//	alert("Close");
	incorrectcount = 0;
	if(IsLayerVisible('objIncorrect')) {
		HideLayer('objIncorrect');
		HideLayer('objIncorrect2')
		gtryagain = true;			
	}
	if(IsLayerHidden('objIncorrect')) {
		HideLayer('objbackbutton');
		gtryagain = true;			
	}
	ClearBtns();
}

function CloseClearBtnLayer()
{
	if(IsLayerVisible('objIncorrect2')) {
		HideLayer('objIncorrect2');
		HideLayer('objbackbutton');
		HideLayer('objfinishbutton');
		HideLayer('objforwardbutton');							
		ShowLayer('objclearbutton');						
		gtryagain = true;			
	}
	if(IsLayerVisible('objIncorrect2') && questionno == 7) {
		HideLayer('objfinishbutton');
		HideLayer('objIncorrect2');
		HideLayer('objbackbutton');
		HideLayer('objforwardbutton');				
		ShowLayer('objclearbutton');						
		gtryagain = true;
	}
				
	if(IsLayerHidden('objIncorrect2')) {
		HideLayer('objclearbutton');		
		ShowLayer('objforwardbutton');				
		gtryagain = true;			
	}	

	if(IsLayerHidden('objIncorrect2') && questionno == 7) {
		HideLayer('objclearbutton');
		HideLayer('objforwardbutton');
		ShowLayer('objfinishbutton');						
		gtryagain = true;			
	}	
	ClearBtns();
}


function ClearBtns()
{	
	for(i=0; i<3; i++){
		if(gtryagain == true)
			itemBank[questionno].responsechoices[i].answered = false;
	}
	gtryagain == false;
	PresentQuestion( questionno );							
}

function ClearCorrect()
{	
	gfinish = true;

	for(i=0; i<8; i++){	
		for(j=0; j<3; j++){
			if(gfinish == true)
				itemBank[i].responsechoices[j].answered = false;
		}
	itemBank[i].answer = 0
	}
	FinishQuestion();								
}
	  
function FinishQuestion() 
{
	testnav = false;
			
	ShowLayer('Finishpanel');
	HideLayer('qlayer');
	HideLayer('sectdisp');
	HideLayer('numberon');
	HideLayer('backbutton');
	HideLayer('finishbutton');
	HideLayer('forwardbutton');
	ShowLayer('CubiksCurvelayer');			
	ShowLayer('labellayer');
	HideLayer('InstructionPage');			
	HideLayer('Incorrect2');
	HideLayer('instructbackbutton');
	HideLayer('instructbutton');
	HideLayer('Correct');						
	HideLayer('Incorrect');
	HideLayer('clearbutton');
	HideLayer('qtoplayer');			
	
	var labelcontent = '<table class="label" cellspacing="0" cellpadding="0" width="480" height="35">';			 
		labelcontent += '<tr height="35"><td width="15">&nbsp;</td>';
		labelcontent += '<td width="465" class="label">';
		labelcontent += Labeltext[4];
		labelcontent += '</td>';
		labelcontent += '</tr>';					
		labelcontent += '</table>';			

	SetLayerHtml('labellayer',labelcontent);
	ShowLayer('labellayer');
		
	MoveQuestion(0);
}
