//Javascript
/*
Il seguente javascript è compatibile sui diversi browser (Testato su IE 6.0, firefox 0.8, Opera 7.50)
*/

function change_visibility(id){
	if (document.getElementById) 
    if (document.getElementById(id).style.display=='none')			
		  document.getElementById(id).style.display='block'; // cambiare block con inline a seconda dell'elemento da mostrare 
		else
      document.getElementById(id).style.display='none'; 
	else if (document.all)
	  if (document.all[id].style.display=='none') 
		  document.all[id].style.display='block';
		else
		  document.all[id].style.display='none';
	else if (document.layers)
	  if (document.layers[id].display=='none')
		  document.layers[id].display='block';
		else
      document.layers[id].display='none';  
	else
		alert("Browser incompatibile!");
}

function show(id){
	if (document.getElementById) 
		document.getElementById(id).style.display='block';
	else if (document.all)
		document.all[id].style.display='block';
	else if (document.layers)
		document.layers[id].display='block';
	else
		alert("Browser incompatibile!");
}
function reset(id){
	if (document.getElementById) 
		document.getElementById(id).style.display='none';
	else if (document.all)
		document.all[id].style.display='none';
	else if (document.layers)
		document.layers[id].display='none';
	else
		alert("Browser incompatibile!");
}


function popupInformativa(info) {
	window.open(info,"informative","width=600,height=260,scrollbars=yes,resizable=yes");
	return false;
}
						
/*function controlloform(){
	if (document.contact.from.value=="") {
		alert("Devi inserire un indirizzo email per poter inviare il messaggio");
	}else if (document.contact.msg.value=="") {
		alert("Devi inserire un messaggio per poter continuare");
	} else if(document.contact.accetto[0].checked){
		document.contact.submit();
	} else {
		alert("Devi accettare l'informativa per poter inviare il messaggio");
	}
	return false;
}*/



function indietro(){
  history.back();
	return false;
}

function restituisciElemento(id) {
	if (document.getElementById)
		elemento = document.getElementById(id);
	else if (document.all)
		elemento = document.all[id];
	else if (document.layers)
		elemento =  document.layers[id];
	else
		alert("Browser incompatibile!");
	return elemento;
}
function controllaForm_it() {
  /*nome = restituisciElemento('nome');
  cognome = restituisciElemento('cognome');
  ruolo = restituisciElemento('ruolo');
  citta = restituisciElemento('citta');
  email = restituisciElemento('email');
  note = restituisciElemento('note');*/
  strAccetto = restituisciElemento('strAccetto');
  strEmail =  restituisciElemento('strEmail');
	/*if 	(nome.value=="") {
		alert("Ha dimenticato di inserire il Nome");
		return false;
	} else if 	(cognome.value=="") {
		alert("Ha dimenticato di inserire il Cognome");
		return false;
	} else if 	(ruolo.value=="") {
		alert("Ha dimenticato di inserire la Funzione aziendale");
		return false;
	} else if 	(citta.value=="") {
		alert("Ha dimenticato di inserire la Città");
		return false;
	} else if 	(note.value=="") {
		alert("Ha dimenticato di inserire il Messaggio");
		return false;
	} else if (validaEmail(email)) {*/
		if(indirizzoEmailValido(strEmail.value)==false){
	
	 alert("L'indirizzo email inserito non è valido");
	 return false;
  }else{
		if (strAccetto.checked) {
			return true;
		} else {
			alert("Per inviare il messaggio è necessario accettare le condizioni sul trattamento dei dati personali");
			return false;
		}
  }
  /*
		if (strAccetto.checked) {
			return true;
		} else {
			alert("Per inviare il messaggio è necessario accettare le condizioni sul trattamento dei dati personali");
			return false;
		}
	} else {
		return false;
	}*/
}	


function controllaForm_en() {
  /*nome = restituisciElemento('nome');
  cognome = restituisciElemento('cognome');
  ruolo = restituisciElemento('ruolo');
  citta = restituisciElemento('citta');
  email = restituisciElemento('email');
  note = restituisciElemento('note');*/
  strAccetto = restituisciElemento('strAccetto');	
	/*if 	(nome.value=="") {
		alert("You forgot to insert a Name");
		return false;
	} else if 	(cognome.value=="") {
		alert("You forgot to insert the Last Name");
		return false;
	} else if 	(ruolo.value=="") {
		alert("You forgot to insert your Business occupation");
		return false;	
	} else if 	(citta.value=="") {
		alert("You forgot to insert the City");
		return false;
	} else if 	(note.value=="") {
		alert("You forgot to insert a Note");
		return false;
	} else if (validaEmail_en(email)) {*/
		if (strAccetto.checked) {
			return true;
		} else {
			alert("You forgot to accept the conditions of law n. 196/2003");
			return false;
		}
	/*} else {
		return false;
	}*/
}

function controllaForm_fr() {
  /*nome = restituisciElemento('nome');
  cognome = restituisciElemento('cognome');
  ruolo = restituisciElemento('ruolo');
  citta = restituisciElemento('citta');
  email = restituisciElemento('email');
  note = restituisciElemento('note');*/
  strAccetto = restituisciElemento('strAccetto');	
	/*if 	(nome.value=="") {
		alert("You forgot to insert a Name");
		return false;
	} else if 	(cognome.value=="") {
		alert("You forgot to insert the Last Name");
		return false;
	} else if 	(ruolo.value=="") {
		alert("You forgot to insert your Business occupation");
		return false;	
	} else if 	(citta.value=="") {
		alert("You forgot to insert the City");
		return false;
	} else if 	(note.value=="") {
		alert("You forgot to insert a Note");
		return false;
	} else if (validaEmail_en(email)) {*/
		if (strAccetto.checked) {
			return true;
		} else {
			alert("You forgot to accept the conditions of law n. 196/2003");
			return false;
		}
	/*} else {
		return false;
	}*/
}

function indirizzoEmailValido(indirizzo) {
  if (window.RegExp) {
    var nonvalido = "(@.*@)|(\\.\\.)|(@\\.)|(\\.@)|(^\\.)";
    var valido = "^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,4}|[0-9]{1,3})(\\]?)$";
    var regnv = new RegExp(nonvalido);
    var regv = new RegExp(valido);
    if (!regnv.test(indirizzo) && regv.test(indirizzo))
      return true;
    return false;
	}else {
    if(indirizzo.indexOf("@") >= 0)
      return true;
    return false;
  }
}
