function TodayDate(TheDiv)
{
	var today = new Date();
	var day   = today.getDate();
	var year  = y2k(today.getYear());

	function y2k(number)
	{
		return (number < 1000) ? number + 1900 : number;
	}

	var nomeMese=new Array(12)
	nomeMese[0]="Gennaio"
	nomeMese[1]="Febbraio"
	nomeMese[2]="Marzo"
	nomeMese[3]="Aprile"
	nomeMese[4]="Maggio"
	nomeMese[5]="Giugno"
	nomeMese[6]="Luglio"
	nomeMese[7]="Agosto"
	nomeMese[8]="Settembre"
	nomeMese[9]="Ottobre"
	nomeMese[10]="Novembre"
	nomeMese[11]="Dicembre"

	document.getElementById(TheDiv).innerHTML = day + " " + nomeMese[today.getMonth()] + " " + year;
}

//---- Function Sito Unioncamere ----//

	function openW(pagina,tit,lar,alt)
	{
		window.event.returnValue = false;
        aiuto = window.open(pagina,tit,'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=0,width='+lar+',height='+alt);
                }

	function openFinestra(pagina,tit,lar,alt,i,y)
	{
		window.event.returnValue = false;
		//aiuto = window.open(pagina,tit,'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=0,width='+lar+',height='+alt);
		aiuto = window.open(pagina,tit,'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=0,width='+lar+',height='+alt);
	}

	function OpenT(pagina)
	{
		window.event.returnValue = false;
        //aiuto = window.open(pagina);
		aiuto = window.open(pagina,'newPage','toolbar=1,location=1,directories=1,status=1,menubar=1,scrollbars=1,resizable=1'); //,width=500,height=500');
     }

	function check_email(c3) {
				var chio = c3.indexOf("@");
				var punt = c3.lastIndexOf(".");
				if(chio == -1 				// manca la chiocciola
				|| punt == -1 				// manca il punto
				|| chio > punt				// la chiocciola viene dopo il punto
				|| punt == c3.length-1 	// il punto è l'ultimo carattere
				|| chio == c3.length-1	// la chiocciola è l'ultimo carattere
				|| punt == 0				// il punto è il primo carattere
				|| chio == 0				// la chiocciola è il primo carattere
				|| chio+1 == punt           // chiocciola e punto attaccati
				) {
					return false;
				} else {
					return true;
				}
			}


	function lfCerca(){
		var valore=document.forms.ricerca.paroleFt.value;
		if (valore!=""){
			return true;
		}
		else
		{
			alert ('Attenzione inserire una o più parole per la ricerca!');
			return false;
		}
	}


	function checkReg() {
		var c1 = document.forms["registra"].email.value;
		var c2 = document.forms["registra"].nome.value;
		var c3 = document.forms["registra"].cognome.value;
		var c4 = document.forms["registra"].societa.value;

		var ok = 1;
		var messaggio = "Attenzione! ";

		if (c1 == "" || c2 == "" || c3 == "" || c4== ""){
			ok = 0;
			messaggio = messaggio + "\nRiempire tutti i campi obbligatori.";
		}
		if (!check_email(c1)) {
			ok = 0;
			messaggio = messaggio + "\nL'indirizzo e-mail non è corretto.";
		}
		if (!document.forms["registra"].privacy.checked) {
			ok = 0;
			messaggio = messaggio + "\nL'autorizzazione al trattamento dei dati è richiesta per proseguire.";
		}

		if (ok == 0){
			alert(messaggio);
			return false;
		}
		else {
			return true;
		}

	}

	function conferma(){
		if (confirm("La rinuncia al servizio comporta l'eliminazione dei vostri dati personali dalla banca dati. Procedere?")) {
		document.forms["rinuncia"].submit()
 		}
	}


	function inviaAR(){
		document.forms["f_login"].submit();
	}


	function check_richiedi_pwd(){
		var c1 = document.forms["richiedi_pwd"].email.value;
		if (c1 != ""){
			if (!check_email(c1)) {
				alert("Attenzione!\nL'indirizzo e-mail inserito non è corretto.");
				return false;
			} else {
				return true;
			}
		} else {
			alert("Attenzione!\nL'inserimento dell'indirizzo e-mail è obbligatorio.");
			return false;
		}
	}

	function checkFormAR(frm){
	 	var ok = true;
		var nomeEtichetta;

		for (x = 0 ; x < frm.length; x ++){
			var lvNomeCampo = frm.elements[x].name;
//alert(lvNomeCampo + "#" + lvNomeCampo.substring(5,10))
			if (lvNomeCampo.substring(5,10) == "E-mai") {
				var myValore = frm.elements[x].value;
				if(myValore||""){
					if(!check_email(myValore)) {
						alert("Attenzione! L'indirizzo di posta elettronica non è valido");
						return false;
					}
				}
			}

/*		if (lvNomeCampo == "pwd") {
			var myValore = frm.elements[x].value;
			var myUsr = frm.username.value;

			var lvControllaPwd = lfControllaPwd(myUsr, myValore);
			if (lvControllaPwd != "") {
				alert(lvControllaPwd);
				return false;
			}
		}

		if (lvNomeCampo == "username") {
			var myValore = frm.elements[x].value;
			if (myValore.indexOf(" ") > 0) {
				alert("Attenzione! Lo username non può contenere spazi.");
				return false;
			}
		}
*/

			//if (frm.elements[x].type == "hidden"){
			var myNome = frm.elements[x].name;

			if (myNome.substring(0,4) == "obb_") {

				var myObb = frm.elements[x].value;
				var myIdcampo = myNome.substring(4);

				//if (eval("frm." + myObb + ".type") == "checkbox") 
				if (document.getElementById(myNome).type == "checkbox") 
				{
					//if (eval("frm." + myObb + ".checked") == false) {
					if (document.getElementById(myNome).checked == false) {
						var ok = false;
					}
				}

				//if (eval("frm." + myObb + ".type") == "select-one") {
				if (document.getElementById(myNome).type == "select-one") {
					//if (eval("frm." + myObb + ".options[frm." + myObb + ".selectedIndex].value") == "") {
					if (document.getElementById(myNome).value == "") {
						var ok = false;
					}
				}

				//if (eval("frm." + myObb + ".type") == "text" || eval("frm." + myObb + ".type") == "password" || eval("frm." + myObb + ".type") == "textarea") {
				if (document.getElementById(myNome).type == "text" || document.getElementById(myNome).type == "password" || document.getElementById(myNome).type == "textarea")
				{
					//if (eval("frm." + myObb + ".value") == "" || (eval("frm." + myObb + ".value")) == (eval("frm.eti_" + myIdcampo + ".value")) ){
					nomeEtichetta = "eti_" + myIdcampo;

//alert("myNome:" + myNome + "#nomeEtichetta:" + nomeEtichetta + "#val1:" + document.getElementById(myNome).value + "#val2:" + document.getElementById("eti_" + myIdcampo).value + "--")
//alert((document.getElementById(myNome).value == (document.getElementById("eti_" + myIdcampo).value)));

					if ((document.getElementById(myNome).value == "") || (document.getElementById(myNome).value == (document.getElementById(nomeEtichetta).value)))
					{
						var ok = false;
					}
				}
			}
		}

		if (ok) {
			return true;
		} else {
			alert ("È necessario riempire tutti i campi obbligatori!");
			return false;
		}
	 }

	function check_email_new() {      //controllo e-mail
        var  email= document.newsletter.newsletter.value

		var chio = email.indexOf("@");
		var punt = email.lastIndexOf(".");

		if (email==""){
			 alert('Il campo è vuoto, inserire un indirizzo e-mail');
			 return false;
		}
		else
		{
			if(!check_email(email)){
				alert('E-mail inserita non correttamente!');
				return false;
			}
			else
			{
				return true
			}
		}
	}

	function controlla() {
		flag = "";
		verificato = "no";
		if (verificato == "no") {
			if (document.autentica.usr.value == "") {
				alert("E' necessario inserire lo username")
				flag = "si";
				verificato = "si";
			}
		}
		if (verificato == "no") {
			if (document.autentica.pwd.value == "") {
				alert("E' necessario inserire la  pwd")
				flag = "si";
				verificato = "si";
			}
		}


		if (flag != "si") {
			return true;
			}
		else {
			return false;
			}
	}


	function controllacampi() {
		flag = "";
		verificato = "no";
		if (verificato == "no") {
			if (document.newsletter.nome.value == "") {
				alert("E' necessario inserire il  nome")
				flag = "si";
				verificato = "si";
			}
		}
		if (verificato == "no") {
			if (document.newsletter.cognome.value == "") {
				alert("E' necessario inserire il  cognome")
				flag = "si";
				verificato = "si";
			}
		}
		if (verificato == "no") {
			if (document.newsletter.email.value == "") {
				alert("E' necessario inserire l'indirizzo  email")
				flag = "si";
				verificato = "si";
			}
		}
		if (verificato == "no") {
			if (document.newsletter.citta.value == "") {
				alert("E' necessario inserire la  città")
				flag = "si";
				verificato = "si";
			}
		}

		if (flag != "si") {
			return true;
			}
		else {
			return false;
			}
	}

	function checkFMess (){
		var c1 = document.forms["mess_f"].autore.value;
		var c2 = document.forms["mess_f"].email.value;
		var c3 = document.forms["mess_f"].soggetto.value;
		var c4 = document.forms["mess_f"].testo.value;

		if (c1 != "" && c1.toLowerCase() != "autore"  && c2 != "" && c3 != "" && c3.toLowerCase() != "oggetto"  && c4 != "" && c4.toLowerCase() != "inserire il testo del messaggio" ){
			if (!check_email(c2)) {
				alert ("Attenzione! L'indirizzo email non è corretto.")
				return false;
			} else {
				return true;
			}
		} else {
			alert("I campi contrassegnati da asterisco sono obbligatori!");
			return false;
		}
	}

	function checkFRisp (){
		var c1 = document.forms["mess_f"].autore.value;
		var c2 = document.forms["mess_f"].email.value;
		var c3 = document.forms["mess_f"].testo.value;

		if (c1 != "" && c1.toLowerCase() != "autore"  && c2 != "" && c3 != "" && c3.toLowerCase() != "inserire il testo del messaggio" ){
			if (!check_email(c2)) {
				alert ("Attenzione! L'indirizzo email non è corretto.")
				return false;
			} else {
				return true;
			}
		} else {
			alert("I campi contrassegnati da asterisco sono obbligatori!");
			return false;
		}
	}

function lfControllaPwd (lvU, lvP){
	var lvReturn = "";
	if (lvP.toLowerCase() == lvU.toLowerCase()) {
		lvReturn = "Username e password non possono essere uguali";
	}

	if (lvP.length < 8) {
		lvReturn = "La password deve essere di almeno 8 caratteri";
	}

	if (lvP.indexOf(" ") > 0) {
		lvReturn = "La password non può contenere spazi";
	}
	return lvReturn;
}

function changeHiddenVal(nomeMitt,nomeDest)
{
	document.getElementById(nomeDest).value = document.getElementById(nomeMitt).value;
}