function Question (qname,
type,
qstring,
response,
comment,
corrects,
explan,
score,
ifcorrect,ifwrong,ifnull,
img)
{this.qname=qname;
this.type=type;
this.qstring=qstring;
this.response=response;
this.comment=comment;
this.corrects=corrects;
this.explan=explan;
this.score=score;
this.ifcorrect=ifcorrect;
this.ifwrong=ifwrong;
this.ifnull=ifnull;
this.img=img;
}

var zin=1,top=0, mycount=0, waitTime=3420, qright=0, mycomment;
var global=new Array(3);
var recent, recent2, recdone=false, opera7, opera=CheckOpera56();
function cachewrite(s,idx){global[idx]+=s;}
function CheckOpera56()
{
var version;
if (navigator.userAgent.toLowerCase().indexOf('opera') == -1) return false;
version=parseInt(navigator.appVersion.toLowerCase());
if (version>6) {opera7=true; return false;}
if (version<5) return false;
return true;
}
resp=new Array("To help you slow down quickly when you brake","To help prevent wheelspin","So that wheelspin does not cause your engine to run too fast","To leave a lower gear available in case of wheelspin")
corr=new Array("0","1","0","0")
comm=""
valu=""
quest001 = new Question(
"Question 1",
0,
"When driving in snow it is best to keep in as high a gear as possible.Why is this?<br><br>Mark one answer.",
resp,
comm,
corr,
"",
valu,
1,
0,
0,
"");

resp=new Array("sound your horn","switch on your hazard lights","switch on your fog light","switch on the headlights to full beam")
corr=new Array("0","1","0","0")
comm=""
valu=""
quest002 = new Question(
"Question 2",
0,
"Whilst driving on the motorway you have to slow down quickly due to a hazard. What should you do? <br><br>Mark one answer.",
resp,
comm,
corr,
"",
valu,
1,
0,
0,
"");

resp=new Array("10 metres (33 feet)","15 metres (49 feet)","20.5 metres (67 feet)","30 metres (98 feet)")
corr=new Array("0","0","1","0")
comm=""
valu=""
quest003 = new Question(
"Question 3",
0,
"While driving a vehicle, at what distance MUST you be able to read a number plate?<br><br>Mark one answer.",
resp,
comm,
corr,
"",
valu,
1,
0,
0,
"");

resp=new Array("Poorly adjusted brakes","Incorrect tyre pressure","Low levels of power steering fluid","A faulty handbrake")
corr=new Array("1","0","0","0")
comm=""
valu=""
quest004 = new Question(
"Question 4",
0,
"The vehicle you are driving pulls to one side when you brake. What is the most likely cause of the problem? <br><br>Mark one answer.",
resp,
comm,
corr,
"",
valu,
1,
0,
0,
"");

resp=new Array("53 metres","58 metres","73 metres","96 metres")
corr=new Array("0","0","1","0")
comm=""
valu=""
quest005 = new Question(
"Question 5",
0,
"Driving at 60 mph on a dry road what would be the shortest overall stopping distance?<br><br>Mark one answer.",
resp,
comm,
corr,
"",
valu,
1,
0,
0,
"");

resp=new Array("have a large, deep cut in the side wall","are of different makes","were bought second-hand","are more than three years old")
corr=new Array("1","0","0","0")
comm=""
valu=""
quest006 = new Question(
"Question 6",
0,
"It is illegal to drive with tyres that - <br><br>Mark one answer.",
resp,
comm,
corr,
"",
valu,
1,
0,
0,
"");

resp=new Array("Pedestrians crossing the road unexpectedly","Driving too close to the vehicle in front","Traffic lights","A wet road surface")
corr=new Array("0","1","0","0")
comm=""
valu=""
quest007 = new Question(
"Question 7",
0,
"Which of the following is the main cause of rear-end collisions? <br><br>Mark one answer.",
resp,
comm,
corr,
"",
valu,
1,
0,
0,
"");

