/**************************************************************
 LTrim: Returns a String containing a copy of a specified 
        string without leading spaces 

 Parameters:
      String = The required string argument is any valid 
               string expression. If string contains null, 
               false is returned

 Returns: String
***************************************************************/
function LTrim(String)
{
	var i = 0;
	var j = String.length - 1;

	if (String == null)
		return (false);

	for (i = 0; i < String.length; i++)
	{
		if (String.substr(i, 1) != ' ' &&
		    String.substr(i, 1) != '\t')
			break;
	}

	if (i <= j)
		return (String.substr(i, (j+1)-i));
	else
		return ('');
}

/**************************************************************
 RTrim: Returns a String containing a copy of a specified 
        string without trailing spaces 

 Parameters:
      String = The required string argument is any valid 
               string expression. If string contains null, 
               false is returned

 Returns: String
***************************************************************/
function RTrim(String)
{
	var i = 0;
	var j = String.length - 1;

	if (String == null)
		return (false);

	for(j = String.length - 1; j >= 0; j--)
	{
		if (String.substr(j, 1) != ' ' &&
			String.substr(j, 1) != '\t')
		break;
	}

	if (i <= j)
		return (String.substr(i, (j+1)-i));
	else
		return ('');
}

/**************************************************************
 RTrim: Returns a String containing a copy of a specified 
        string without both leading and trailing spaces 

 Parameters:
      String = The required string argument is any valid 
               string expression. If string contains null, 
               false is returned

 Returns: String
***************************************************************/
function Trim(String)
{
	if (String == null)
		return (false);

	return RTrim(LTrim(String));
}

function e_mail(val)
{
	test=true;
	var r;
	var x;
	x="[A-Za-z0-9_&-]+[A-Za-z0-9_&-]*[.]?[A-Za-z0-9_&-]+[@][A-Za-z0-9_&-]+[.][A-Za-z0-9_&-]+[.]?[A-Za-z0-9_&-]+" ;
	r=val.match(x);
	if (r!=val)
	{
		test=false;				
	}
	return(test);	
}	
	
function check_form()
{
    if (Trim(document.form_mail.fromwho.value)=="")
	{
		alert("Please type your email address")
		document.form_mail.fromwho.select()
		document.form_mail.fromwho.focus()
		return false
	}
	else if (e_mail(document.form_mail.fromwho.value)==false )
	{			
		alert("Please check your email address")							
		document.form_mail.fromwho.select()
		document.form_mail.fromwho.focus()
		return false
	}
	else if (Trim(document.form_mail.body.value)=="")
	{
		alert("Please type your comments")
		document.form_mail.body.select()
		document.form_mail.body.focus()
		return false
	}
	else 
	{
		return true
	}												
}