/* LEFT MENU FOR FRATELLI-RODA SA */

/* ATTENTION: myMenuName SIZE must be the same of mySubMenuNameLink!!! */
/* This array contains the MAINMENU sections name */
var myMenuName=new Array(	"Azienda",
							"Prodotti",
							"Servizi",
							"Qualit&agrave;",
							"Offerte",
							"News",
							"Galleria",
							"Contatti",
							"Server"
						 );

/* ATTENTION: mySubMenuNameLink SIZE must be the same of myMenuName !!! */
/* This array contains the SUBSECTIONS NAMES AND LINKS of main-menu */
var mySubMenuNameLink=new Array (	new Array(
											new Array("Facts & Figures","index.php?content=factsfigures&menu=0"),
											new Array("Organigramma","index.php?content=organigramma&menu=0"),
											new Array("Filosofia","index.php?content=filosofia&menu=0"),
											new Array("Cenni Storici","index.php?content=storia&menu=0"),
											new Array("Documentazione","index.php?content=documentazione&menu=0"),
											new Array("Posti Vacanti","message.php?view=lavoro&menu=0")),
									new Array(
											new Array("Imballaggi","index.php?content=imballaggi&menu=1"),
											new Array("POS","index.php?content=pos&menu=1"),
											new Array("Blister","index.php?content=blister&menu=1"),
											new Array("Stampati","index.php?content=stampati&menu=1"),
											new Array("Manifesti","index.php?content=manifesti&menu=1")),
									new Array(
											new Array("Prestampa","index.php?content=prestampa&menu=2"),
											new Array("Campionatura CAD","index.php?content=campionatura&menu=2"),
											new Array("Confezionamento","index.php?content=confezionamento&menu=2"),
											new Array("Directmail","index.php?content=directmail&menu=2"),
											new Array("Logistica","index.php?content=logistica&menu=2")),
									new Array(
											new Array("Certificazione","index.php?content=certificazione&menu=3"),
											new Array("La nuova Norma","index.php?content=nuovanorma&menu=3")),
									new Array(
											new Array("Modulo Online","reg_form.php?menu=4"),
											new Array("Offerta speciale","index.php?content=special_offer&menu=4")),
									new Array(
											new Array("Tutte le News","message.php?&menu=5")),
									new Array(
											new Array("Manifesti","manifesto.php?dir=Manifesti&menu=6"),
											new Array("Imballaggi","manifesto.php?dir=Imballaggi&menu=6"),
											new Array("POS","manifesto.php?dir=PointOfSale&menu=6"),
											new Array("Origami","manifesto.php?dir=Origami&menu=6"),
											new Array("Slide Show","index.php?content=slideshow&menu=6")),
									new Array(
											new Array("Contatti","index.php?content=contatti&menu=7"),
											new Array("Cartina","index.php?content=cartina&menu=7")),
									new Array(
											new Array("Server","index.php?content=ftp&menu=8"))
								 );

function createMenuLeft() {
	/*STRUCTURE OF MASTERDIV
		<masterdiv>
			<s_div>
			<span>
				<img> <a>
				<img> <a> ...
			<s_div>
			<span>
				<img> <a>
				<img> <a> ...
			...
		</div>
	*/
    var masterdiv = document.getElementById("masterdiv"); //main div, already present in html
	var subdiv,span,a,img,br; //html elements
	var m,sm; //vars needed by the 2 for loop
	
	for(m=0;m<mySubMenuNameLink.length;m++){
		//internal div of masterdiv
		subdiv = document.createElement("div");
		subdiv.setAttribute("class","menutitle");
		subdiv.setAttribute("className","menutitle");
		subdiv.onclick=Function("SwitchMenu('subM"+m+"')");
		subdiv.innerHTML=myMenuName[m];
		//internal span of masterdiv
		span = document.createElement("span");
		span.setAttribute("class","submenu");
		span.setAttribute("className","submenu");
		span.setAttribute("id","subM"+m);
		for(sm=0;sm<mySubMenuNameLink[m].length;sm++){
			//internal a of span
			a = document.createElement("a");
			//a.className="submenu";
			a.setAttribute("href",mySubMenuNameLink[m][sm][1]);
			a.innerHTML=mySubMenuNameLink[m][sm][0]; 
			//internal img of span (always the same)
			img = document.createElement("img");
			img.setAttribute("src","img/quandratomenu8x8.gif");
			//append the img and the a to the span
			span.appendChild(img);
			span.appendChild(a);
			//append a newline after img and a
			br = document.createElement("br");
			span.appendChild(br);
		}
		//append to masterdiv subdiv and span
		masterdiv.appendChild(subdiv);
		masterdiv.appendChild(span);
	}
}

//Function that control the open and close command of the menu
function SwitchMenu(obj){
	if(document.getElementById){
	var el = document.getElementById(obj);
	var ar = document.getElementById("masterdiv").getElementsByTagName("span"); 
		if(el.style.display != "block"){ 
			for (var i=0; i<ar.length; i++){
				if (ar[i].className=="submenu") 
				ar[i].style.display = "none";
			}
			el.style.display = "block";
		}else{
			el.style.display = "none";
		}
	}
}