// 28-June-2001
// originally by Keith Jenci
// MREDKJ.com

var ALPHABET = 'abcdefghijklmnopqrstuvwxyz';
var currentLetter;
var PHRASES = new Array
(
	'You typed',
	'Once again you have typed',
	'There you go again with',
	'You keep on typing',
	'The other keys are getting jealous of'
);
var phraseCount;

resetTheLetter();

function resetTheLetter()
{
	currentLetter = ALPHABET.charAt(getRandom(0,25));
	phraseCount = 0;
}

function revealTheLetter(frm)
{
	frm.txtRevealKP.value = frm.cbRevealKP.checked ? currentLetter : '';
}

function validateKeyPress(e)
{
	var key;
	var keychar;
	var isMasked = document.frmKP.cbBlockedKP.checked;
		
	if(window.event || !e.which) // IE
	{
		key = e.keyCode; // for IE, same as window.event.keyCode
	}
	else if(e) // netscape
	{
		key = e.which;
	}
	else
	{
		return true;
	}

	keychar = String.fromCharCode(key);
	keychar = keychar.toLowerCase();
	
	if(keychar == currentLetter)
	{
		document.frmKP.txtKP.value = PHRASES[phraseCount] + ' ' + currentLetter;
		phraseCount++;
		if(phraseCount > PHRASES.length - 1)
		{
			phraseCount = 1; // start at second phrase
		}
		
		if (isMasked) return false;
	}
	return true;
}
