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;
}

var mouseX = 0;
var mouseY = 0;
if (document.layers) 
document.captureEvents(Event.MOUSEMOVE);
document.onmousemove = getCursor; 
function getCursor(e) {
if (document.all) {
mouseX = event.clientX + document.body.scrollLeft;
mouseY = event.clientY + document.body.scrollTop;
}
else
{
  if (document.getElementById) {
  mouseX = e.pageX;
  mouseY = e.pageY;
  }
}
}

function livello_vis2(idel, widthimg, heightimg){
var rpx, rpy, x1, y1, vx, vy, sc_x, sc_y, sc_x2, sc_y2, nome, file;
var dim_page = new Array();
dim_page = getPageSize();
nome = document.getElementById("id_imgx_" + idel).src;

document.getElementById("id_livello13").style.left = 0;
document.getElementById("id_livello13").style.top = 0;	  
document.getElementById("id_livello13").style.width = dim_page[0] - 18;
document.getElementById("id_livello13").style.height = dim_page[1];	
document.getElementById("id_livello13").style.visibility = "visible";
//document.getElementById(idel).style.background = "url('img/vuoto.gif')";
document.getElementById("id_livello13").style.background = "url('img/sfondo.png')"; 

rpx = ((dim_page[2] / 2) - (widthimg / 2)) + document.body.scrollLeft;
rpy = ((dim_page[3] / 2) - (heightimg / 2)) + document.body.scrollTop;
	  //alert(rpx + " " + rpy);

      document.getElementById("id_livello12").style.left = rpx;
	  document.getElementById("id_livello12").style.top = rpy;
      document.getElementById("id_livello12").style.width = widthimg;
      document.getElementById("id_livello12").style.height = heightimg;	
	  document.getElementById("id_livello12").style.background = "white";	
      document.getElementById("id_livello12").style.opacity = 1;
      document.getElementById("id_livello12").style.filter = "alpha(opacity:" + (1 * 100) + ")";	  	  
	  document.getElementById("id_livello12").style.visibility = "visible";
	  file = "livello_img_auto.php";
	  par = "nome1=" + nome + "&width1=" + widthimg + "&height1=" + heightimg;
	  //alert(file);
	  cc("id_livello12", file, "post", par);

}

function livello_vis3(img, widthimg, heightimg){
var rpx, rpy, x1, y1, vx, vy, sc_x, sc_y, sc_x2, sc_y2, nome, file;
var dim_page = new Array();
dim_page = getPageSize();

document.getElementById("id_livello13").style.left = 0;
document.getElementById("id_livello13").style.top = 0;	  
document.getElementById("id_livello13").style.width = dim_page[0] - 18;
document.getElementById("id_livello13").style.height = dim_page[1];	
document.getElementById("id_livello13").style.visibility = "visible";
//document.getElementById(idel).style.background = "url('img/vuoto.gif')";
document.getElementById("id_livello13").style.background = "url('img/sfondo.png')"; 

rpx = ((dim_page[2] / 2) - (widthimg / 2)) + document.body.scrollLeft;
rpy = ((dim_page[3] / 2) - (heightimg / 2)) + document.body.scrollTop;
	  //alert(rpx + " " + rpy);

      document.getElementById("id_livello12").style.left = rpx;
	  document.getElementById("id_livello12").style.top = rpy;
      document.getElementById("id_livello12").style.width = widthimg;
      document.getElementById("id_livello12").style.height = heightimg;	
	  document.getElementById("id_livello12").style.background = "white";	
      document.getElementById("id_livello12").style.opacity = 1;
      document.getElementById("id_livello12").style.filter = "alpha(opacity:" + (1 * 100) + ")";	  	  
	  document.getElementById("id_livello12").style.visibility = "visible";
	  file = "livello_img_auto.php";
	  par = "nome1=" + img + "&width1=" + widthimg + "&height1=" + heightimg;
	  //alert(par);
	  cc("id_livello12", file, "post", par);

}


function livello_vis(idel, widthimg, heightimg){
//alert(idel);
var rpx, rpy, x1, y1, vx, vy;
var lar, alt;
lar = (document.body.clientWidth / 2) - 150;
alt = 200;
x1 = 460;
y1 = 200;
//x1 = (widthimg / 2);
//x1 = (heightimg / 2);
  if (document.all){
  vx = mouseX  + document.body.scrollLeft - x1;
  vy = document.body.scrollTop + 50;
  //alert(vy);
   if (vy < 0){
   vy = 0;
   }
   if (vx < 0){
   vx = 0;
   }  
  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;
    document.idel.left = mouseX  - x1;
	 document.idel.top = mousey - y1;
    }
    else
    {
      if(document.getElementById) {
	  
	  //vx = mouseX  + document.body.scrollLeft - x1;
      //vy = document.body.scrollTop + y1;
      document.getElementById(idel).style.left = lar + "px";
	  document.getElementById(idel).style.top = alt + document.body.scrollTop + "px" ;
	  document.getElementById(idel).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(idel).innerHTML = "";
}

function livello_no_vis2(){
document.getElementById("id_livello13").style.visibility = "hidden";
document.getElementById("id_livello12").style.visibility = "hidden";
document.getElementById("id_livello12").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){
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";
}

 if (document.getElementById(idel)){
 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";
}
 if (document.getElementById(idel)){
 document.getElementById(idel).style.background = "white";
 document.getElementById(idel).style.opacity = 0;
 document.getElementById(idel).style.filter = "alpha(opacity:0)";
 }
}