function ValidateEmailAddress(eAddr){
    var i, badChars = " /:,#'\'`$~!%^&*();<>?\|{}[]",
        atPos = eAddr.indexOf("@"), dotPos = eAddr.indexOf(".", atPos + 2);
        
    for(i = 0; i < badChars.length; ++i) {if(eAddr.indexOf(badChars.charAt(i)) > -1) {return false;}}
                    
    if(eAddr.length < 7 || atPos == -1  ||  dotPos == -1)   {return false;}
        return true;
}

function mytrim (tempStr){

   var Str=new String(tempStr);
   while (Str.charAt(0)==" " && Str.length>0){
       Str=Str.substr(1);
   }
   while (Str.charAt(Str.length-1)==" " && Str.length>0){
       Str=Str.substr(0,Str.length-1);
   }
   return (Str);

}
function doCheck (theForm)
{
    err = false; errText = '';
    theForm.name.value = mytrim(theForm.name.value);
    if (theForm.name.value == '')
    {
        err = true; errText += ' - your name\r\n';
    }
    theForm.email.value = mytrim(theForm.email.value);
    if (theForm.email.value == '' || !ValidateEmailAddress(theForm.email.value))
    {
        err = true; errText += ' - valid email\r\n';
    }
    theForm.message.value = mytrim(theForm.message.value);
    if (theForm.message.value == '')
    {
        err = true; errText += ' - contact message\r\n';
    }
    if (err)
    {
        alert ('Please enter:\r\n' + errText + 'before submitting');
        return false;
    }

    return true;
}

