//ValidAllFields (frm)

function ValidField(frm, all)
{
  var nberrors=0;

	for (i=0; i<frm.elements.length; i++)
	{
		var obj = frm.elements[i];
		if ( (obj.getAttribute('required')=="1") || (obj.getAttribute('test')=="notempty") )
		{
			if (obj.value.length==0)
			{
			  if (obj.getAttribute('msg'))
				  alert(obj.getAttribute('msg'));
				obj.setAttribute("style", 'border: solid #FF0000 1px;');
			  if (document.getElementById("tooltip-"+obj.getAttribute("id")))
          document.getElementById("tooltip-"+obj.getAttribute("id")).style.display="inline";
			//	obj.focus()
			   if (nberrors==0)
			     obj.focus();
			     
			   if (all=="false")
			     return(false);
			   nberrors=nberrors+1;
			}
			else
			{
			    obj.setAttribute("style", '');
          if (document.getElementById("tooltip-"+obj.getAttribute("id")))
          document.getElementById("tooltip-"+obj.getAttribute("id")).style.display="none";
      }
		}
    
    
    if (obj.name!=undefined)
  	{
    	if ( (obj.value.length>0) && (obj.getAttribute('test')!=null) && (obj.getAttribute('test')!='') && ( (obj.getAttribute('disabled')==false) || (obj.getAttribute('disabled')==null) ) && (obj.getAttribute('test')!="notempty") )
  		{
  			var pattern;
  			//Création des patterns de vérification
  			if (obj.getAttribute('test')=="alphanumeric_")
  				pattern = /^[a-zA-Z0-9_\-\.]*$/
  			if (obj.getAttribute('test')=="alphanumeric")
  				pattern = /^[a-zA-Z0-9\-\.]*$/
  			if (obj.getAttribute('test')=="domain")
  				pattern = /^[a-zA-Z0-9\-]{3,}$/
  			if (obj.getAttribute('test')=="numeric")
  				pattern = /^[0-9]*$/
  			if (obj.getAttribute('test')=="numeric-")
  				pattern = /^[\-]?[0-9]*$/
  			if (obj.getAttribute('test')=="directory")
  				pattern = /^[a-zA-Z0-9\-\.\/]*$/
  			if (obj.getAttribute('test')=="url")
  				pattern = /^(http|https|ftp)\:\/\/[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,3}(:[a-zA-Z0-9]*)?\/?([a-zA-Z0-9\-\._\?\,\'\/\\\+&%\$#\=~])*$/;
  			if (obj.getAttribute('test')=="email")
  				pattern = /^([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/;
  			if (obj.getAttribute('test')=="heure")
  				pattern = /^([0-1]?[0-9]|[2][0-3]):([0-5][0-9])$/
  			if (obj.getAttribute('test')=="ip")
  				pattern = /^(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9])\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[0-9])$/;
  			if (obj.getAttribute('test')=="date")
  				pattern = /^(((0[1-9]|[12][0-9]|3[01])([\/])(0[13578]|10|12)([\/])([1-2][0-9][0-9][0-9]))|((0[1-9]|[12][0-9]|30)([\/])(0[469]|11)([\/])([1-2][0-9][0-9][0-9]))|((0[1-9]|[12][0-9])([\/])(02)([\/])([1-2][0-9][0-9][0-9])))$/
        
  			
  			if (!pattern.test(obj.value))
  			{
  			  if (obj.getAttribute('msg'))
            alert(obj.getAttribute('msg'));
          obj.setAttribute("style", 'border: solid #FF0000 1px;');
          if (document.getElementById("tooltip-"+obj.getAttribute("id")))
            document.getElementById("tooltip-"+obj.getAttribute("id")).style.display="inline";
          
          if (nberrors==0)
  			     obj.focus();
  			  
  			  if (all=="false")
  			     return(false);
  			  
          nberrors=nberrors+1;
  			}
  			else
  			{
          obj.setAttribute("style", '');
        	if (document.getElementById("tooltip-"+obj.getAttribute("id")))
            document.getElementById("tooltip-"+obj.getAttribute("id")).style.display="none";
          
        }
  			
  		}
  	}
  	
	}
	if (nberrors==0)
	 return (true);
	else
	 return (false);
}