// JavaScript Document
/* generic function to validate an email */
    function test_email(my_email) {
        var new_string = new String(my_email);
        if (!new_string.match('^[-_\.0-9a-zA-Z]{1,}@[-_\.0-9a-zA-Z]{1,}[\.][0-9a-zA-Z]{2,}$')) {
                return false;
        }
        else {
                return true;
        }
    }
	
function validate(v_form,v_input,v_name,v_email_test,v_email)
{
	var nogo='0';
	var message='';
	var returnval;
	var email;
	
	if (v_email_test == '1')
	{
		email = eval('document.'+v_form+'.'+v_email+'.value');
	}
	
	for (i=0;i<v_input.length;i++)
	{
		var v1 = eval('document.'+v_form+'.'+v_input[i]+'.value');
		if (v1 == '') {nogo='1';message=message+"Le champs '"+v_name[i]+"' est vide \n";}
	}
	
	if ((v_email_test == '1') && (email != ''))
	{
		if (test_email(email) == false)
		{
			nogo='1';
			message=message+"L'email du contact ("+email+") est invalide \n";
		}		
	}
	
	if (nogo == '0')
	{
		returnval = true;
	}
	else
	{
		alert(message);
		returnval = false;
	}
	
	return returnval;	
}
