/*****************************************************************/
/* objet text : "check_on_text"
/* objet mail : "check_on_mail"
/* objet textarea : "check_on_textarea"
/* objet password : "check_on_pwd"
/* objet checkbox : "check_on_boxs"
/* objet radio (groupe de boutons) : "check_on_radios"
/* objet select (liste/menu) : "check_on_list"
/*****************************************************************/
function verif_form(formu){
	// variables
	var expr_reg_mail= /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]{2,}[.][a-zA-Z]{2,4}$/;
	var expr_reg_nums= /\D/;
	var formulaire= document.forms[formu];
	var form_items_nb= formulaire.length;
	var check="";
	var Objet_radio="";
	var Item_To_avoid="";
	
	for (i=0;i<=form_items_nb-1;i++){
		Item_name=formulaire[i].name;
		Item_id=formulaire[i].id;
		Item_valeur=formulaire[i].value;
		Item_Type=formulaire[i].type;

		if(Item_Type=="hidden"){
			check_object="false";
			group_str_length=Item_id.length;
			if (Item_name.substring(0,8)=="check_on"){
				if (Item_name=="check_on_boxs")
					check_type="checkbox";
				if (Item_name=="check_on_radios")
					check_type="radio";
				if (Item_name=="check_on_list")
					check_type="select-one";
				if (Item_name=="check_on_pwd")
					check_type="password";
				if (Item_name=="check_on_textarea")
					check_type="textarea";
				if ((Item_name=="check_on_text")||(Item_name=="check_on_number")||(Item_name=="check_on_mail"))
					check_type="text";
				for (j=0;j<=form_items_nb-1;j++){
					tmp_object=formulaire[j]
					tmp_name=tmp_object.name;
					tmp_valeur=tmp_object.value;
					tmp_Type=tmp_object.type;
					if(tmp_Type==check_type){
						if(tmp_name.substring(0,group_str_length)==Item_id){
							if (check_type=="select-one"){
								if(tmp_object.options[tmp_object.selectedIndex].value!="")
									check_object="true";
							}else if ((check_type=="text")||(check_type=="textarea")){
								if (Item_name=="check_on_mail"){
									if (expr_reg_mail.test(tmp_valeur)==true)
										check_object="true";
								}else if (Item_name=="check_on_number"){
									if (expr_reg_nums.test(tmp_valeur)==false){
										if(tmp_valeur!="")
											check_object="true";
									}
								}else if(tmp_valeur!="")
									check_object="true";
							} else if (Item_name=="check_on_pwd"){
								if (tmp_valeur.length > 2)
									check_object="true";
							}else {
								if (tmp_object.checked==true)
								check_object="true";
							}
						}
					}
				}
				if (check_object=="false"){
					alert(formulaire[i].value);
					formulaire[i].focus;
					return false;
				}
			}
		}
	}
	formulaire.submit();
}
