function getPageScroll(){

	var yScroll;

	if (self.pageYOffset) {
		yScroll = self.pageYOffset;
	} else if (document.documentElement && document.documentElement.scrollTop){	 // Explorer 6 Strict
		yScroll = document.documentElement.scrollTop;
	} else if (document.body) {// all other Explorers
		yScroll = document.body.scrollTop;
	}

	arrayPageScroll = new Array('',yScroll) 
	return arrayPageScroll;
}

function getPageSize(){
	
	var xScroll, yScroll;
	
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	
	var windowWidth, windowHeight;
	if (self.innerHeight) {	// all except Explorer
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = windowWidth;
	} else {
		pageWidth = xScroll;
	}


	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight);
	return arrayPageSize;
}

function livello_vis(idel, idel2, widthimg, heightimg){
var rpx, rpy, x1, y1, vx, vy, sc_x, sc_y, sc_x2, sc_y2, dif, scroll_x, scroll_y;
var dim_page = new Array();
var dim_scroll = new Array();
dim_page = getPageSize();
dim_scroll = getPageScroll();
dif = (dim_page[0] - 18);
scroll_x = dim_scroll[0];
scroll_y = dim_scroll[1];

document.getElementById(idel).style.left = "0px";
document.getElementById(idel).style.top = "0px";	  
document.getElementById(idel).style.width = dif + "px";
document.getElementById(idel).style.height = dim_page[1] + "px";	
//document.getElementById(idel).style.background = "url('img/vuoto.gif')";	 
document.getElementById(idel).style.background = "url('img/sfondo.png')"; 
//alert(document.getElementById(idel).style.height);
rpx = ((dim_page[2] / 2) - (widthimg / 2)) + scroll_x;
rpy = ((dim_page[3] / 2) - (heightimg / 2)) + scroll_y;
//alert(dim_page[3]);
	  //alert(rpx + " " + rpy);
      document.getElementById(idel2).style.left = rpx + "px";
	  document.getElementById(idel2).style.top = rpy + "px";
	  //alert(document.getElementById(idel2).style.top);
      //document.getElementById(idel).style.opacity = 0.70;
      //document.getElementById(idel).style.filter = "alpha(opacity:" + (1 * 70) + ")";	  
      document.getElementById(idel2).style.opacity = "1";
      document.getElementById(idel2).style.filter = "alpha(opacity:" + (1 * 100) + ")";	  	  
	  document.getElementById(idel).style.visibility = "visible";
	  document.getElementById(idel2).style.visibility = "visible";
}

function visibile_ev2(idel){
var rpx, rpy, x1, y1, vx, vy;
  if (document.all){
  vx = 200;
  vy = document.body.scrollTop + 30;
  document.getElementById(idel).style.pixelLeft = vx;
  document.getElementById(idel).style.pixelTop = vy;
  document.getElementById(idel).style.visibility = "visible";

  }
  
  else
  {
    if (document.layers){
    //bx = (window.innerWidth / 2) - 350;
    rpx = (mouseX / window.innerWidth);
	rpy = (mouseY / window.innerHeight);
	x1 = (widthimg * rpx);
	y1 = (heightimg * rpy);
    document.idel.left = mouseX  - x1;
	document.idel.top = mousey - y1;
    }
    else
    {
      if(document.getElementById) {
	  vx = 200;
      vy = document.body.scrollTop + 30;
      if (vy < 0){
      vy = 0;
      }
      if (vx < 0){
      vx = 0;
      }  
      document.getElementById(idel).style.left = vx;
	  document.getElementById(idel).style.top = vy;
	  document.getElementById(idel).style.visibility = "visible";
      }
    }
  }
}

function livello_no_vis(idel){
document.getElementById(idel).style.visibility = "hidden";
document.getElementById("id_livello").innerHTML = "";
}

function livello_no_vis2(idel){
document.getElementById(idel).style.visibility = "hidden";
//document.getElementById(idel).innerHTML = "";
}

function vismes(idmes){
document.getElementById("contau").style.visibility = "hidden";
document.getElementById("conten").style.visibility = "hidden";
document.getElementById("conttr").style.visibility = "hidden";
document.getElementById(idmes).style.visibility = "visible";
document.getElementById(idmes).style.left = mouseX - 280;
document.getElementById(idmes).style.top = mouseY - 280;
}

function mostra_freccia(idel){
//alert("ciao");
var img;
if (idel == "id_imgsx"){
img = "url('img/freccia_sx.gif') no-repeat left";
}

if (idel == "id_imgdx"){
img = "url('img/freccia_dx.gif') no-repeat right";
}

document.getElementById(idel).style.opacity = 0.80;
document.getElementById(idel).style.filter = "alpha(opacity:80)";
document.getElementById(idel).style.background = img;
}

function nascondi_freccia(idel){
var img;
if (idel == "id_imgsx"){
img = "green";
}

if (idel == "id_imgdx"){
img = "red";
}

document.getElementById(idel).style.background = "white";
document.getElementById(idel).style.opacity = 0;
document.getElementById(idel).style.filter = "alpha(opacity:0)";
}
