function IsEmpty( text )
{
    if( text.value.length == 0 ) 
        return( true );
    for( var i=0; i<text.value.length; ++i )  
    {
        var ch = text.value.charAt(i);
        if( ch != ' ' && ch != '\t' ) 
            return( false );
    }
    return( true );
}


function IsEmail( text )
{
    if( text.value.length == 0 ) 
        return( false );
    if( text.value.indexOf("@") == -1 || text.value.indexOf(".") == -1 )
        return( false );
    return( true );
}

function IsEmailValid(F)
{
    if( F.verify_email.value != F.email.value ) 
        return( false );

    return( true );
}


function ValidateContactForm(F)
{
    
   if ( IsEmpty(F.email) || !IsEmail(F.email) )
        {
        alert("Please enter a valid e-mail address.");
        F.email.focus();
        }
    else
   if ( IsEmpty(F.verify_email) )
        {
        alert("Please verify your e-mail address.");
        F.verify_email.focus();
        }
    else
	if ( IsEmpty(F.verify_email) || !IsEmailValid (F) )
        {
        alert("Please confirm that your e-mail has been re-typed correctly.");
        F.verify_email.focus();
        }
    else
	if ( IsEmpty(F.first_name) )
        {
        alert("Please enter your first name");
        F.first_name.focus();
        }
   else 
   if ( IsEmpty(F.last_name) )
        {
        alert("Please enter your last name");
        F.last_name.focus();
        }
   else
    	return( true );
    
    return( false );
}
