<!--
function avvisi(testo) {
var div = document.createElement('div');
	div.id = 'popAvviso';
	div.className ='avvisiBox';
	document.body.appendChild(div);
	document.getElementById("popAvviso").innerHTML = testo;
	setTimeout("eliminaAvvisi()", 1000);
}

function eliminaAvvisi() {
var olddiv = document.getElementById("popAvviso");
  document.body.removeChild(olddiv);
}

function popup() {
var div = document.getElementById('popAlert');
	div.style.display = "block";
	div.className ='avvisoBox';
}


function mail_no_spam(user,dominio) {
    document.location.href = "mailto:" + user + "@" + dominio;
}

function apriDiv(quale){
	document.getElementById(quale).style.display= "block";
	}

function chiudiDiv(quale){
	document.getElementById(quale).style.display= "none";
	}

function apriIstruzioni(quale){
		if (document.getElementById(quale).style.display != "none") {
			document.getElementById(quale).style.display= "none";
			document.getElementById("bottAvviso").innerHTML = "apri le istruzioni";
		} else {
			document.getElementById(quale).style.display = "block";
			document.getElementById("bottAvviso").innerHTML = "chiudi le istruzioni";
		}
	}

function echeck(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    return false
		 }

 		 return true					
	}


function ValidaForm(formRegAccredito)
	{
	Invia = true;
	
	attivitaImpostata=false;
	for (i = 0; i < formRegAccredito.elements.length; i++){
		if (formRegAccredito.elements[i].type == 'checkbox'){
			if (formRegAccredito.elements[i].checked){
				if (formRegAccredito.elements[i].id.indexOf('MERCEOLOGIE')>=0){
					attivitaImpostata = true;
				}
			}
		}
	}
	
	if (!attivitaImpostata){
		document.getElementById('elencoAttivita').parentNode.className = "Errori";
		Invia = false;
	}else{
		document.getElementById('elencoAttivita').parentNode.className = "";
	}
	
	if(!document.getElementById('codiceAccreditoSelezionato').value ){
		if (formRegAccredito.Tipologia!=undefined){
			formRegAccredito.Tipologia[0].parentNode.className = "Errori";
			formRegAccredito.Tipologia[1].parentNode.className = "Errori";
		}else if(document.getElementById('select_accredito')!=undefined){
			document.getElementById('select_accredito').parentNode.className = "Errori";
		}
		Invia = false;
	}else{
		if (formRegAccredito.Tipologia!=undefined){
			formRegAccredito.Tipologia[0].parentNode.className = "";
			formRegAccredito.Tipologia[1].parentNode.className = "";
		}else if(document.getElementById('select_accredito')!=undefined){
			document.getElementById('select_accredito').parentNode.className = "";
		}
	}
	if (!document.getElementById('VServizio1').checked && !document.getElementById('VServizio0').checked){
		document.getElementById('VServizio1').parentNode.className = "Errori";
		Invia = false;
	}else{
		document.getElementById('VServizio1').parentNode.className = "";
	}
	
	if (!document.getElementById('VRetailer1').checked && !document.getElementById('VRetailer0').checked){
		document.getElementById('VRetailer1').parentNode.className = "Errori";
		Invia = false;
	}else{
		document.getElementById('VRetailer1').parentNode.className = "";
	}
	
	if(trim(document.getElementById('VEmail').value) == "" || echeck(trim(document.getElementById('VEmail').value))==false){
		document.getElementById('VEmail').parentNode.className = "Errori";
		Invia = false;
	}else{
		document.getElementById('VEmail').parentNode.className = "";
	}
	
	if(trim(document.getElementById('VCognome').value) == ""){
		document.getElementById('VCognome').parentNode.className = "Errori";
		Invia = false;
	}else{
		document.getElementById('VCognome').parentNode.className = "";
	}

	if(trim(document.getElementById('VNome').value) == ""){
		document.getElementById('VNome').parentNode.className = "Errori";
		Invia = false;
	}else{
		document.getElementById('VNome').parentNode.className = "";
	}

	if(trim(document.getElementById('VRagSoc').value) == ""){
		document.getElementById('VRagSoc').parentNode.className = "Errori";
		Invia = false;
	}else{
		document.getElementById('VRagSoc').parentNode.className = "";	
	}

	if(trim(document.getElementById('VIndirizzo').value) == ""){
		document.getElementById('VIndirizzo').parentNode.className = "Errori";
		Invia = false;
	}else{
		document.getElementById('VIndirizzo').parentNode.className = "";
	}

	if(trim(document.getElementById('VCap').value) == ""){
		document.getElementById('VCap').parentNode.className = "Errori";
		Invia = false;
	}else{
		document.getElementById('VCap').parentNode.className = "";
	}

	if(trim(document.getElementById('VCitta').value) == ""){
		document.getElementById('VCitta').parentNode.className = "Errori";
		Invia = false;
	}else{
		document.getElementById('VCitta').parentNode.className = "";
	}

	if(trim(document.getElementById('VEmailComunicazioni').value) == "" || echeck(trim(document.getElementById('VEmailComunicazioni').value))==false){
		document.getElementById('VEmailComunicazioni').parentNode.className = "Errori";
		Invia = false;
	}else{
		document.getElementById('VEmailComunicazioni').parentNode.className = "";
	}

	if(document.getElementById('VNazione').selectedIndex == 0){
		document.getElementById('VNazione').parentNode.className = "Errori";
		if(document.getElementById('VProvincia').selectedIndex == 0){
			document.getElementById('VProvincia').parentNode.className = "Errori";
		}else{
			document.getElementById('VProvincia').parentNode.className = "";
		}
		Invia = false;
	}else if(document.getElementById('VNazione').selectedIndex == 1){
		if(document.getElementById('VProvincia').selectedIndex == 0){
			document.getElementById('VProvincia').parentNode.className = "Errori";
			Invia = false;
		}else{
			document.getElementById('VProvincia').parentNode.className = "";
		}
	}else{
		document.getElementById('VNazione').parentNode.className = "";
	}
	
	if(document.getElementById('VLingua').selectedIndex == 0){
		document.getElementById('VLingua').parentNode.className = "Errori";
		Invia = false;
	}else{
		document.getElementById('VLingua').parentNode.className = "";
	}
		
	if(document.getElementById('VPrivacy').checked == false){
		document.getElementById('VPrivacy').parentNode.className = "Errori";
		Invia = false;
	}else{
		document.getElementById('VPrivacy').parentNode.className = "";
	}

	if(Invia == true)
		{
		if(confirm("Conferma l'operazione?\nDo you confirm registration?"))
			Invia = true;
		else
			Invia = false;
		}
	return Invia;
	}
	
