    var DHTML = (document.getElementById || document.all || document.layers);        

    function myGetObj(name){
      if (document.getElementById){
        this.obj = document.getElementById(name);
        this.style = document.getElementById(name).style;
        this.inner = document.getElementById(name).innerHTML;    
      }else if (document.all){
        this.obj = document.all[name].id;
        this.style = document.all[name].style;
        this.inner = document.all[name].innerHTML;    
      }else if (document.layers){
        this.obj = document.layers[name].id;
        this.style = document.layers[name];
        this.inner = document.layers[name]; 
      }
  }  
  
  function validateDate(dat1,dat2,formToSubmit,nameONE) {
 
      var RegExPattern = /^((((0?[1-9]|[12]\d|3[01])[\.\-\/](0?[13578]|1[02])[\.\-\/]((1[6-9]|[2-9]\d)?\d{2}))|((0?[1-9]|[12]\d|30)[\.\-\/](0?[13456789]|1[012])[\.\-\/]((1[6-9]|[2-9]\d)?\d{2}))|((0?[1-9]|1\d|2[0-8])[\.\-\/]0?2[\.\-\/]((1[6-9]|[2-9]\d)?\d{2}))|(29[\.\-\/]0?2[\.\-\/]((1[6-9]|[2-9]\d)?(0[48]|[2468][048]|[13579][26])|((16|[2468][048]|[3579][26])00)|00)))|(((0[1-9]|[12]\d|3[01])(0[13578]|1[02])((1[6-9]|[2-9]\d)?\d{2}))|((0[1-9]|[12]\d|30)(0[13456789]|1[012])((1[6-9]|[2-9]\d)?\d{2}))|((0[1-9]|1\d|2[0-8])02((1[6-9]|[2-9]\d)?\d{2}))|(2902((1[6-9]|[2-9]\d)?(0[48]|[2468][048]|[13579][26])|((16|[2468][048]|[3579][26])00)|00))))$/;
      //var errorMessage = 'Per favore inserire le date nel formato corretto (gg/mm/aaaa) utilizzando il calendario .';
      if ((dat1.value.match(RegExPattern)) && (dat1.value!='')) {
          var data1Validata="OK";
      }
      if ((dat2.value.match(RegExPattern)) && (dat2.value!='')) {
          var data2Validata="OK";
      } 
      if(data1Validata=="OK" && data2Validata=="OK"){
           document.forms[formToSubmit].submit();
      } else {
          //alert(errorMessage);
          inizializza(nameONE,"v");
      } 
  }
  
  function validateMail(mail,formToSubmit,nameONE) {
 
      var RegExPattern = /^([0-9a-zA-Z]([-.\w]*[0-9a-zA-Z])*@([0-9a-zA-Z][-\w]*[0-9a-zA-Z]\.)+[a-zA-Z]{2,9})$/;
      //var errorMessage = 'Per favore inserire le date nel formato corretto (gg/mm/aaaa) utilizzando il calendario .';
      if ((mail.value.match(RegExPattern))) {
          var mailValidata="OK";
      }
      if(mailValidata=="OK"){
           document.forms[formToSubmit].submit();
      } else {
          //alert(errorMessage);
          inizializza(nameONE,"v");
      } 
  }


	  function inizializza(nameONE,visibility){
		if (!DHTML) return;
		  invisible(nameONE,visibility);
	  }
	  
	  function invisible(nameONE,vis){
		x = new myGetObj(nameONE);
		//vis = x.style.display;
		//alert (vis);
		//if(vis=='' || vis=='none'){
		if(vis=='v'){
		  x.style.display = 'block';
		  //alert('block');
		}else{
		  x.style.display = 'none';
      //alert('none');		  
		}       
	  }   
