// Grammar Monster © | Copyright Registration Number: 226604 | All rights reserved  

selec = new Array (3)
correct = new Array (100)
selec[1] = " | He turned and shouted, #'She&nbsp;is&nbsp;in&nbsp;the&nbsp;taxi =she&nbsp;is&nbsp;in&nbsp;the&nbsp;taxi.' | I travel at =North #north weekends. | Do not drink =Water #water from the taps in the gymnasium. | He sat at the top of Nelson's #Column =column for 3 hours. | The aliens will probably attack in the =Winter #winter. | The horse was eventually found in =Ashton&nbsp;Under&nbsp;Lyne #Ashton&nbsp;under&nbsp;Lyne. | The shark kept circling #;however =,however we knew we were safe."
selec[2] = " | The company motto used to be: #‘Make&nbsp;a&nbsp;customer&nbsp;not&nbsp;a&nbsp;sale =make&nbsp;a&nbsp;customer&nbsp;not&nbsp;a&nbsp;sale.’ | Start heading #south =South once you spot the green zone along the river. | We value all our =Clients’ #clients’ opinions. | The rooms were comparable to the ones in #Caesars&nbsp;Palace =Caesars&nbsp;palace in the 80s. | It was #Summer’s =summer’s last attempt to ripen the grapes. | What did Jade think of Liam’s performance in #Phantom&nbsp;of&nbsp;the&nbsp;Opera  =Phantom&nbsp;Of&nbsp;The&nbsp;Opera? | Lucy was pleased when the police returned her stolen car from Ipswich. #However,  =,however, she was less impressed the following week when she received a bill for its recovery and storage. " 




correct[11] = "He turned and shouted, 'She is in the taxi.'#Sentences start with capital letters. (This includes sentences within quotation marks.)"
correct[12] = "I travel north at weekends.#The points of the compass are only given capital letters when they form part of a name (e.g. South Shields).  The word <font color=yellow>north</font> is simply a direction and does not form part of a name."
correct[13] = "Do not drink water from the taps in the gymnasium.#Do not capitalise a word just because it is an important word in the sentence.  Although the word <font color=yellow>water</font> is an important word in the sentence, there is no reason to capitalise it."
correct[14] = "He sat at the top of Nelson's Column for 3 hours.#Use capital letters for the names of things or people (i.e. for proper nouns).  Nelson's Column is the name of a column in London; therefore, it is written with capital letters."
correct[15] = "The aliens will probably attack in the winter.#Only capitalise the seasons when they have been given human traits (e.g. Winter's icy breath; the touch of Autumn)."
correct[16] = "The horse was eventually found in Ashton under Lyne.#Only capitalise the principal words in titles.  The word <font color=yellow>under</font> is a preposition and should not be capitalised. (Other words which are not considered principal words are <font color=yellow>on</font>, <font color=yellow>in</font>, <font color=yellow>the</font>, <font color=yellow>a</font> and <font color=yellow>an</font>.)"
correct[17] = "The shark kept circling; however, we knew we were safe.#In its most common role, the word <font color=yellow>However</font> is used at the <i>start of a sentence</i> to link the idea in its own sentence to the idea in the previous one. It should not be used to merge two sentences into one with a comma. <i>Occasionally</i>, a semicolon can be used before <font color=yellow>however</font> to offer a smoother transition between the two sentences."

correct[21] = "The company motto used to be: ‘Make a customer not a sale.’#Sentences start with capital letters. (This includes sentences within quotation marks.)"
correct[22] = "Start heading south once you spot the green zone along the river.#The points of the compass are only given capital letters when they form part of a name (e.g. South Shields).  The word <font color=yellow>south</font> is simply a direction and does not form part of a name."
correct[23] = "We value all our clients’ opinions.#Do not capitalise a word just because it is an important word in the sentence.  Although the word <font color=yellow>client</font> is an important word in the sentence, there is no reason to capitalise it."
correct[24] = "The rooms were comparable to the ones in Caesars Palace in the 80s.#Use capital letters for the names of things or people (i.e. for proper nouns).  Caesars Palace is the name of a hotel in Las Vegas; therefore, it is written with capital letters."
correct[25] = "It was Summer’s last attempt to ripen the grapes...#Only capitalise the seasons when they have been given human traits (e.g. Winter's icy breath; the touch of Autumn; go skiing in winter; leave it until spring)."
correct[26] = "What did Jade think of Liam’s performance in Phantom of the Opera?#Only capitalise the principal words in titles.  The words <font color=yellow>of the</font> should not be capitalised. (Other words which are not considered principal words are <font color=yellow>on</font>, <font color=yellow>in</font>, <font color=yellow></font>, <font color=yellow>a</font> and <font color=yellow>an</font>.) "
correct[27] = "...from Ipswich. However, she was less impressed the following week…#In its most common role, the word <font color=yellow>However</font> is used at the start of a sentence to link the idea in its own sentence to the idea in the previous one. It should not be used to merge two sentences into one with a comma. Occasionally, a semicolon can be used before <font color=yellow>however</font>."