resp=new Array("10 metres","15 metres","20 metres","22 metres")
corr=new Array("1","0","0","0")
comm=""
valu=""
quest008 = new Question(
"Question 8",
0,
"What is the nearest you can park your vehicle to a junction?<br><br>Mark one answer.",
resp,
comm,
corr,
"",
valu,
1,
0,
0,
"");

resp=new Array("When the tyres are cold","After a long journey","When the tyres are hot","After filling the vehicle with fuel")
corr=new Array("1","0","0","0")
comm=""
valu=""
quest009 = new Question(
"Question 9",
0,
"It is essential that tyre pressures are checked regularly. When should this be done?<br><br>Mark one answer.",
resp,
comm,
corr,
"",
valu,
1,
0,
0,
"");

resp=new Array("2 years old","3 years old","4 years old","5 years old")
corr=new Array("0","1","0","0")
comm=""
valu=""
quest010 = new Question(
"Question 10",
0,
"At what age does a car need its first MOT certificate?<br><br>Mark one answer.",
resp,
comm,
corr,
"",
valu,
1,
0,
0,
"");

resp=new Array("Select a high gear and use the brakes carefully","Select neural and let the car freewheel down the hill","Activate cruise control","Select a low gear and use the brakes carefully")
corr=new Array("0","0","0","1")
comm=""
valu=""
quest011 = new Question(
"Question 11",
0,
"When driving down a steep hill what should you do in order to control your speed?<br><br>Mark one answer.",
resp,
comm,
corr,
"",
valu,
1,
0,
0,
"");

resp=new Array("Retake your theory and practical tests","Reapply for your provisional licence","Incur a maximum fine of £1000","Retake the theory test only")
corr=new Array("1","1","0","0")
comm=""
valu=""
quest012 = new Question(
"Question 12",
1,
"If you get six penalty points within two years of passing your practical test what will you have to do?<br><br>Mark two answers.",
resp,
comm,
corr,
"",
valu,
1,
0,
0,
"");

resp=new Array("Ghosting","Sking","Aquaplaning","Coasting")
corr=new Array("0","0","1","0")
comm=""
valu=""
quest013 = new Question(
"Question 13",
0,
"You are driving in torrential rain and your vehicle begins to slide. What is this called?<br><br>Mark one answer.",
resp,
comm,
corr,
"",
valu,
1,
0,
0,
"");

resp=new Array("Red","Blue","Green","Purple")
corr=new Array("0","1","0","0")
comm=""
valu=""
quest014 = new Question(
"Question 14",
0,
"On a motorway traffic signs are mostly which colour?<br><br>Mark one answer.",
resp,
comm,
corr,
"",
valu,
1,
0,
0,
"");

resp=new Array("To read a map","When your vehicle breaks down","To rest","To overtake slow moving traffic")
corr=new Array("0","1","0","0")
comm=""
valu=""
quest015 = new Question(
"Question 15",
0,
"When are you allowed to use a motorway hard shoulder?<br><br>Mark one answer.",
resp,
comm,
corr,
"",
valu,
1,
0,
0,
"");

resp=new Array("The area behind you","Your side mirrors","All round","Your rear view mirror")
corr=new Array("0","0","1","0")
comm=""
valu=""
quest016 = new Question(
"Question 16",
0,
"Before reversing you should always check:<br><br>Mark one answer.",
resp,
comm,
corr,
"",
valu,
1,
0,
0,
"");

resp=new Array("Traffic lights","White zig-zag lines","Yellow zig-zag lines","A white stop line","Flashing yellow beacons")
corr=new Array("1","1","0","1","0")
comm=""
valu=""
quest017 = new Question(
"Question 17",
1,
"When approaching a pelican crossing what key features will you see?<br><br>Mark three answers.",
resp,
comm,
corr,
"",
valu,
1,
0,
0,
"");

