
	function openWindow(qualeURL,w,h)
	{
		opener = window.open(qualeURL,"new","toolbar=y,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes"+",width="+w+",height="+h);
	}


	function openWindow2(qualeURL,w,h)
	{
		opener2 = window.open(qualeURL,"new2","toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no"+",width="+w+",height="+h);
	}


	function isNum(chr)            // is character a number?
	  {
	  if (((chr < "0") || (chr > "9")) && ((chr != ".") && (chr != ","))) // nope
		return false;
	  else                         // yep
		return true;
	  }

	function all_num(numero)
	{
	if (numero == null)
	{
			return true;
	}
	lunghezza = numero.length;
	for (i=0; i<lunghezza; i++)
		{
		chr = numero.charAt(i);
		if ((!isNum(chr)) && ((chr != ".") && (chr != ",")))
		{
		  return false;
			}
	}
	return true;
	}



function codiceFISCALE(cfins)
   {
   var cf = cfins.toUpperCase();
   var cfReg = /^[A-Z]{6}\d{2}[A-Z]\d{2}[A-Z]\d{3}[A-Z]$/;
   if (!cfReg.test(cf))
      return false;
   var set1 = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
   var set2 = "ABCDEFGHIJABCDEFGHIJKLMNOPQRSTUVWXYZ";
   var setpari = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
   var setdisp = "BAKPLCQDREVOSFTGUHMINJWZYX";
   var s = 0;
   for( i = 1; i <= 13; i += 2 )
      s += setpari.indexOf( set2.charAt( set1.indexOf( cf.charAt(i) )));
   for( i = 0; i <= 14; i += 2 )
      s += setdisp.indexOf( set2.charAt( set1.indexOf( cf.charAt(i) )));
   if ( s%26 != cf.charCodeAt(15)-'A'.charCodeAt(0) )
      return false;
   return true;
}

function CheckForm(cf)
   {
   var CFok=codiceFISCALE(cf)
   if (CFok==false)
     {
      alert("Codice Fiscale errato");
      return false; 
   }
}
	function controllaTextNonVuoti(form,nomi,numeri,lingua)
	{
		arrayOfStrings = nomi.split(",")

		virgola = "";
		errore = "";
		virgola2 = "";
		errore2 = "";

		if (nomi != "")
		{
			for (var i=0; i < arrayOfStrings.length; i++)
			{
				if (form.elements[arrayOfStrings[i]].value == "")
				{
					errore = errore + virgola + arrayOfStrings[i];
					virgola = ", ";
				}

			}
			if (errore != "")
			{
				if(lingua=="it"){
					errore = "I seguenti campi devono essere compilati: " + errore + "\n";
				}else{
					errore = "The following fields are mandatory: " + errore + "\n";
				}
			}
		}



		if (numeri != "")
		{
			arrayOfNumber = numeri.split(",")

			for (var i=0; i < arrayOfNumber.length; i++)
			{
				if ((form.elements[arrayOfNumber[i]].value == "") || (all_num(form.elements[arrayOfNumber[i]].value) == false))
				{
					errore2 = errore2 + virgola2 + arrayOfNumber[i];
					virgola2 = ", ";
				}

			}
			if (errore2 != "")
			{
				if(lingua=="it"){
					errore = errore + "I seguenti campi devono essere compilati con un valore numerico valido: " + errore2;
				}else{
					errore = errore + "The following fields should be filled with a numeric value : " + errore2;
				}
			}
			
		}





		if (errore != "")
		{
			alert (errore)
			return false;
		}
		else
		{
			return true;
		}

	}


function ControllaMail(MailToCheck)
   {
   Filtro = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-]{2,})+\.)+([a-zA-Z0-9]{2,})+$/;
   return Filtro.test(MailToCheck)
   }

function Controlla(inputvalue,lingua)
   {
   var r1=ControllaMail(inputvalue);
   if (r1){
      return true;
   }else{
      if (!r1)
      	if(lingua=='it'){
        	alert("La mail non è corretta");
        }else{
        	alert("Email account not valid");
      	}
   			return false;
   }
}

	function y2k(number)
   {
   return (number < 1000) ? number + 1900 : number;
   }
   
	function ControllaData(gg,mm,yyyy){

		if (gg!="" && mm!="" && yyyy!=""){
	    var today = new Date();
	    yyyy = ((!yyyy) ? y2k(today.getYear()):yyyy);
	    mm = ((!mm) ? today.getMonth():mm-1);
	    if (!gg) return false
	    var test = new Date(yyyy,mm,gg);
	    if ((y2k(test.getYear()) == yyyy) && (mm == test.getMonth()) && (gg == test.getDate())){
				return true;	  
		  }else{
		     alert('Data errata!!');
		     return false;
			}
		}
	}

	