String.prototype.trim = function() {
	var x = this;
	x = x.replace(/^\s*(.*)/, "$1");
	x = x.replace(/(.*?)\s*$/, "$1");
	return x;
}

function checkSyntax()
{
	var highlightcolor = "#ffcccc";
	var nohighlightcolor = "#ffffff";
	var res = true;

	for (var i = 0; (i < checkSyntax.arguments.length) && (res == true); i+=3)
	{
		var element = checkSyntax.arguments[i];
		element.style.backgroundColor = nohighlightcolor;
		var additional_ok = (checkSyntax.arguments[i + 1] != '') ? checkSyntax.arguments[i + 1](element) : true;
	  if (element.value.trim().length == 0 || !additional_ok)
		{
			alert(checkSyntax.arguments[i + 2]);
			element.style.backgroundColor = highlightcolor;
			res = false;
		}
	}
	
	if (!res)
		element.focus();
	return res;
}
	
function checkSyntaxEmail(element) 
{
	var exp = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/;
	return (exp.test(element.value.toLowerCase()));
}	

function IsNumeric(strString)
// check for valid numeric strings
{
	var strValidChars = "0123456789.-";
	var strChar;
	var blnResult = true;

	if (strString.value.length == 0) return false;

	// test strString consists of valid characters listed above
	for (i = 0; i < strString.value.length && blnResult == true; i++)
	{
		strChar = strString.value.charAt(i);
		if (strValidChars.indexOf(strChar) == -1)
		{
			blnResult = false;
		}
	}
	return blnResult;
}
