function pressedkey(e, IDcounter, IDbox, maxlength)
//Use this function	to block certain keys(I.E. strip out all k characters...) or perform simple	validation
//This function acts as a wrapper for the DisplayCharsLeft function, and merely stops calls to it if a key should be ignored
{
	var	keycode;
	if (window.event) keycode =	window.event.keyCode; //Use	the	IE event model
	else if	(e)	keycode	= e.which; //Netscape event	model
	else //just	pass through, don't	block keys if they're using a wierd browser
	{
		DisplayCharsLeft(e, IDcounter, IDbox, maxlength);
		return;	
	}

	//To cancel	keys or	perform	substitutions, detect the keycode and do it	here
	if (keycode	== 13)//cancels	returns
	{
		e.returnValue=false;
		e.cancel = true;
		return;
	}				
	DisplayCharsLeft(e, IDcounter, IDbox, maxlength);
} 

function DisplayCharsLeft(e, IDcounter, IDbox, maxlength)
//Call this	function directly if you don't want	to block anything, and just	want the counter
//e = an event, in this case keypress, captured by javascript and the DOM
//IDcounter = the id of the element displaying the number of characters you want to change. Usually a span, but perhaps a layer as well
//IDbox = the id of the textbox you want to count characters in
//maxlength = the specified total number of characters allowed
{		
	if	(document.all)//Explorer 4+, Opera 6+, iCab, Ice, Omniweb 4.2-
	{
		var counter = document.all[IDcounter];
		var box = document.all[IDbox]
		if (maxlength - box.value.length < 0)
		{
			e.returnValue=false;
			e.cancel = true;
			counter.innerHTML = 0;
			return;
		}
		else
		{
			counter.innerHTML = maxlength - box.value.length-1;
			return;
		}
	}
	else if (document.getElementById) //Mozilla,	Explorer 5+, Opera 5+, Konqueror, Safari, iCab,	Ice, OmniWeb 4.5
	{
		var counter = document.getElementById(IDcounter);
		var box = document.getElementById(IDbox);
		counter.innerHTML = '';//workaround for bug in Explorer 5.1 and higher on	Mac	
		if (maxlength - box.value.length < 0)
		{
			e.returnValue=false;
			e.cancel = true;
			counter.innerHTML = 0;
			return;
		}
		else
		{
			counter.innerHTML = maxlength - box.value.length-1;
			return;
		}
	}
}