var mIDOld = "x"

function mmenu(mID) {
	var menuOld ;
	var displayOld; 
	if (mIDOld != mID && mIDOld != "x" ) {
		if  (mIDOld.substring(1,9) !=  mID.substring(1,9)) {
	    //document.write (document.getElementById(mID).parentNode.Id);
//		menuOld = document.getElementById(mIDOld)
//		displayOld = menuOld.style.display;;
//		menuOld.style.display = (displayOld == "block") ? "none" : "block";
		//menuOld.parentNode.style.listStyleImage = (displayOld == "block") ? "url(cartellachiusa.gif)" : "url(cartellaaperta.gif)";
		};
	};
	var mIDSub = "submenu." + mID;
	var menu = document.getElementById(mIDSub);
	if (menu == null) {return;}
	
	var display = menu.style.display;
		
	if (idMenu.substr(0, mID.length) == mID && display == "block") {return;}

	menu.style.display = (display == "block") ? "none" : "block";
	//menu.parentNode.style.listStyleImage = (display == "block") ? "url(images/FrecciaMenuDx.gif)" : "url(images/FrecciaMenuGiu.gif)";

	var menu = document.getElementById(mID);
	//menu.style.background = "url(images/BottonemenuGiu.gif)";
	if (display == "none")
	{
		menu.style.background = "url(images/BottonemenuGiu.gif)";
	}
	else {
		menu.style.background = "url(images/BottonemenuDx.gif)";
	}
	if (mIDOld == "x" || mIDOld.substring(1,9) !=  mID.substring(1,9)) {
		mIDOld = mID;
	}
}


window.onload = function() {
	//per il font                                       INIZIO
    if (idMenu == "999") {googleMaps();}

	var cookie = readCookie("style");
	var title = cookie ? cookie : getPreferredStyleSheet();
	if (title==null) title = 'piccolo'; 
	setActiveStyleSheet(title);
	//per il font                                       FINE

	//per il menu      apro e chiudo gli UL              INIZIO
	var uls = document.getElementsByTagName("ul");
	for (i=0;i < uls.length;i++) {
		if(uls[i].className=="submenu")
			uls[i].style.display = "none";
	} //per il menu      apro e chiudo gli UL              FINE

	//per il menu      accendo e spengo i LI          INIZIO
	if (idMenu == "0") {return;}
	var lis = document.getElementById(idMenu);
	
	lis.style.background = "#fff";
	
	var livelli = new Array();
	livelli = idMenu.split(".");
	var numLivelli = livelli.length - 1;
	
	switch (numLivelli) {
		case 2: 
			var subMenu = livelli[0] + "." +livelli[1]
			mmenu(subMenu);     //richiamo la funzione di apertura
			//var lis = document.getElementById(idMenu);
			//lis.style.background = "url(images/BottonemenuGiu.gif)";
		case 3: 
			var subMenu = livelli[0] + "." +livelli[1]
			mmenu(subMenu);     //richiamo la funzione di apertura
			var subMenu = livelli[0] + "." +livelli[1]+ "." +livelli[2]
			mmenu(subMenu);     //richiamo la funzione di apertura
	}
}


function gup( name ) 
  { 
  name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]"); 
  var regexS = "[\\?&]"+name+"=([^&#]*)"; 
  var regex = new RegExp( regexS ); 
  var results = regex.exec( window.location.href ); 
  if( results == null ) 
  return ""; 
  else 
  return results[1]; 
  } 
  
  
function googleMaps() {
	var map = new GMap2(document.getElementById("map"));
    map.addControl(new GLargeMapControl());
	map.addControl(new GMapTypeControl());
	map.setCenter(new GLatLng(45.792861, 12.4981067), 15, G_HYBRID_MAP);
	map.openInfoWindow(map.getCenter(), '<b>' + "ISI engineering" + '</b><br>'+ "via Sordello, 25" + '<br>' + "Oderzo - TV");
}