function scambio(id)
{
if (document.getElementById)
	{
		if(document.getElementById(id).style.display == 'none')
		{
			document.getElementById(id).style.display = 'block';
		}
		else if (document.getElementById(id).style.display == '')
		{
		document.getElementById(id).style.display = 'block';
		}
		else 
		{
			document.getElementById(id).style.display = 'none';
		}
	}
}
//funzione per il menu principale, accende il proprio menu e spegne gli altri
function menudisplay(id,menuuno,menudue,menutre,menuquattro)
{
if (document.getElementById)
	{
		if(document.getElementById(id).style.display == 'none')
		{
			document.getElementById(id).style.display = 'block';
			document.getElementById(menuuno).style.display = 'none';
			document.getElementById(menudue).style.display = 'none';
			document.getElementById(menutre).style.display = 'none';
			document.getElementById(menuquattro).style.display = 'none';
		}
		else if (document.getElementById(id).style.display == '')
		{
			document.getElementById(id).style.display = 'block';
			document.getElementById(menuuno).style.display = 'none';
			document.getElementById(menudue).style.display = 'none';
			document.getElementById(menutre).style.display = 'none';
			document.getElementById(menuquattro).style.display = 'none';
		}
		else 
		{
			document.getElementById(id).style.display = 'none';
		}
	}
}
//carica una png per lo sfondo del menuprincipale in "onclick",spegne gli altri e se stesso e il menu orna chiuso (uno per ogni menu perchè sfondi diversi)
function sfondorelatori()
{
	document.getElementById('menuuno').style.background = 'none';
	document.getElementById('menutre').style.background = 'none';
	document.getElementById('menuquattro').style.background = 'none';
	document.getElementById('menucinque').style.background = 'none';
	if(document.getElementById('menu_relatori').style.display == 'none')
	{
		document.getElementById('menudue').style.background = 'url(/layout/relatori.png)';
	}
	else if (document.getElementById('menu_relatori').style.display == '')
	{
		document.getElementById('menudue').style.background = 'url(/layout/relatori.png) 0 0';
	}
	else 
	{
		document.getElementById('menudue').style.background = 'none';
	}
}
function sfondoautori()
{
	document.getElementById('menuuno').style.background = 'none';
	document.getElementById('menutre').style.background = 'none';
	document.getElementById('menudue').style.background = 'none';
	document.getElementById('menucinque').style.background = 'none';
	if(document.getElementById('menu_autori').style.display == 'none')
	{
		document.getElementById('menuquattro').style.background = 'url(/layout/relatori.png)';
	}
	else if (document.getElementById('menu_autori').style.display == '')
	{
		document.getElementById('menuquattro').style.background = 'url(/layout/relatori.png) 0 0';
	}
	else 
	{
		document.getElementById('menuquattro').style.background = 'none';
	}
}
//sfondo vecchio quando il titolo era solo "Gli Incontri"
function sfondoincontri()
{
	document.getElementById('menudue').style.background = 'none';
	document.getElementById('menutre').style.background = 'none';
	document.getElementById('menuquattro').style.background = 'none';
	if(document.getElementById('menu_incontri').style.display == 'none')
	{
		document.getElementById('menuuno').style.background = 'url(/layout/incontri.png)';
	}
	else if (document.getElementById('menu_incontri').style.display == '')
	{
		document.getElementById('menuuno').style.background = 'url(/layout/incontri.png) 0 0';
	}
	else 
	{
		document.getElementById('menuuno').style.background = 'none';
	}
}

function sfondoeventipassati()
{
	document.getElementById('menudue').style.background = 'none';
	document.getElementById('menutre').style.background = 'none';
	document.getElementById('menuquattro').style.background = 'none';
	document.getElementById('menucinque').style.background = 'none';
	if(document.getElementById('menu_incontri').style.display == 'none')
	{
		document.getElementById('menuuno').style.background = 'url(/layout/eventipassati.png)';
	}
	else if (document.getElementById('menu_incontri').style.display == '')
	{
		document.getElementById('menuuno').style.background = 'url(/layout/eventipassati.png) 0 0';
	}
	else 
	{
		document.getElementById('menuuno').style.background = 'none';
	}
}
function sfondoeventifuturi()
{
	document.getElementById('menudue').style.background = 'none';
	document.getElementById('menutre').style.background = 'none';
	document.getElementById('menuquattro').style.background = 'none';
	document.getElementById('menuuno').style.background = 'none';
	if(document.getElementById('menu_eventifuturi').style.display == 'none')
	{
		document.getElementById('menucinque').style.background = 'url(/layout/eventifuturi.png)';
	}
	else if (document.getElementById('menu_eventifuturi').style.display == '')
	{
		document.getElementById('menucinque').style.background = 'url(/layout/eventifuturi.png) 0 0';
	}
	else 
	{
		document.getElementById('menucinque').style.background = 'none';
	}
}