resp=new Array("Mirrors, speed, position, look, mirrors, signal, manoeuvre","Speed, mirrors, look, signal, manoeuvre","Look, mirrors, position, mirrors, signal, manoeuvre","Mirrors, position, speed, look, mirrors, signal, manoeuvre")
corr=new Array("0","0","0","1")
comm=""
valu=""
quest018 = new Question(
"Question 18",
0,
"When overtaking which routine should you use?<br><br>Mark one answer.",
resp,
comm,
corr,
"",
valu,
1,
0,
0,
"");

resp=new Array("A police officer","A stop-go sign","Temporary traffic lights","A lollypop lady")
corr=new Array("1","1","1","0")
comm=""
valu=""
quest019 = new Question(
"Question 19",
1,
"At roadworks which THREE of the following can control the flow of traffic?<br><br>Mark three answers.",
resp,
comm,
corr,
"",
valu,
1,
0,
0,
"");

resp=new Array("When you change your vehicle","when you change your permament address","When you use your vehicle abroad","When you reach the age of sixty","When you change your name")
corr=new Array("1","1","0","0","1")
comm=""
valu=""
quest020 = new Question(
"Question 20",
1,
"When must you contact the vehicle licensing authority?<br><br>Mark three answers.",
resp,
comm,
corr,
"",
valu,
1,
0,
0,
"");

resp=new Array("Driving in fog","Driving in rain","Driving in strong winds","Driving ona very hot day")
corr=new Array("0","1","0","0")
comm=""
valu=""
quest021 = new Question(
"Question 21",
0,
"Your overall stopping distance will be much longer when:<br><br>Mark one answer.",
resp,
comm,
corr,
"",
valu,
1,
0,
0,
"");

resp=new Array("Triangular","Circular","Square","Octagonal")
corr=new Array("0","0","0","1")
comm=""
valu=""
quest022 = new Question(
"Question 22",
0,
"What shape is a STOP sign?<br><br>Mark one answer.",
resp,
comm,
corr,
"",
valu,
1,
0,
0,
"");

resp=new Array("Green","Blue","Red","Purple")
corr=new Array("1","0","0","0")
comm=""
valu=""
quest023 = new Question(
"Question 23",
0,
"The reflective studs between a motorway and its slip road are what colour?<br><br>Mark one answer.",
resp,
comm,
corr,
"",
valu,
1,
0,
0,
"");

resp=new Array("Drive home without going faster than 30 mph","Drive home at night so that the lights will help you","Find a way of getting home without driving","Only drive on minor roads")
corr=new Array("0","0","1","0")
comm=""
valu=""
quest024 = new Question(
"Question 24",
0,
"You are about to drive home but you can't find the glasses you need to wear. You should:<br><br>Mark one answer.",
resp,
comm,
corr,
"",
valu,
1,
0,
0,
"");

resp=new Array("Try to overtake","Move to the right hand lane","Keep in the left lane to get used to the speed","Move to the centre lane")
corr=new Array("0","0","1","0")
comm=""
valu=""
quest025 = new Question(
"Question 25",
0,
"Immediately after joining a motorway you should:<br><br>Mark one answer.",
resp,
comm,
corr,
"",
valu,
1,
0,
0,
"");

resp=new Array("Warnings","Information","Instructions","Directions")
corr=new Array("1","0","0","0")
comm=""
valu=""
quest026 = new Question(
"Question 26",
0,
"triangular road signs give:<br><br>Mark one answer.",
resp,
comm,
corr,
"",
valu,
1,
0,
0,
"");

resp=new Array("By using leaded fuel","By driving faster","By driving with your windows down","By reducing your speed")
corr=new Array("0","0","0","1")
comm=""
valu=""
quest027 = new Question(
"Question 27",
0,
"As a driver, how can you help the environment?<br><br>Mark one answer.",
resp,
comm,
corr,
"",
valu,
1,
0,
0,
"");

