/*  Spelling Grader by John Rickey. All rights reserved */
/*  Status Marquee by  Benjamin Wright */
/*  Begin  */
var msg = "Click 'Next_Word' above to start";
var chars = msg.length + 1;
var updateStatus = "";
var i = 0;
function statusMessage() {
if (i < chars) setTimeout("nextLetter()", 300);
}
function nextLetter() {
updateStatus = msg.substring(0,i) + '_';
window.status = updateStatus;
i++;
statusMessage();
}

wordcount = 12 //Set the number of words, minus one (because the computer starts at zero)
words = new Array("run", "man", "red", "book", "must", "play", "lay", "led", "add", "alike", "mine", "with","easy"
 );
var pos = -1; 
var score = 0;
var mistake = -2;
var err = -2;
var grade = 0;
onerror = next;
function next() 
{		
	if (pos < wordcount) 
	{pos = pos + 1;

		draw();
//-------------
 if (navigator.appName.indexOf('Microsoft')>=0)
  {
    parent.say.document.open();
    parent.say.document.writeln ("<bgsound src="+words[pos]+".wav>");
    parent.say.document.close();
  }
  else
  {
      parent.say.document.open()
	parent.say.document.write ("<EMBED SRC=" + words[pos] + ".wav AUTOSTART=TRUE LOOP=0>")
	parent.say.document.close()
  }

//-----------
		
             
		}
else
{{window.open("spell.htm", "remote")
spell.focus(spell.htm);}
if (mistake ==  3)
	{window.close(index.html);}


}

	
}



function draw() //Updates the Window

{
	document.MyForm.txtPos.value= "Word " + (pos + 1) + " of " + (wordcount + 1); //Updates Position Display
	str1 = words[pos - 1]; //Updates Word Display
	str2 = document.MyForm.txtspell.value



if (str1==str2)
{document.MyForm.result.value = "correct";
score = score + 1;
document.green.src="lightang.gif";
document.MyForm.score.value = eval(score)
if (score ==0){grade = "1.0"}
if (score ==1){grade= "1.3"}
if (score ==2){grade= "1.5"}
if (score ==3){grade= "1.7"}
if (score ==4){grade= "1.8"}
if (score ==5){grade= "1.9"}
if (score ==6){grade= "2.0"}
if (score ==7){grade= "2.1"}
if (score ==8){grade= "2.2"}
if (score ==9){grade= "2.3"}
if (score ==10){grade= "2.4"}
if (score ==11){grade= "2.5"}
if (score ==12){grade= "2.6"}
}
else {

document.MyForm.result.value = "wrong";
mistake = mistake +1;
err = err +1;
document.red.src="lightran.gif";
document.MyForm.err.value =eval(err);
if (mistake == 3)
{spellwindow =window.open(""); 
spellwindow.document.write("<html><head></head><body><center><h1><U>Spelling Results<\/h1><\/U><br><br>"+"<script>"+ "\{"+ 
"var Name1\;"+ 
"var Writing\;"+ 
"Name1=prompt('Print the students name below'\,'Students Name')\;"+ 
"Writing='<h2>Student Name:<\/h2>'"+ 
"\;"+"\}"+ 
"<\/script>"+
"<script>"+ 
"document.write(Writing+'<h2>' +Name1+'<\/h2>')\;"+ 
"<\/script>"+ "<h2>Your  score is " + score + " correct and you"+
" are spelling at a grade "+ grade + " level ."+" If you do not make three mistakes in a row "+
" you are beyond the range of this test and will need to get the full "+ 
" version at the " +
"<a href=\"http:\/\/www.netrover.com\/\~kingskid\/teacherstore2.htm\#spell\"" + 
">Teacherstore<\/a> "+  
" to test further."+
" <\/h2> "+"<\/center>"+
"<hr width=75%><hr width=50%><hr width=25%><br>"+
"<center><a href=index.html  >Return to test<\/a><\/center>"+"<\/body><\/html>"
);

window.close(index.html);


}


}
if (str1 == str2)
{
mistake = 0

;}





document.MyForm.txtspell.value = "";



}
function say()
{
	
	parent.say.document.open()
	parent.say.document.write ("<EMBED SRC=" + words[pos] + ".wav AUTOSTART=TRUE LOOP=0>")
	parent.say.document.close()
}