var prev= null;
var att_last=0;
var prev_last=0;
window.onload=function(){
if(document.getElementsByTagName && document.getElementById){
    document.getElementById("menu").className="jsenable";
    BuildList();
    }
}

function BuildList(){
var hs=document.getElementById("menu").getElementsByTagName("h3");

	for(var i=0;i<hs.length;i++){
    hs[i].onclick=function(){
			if(this.parentNode.className!="show"){
				//se last ricordiamoci che è last ed è da aprire.
				if (this.parentNode.className=="last")
					att_last=1;//salvato attuale.
				else
					att_last=0;
				this.parentNode.className="show";//apri
				if(prev && prev!=this && prev.parentNode.className=="show"){
					if(prev_last==1){
						prev.parentNode.className="last";
						prev_last=0;
					}
					else
						prev.parentNode.className="hide";
				}
				prev=this;
				if(att_last==1)
					prev_last=1;
			}
			else {
				if (att_last==1)
					this.parentNode.className="last";
				else
					this.parentNode.className="hide";
				att_last=0;
				prev_last=0;
			}
		}
	}
} 