ques = 0; var mid = ""

// choose a random sentence

ques = Math.ceil(2*Math.random())

mid = selec[ques]
var len = 0
var i = 0
var sw = 0
var ew = 0
var shw = ""
var wc = 0
var rep = ""
var ges = 0
var shr = 1
var score = 0; var wrong=0; var missed = 0; var total = 0; var tc=0; var totq = 0; var mar = 0; var nding=0; var qu=1
words = new Array (150)
check = new Array (150)
quest = new Array (20)
ans = new Array (150)
for (k = 0; k < 150; k++){check[k]=0}
for (k = 0; k < 150; k++){ans[k]=0}
len=mid.length

// check the text

function text(){
wc=0; qu=1
for (i = 0; i < len; i++){
if (mid.substr(i,1)==" "){
	ew=i+1; rep=mid.substr(i,1)
	if (mid.substr(sw,1)=="#" || mid.substr(sw,1)=="="){ans[wc]=1; sw++;}
	else {words[wc]=" " + mid.substr(sw, (ew-sw)) + " "}
      if (mid.substr(sw,1)=="|"){words[wc]="<br><br><img src=../images/q"+qu+".gif>&nbsp; ";qu++}
	if (mid.substr(sw-1,1)=="="){ans[wc]=2;}
	if (check[wc]==1 && (ans[wc]==1 || ans[wc]==2)){words[wc]="<span class=curs onclick=sel('" + wc + "') style='background-color: #FFFF00'>" + mid.substr(sw, ((ew-sw)-1)) + "</span>" + rep}
	if (check[wc]==0 && (ans[wc]==1 || ans[wc]==2)){words[wc]="<span class=curs onclick=sel('" + wc + "') style='background-color: #FFFFFF'>" + mid.substr(sw, ((ew-sw)-1)) + "</span>" + rep}
	sw=ew
	wc++
}
}
display()
}


function display(){
shw=""; shr=1; totq=1; mar = 0
for (k = 0; k < wc; k++){
if (ans[k]==1 || ans[k]==2){shw = shw + "<font color=blue>" ; shr++;}
if (nding==1 && (ans[k]==1 || ans[k]==2)){mar = totq + (ques*10); shw = shw + "<span class=curs onclick=showcorrect(" + mar + ",event)>";}
shw = shw + words[k]
if (shr%2==0 && (ans[k]==1 || ans[k]==2)){shw = shw + "/ "}
if ((shr-1)%2==0 && (ans[k]==1 || ans[k]==2)){totq++}
if (nding==1 && (ans[k]==1 || ans[k]==2)){shw = shw + "</span>"}
if (ans[k]==1 || ans[k]==2){shw = shw + "</font>"}
}
document.getElementById('topmsg').innerHTML=shw;
sw=0
}

function sel(a){
chosen = ""; ges = 0; 
if (check[a]==0){check[a]=1; check[(a-1)]=0; a++; check[a]=0}
else {check[a]=0}
for (k = 0; k < wc ; k++){
if (check[k]==1){ges++}
}
document.getElementById('btmmsg').innerHTML="Number of selections: " + ges;

text()
}

function cler(){
for (k = 0; k < wc; k++){check[k]=0}
check[2]=1;sel(2)
text()
}