resp=new Array("17 to 25 year olds","34 to 45 year olds","46 ro 55 year olds","65 to 75 year olds")
corr=new Array("1","0","0","0")
comm=""
valu=""
quest028 = new Question(
"Question 28",
0,
"Which age group of drivers is most likely to be involved in an accident?",
resp,
comm,
corr,
"",
valu,
1,
0,
0,
"");

resp=new Array("Car drivers","Lorry drivers","Pedestrians","Cyclists","Motorcyclists")
corr=new Array("0","0","1","1","1")
comm=""
valu=""
quest029 = new Question(
"Question 29",
1,
"At road junctions which of the following are most vunerable?<br><br>Mark THREE answers.",
resp,
comm,
corr,
"",
valu,
1,
0,
0,
"");

resp=new Array("Use your hazard lights","Use dipped headlights","Allow more time for your journey","Slow down","Use headlights on full beam")
corr=new Array("0","1","1","1","0")
comm=""
valu=""
quest030 = new Question(
"Question 30",
1,
"You are driving in fog, which of the following should you do?<br><br>Mark THREE answers.",
resp,
comm,
corr,
"",
valu,
1,
0,
0,
"");

resp=new Array("12 hours","24 hours","36 hours","48 hours")
corr=new Array("0","1","0","0")
comm=""
valu=""
quest031 = new Question(
"Question 31",
0,
"Whilst driving you have an accident in which someone is injured. You must report this to the police within:",
resp,
comm,
corr,
"",
valu,
1,
0,
0,
"");

resp=new Array("1 second","2 seconds","3 seconds","4 seconds")
corr=new Array("0","0","0","1")
comm=""
valu=""
quest032 = new Question(
"Question 32",
0,
"When following a vehicle on a wet road you should leave a time gap of at least?",
resp,
comm,
corr,
"",
valu,
1,
0,
0,
"");

resp=new Array("First or second","Third","Fourth","Fifth","Reverse")
corr=new Array("1","0","0","0","0")
comm=""
valu=""
quest033 = new Question(
"Question 33",
0,
"When driving through a Ford or flood water, what gear should you use?",
resp,
comm,
corr,
"",
valu,
1,
0,
0,
"");

resp=new Array("1/2 second","1 second","2 seconds","3 seconds")
corr=new Array("1","0","0","0")
comm=""
valu=""
quest034 = new Question(
"Question 34",
0,
"The reaction time of most drivers is over?",
resp,
comm,
corr,
"",
valu,
1,
0,
0,
"");

resp=new Array("Tunnel ahead","Low bridge ahead","Tourist route ahead","Holiday route ahead")
corr=new Array("1","0","0","0")
comm=""
valu=""
quest035 = new Question(
"Question 35",
0,
"What is the meaning of this sign?",
resp,
comm,
corr,
"",
valu,
1,
0,
0,
"signs131.gif");

resp=new Array("Side winds","Quayside or river bank","Falling or fallen rocks","Cliff face ahead")
corr=new Array("0","0","1","0")
comm=""
valu=""
quest036 = new Question(
"Question 36",
0,
"What is the meaning of this sign?",
resp,
comm,
corr,
"",
valu,
1,
0,
0,
"signs128.gif");

resp=new Array("Toll bridge ahead","Opening or swing bridge ahead","Humpback bridge ahead","Road ahead closed")
corr=new Array("0","1","0","0")
comm=""
valu=""
quest037 = new Question(
"Question 37",
0,
"What is the meaning of this sign?",
resp,
comm,
corr,
"",
valu,
1,
0,
0,
"signs126.gif");

resp=new Array("Accompanied horses or ponies","Wild horses or ponies","Wild animals","No horses allowed")
corr=new Array("1","0","0","0")
comm=""
valu=""
quest038 = new Question(
"Question 38",
0,
"What is the meaning of this sign?",
resp,
comm,
corr,
"",
valu,
1,
0,
0,
"signs124.gif");

