// JavaScript Document

function getXMLHttp() {
var xmlhttp = null;
if (window.ActiveXObject) {
  if (navigator.userAgent.toLowerCase().indexOf("msie 5") != -1) {
  xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
  } else {
    xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
  }
}
if (!xmlhttp && typeof(XMLHttpRequest) != 'undefined') {
  xmlhttp = new XMLHttpRequest()
}
return xmlhttp
}

var http = getXMLHttp();


function showMain(id){ 
  if(http.readyState == 4) {
    var response = http.responseText; document.getElementById(id).innerHTML = response;
    try {
      document.getElementById(id).innerHTML = http.responseXML.getElementsByTagName("htmlData")[0].firstChild.nodeValue;
    } catch(e) {
    }
    try {
      javascriptCode = http.responseXML.getElementsByTagName("javascriptCode")[0].firstChild.nodeValue;
      if(javascriptCode) eval(javascriptCode);
    } catch(e) {
    }
  } else {
    document.getElementById(id).innerHTML = "<span class=\"testoChiaro\"><strong>Loading...</strong></span>";
  }
}

function apriMenu(livello) {		
		var posx = 0;
		var posy = 0;
		
		if(window.event) { 
		
		var e = window.event; 
		if (e.pageX || e.pageY)
		{
			posx = e.pageX;
			posy = e.pageY;
		}
		else if (e.clientX || e.clientY)
		{
			posx = e.clientX + document.documentElement.scrollLeft;
			posy = e.clientY + document.body.scrollTop;
		}
		else if (e.screenX || e.screenY)
		{
			posx = e.screenX + document.documentElement.scrollLeft;
			posy = e.screenY + document.documentElement.scrollTop;
		}
		
		} else { 
			posy = parseFloat(document.documentElement.scrollTop) + parseFloat(mouseY);
			// alert(mouseY);
		}
		
		tt = document.documentElement.scrollTop;
		var top = (posy-20);
		
		if(getResolution() <= '1024') {
			var left = 1;
		} else if(getResolution() > '1024') {
			// alert(getResolution());
			var left = 1;
		}
		
		if(livello == 'livello2') {
			var ll = (parseFloat(left) + parseFloat(130));
		} else if(livello == 'livello3') {
			var ll = (parseFloat(left) + parseFloat(300));
		}
		
		document.getElementById(livello).style.display='block';
		document.getElementById(livello).style.top=top+'px';
		document.getElementById(livello).style.left=ll+'px';
		
		
	}


function menuLivello(livello, parent) {
	http.open('get', 'include_parts/menu_new.php?action=riempi&livello=' + livello + '&parent=' + parent);
	// alert('include/menu_new.php?action=riempi&livello=' + livello + '&parent=' + parent);
	http.onreadystatechange = function() { showMain('livello'+livello); };
	http.send(null);
}


function chiudiMenu() {
	document.getElementById('livello2').style.display='none';
	document.getElementById('livello3').style.display='none';
	document.getElementById('livello4').style.display='none';
	document.getElementById('livello5').style.display='none';
}


function getResolution() {
	width = screen.width; 
	return width;
}

var isIE = document.all;
var mouseX = 0;
var mouseY = 0;

function getMouseXY(e)
{ 
if (!e) e = window.event;
if (e)
{ 
mouseX = isIE ? (e.clientX + document.body.scrollLeft) : e.pageX;
mouseY = isIE ? (e.clientY + document.body.scrollTop) : e.pageY;
}

}

document.onmousemove = getMouseXY;
