function trim(strText) 
{ 
    while (strText.substring(0,1) == ' ')
	{
        strText = strText.substring(1, strText.length);
	}
	while (strText.substring(strText.length-1,strText.length) == ' ')
	{
        strText = strText.substring(0, strText.length-1);
	}
   return strText;
}

function isEmpty(strText)
{
	if (trim(strText) == "")
	{
		return true;
	}
	else
	{
		return false;
	}
}

function verifyLength(myMin, myMax, myValue)
{
	if (trim(myValue).length < myMin )
	{
		return -1;
	}
	else if (trim(myValue).length > myMax)
	{
		return 1;
	}
	else
	{
		return 0;
	}
}

alphaNumericPure = "[^A-Za-z0-9]";
alphaNumericPureWithFullStop = "[^A-Za-z0-9@\.]";

function characterCheck(myStr, myRegExp)
{	
	myRXP = new RegExp(myRegExp)
    if (myRXP.test(myStr)) 
	{
      	return false;
    } 
	else 
	{
      	return true;
    }
}

function verifyEmail(single_mail_address)
{
	match_good = /\b([A-Z\.\_\-\d]+)@([A-Z\.\_\-\d]+\.)+([A-Z][A-Z][A-Z][A-Z]|[A-Z][A-Z][A-Z]|[A-Z][A-Z])$/i.test(trim(single_mail_address));
	match_bad = /(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)/.test(trim(single_mail_address));
  	if (match_good && !match_bad)
	{
		return true;
	}
	else
	{
		return false;
	}
}