/*
son of suckerfish menu script from:
http://www.htmldog.com/articles/suckerfish/dropdowns/
 */
 
 sfHover = function() {
	var sfEls = document.getElementById("nav").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
			this.style.zIndex=200; //this line added to force flyout to be above relatively positioned stuff in IE
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", sfHover);

function IsValidEmail(Stringa) {
	var i;
	var chioccia;
	var punto;
	chioccia = 0;
	punto = 0;
	for (i=0; i<Stringa.length; i++) {
		if ( Stringa.charAt(i) == "@" ) {
			chioccia = chioccia + 1;
		}
		if (( chioccia > 0 ) && ( Stringa.charAt(i) == "." )) {
			punto = punto + 1;
		}
	}
	if ((chioccia < 1) || (punto < 1)) { 
		return false;
	}
	return true;
}

function showHideElement(id) {
	if(document.getElementById(id).style.visibility == "hidden" || document.getElementById(id).style.visibility == "") {
		document.getElementById(id).style.visibility = "visible";
		document.getElementById(id).style.display = "block";
	} else {
		document.getElementById(id).style.visibility = "hidden";
		document.getElementById(id).style.display = "none";
	}
}

function goForm() {
	var cognome = document.frmConto.cognome.value;
	var nome = document.frmConto.nome.value;
	var citta = document.frmConto.citta.value;
	var provincia = document.frmConto.provincia.options[document.frmConto.provincia.selectedIndex].value;
	var email = document.frmConto.email.value;
	var errore = "";
	if(cognome=="") errore += "Occorre inserire il COGNOME\n";
	if(nome=="") errore += "Occorre inserire il NOME\n";
	if(citta=="") errore += "Occorre inserire la CITTA'\n";
	if(provincia=="") errore += "Occorre selezionare la PROVINCIA\n";
	if(email=="") errore += "Occorre inserire l'E-MAIL\n";
	else if(!IsValidEmail(email)) errore += "L'E-MAIL inserita non e' valida\n";
	if(errore=="")
		document.frmConto.submit();
	else
		alert(errore);
}