var totalLength = 0;
var astring = "";
var astring2 = "" ;
var errors = 0;
var baderrors = 0;
var awfulerrors = 0;
var a1 = "";
var b1 = "";
var totalTime = 0;
var speed = 0;
var starttime = 0;

<!-- Begin
msg = new Array("Other than sliced bread, this web-site is the greatest thing.",
"For having fun, PickANumber.com is an excellent time waster.",
"For me and Zach, typing text is a tough task.",
"Almost everyone at Microsoft, except for Bill, is a millionaire.",
"Can you count one potato, two potato, three potato, four?")

function b() {
msg = new Array("Jack and Jill fell down the hill.",
"She sells sea shells wholesale.",
"Fred feels foolish feeling fools.",
"Mary had a little lamp and it was dark.",
"Old King Cole was a merry old soul.")
}

function i() {
msg = new Array("Now is the time for all good men to come to the aid of his party.",
"The quick brown fox jumped over the lazy dog.",
"This grand web site is just for very lazy bumpkins quite like me and you.",
"Almost everyone at Microsoft, except for Bill, is a millionaire.",
"Can you count one potato, two potato, three potato, four?")
}

function e() {
msg = new Array("Exactly seven (7) undersized dwarfs kept Snow White company in the deep, dark (and 'mysterious') forest.",
"To arrive at this web site (PickANumber.com), type this in your browser: http://www.pickanumber.com.",
"Typing text is an exacting task for fingers that fumble like mine (and yours)!",
"Zach stood there quite perplexed, his zipper down, and wondered at the tittering crowd.",
"Can you type the following six (6) simple words: The sixth sheik's sixth sheep's sick?")
}


function beginIt() {
randNum = Math.floor((Math.random() * 10)) % 5
msgType = msg[randNum]
day = new Date();
starttime = day.getTime();
document.theForm.given.value = msgType
document.theForm.typed.value=""
document.theForm.typed.focus();
}

function cheat() {
document.theForm.typed.focus();
}

function checkWork() {
	errors = 0;
	baderrors = 0;
	awfulerrors = 0;
	astring = document.theForm.given.value
	astring2 = document.theForm.typed.value
	totalLength = astring.length
	for (j = 0; j <= totalLength; j++ ) {
		a1 = astring2.charAt(j);
		b1 = astring.charAt(j);
			if ( a1 != b1 ) {
				errors = errors + 1;
			}
	}

	for (j = 0; j <= totalLength; j++ ) {
		a1 = astring2.charAt(j);
			if ( a1 == astring.charAt(j + 1) 
				&& astring.charAt(j) != astring.charAt(j + 1)) {
				baderrors = baderrors + 1;
			}
			if	( a1 == astring.charAt(j + 2) 
				&& astring.charAt(j + 1) != astring.charAt(j + 2)) {
				baderrors = baderrors + 1;
			}
			if ( a1 == astring.charAt(j - 2) 
				&& astring.charAt(j - 1) != astring.charAt(j - 2)) {
				baderrors = baderrors + 1;
			}
			if ( a1 == astring.charAt(j - 1)
				&& astring.charAt(j) != astring.charAt(j - 1)) {
				baderrors = baderrors + 1;
			}
	}	
	if (errors == 0) return;
	if ( errors != 0 ) awfulerrors = errors;
	errors = Math.abs( errors - baderrors );
	if ( errors == 0 ) errors = awfulerrors;
}

//Is length correct?
function ending() {
	dayTwo = new Date();
	endType = dayTwo.getTime();
	totaltime = ((endType - starttime) / 1000)
	checkWork();
	newlength = astring2.length;
	total_words = newlength - errors;
	gwpm = Math.round(((newlength/6)/totaltime) * 60)
	speed = Math.round(((total_words/6)/totaltime) * 60)
	document.theForm.txtErrors.value=errors
	document.theForm.txtSpeed.value=Math.floor(speed)
//	document.theForm.txtNoErrors.value=Math.floor(gwpm)
}

function writeblind() {
	document.write("<TR><TD colspan=2><input type=password name=typed></TD></TR>")
}

function writevisible() {
	document.write("<TR><TD colspan=2><textarea name=typed cols=42 rows=4 wrap=on></textarea></TD></TR>")
}

// End -->