resp=new Array("Level crossing without barrier or gate","Level crossing with barrier or gate","Trams crossing ahead","Trams only")
corr=new Array("1","0","0","0")
comm=""
valu=""
quest039 = new Question(
"Question 39",
0,
"What is the meaning of this sign?",
resp,
comm,
corr,
"",
valu,
1,
0,
0,
"signs118.gif");

resp=new Array("Humps on the road","Humpback bridge","Uneven road surface","Risk of grounding")
corr=new Array("0","0","0","1")
comm=""
valu=""
quest040 = new Question(
"Question 40",
0,
"What is the meaning of this sign?",
resp,
comm,
corr,
"",
valu,
1,
0,
0,
"signs115.gif");

resp=new Array("Accident blackspot ahead","Pedestrian crossing ahead","Light signals ahead at a level crossing","Traffic queues likely")
corr=new Array("0","0","1","0")
comm=""
valu=""
quest041 = new Question(
"Question 41",
0,
"What is the meaning of this sign?",
resp,
comm,
corr,
"",
valu,
1,
0,
0,
"signs116.gif");

resp=new Array("Toucan","Zebra","Puffin","Pelican")
corr=new Array("1","0","0","0")
comm=""
valu=""
quest042 = new Question(
"Question 42",
0,
"At which pedestrian crossings are cyclists permitted to cross?",
resp,
comm,
corr,
"",
valu,
1,
0,
0,
"");

resp=new Array("30 mph","40 mph","50 mph","60 mph")
corr=new Array("0","0","0","1")
comm=""
valu=""
quest043 = new Question(
"Question 43",
0,
"The national speed limit for cars and motorcycles on a single carriageway road is?",
resp,
comm,
corr,
"",
valu,
1,
0,
0,
"");

resp=new Array("Your comfort","The Handling","Your ability to change gears","The steering")
corr=new Array("0","0","0","1")
comm=""
valu=""
quest044 = new Question(
"Question 44",
0,
"Overloading your vehicle can seriously affect?",
resp,
comm,
corr,
"",
valu,
1,
0,
0,
"");

resp=new Array("When they are over 18 years old","Never","When travelling on minor roads","When travelling on motorways")
corr=new Array("0","1","0","0")
comm=""
valu=""
quest045 = new Question(
"Question 45",
0,
"When are passengers allowed to ride in a caravan that is being towed?",
resp,
comm,
corr,
"",
valu,
1,
0,
0,
"");

resp=new Array("At night","On a dual carriageway","Alone","With passengers in the back")
corr=new Array("0","0","1","0")
comm=""
valu=""
quest046 = new Question(
"Question 46",
0,
"A provisional licence holder must not drive a motor car",
resp,
comm,
corr,
"",
valu,
1,
0,
0,
"");

resp=new Array("Cyclists","Cars","High-sided vehicles","Motorcycles")
corr=new Array("0","1","0","0")
comm=""
valu=""
quest047 = new Question(
"Question 47",
0,
"A strong cross wind is least likely to affect which of these vehicles?",
resp,
comm,
corr,
"",
valu,
1,
0,
0,
"");

resp=new Array("Increase your speed to reduce your journey time","Decrease your speed","Stop at a safe place and rest","Turn on the radio and listen to loud music")
corr=new Array("0","0","1","0")
comm=""
valu=""
quest048 = new Question(
"Question 48",
0,
"You start to feel tired whilst driving, you should?<br><br>Mark one answer.",
resp,
comm,
corr,
"",
valu,
1,
0,
0,
"");

resp=new Array("Entry into a 20 mph zone","End of a 20 mph zone","Minimum speed 20 mph")
corr=new Array("1","0","0")
comm=""
valu=""
quest049 = new Question(
"Question 49",
0,
"What is the meaning of this sign?",
resp,
comm,
corr,
"",
valu,
1,
0,
0,
"signs355.gif");