function sfondocontatti()
{
	document.getElementById('menuuno').style.background = 'none';
	document.getElementById('menudue').style.background = 'none';
	document.getElementById('menuquattro').style.background = 'none';
	document.getElementById('menucinque').style.background = 'none';
	if(document.getElementById('menu_contatti').style.display == 'none')
	{
		document.getElementById('menutre').style.background = 'url(/layout/contatti.png)';
	}
	else if (document.getElementById('menu_contatti').style.display == '')
	{
		document.getElementById('menutre').style.background = 'url(/layout/contatti.png) 0 0';
	}
	else 
	{
		document.getElementById('menutre').style.background = 'none';
	}
}

function cambiacaratteriperajax(valore) { //questa funzione permette di convertire i caratteri in formato #numero# per poterli passare ad eventuali pagine ajax e viene utilizzata per l'invio di moduli)
	for( i = 1; i < 254 ; i++ )
	{
		valore = valore.replace(/String.fromCharCode(i)/g,"#"+i+"#");
	}
	valore = valore.replace(/&/g,"#amp#");
	valore = valore.replace(/ /g,"#nbsp#");
	valore = valore.replace(/\+/,"#piu#");
	valore = valore.replace(/%/g,"#permil#");
	valore = valore.replace(/\r/g,"#vbcrlf#");
	return valore;
}