function showcorrect(a, e){
chosen = correct[(a)]

var posx = 0;
var posy = 0;

  // Get mouse position; IE & FF Compatibility!
  if (e.pageX || e.pageY)
  {
    posx = e.pageX;
    posy = e.pageY;
  }
  else if (e.clientX || e.clientY)
  {
    posx = e.clientX + document.body.scrollLeft
      + document.documentElement.scrollLeft;
    posy = e.clientY + document.body.scrollTop
      + document.documentElement.scrollTop;}

if (posx > 860){posx = 860}

document.getElementById('popup').style.left = parseInt(posx);
document.getElementById('popup').style.top = parseInt(posy);
document.getElementById('popup').style.display = 'block';


document.getElementById('popup').innerHTML="<table border=0 width=321 cellpadding=3 cellspacing=0 background='../images/footer.jpg' style='border: 6px solid #0000FF'><tr><th align=left width=311 style='color:white'><font color=yellow>THE ANSWER</font><br><br>&quot;<span id='toppmsg'></span>&quot; <img border=0 src=../images/bultik.gif width=11 height=11></th><td width=20 align=right valign=top><span onclick='clos()'><img border=0 src=../images/close.gif width=15 height=15></span></td></tr><tr><th align=left colspan=2 style='color: white'><br><font color=yellow>WHY?</font><br><br><span id='bottommsg'></span></th></tr></table>"

len=chosen.indexOf('#')

document.getElementById('toppmsg').innerHTML="<font color=white>" + chosen.substr(0,len) + "</font>";
document.getElementById('bottommsg').innerHTML="<font color=white>" + chosen.substr(len+1, (chosen.length)+1) + "</font>";
}

function clos(){
document.getElementById('popup').innerHTML="";}


// check the text

function look(){
wc=0; score = 0; wrong=0; missed = 0; tc = 0; qu=1
for (i = 0; i < len; i++){
if (mid.substr(i,1)==" "){
	ew=i+1; rep=mid.substr(i,1)
	if (mid.substr(sw,1)=="#"){ans[wc]=1; sw++; tc++} 
      if (mid.substr(sw,1)=="="){ans[wc]=2; sw++;}
	words[wc]=mid.substr(sw, (ew-sw))
      if (mid.substr(sw,1)=="|"){words[wc]="<br><br><img src=../images/q"+qu+".gif>&nbsp; ";qu++}
	if (check[wc]==1 && ans[wc]==2){words[wc]="<span style='background-color: #FFFF00'>" + mid.substr(sw, ((ew-sw)-1)) + "</span>" + rep + "<img border=0 src=../images/bulxw.gif width=25 height=11> "; wrong++}
	if (check[wc]==0 && check[wc-1]==0 && check[wc+1]==0 && ans[wc]==1){words[wc]="<span style='background-color: #FFCCCC'>" + mid.substr(sw, ((ew-sw)-1)) + "</span>" + rep + "<img border=0 src=../images/bulxw.gif width=25 height=11> "; missed++}
	if (check[wc]==1 && ans[wc]==1){words[wc]="<span style='background-color: #CCFFCC'>" + mid.substr(sw, ((ew-sw)-1)) + "</span>" + rep + "<img border=0 src=../images/bultickw.gif width=25 height=11> "; score++}

	
	sw=ew
	wc++}
}
nding=1; display(); 
total = score -(wrong + missed)
document.getElementById('btmmsg').innerHTML="<table border=0><tr><td><b>Total Selections:</b></td><td width=50 align=center>" + ges + "</td><td></td></tr><tr><td BGCOLOR=#CCFFCC>Correct selections:</td><td align=center>" + score + "</td><td><font color=#999999>(score: "+ score + ")</font></td></tr><tr><td BGCOLOR=#FFFF00>Wrong selections:</td><td align=center>" + wrong + "</td><td><font color=#999999>(score: "+ wrong*-1 + ")</font></td></tr><tr><td BGCOLOR=#FFCCCC>Missed answers:</td><td align=center>" + missed + "</td><td><font color=#999999>(score: "+ missed*-1 + ")</font></td></tr><tr><td><b>Total Score:<b></td><td align=center>" + total + "</td><td><font color=#999999>(highest possible score: " + tc + ")</font></td></tr></table><br><span class=big>Click on the answers for explanations</span>."

document.getElementById('buttons').innerHTML="<input type='button' value='Next Test' style='background-color: #222299; color: #ffffff;' onClick='nexttest()'>"
}

function nexttest(){
mar=0
if (ques==1 && mar ==0){ques=2;mid=selec[2]; mar=1}
if (ques==2 && mar==0){ques=1;mid=selec[1]; mar=1}
for (k = 0; k < 150; k++){check[k]=0; ans[k]=0; words[k]=""}
var sw = 0
var ew = 0
nding = 0
len=mid.length
document.getElementById('popup').innerHTML="&nbsp;";
document.getElementById('btmmsg').innerHTML="<span id='btmmsg' class='mid'>&nbsp;</span>";
document.getElementById('buttons').innerHTML="<input type='button' value='Next test' style='background-color: #222299; color: #ffffff;' onClick='nexttest()'><input type='button' value='Clear my answers' style='background-color:#222299; color: #ffffff;' onclick='cler()'><input type='button' value='Check my answers' style='background-color:GREEN; color: #ffffff;' onclick='look()'>";
text()
}






























































