function visualizzaMenu(nome,nascondi1,nascondi2)
{
	document.getElementById(nome).style.display = "block";
	document.getElementById(nascondi1).style.display = "none";
	document.getElementById(nascondi2).style.display = "none";
}
function nascondiDiv()
{
	document.getElementById("menuProgetto").style.display = "none";
	document.getElementById("menuServizi").style.display = "none";
	document.getElementById("menuAssistenza").style.display = "none";
}
function espandiDiv(nome, numero)
{
	var i;
	var div;
	if (document.getElementById(nome+numero).style.display == "" || document.getElementById(nome+numero).style.display == "none") {
		// rendo invisibili tutti i DIV con ID nome+numero
		i=1;
		div = document.getElementById(nome+i);
		while (div) {
			div.style.display = "none";
			i++;
			div = document.getElementById(nome+i);
	    }
		// rendo visibile il DIV richiesto
		document.getElementById(nome+numero).style.display = "block";
	}
}

function SubmitOnEnter(myfield,e)
{
var keycode;
var nome = document.getElementById('login').username.value;
var password = document.getElementById('login').password.value;
if (window.event) keycode = window.event.keyCode;
else if (e) keycode = e.which; 
else return true;
if (keycode == 13)
{
	if ((nome == "") || (nome == "undefined")) {
	   alert("Il campo Nome utente è obbligatorio.");
	   document.getElementById('login').username.focus();
	   return false;
	}

	else if ((password == "") || (password == "undefined")) {
	   alert("Il campo Password è obbligatorio.");
	   document.getElementById('login').password.focus();
	   return false;
	}
setCookie('loginOk','false','','/');
document.forms['login'].submit();
return false;
}
else
return true;
}

function Controllo(){	
     var nome = document.getElementById('login').username.value;
     var password = document.getElementById('login').password.value;

        if ((nome == "") || (nome == "undefined")) {
           alert("Il campo Nome utente è obbligatorio.");
           document.getElementById('login').username.focus();
        }

        else if ((password == "") || (password == "undefined")) {
           alert("Il campo Password è obbligatorio.");
           document.getElementById('login').password.focus();
        }

        else {
			setCookie('loginOk','false','','/');
           	document.getElementById('login').submit();
        }
}

function setCookie(name, value, expires, path, domain, secure) {
  var curCookie = name + "=" + escape(value) +
      ((expires) ? "; expires=" + expires.toGMTString() : "") +
      ((path) ? "; path=" + path : "") +
      ((domain) ? "; domain=" + domain : "") +
      ((secure) ? "; secure" : "");
  document.cookie = curCookie;
  //alert(curCookie);
}
function getCookie(NameOfCookie){
	if (document.cookie.length > 0) {              
	begin = document.cookie.indexOf(NameOfCookie+"=");       
	if (begin != -1) {           
		begin += NameOfCookie.length+1;       
		end = document.cookie.indexOf(";", begin);
		if (end == -1) end = document.cookie.length;
			return unescape(document.cookie.substring(begin, end));
	} 
  }
  return null;
}
function espandiMenu(idMenu){
	var divMenu = document.getElementById("Menu"+idMenu);
	var imgEspandi = document.getElementById("Img"+idMenu);
	//window.alert(divMenu.className);
	if (divMenu.className=='divMenuInvisibile'){
		divMenu.className = 'divMenuVisibile'
		imgEspandi.title = "Comprimi menu"
		imgEspandi.className = "imgComprimiMenu";
	} else {
		divMenu.className = 'divMenuInvisibile'
		imgEspandi.title = "Espandi menu"
		imgEspandi.className = "imgEspandiMenu";
	}
}

