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

selec = new Array (3)
correct = new Array (100)
selec[1] = "| I have just seen =it's #its tail rise out of the water. | The aliens #cannot =can&nbsp;not survive in our atmosphere. | When they were here, =there #their opinions counted for nothing. | The heroine is a wistful recluse #who =whom lives above an elegant cafe. | Keep =practicing #practising that dance routine. | Applicants should have =3&nbsp;year's #3&nbsp;years' experience. | Craig joined Barnstoneworth United =and #,&nbsp;and Darren joined Brighouse FC. | Nobody was seriously hurt #&nbsp;; =&nbsp;: one man broke his toe. | The girls =,who&nbsp;live&nbsp;upstairs, #who&nbsp;live&nbsp;upstairs are all married."
selec[2] = "| She carefully bandaged the #dog's =dogs' leg.| The European =gardener's #gardeners' conference...| There is nobody in the #women's =womens' team.| Keep the =wing's #wings in line with the barrier.| Consider =Charle's #Charles' defence.| Each month accrues an extra #day's =days' leave.| Ten =day's #days' training is insufficient." 

correct[11] = "I have just seen its tail rise out of the water.# The word <font color=#CC2222>its</font> is used to show possession (like <font color=#CC2222>his</font> and <font color=#CC2222>her</font>); whereas, <font color=#CC2222>it's</font> is short for <font color=#CC2222>it is</font> or <font color=#CC2222>it has</font>."
correct[12] = "The aliens cannot survive in our atmosphere.#<font color=#CC2222>Cannot</font> is one word (i.e. not <font color=#CC2222>can not</font>). (Note: There is a lot of leniency on this rule nowadays.)"
correct[13] = "When they were here, their opinions counted for nothing.#The word <font color=#CC2222>their</font> is used to show possession - like the word <font color=#CC2222>our</font>."
correct[14] = "The heroine is a wistful recluse who lives above an elegant cafe.#<font color=#CC2222>Whom</font> (like <font color=#CC2222>him</font>) cannot be the subject of a verb. You must use <font color=#CC2222>who</font>. In this example, <font color=#CC2222>who</font> is the subject of the verb <font color=#CC2222>to live</font>. Remember, <font color=#CC2222>who</font> is similar to <font color=#CC2222>he</font>. (e.g. He lives...)"
correct[15] = "<img border=1 src=../images/flag_us.gif width=16 height=10> Keep practicing/practising that dance routine. <img border=0 src=../images/bultik.gif width=11 height=11><br><img border=1 src=../images/flag_uk.gif width=16 height=10> Keep practising that dance<br>routine.#<img border=1 src=../images/flag_uk.gif width=16 height=10> In English, all the forms of the verb <font color=#CC2222>to practise</font> are spelt with an <font color=#CC2222>s</font>. (e.g. I practise. / He practises. / I practised. / I am practised. / She is practising.)<br><img border=1 src=../images/flag_us.gif width=16 height=10> Whilst the verb <font color=#CC2222>to practise</font> is adopted by many in the US, <font color=#CC2222>to practice</font> also exists as a verb in American English. Therefore, both versions are acceptable to Americans. (e.g. I practise/practice. / He practises/practices. / I practised/practiced.)"
correct[16] = "Applicants should have three years' experience.#In expressions like <font color=#CC2222>3 years' insurance</font>, the apostrophe is after the <font color=#CC2222>s</font> for more than one measurement of time (e.g. 2 years' tax, 15 minutes' rest)."
correct[17] = "Craig joined Barnstoneworth United, and Darren joined Brighouse FC.#A conjunction (words like <font color=#CC2222>and</font>, <font color=#CC2222>or</font> and <font color=#CC2222>but</font>) used to join two simple sentences should be preceded by a comma."
correct[18] = "Nobody was seriously hurt; one man broke his toe.#A semicolon can be used when a slight break is preferable to new sentence."
correct[19] = "The girls who live upstairs are all married.#The information provided by the clause <font color=#CC2222>who live upstairs</font> is necessary to identify the girls; therefore, it should not be offset with commas."


correct[21] = "She carefully bandaged the<br>dog's leg.#If one person (or thing) possesses the object (or objects), then the apostrophe comes before the <font color=#CC2222>s</font>. (There are exceptions to this rule. See question 5.) One dog - apostrophe before the <font color=#CC2222>s</font>."
correct[22] = "The European gardeners' conference...#If more than one person (or thing) possess the object (or objects), then the apostrophe comes after the <font color=#CC2222>s</font>. (There are exceptions to this rule. See question 3.) The apostrophe comes after the <font color=#CC2222>s</font> as it is clear from context that this refers to the conference of more than one gardener."
correct[23] = "There is nobody in the women's<br>team.#Words like <font color=#CC2222>women</font>, <font color=#CC2222>men</font>, <font color=#CC2222>people</font> and <font color=#CC2222>children</font> (i.e. plural words that do not end in <font color=#CC2222>s</font>) show their possessive forms by adding <font color=#CC2222>'s</font>."
correct[24] = "Keep the wings in line with the<br>barrier.#Do not be tempted to use an apostrophe just because a word ends in <font color=#CC2222>s</font>."
correct[25] = "Consider Charles' defence.#A word like Charles, Wales, Moses or Thomas (i.e. a singular word that ends in <font color=#CC2222>s</font>) shows its possessive form by adding an apostrophe or <font color=#CC2222>'s</font>. (You have a choice. The apostrophe never appears inside the word itself, which is why <font color=#CC2222>Charle's</font> is wrong." 
correct[26] = "Each month accrues an extra day's leave.#In expressions like <font color=#CC2222>1 year's insurance</font>, the apostrophe is before the <font color=#CC2222>s</font> for single periods of time (e.g. 1 year's tax, a minute's rest). This example is about <i>one</i> day's leave; therefore, the apostrophe must be positioned before the <font color=#CC2222> s</font>."
correct[27] = "Ten days' training is insufficient.#In expressions like <font color=#CC2222>3 years' insurance</font>, the apostrophe is after the <font color=#CC2222>s</font> for more than one measurement of time (e.g. 2 years' tax, 15 minutes' rest).  This example is about <i>ten</i> days of training."

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)==" " || 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+".jpg>&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;}

posx = posx - 140
posy = posy - 148

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=350 cellpadding=0 cellspacing=0><tr><td><img src='../images/callout_top.gif' border='0' usemap='#smap'><map name='smap' id='smap'><area	shape='rect' coords='323,12,338,26' href='javascript: clos()'/></map></td></tr></table><table border=0 width=350 cellpadding=0 cellspacing=0 background='../images/callout_mid.gif'><tr><td><table cellpadding='7' cellspacing=0><tr><td valign='top'>&quot;<span id='toppmsg'></span>&quot; <img src='../images/bultik.gif'><h2>Why?</h2><span id='bottommsg'></span></td></tr></table></td></tr></table><table border=0 width=350 cellpadding=0 cellspacing=0><tr><td><img src='../images/callout_bot.gif' border='0'></td></tr></table>"

len=chosen.indexOf('#')

document.getElementById('toppmsg').innerHTML= chosen.substr(0,len);
document.getElementById('bottommsg').innerHTML= chosen.substr(len+1, (chosen.length)+1);
}

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)==" " || 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+".jpg>&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()
}
































