resp=new Array("Caravans","Cyclists","Coaches","Motorcycles over 50cc","Learner driver cars","Tractors")
corr=new Array("0","1","0","0","1","1")
comm=""
valu=""
quest050 = new Question(
"Question 50",
1,
"Which three of these must not use motorways?",
resp,
comm,
corr,
"",
valu,
1,
0,
0,
"");

questions = new Array (
quest001,quest002,quest003,quest004,quest005,quest006,quest007,quest008,quest009,quest010,quest011,quest012,quest013,quest014,quest015,quest016,quest017,quest018,quest019,quest020,quest021,quest022,quest023,quest024,quest025,quest026,quest027,quest028,quest029,quest030,quest031,quest032,quest033,quest034,quest035,quest036,quest037,quest038,quest039,quest040,quest041,quest042,quest043,quest044,quest045,quest046,quest047,quest048,quest049,quest050)

function doQuestion(quest)
{
var numdo;
var numord=eval(quest+1);
var i=-1, ii, type, myname, gadget;
type=questions[quest].type;
numdo=type>=3?1:questions[quest].response.length;


document.writeln ("<a name=\""+questions[quest].qname+"\"></a>")
document.write("\n")
document.write("    <tr>\n")
document.write("      <td width=\"5%\" align=\"center\" valign=\"top\" bgcolor=\"#E6E6FF\"><font face=\"Verdana\"\n")
document.write("      color=\"#000080\"><strong><small>")
document.write(numord)
document.write("</small></strong></font></td>\n")
document.write("      <td width=\"95%\" valign=\"top\" bgcolor=\"#F4F4FF\"><font face=\"Verdana\"><font color=\"#000080\"><strong><small>\n")
document.write("      ")
if (questions[quest].img!="") {
document.write("\n")
document.write("         <img border=\"0\" hspace=\"10\" vspace=\"5\" align=\"left\" src=\"")
document.write(questions[quest].img)
document.write("\">\n")
document.write("      ")
}
document.write("\n")
document.write("      ")
document.writeln(questions[quest].qstring)
document.write("</small></strong></font><br>\n")
document.write("      <br><small><small>\n")
document.write("      ")
for (i=0; i<numdo; i++) {
myname=questions[quest].qname;
gadget="radio";
if (type>=3) gadget="text";
else if (type==1) {
myname+="_"+(i<9?"0":"")+(i+1);
gadget="checkbox";}
document.write("\n")
document.write("         ")
document.write(type==7?"<textarea name=\""+myname+"\" rows=5 cols=30 class=\"input\">":" <input type="+gadget+" name=\""+myname);
if (type<3) document.write("\" value=\""+i+"\">\n")
else document.write(type==7?"</textarea>":"\" class=\"input\" value=\"\">\n")
if (type<3) document.write(questions[quest].response[i]);
document.write("<br>\n")
document.write("      ")
}
document.write("\n")
document.write("      </small></small></font></td>\n")
document.write("    </tr>\n")
document.write("    ")
}
function doTest() {
var count, i;
questions.sort(myrandom);
for (i=0; i<questions.length; i++) {
questions[i].qname="Question "+(i+1);}
count=questions.length;
for (i=0; i<count; i++) doQuestion(i);
}
function fill(s,l){
s=s+""
for (y=1;y<=l;y++)
if (s.length>=l) break; else s="0"+s;
return s
}
function CheckQName(wapf,ii,i,multi,selection){
var len;
if (!multi) return(wapf.elements[ii].name==questions[i].qname);
len=questions[i].qname.length;
if (wapf.elements[ii].name.substring(0,len)!=questions[i].qname) return false;
if (wapf.elements[ii].name.substring(len,len+1)!="_") return false;
if (eval(wapf.elements[ii].name.substring(len+1,len+3))==(selection+1)) return true;
return false;
}
function errore(uno,due,tre)
{
if (!errori) global[1]="<H3>You have made the following errors</H3>";
++errori;
cachewrite("<p><b>"+uno+"</b><br>"+due+"<br>"+mycomment+tre+"</p>",2);
mycomment="";
}
function testIE5plus(){
var pos=navigator.appVersion.lastIndexOf('MSIE ');
if (pos != -1) {
pos+=5;
if (eval(navigator.appVersion.charAt(pos))>4)
return true;}
return false;}
function correct(wapf)
{
var i, ii, t, re, tmp, selection, multi, multipage=0, type, isnull, iswrong, iscorrect, evaluation=0, total=0, udat;
errori=waitTime=0;
udat=new Array();
for (i=0, ii=0; i<wapf.elements.length; i++)
{tmp=wapf.elements[i];
if (tmp.name.substring(0,13)=="Quiz.UserData"){
t=tmp.name.substring(14,tmp.name.length);
re=new RegExp("_", "g");
t=t.replace(re," ");
udat[ii++]=t+": <i>"+tmp.value+"</i><br>";
if (opera) tmp.value="";}}
global[0]=global[2]="";
global[1]="<h3>Congratulations, you haven't made any errors</h3>";
cachewrite("<html><head><title>Results</title><BASE target='_blank'></head><body bgcolor='#FFFFFF'><font face='Verdana, Arial'><table border=0 cellpadding=0 cellspacing=0 width='100%' bgcolor='#C0C0C0'><tr><td width='100%'><font face='Verdana, Arial' size=5 color='#FFFFFF'><b>&nbsp;Results</b></font></td></tr></table>",0)
now= new Date()
cachewrite("<small><p>"+fill((now.getMonth()+1),2)+"/"+fill(now.getDate(),2)+"/"+now.getYear()+"&nbsp;&nbsp;"+fill(now.getHours(),2)+":"+fill(now.getMinutes(),2)+"</p>",0)
cachewrite("<b>Mock Theory Test</b><br><br>\n",0);
if (udat.length>0) {
cachewrite("<b>Information</b><br>\n",0);
for (i=0; i<udat.length; i++) cachewrite(udat[i],0);}
if (opera7 && multipage) {
for (i=0; i<questions.length; i++) {
id=document.getElementById("q"+(i+1));
id2=document.getElementById("q"+(i+1)+"a");
id.style.display=id2.style.display="block";}}

for (i=0; i<questions.length; i++) {
if (opera && multipage) {
id=document.getElementById("q"+(i+1));
id2=document.getElementById("q"+(i+1)+"a");
id.style.visibility=id2.style.visibility="visible";}
type=questions[i].type;
if (type==1) multi=1;
else multi=0;
isnull=true;
iscorrect=false;iswrong=false;
selection=0;
evaluation=0;
mycomment="";
for (ii=0; ii<wapf.elements.length; ii++) {
if (CheckQName(wapf,ii,i,multi,selection)) {
if (type>=3 && wapf.elements[ii].value!="") {
isnull=false;
if (wapf.elements[ii].value.toLowerCase()==questions[i].corrects.toLowerCase()) iscorrect=true;
else iswrong=true;
++selection;}
else if (wapf.elements[ii].checked) {
if (questions[i].score!="") evaluation+=questions[i].score[selection];
if (isnull) isnull=false;
if (questions[i].corrects[selection]=="1") iscorrect=(iswrong==false)?true:false;
else {
iswrong=true;
if (multi && questions[i].corrects!='') errore(questions[i].qname,"The checkbox  <i>"+questions[i].response[selection]+"</i>  shouldn't have been selected.",questions[i].explan)
}
if (questions[i].comment!="" && questions[i].comment[selection]!="")
mycomment+=((iscorrect || questions[i].corrects=='')?"<b>"+questions[i].qname+"</b><br>":"")+"<small>"+questions[i].comment[selection]+"</small><br>";
} else {
if (questions[i].corrects[selection]=="1") {
iswrong=true;
if (multi && questions[i].corrects!='') errore(questions[i].qname,"The checkbox  <i>"+questions[i].response[selection]+"</i>  should have been selected.",questions[i].explan);
}}
++selection;
}}
if (multi==false && (isnull || iswrong)) {
var okresp="", z;
if (type>=3) okresp=questions[i].corrects;
else {
for (z=0; z<questions[i].corrects.length; z++) {
if (questions[i].corrects[z]==1) {
okresp=questions[i].response[z];
break;
}}}
if (okresp!="") errore(questions[i].qname,"The right answer was <i>"+okresp+".</i>",questions[i].explan);
}
if (mycomment!="") cachewrite(mycomment,2);
if (questions[i].corrects!="") ++qright;
if (isnull) evaluation+=questions[i].ifnull;
else if (iswrong) evaluation+=questions[i].ifwrong;
else if (iscorrect) evaluation+=questions[i].ifcorrect;
total+=evaluation;}
if (qright==0) global[1]="<br>";
if (errori) cachewrite("<br><b>You have made "+errori+" "+(errori==1?"error":"errors")+".</b>",2);
cachewrite("<br><b>Total score: "+total+".</b><br>",2);

cachewrite("</small><hr noshade><center><form>",2)
printest=(((navigator.appName=="Netscape") && (navigator.appVersion.charAt(0)>="4")) || (testIE5plus() == true))? "print()": "alert('This button can be used with Netscape Navigator 4 or Microsoft Internet Explorer 5 only. If you want to print with other browsers, please select the Print command in the File menu.')"
cachewrite("<input type='button' value='Print...' onClick='"+printest+"'>&nbsp;&nbsp;&nbsp;&nbsp;",2)
cachewrite("<input type='button' value='Close' onClick='window.close()'></form></center>",2)
cachewrite(aknw,2)
winr=window.open('','wapres', 'titlebar=1,location=0,directories=0,menubar=1,toolbar=0,scrollbars=1,resizable=1,status=1')
for (i=0; i<3; i++) winr.document.write(global[i]);winr.document.close()
if ((opera || opera7) && multipage) {
document.forms[0].elements[0].value='Print...';
document.forms[0].elements[1].value='Close';
for (i=0; i<questions.length-1; i++) {
id=document.getElementById("q"+(i+1));
id2=document.getElementById("q"+(i+1)+"a");
opera?id.style.visibility=id2.style.visibility="hidden":id.style.display=id2.style.display="none";}}
}
aknw="<br><p align='center'><small><small>Created and managed with <a title='Click here to visit WebQuiz site' href='http://www.smartlite.it/go.asp?OLDLP' target = '_blank'>SmartLite WebQuiz</a></small></small></p>"
function myrandom(a,b)
{
var rc;
do {rc=Math.floor(Math.random()*3)-1;} while (rc==2);
return(rc);
}
function update_time(t) {
self.status=t;}
function stms(s){
if (Math.abs(tmMx)>=3600){
h=Math.floor(s/3600);m=Math.floor((s%3600)/60);s=((s%3600)%60);return fill(h,2)+':'+fill(m,2)+':'+fill(s,2);
}else{m=Math.floor(s/60);s=s%60;return fill(m,2)+':'+fill(s,2);}}
function shtm(t){
tmVl=t+1;update_time(stms(Math.abs(t)))
if (waitTime==0) return;
tmId = setTimeout('shtm(tmVl)',1000)
if (t==((tmMx>0)? tmMx : 0)){
clearTimeout(tmId)
alert('Time is over, correcting questionnaire now.')

correct(document.WapForm)}}
function checkTime(){
tmMx=-waitTime;
if (tmMx!=0){
alert('Time to complete your questionnaire is: '+stms(Math.abs(tmMx))+'\n\nPlease check time count.');
shtm((tmMx>0) ? 0 : tmMx)}}
