// Modulo per la dichiarazione delle strutture generali
//
	// Funzione per il controllo delle stringhe nelle pagine
	function ControllaCampoStringa(CodCampo,DescCampo,Lungmin,Lungmax)
	{
	  if (Lungmin > 0)
	  {
		if (CodCampo.value == "")
		{
		  alert("Inserire un valore per il campo '" + DescCampo + "'.");
			CodCampo.focus();
		  return (false);
		}
	  }
	  if (CodCampo.value.length < Lungmin)
	  {
	    alert("Inserire almeno " + Lungmin + " caratteri per il campo '" + DescCampo + "'.");
		CodCampo.focus();
	    return (false);
	  }
	  if (CodCampo.value.length > Lungmax)
	  {
	    alert("Inserire al massimo " + Lungmax + " caratteri per il campo '" + DescCampo + "'.");
		CodCampo.focus();
	    return (false);
	  }
	  return (true);
	}
	
	// Funzione per il controllo dei campi interi nelle pagine
	function ControllaCampoNumero(CodCampo,DescCampo,decPoints,valmin,valmax)
	{
		var checkOK = "0123456789-,";
		var allValid = true;
		var decPoints = 0;
		var allNum = "";

		if (CodCampo.value == "")
		{
		  alert("Inserire un valore per il campo '" + DescCampo + "'.");
		  CodCampo.focus();
		  return (false);
		}
		  
		for (i = 0;  i < CodCampo.value.length;  i++)
		{
		  ch = CodCampo.value.charAt(i);
		  for (j = 0;  j < checkOK.length;  j++)
		    if (ch == checkOK.charAt(j))
		      break;
		  if (j == checkOK.length)
		  {
		    allValid = false;
		    break;
		  }
		  if (ch == ",")
		  {
		    allNum += ".";
		    decPoints++;
		  }
		  else
		    allNum += ch;
		}
		if (!allValid)
		{
			alert("Inserire solo cifre per il campo '" + DescCampo + "'.");
			CodCampo.focus();
			return (false);
		}
		if (decPoints > 1)
		{
			alert("Inserire un numero valido per il campo '" + DescCampo + "'.");
			CodCampo.focus();
			return (false);
		}
		if (CodCampo.value > valmax)
		{
			alert("Inserire un numero non superiore a " + valmax + " per il campo '" + DescCampo + "'.");
			CodCampo.focus();
			return (false);
		}
		if (CodCampo.value <= valmin)
		{
			alert("Inserire un numero non inferiore a " + valmin + " per il campo '" + DescCampo + "'.");
			CodCampo.focus();
			return (false);
		}
		
		return (true);
	}

	    function check_Data(st)
	      {
		       var dt = new Date(); // Establishes a specific date for the object.
		   	dt.setDate(st.substr(0, 2 ));
		   	dt.setMonth(st.substr(3, 2 )-1);
		   	dt.setYear(st.substr(6, 4 ));
		   	y = dt.getYear();
		   	if( y < 1900)
		   		y = y + 1900;
              if(st.length > 10)
              {
                return false;
	          }
	          else if(st.charAt(2) != '/' || st.charAt(5) != '/' )
	          {
              	return false;
              }
	          else if(dt.getDate() != st.substr(0, 2 ))
	          {
              	return false;
              }
	          else if((dt.getMonth()+1)!=st.substr(3, 2 ))
	          {
              	return false;
              }
	          else if(y!=st.substr(6, 4 ) || st.substr(6, 4 )<1900)
	          {
              	return false;
              }
		      return true;
	      }

	 function ControllaData(CodCampo,DescCampo)
	 {
	  if(!(check_Data(CodCampo.value)))
	  {
	  
			alert("Il campo '" + DescCampo + "' non e' nel formato corretto o la data inserita non e' valida");
			
			return (false);
	  }
	  return (true);
	 }

	function ControllaEmail(CodCampo,DescCampo,Lungmin,Lungmax) {
	  if (Lungmin > 0)
	  {
		if (CodCampo.value == "")
		{
		  alert("Inserire un valore per il campo '" + DescCampo + "'.");
			CodCampo.focus();
		  return (false);
		}
	  }
	  if ((CodCampo.value.indexOf("@") == -1) |
		(CodCampo.value.indexOf(".") == -1) | (CodCampo.value.length < 7))
	  {
			alert("Il campo '" + DescCampo + "' non e' nel formato corretto")
			CodCampo.focus();
			return (false);
	  }
	  if (CodCampo.value.length < Lungmin)
	  {
	    alert("Inserire almeno " + Lungmin + " caratteri per il campo '" + DescCampo + "'.");
		CodCampo.focus();
	    return (false);
	  }
	  if (CodCampo.value.length > Lungmax)
	  {
	    alert("Inserire al massimo " + Lungmax + " caratteri per il campo '" + DescCampo + "'.");
		CodCampo.focus();
	    return (false);
	  }
		
	  return (true);			
	}


	// Funzione per il controllo delle stringhe nelle pagine
	function ConfermaCancellazione()
	{
		return (confirm("Eliminare l'elemento selezionato ?"));
	}

function CambioPwd(pwdold,pwdnew,pwdconf) 
 {
		if (pwdold == "")
		{
		  alert("Inserire la vecchia password.");
		  return (false);
		}
		if (pwdnew == "")
		{
		  alert("Inserire la nuova password.");
		  return (false);
          }
		   else
		  {
			     if (pwdnew.length < 8)
						{
						  alert("La password deve essere di almeno 8 caratteri.");
						  return (false);
						}
		  }	
		if (pwdconf == "")
			{
			  alert("Reinserire la password per conferma.");
			  return (false);
			}
		
		 if (pwdconf != pwdnew)
			{
			  alert("Nuova password e conferma non corrispondenti: reinserire.");
			  return (false);
			}
	 
		return (true);			
 }

	function visdett(ID)
	{				
		if (document.getElementById(ID).style.display == 'block')
		{				 
			document.getElementById(ID).style.display='none';
		}   else	{						
			document.getElementById(ID).style.display='block';				  									
		}					  									
	}	

		function MM_openBrWindow(theURL,winName,features) { //v2.0
		  window.open(theURL,winName,features);	
		}

