/******************************************************************
These functions are used by the SmartTextBox.
This file MUST be stored at wwwroot/aspnet_client/Imagine/SmartTextBox 2.0
on the web server.
******************************************************************/

//Does not allow dangerous characters to be entered
function EscapeHtml(event, control) {
	var lt  = "&lt;";
	var gt  = "&gt;";
	var amp = "&amp;";
	
	//the event property we need is browser-dependent:
	//	keyCode in IE, charCode in Netscape/Mozilla	
	var key = (document.all) ? event.keyCode : event.charCode;
	
	switch( String.fromCharCode(key) ) {
		//case ">": control.value += gt; return false;
		case "<": control.value += "< "; return false;
		//case "&": control.value += amp;return false;
	}
	return true;
}

//Click the appropriate input button
function PressButton(submitBtn, event) {
	var btn = document.getElementById(submitBtn);
	if ((btn) && (event.keyCode == 13)) {
		btn.focus();
		btn.click();
		return false;
	}
	return true;
}

//limits the length of a textarea
function EnforceMaxLen(control, len)
{
	if(control.value.length >= len) {
		control.value = control.value.substr(0, len);
	}
}
