function trim(str)
{
   return str.replace(/^\s+|\s+$/g,'');
}

function chkspaces(chkStr,fieldname)
{
	if (chkStr.indexOf(" ")>=0)
	{
		alert("The "+fieldname+" has spaces in it.");
		return false;
	}
	else
	{
		return true;
	}
}

function emailCheck(emailStr)
{
  var str=emailStr

  // BWN added to prevent .ru in the email address
  if (str.search(/\.ru/i) > 0)
  { 
	alert("\nNot a valid input in the following field(s):\n\n\t Email Address contains .ru")
	return false;
  }
  // BWN added to prevent gawab in the email address
  if (str.search(/gawab/i) > 0)
  { 
	alert("\nNot a valid input in the following field(s):\n\n\t Email Address contains gawab")
	return false;
  }

  var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
  if (filter.test(str))
    return true
  else
  {
    alert("\nNot a valid input in the following field(s):\n\n\t Email Address")
	return false;
  }
  return true
}
