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

selec = new Array (3)
correct = new Array (100)
selec[1] = "| Right, #who =whom knows what colour it should be? | Don't forget the lady #who =whom sang last time. | It is the old hag #who =whom owns the black cat. | You are comparing me to =who #whom? | Can you tell me #who =whom sat next to him during the meeting. | Okay, =who #whom do you agree with? "

correct[11] = "Right, who knows what colour it should<br>be?#&quot;Whom&quot; (like &quot;him&quot;) cannot be the <a href='../glossary/subject.htm' target='_blank'><font color=white><u>subject of a verb</u></font></a>. You must use &quot;who&quot;.  In this example, &quot;who&quot; is the subject of the verb &quot;to know&quot;. Remember, &quot;who&quot; is similar to &quot;he&quot;(e.g. He knows...)"
correct[12] = "Don't forget the lady who sang last time.#&quot;Whom&quot; (like &quot;him&quot;) cannot be the <a href='../glossary/subject.htm' target='_blank'><font color=white><u>subject of a verb</u></font></a>. You must use &quot;who&quot;. &quot;Who&quot; is the subject of the verb &quot;to sing&quot;. Remember, &quot;who&quot; is similar to &quot;he&quot;. (e.g. He sang...)"
correct[13] = "It is the old hag who owns the black cat.#&quot;Whom&quot; (like &quot;him&quot;) cannot be the <a href='../glossary/subject.htm' target='_blank'><font color=white><u>subject of a verb</u></font></a>. You must use &quot;who&quot;. &quot;Who&quot; is the subject of the verb &quot;to own&quot;. Remember, &quot;who&quot; is similar to &quot;he&quot;. (e.g. He owns...)"
correct[14] = "You are comparing me to whom?#&quot;Whom&quot; follows a preposition (words like &quot;to&quot;, &quot;with&quot; and &quot;by&quot;). Remember, &quot;whom&quot; is similar to &quot;him&quot;. (e.g. to him...)"
correct[15] = "...who sat next to him during the meeting?#&quot;Whom&quot; (like &quot;him&quot;) cannot be the <a href='../glossary/subject.htm' target='_blank'><font color=white><u>subject of a verb</u></font></a>. You must use &quot;who&quot;. &quot;Who&quot; is the subject of the verb &quot;to sit&quot;. Remember, &quot;who&quot; is similar to &quot;he&quot;. (e.g. He sat...)"
correct[16] = "Whom do you agree with?#&quot;Whom&quot; follows a <a href='../lessons/prepositions.htm' target='_blank'><font color=white><u>preposition</u></font></a> (words like &quot;to&quot;, &quot;with&quot; and &quot;by&quot;). This question could have been written &quot;With whom do you agree?&quot; On occasion, the preposition (in this example &quot;with&quot;) will not be immediately before &quot;whom&quot;. Remember, &quot;whom&quot; is similar to &quot;him&quot;. (e.g. with him...)"

selec[2] = " | You are accusing me of telling =who #whom? | This is the man without =who #whom the project would have collapsed. | I could see three men, one of =who #whom was carrying a bag. | Sarah knew two of those boys #who =whom rowed across the Atlantic. | I do not know =who #whom she means. "


correct[21] = "You are accusing me of telling whom?#&quot;Whom&quot; is similar to &quot;him&quot;. (e.g. ...telling him?) Words like &quot;whom&quot; and &quot;him&quot; are said to be in the <a href='../glossary/objective_case.htm' target='_blank'><font color=white><u>objective case</u></font></a>."
correct[22] = "...without whom the project would have collapsed.#&quot;Whom&quot; follows a <a href='../lessons/prepositions.htm' target='_blank'><font color=white><u>preposition</u></font></a> (words like &quot;to&quot;, &quot;with&quot; and &quot;without&quot;). Remember, &quot;whom&quot; is similar to &quot;him&quot;. (e.g. without him...)"
correct[23] = "...see three men, one of whom was carrying...#&quot;Whom&quot; follows a <a href='../lessons/prepositions.htm' target='_blank'><font color=white><u>preposition</u></font></a> (words like &quot;to&quot;, &quot;with&quot; and &quot;of&quot;). Remember, &quot;whom&quot; is similar to &quot;him&quot;. (e.g. what do you think <font color=yellow>of</font> him...)"
correct[24] = "Sarah knew two of those boys who rowed across the Atlantic.#&quot;Whom&quot; (like &quot;him&quot;) cannot be the <a href='../glossary/subject.htm' target='_blank'><font color=white><u>subject of a verb</u></font></a>. You must use &quot;who&quot;.  In this example, &quot;who&quot; is the subject of the verb &quot;to row&quot;. Remember, &quot;who&quot; is similar to &quot;he&quot; or &quot;they&quot; (for plurals); e.g. they rowed..."
correct[25] = "I do not know whom she means?#&quot;Whom&quot; is similar to &quot;him&quot;. (e.g. ...she means him.) Words like &quot;whom&quot; and &quot;him&quot; are said to be in the <a href='../glossary/objective_case.htm' target='_blank'><font color=white><u>objective case</u></font></a>."

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






























































