//*************************************************************************
// Program: tsMail
// Contact: tscabral.com
// This File: check.js
// Module written by: Thiago Sousa Cabral
// Information: Check fields file
// Browser Testing: IE5
//************************************************************************
// This software is free only for personal use; you CANNOT redistribute 
// and/or modify it without formal permission. This program is distributed 
// in the hope that it will be useful, but WITHOUT ANY WARRANTY.
//************************************************************************

function isEmpty( str){
    strRE = new RegExp( );
    strRE.compile( '^[\s ]*$', 'gi' );
    return strRE.test( str.value );
}

function notValidEmail( str ){
    mailRE = new RegExp( );
    mailRE.compile( '^[\._a-z0-9-]+@[\.a-z0-9-]+[\.]{1}[a-z]{2,4}$', 'gi' );
    return !(mailRE.test( str.value ));
}

function checkForm( form ){

    if( isEmpty( form.name ) ){
        alert( 'Votre nom!' );
        return false;
    }
    
    if( isEmpty( form.subject ) ){
        alert( 'Veuillez inscrire l’objet!' );
        return false;
    }

    if( isEmpty( form.message ) ){
        alert( 'Veuillez ecrire votre message!' );
        return false;
    }

    if( notValidEmail( form.email ) ){
        alert( 'Votre email n’est pas correct!' );
        return false;
    }
else{
    return true;
}
}


