/**********************************************************
** disable submitting a form by pressing ENTER
**********************************************************/
function codes() {
    // disable user press ENTER to submit a form 
	if (event.keyCode==13)
		return false;
	else
		return true;
}
/**********************************************************
** disable submitting a form by pressing ENTER
**********************************************************/
function codes_old(e) {
    // disable user press ENTER to submit a form 
    if (e.type == "keypress")   //if user press any key on keyboard
       var whichCode = e.keyCode;
    if (whichCode == 13) {
		//alert("keypress is "+whichCode);
		return false;
	}		
	return true;		    		
}
/**********************************************************
** Is input entry valid
**********************************************************/
function isValidEntry(string)
{
   if (!string)  return false;

   var iChars = "~`!@#$%^*|{}[]?<>\"=";

   for (var i = 0; i < string.length; i++)
   {
      if (iChars.indexOf(string.charAt(i)) != -1)
         return false;
   }
   return true;
}
/**********************************************************
** Trim Text
**********************************************************/
function TrimText(strText)
{ 
    // this will get rid of leading spaces 
    while (strText.substring(0,1) == ' ') 
        strText = strText.substring(1, strText.length);

    // this will get rid of trailing spaces 
    while (strText.substring(strText.length-1,strText.length) == ' ')
        strText = strText.substring(0, strText.length-1);

   return strText;
}
/**********************************************************
** Event - Check form entries for invalid data.
**********************************************************/
function checkForm()
{
	myEntry = TrimText(document.myForm.keywords.value);
	
	if ((myEntry!="") && (myEntry.length < 4))
	{
		alert("\nPlease enter more than 3 characters for the Search Keywords.");
		document.myForm.keywords.select();
		document.myForm.keywords.focus();
		return false;	
	}
	else if ((myEntry!="") && (isValidEntry(myEntry)==false))
	{
		alert("\nPlease enter valid search keywords (Only letters/numbers allowed).");
		document.myForm.keywords.select();
		document.myForm.keywords.focus();
		return false;
	}
	else
	{
		return true;
	}
}