//controllo il form per l'invio dei dati e delle prenotazioni
function trim(str)
{
  return str.replace(/^\s+|\s+$/g, '');
}
var tfldcampo;
function controllamodulo()
{
	errore = 0
	tfldcampo = document.richiestainformazioni.email.value;
	tfldcampo = trim(tfldcampo)
	var email = /^[^@]+@[^@.]+\.[^@]*\w\w$/  ;
	if (document.richiestainformazioni.email.value==null||document.richiestainformazioni.email.value=="")
	{
	  errore = 1;
	  document.getElementById('labelmail').innerHTML = "e-mail del richiedente: <b>attenzione! e-mail obbligatoria</b>";
	}
	else
	if (!email.test(tfldcampo))
	{
		document.getElementById('labelmail').innerHTML = "e-mail del richiedente: <b>attenzione! e-mail non valida</b>";
		errore = 1
	}
	else
	{
	  document.getElementById('labelmail').innerHTML = "e-mail del richiedente: ";
	}
	if (document.richiestainformazioni.messaggio.value==null||document.richiestainformazioni.messaggio.value=="")
	{
	  errore = 1;
	  document.getElementById('labelmsg').innerHTML = "messaggio: <b>attenzione! messaggio obbligatorio</b>";
	}
	else
	{
	  document.getElementById('labelmsg').innerHTML = "messaggio: ";
	}
	validi = "0123456789+";
	numerotelefono = document.richiestainformazioni.tel.value
	if ((document.richiestainformazioni.eventouno.checked == true|| document.richiestainformazioni.eventodue.checked == true||document.richiestainformazioni.eventotre.checked == true||document.richiestainformazioni.eventoquattro.checked == true) && (document.richiestainformazioni.tel.value==null||document.richiestainformazioni.tel.value==""))
	{
	  errore = 4;
	  document.getElementById('labeltel').innerHTML = "numero di telefono: <b>attenzione! obbligatorio se prenotate un evento</b>";
	}
	else
	{
		if (numerotelefono.length > 16) {
		errore = 2
		document.getElementById('labeltel').innerHTML = "numero di telefono: <b>attenzione! numero di telefono non valido";	
		}
		else
		{
			for( i = 0; i < 100 ; i++ )
			{
				if( validi.indexOf( numerotelefono.charAt(i) ) == -1 )
				{
					errore = 3
					document.getElementById('labeltel').innerHTML = "numero di telefono: <b>attenzione! numero di telefono non valido";	
				}
			}
			if (errore != 3)
			{
				document.getElementById('labeltel').innerHTML = "numero di telefono:";	
			}
		}
	}
	if ((document.richiestainformazioni.eventouno.checked == true|| document.richiestainformazioni.eventodue.checked == true||document.richiestainformazioni.eventotre.checked == true||document.richiestainformazioni.eventoquattro.checked == true|| document.richiestainformazioni.eventocinque.checked == true) && (document.richiestainformazioni.nomeecognome.value==null||document.richiestainformazioni.nomeecognome.value==""))
	{
	  errore = 5;
	  document.getElementById('labelnomeecognome').innerHTML = "nome e cognome: <b>attenzione! obbligatori se prenotate un evento</b>";
	}
	else
	{
	  document.getElementById('labelnomeecognome').innerHTML = "nome e cognome:";
	}
	if (errore==0)
	{
		scambio('testoinviomail');
		scambio('richiestainformazioni');
		document.getElementById('testoinviomail').innerHTML = "Stiamo inviando la tua richiesta... attendi grazie.<br><img src='/layout/wait.gif' />";
		if(window.XMLHttpRequest)
		{
		   richiesta = new XMLHttpRequest();
		}
		else if(window.ActiveXObject)
		{
		   richiesta = new ActiveXObject("Microsoft.XMLHTTP");
		}
		richiesta.open("POST", "/ajax/iscrizione.asp", true);
		richiesta.onreadystatechange = function() 
		{
			if(richiesta.readyState == 4)
			{	
				if(richiesta.status == 200)
				{
					if(richiesta.responseText == "02")
					{
					location.href = "/p/messaggioinviato";
					}
					else if(richiesta.responseText == "03")
					{
					location.href = "/p/messaggiononinviato";
					}
					else
					{
					document.getElementById('testoinviomail').innerHTML = "Purtoppo si &egrave verificato un errore durante la connessione con il server. Vi preghiamo di <a href='javascript: scambio(&#39testoinviomail &#39); scambio(&#39richiestainformazioni&#39);'>riprovare</a> pi&ugrave tardi.";
					}
				}
				else if(richiesta.status == 500)
				{
					document.getElementById('testoinviomail').innerHTML = richiesta.status + " Errore Raccolta Dati <a href='javascript:scambio(&#39testoinviomail&#39);scambio(&#39richiestainformazioni&#39);'>Riprova</a>";
				}
				else if(richiesta.status == 404)
				{
					document.getElementById('testoinviomail').innerHTML = richiesta.status + " XML Rimosso. Server in manutenzione";
				}
				else
				{
					document.getElementById('testoinviomail').innerHTML = "Errore Server " + richiesta.status;
				}
			}
			else
			{
					document.getElementById('testoinviomail').innerHTML = "Stiamo inviando la tua richiesta... attendi grazie.<br><img src='/layout/wait.gif' />";
			}
		}
		richiesta.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		<!--richiesta.send(variabile + "=" + document.eval(idmodulo).eval(idcampomodulo).value); non valido in IE-->>
				
		nomeecognome = cambiacaratteriperajax(document.richiestainformazioni.nomeecognome.value);
		email = document.richiestainformazioni.email.value;
		oggetto = cambiacaratteriperajax(document.richiestainformazioni.oggetto.value);
		messaggio = cambiacaratteriperajax(document.richiestainformazioni.messaggio.value);
		tel = cambiacaratteriperajax(document.richiestainformazioni.tel.value);
		
		
		eventouno = document.richiestainformazioni.eventouno.checked;
		eventodue = document.richiestainformazioni.eventodue.checked;
		eventotre = document.richiestainformazioni.eventotre.checked;
		eventoquattro = document.richiestainformazioni.eventoquattro.checked;
		eventocinque = document.richiestainformazioni.eventocinque.checked;
		if (document.richiestainformazioni.eventouno.checked == false)
		{
			eventouno = "0"
		}
		else
		{
			eventouno = "1"
		}
		if (document.richiestainformazioni.eventodue.checked == false)
		{
			eventodue = "0"
		}
		else
		{
			eventodue = "1"
		}
		if (document.richiestainformazioni.eventotre.checked == false)
		{
			eventotre = "0"
		}
		else
		{
			eventotre = "1"
		}
		if (document.richiestainformazioni.eventoquattro.checked == false)
		{
			eventoquattro = "0"
		}
		else
		{
			eventoquattro = "1"
		}
		if (document.richiestainformazioni.eventocinque.checked == false)
		{
			eventocinque = "0"
		}
		else
		{
			eventocinque = "1"
		}
		
		richiesta.send("nomeecognome=" + nomeecognome + "&email=" + email + "&oggetto=" + oggetto + "&messaggio=" + messaggio + "&tel=" + tel + "&eventouno=" + eventouno + "&eventodue=" + eventodue + "&eventotre=" + eventotre + "&eventoquattro=" + eventoquattro + "&eventocinque=" + eventocinque + "");

		}
}



//attualmente non utilizzati
function scambio(id)
{
if (document.getElementById)
	{
		if(document.getElementById(id).style.display == 'none')
		{
			document.getElementById(id).style.display = 'block';
		}
		else if (document.getElementById(id).style.display == '')
		{
		document.getElementById(id).style.display = 'block';
		}
		else 
		{
			document.getElementById(id).style.display = 'none';
		}
	}
}
function accendi(id)
{
	document.getElementById(id).style.display = 'block'
}

function spegni(id)
{
	document.getElementById(id).style.display = 'none'
}

