function checkValue(formSelected,arg){
		if(arg=="select"){
			lenghtvalue = 0;
		}else{
			lenghtvalue = 3;
		}
		formulaireEle = info[0];
		var obj = formulaireEle.getElementsByTagName(arg);
		strAlert = ""
		errorForm = info[2];
		for(i=0;i<obj.length;i++){
			if (obj[i].className.indexOf("need") >=0){
				iField     = obj[i];
				iId        = obj[i].id;
				iName      = obj[i].name;
				iValue     = obj[i].value;
				iTitle     = obj[i].title;
				iLength    = obj[i].value.length;
				
				iField.className = iField.className.replace("error","");
					
				if(arg=="select"){
					if(iField.selectedIndex == 0){
						iField.className = iField.className+"error";
						errorForm++;
						strAlert += iTitle +", ";
					}
				}else{
					if (iName.indexOf('mail') >= 0 && iValue != "" && iLength < lenghtvalue){
							posAt = iValue.indexOf("@");
							posDot = iValue.substr(posAt,iLength).indexOf(".");
							if (posAt < 2 || posDot < 2){
									iField.className = iField.className+"error";
									errorForm++;
									strAlert += iTitle +", ";
							}
					} else if (iLength < lenghtvalue){
							iField.className = iField.className+"error";
							errorForm++;
							strAlert += iTitle +", ";
					}
				}
			}
		}
		info[0] = formulaireEle;
		info[1] += strAlert;
		info[2] = errorForm;
		return info;
	
}


function checkForm(formSelected,alertString){
		info = new Array();
				info[0] = formSelected;
				info[1] = "";
				info[2] = 0;
		
		info = checkValue(info,"input");
		info = checkValue(info,"textarea");
		info = checkValue(info,"select");
		
		if (info[2]>0){ 
				alert(alertString+"\n"+info[1].substring(0,info[1].length-2)+". ");
				return false;
		} else {
				return true;
		}
}