function ValidaFormLingua(formRegAccredito,messaggio)
	{
	Invia = true;
	
	attivitaImpostata=false;
	for (i = 0; i < formRegAccredito.elements.length; i++){
		if (formRegAccredito.elements[i].type == 'checkbox'){
			if (formRegAccredito.elements[i].checked){
				if (formRegAccredito.elements[i].id.indexOf('MERCEOLOGIE')>=0){
					attivitaImpostata = true;
				}
			}
		}
	}
	
	if (!attivitaImpostata){
		document.getElementById('elencoAttivita').parentNode.className = "Errori";
		Invia = false;
	}else{
		document.getElementById('elencoAttivita').parentNode.className = "";
	}
	
	if(!document.getElementById('codiceAccreditoSelezionato').value ){
		if (formRegAccredito.Tipologia!=undefined){
			formRegAccredito.Tipologia[0].parentNode.className = "Errori";
			formRegAccredito.Tipologia[1].parentNode.className = "Errori";
		}else if(document.getElementById('select_accredito')!=undefined){
			document.getElementById('select_accredito').parentNode.className = "Errori";
		}
		Invia = false;
	}else{
		if (formRegAccredito.Tipologia!=undefined){
			formRegAccredito.Tipologia[0].parentNode.className = "";
			formRegAccredito.Tipologia[1].parentNode.className = "";
		}else if(document.getElementById('select_accredito')!=undefined){
			document.getElementById('select_accredito').parentNode.className = "";
		}
	}
	if (!document.getElementById('VServizio1').checked && !document.getElementById('VServizio0').checked){
		document.getElementById('VServizio1').parentNode.className = "Errori";
		Invia = false;
	}else{
		document.getElementById('VServizio1').parentNode.className = "";
	}
	
	if (!document.getElementById('VRetailer1').checked && !document.getElementById('VRetailer0').checked){
		document.getElementById('VRetailer1').parentNode.className = "Errori";
		Invia = false;
	}else{
		document.getElementById('VRetailer1').parentNode.className = "";
	}
	
	if(trim(document.getElementById('VEmail').value) == "" || echeck(trim(document.getElementById('VEmail').value))==false){
		document.getElementById('VEmail').parentNode.className = "Errori";
		Invia = false;
	}else{
		document.getElementById('VEmail').parentNode.className = "";
	}
	
	if(trim(document.getElementById('VCognome').value) == ""){
		document.getElementById('VCognome').parentNode.className = "Errori";
		Invia = false;
	}else{
		document.getElementById('VCognome').parentNode.className = "";
	}

	if(trim(document.getElementById('VNome').value) == ""){
		document.getElementById('VNome').parentNode.className = "Errori";
		Invia = false;
	}else{
		document.getElementById('VNome').parentNode.className = "";
	}

	if(trim(document.getElementById('VRagSoc').value) == ""){
		document.getElementById('VRagSoc').parentNode.className = "Errori";
		Invia = false;
	}else{
		document.getElementById('VRagSoc').parentNode.className = "";	
	}

	if(trim(document.getElementById('VIndirizzo').value) == ""){
		document.getElementById('VIndirizzo').parentNode.className = "Errori";
		Invia = false;
	}else{
		document.getElementById('VIndirizzo').parentNode.className = "";
	}

	if(trim(document.getElementById('VCap').value) == ""){
		document.getElementById('VCap').parentNode.className = "Errori";
		Invia = false;
	}else{
		document.getElementById('VCap').parentNode.className = "";
	}

	if(trim(document.getElementById('VCitta').value) == ""){
		document.getElementById('VCitta').parentNode.className = "Errori";
		Invia = false;
	}else{
		document.getElementById('VCitta').parentNode.className = "";
	}

	if(trim(document.getElementById('VEmailComunicazioni').value) == "" || echeck(trim(document.getElementById('VEmailComunicazioni').value))==false){
		document.getElementById('VEmailComunicazioni').parentNode.className = "Errori";
		Invia = false;
	}else{
		document.getElementById('VEmailComunicazioni').parentNode.className = "";
	}

	if(document.getElementById('VNazione').selectedIndex == 0){
		document.getElementById('VNazione').parentNode.className = "Errori";
		if(document.getElementById('VProvincia').selectedIndex == 0){
			document.getElementById('VProvincia').parentNode.className = "Errori";
		}else{
			document.getElementById('VProvincia').parentNode.className = "";
		}
		Invia = false;
	}else if(document.getElementById('VNazione').selectedIndex == 1){
		if(document.getElementById('VProvincia').selectedIndex == 0){
			document.getElementById('VProvincia').parentNode.className = "Errori";
			Invia = false;
		}else{
			document.getElementById('VProvincia').parentNode.className = "";
		}
	}else{
		document.getElementById('VNazione').parentNode.className = "";
	}
	
	if(document.getElementById('VLingua').selectedIndex == 0){
		document.getElementById('VLingua').parentNode.className = "Errori";
		Invia = false;
	}else{
		document.getElementById('VLingua').parentNode.className = "";
	}
		
	if(document.getElementById('VPrivacy').checked == false){
		document.getElementById('VPrivacy').parentNode.className = "Errori";
		Invia = false;
	}else{
		document.getElementById('VPrivacy').parentNode.className = "";
	}

	if(Invia == true){
		Invia=confirm(messaggio);
	}
	return Invia;
}

function trim(stringa)
	{
     stringa = stringa.replace(/ /g, "");
     return stringa;
	}

