/*************************************/
/* Copyright 2005 Dr. Markus Senoner */
/* Alle Rechte vorbehalten           */
/*************************************/

var boxnum = 2;
var ie4 = (document.all && !window.opera) ? 1 : 0;
var ns4 = (document.layers) ? 1 : 0;
var ns6 = (document.getElementById) ? 1 : 0;

function Mostra(b,x,y,on) {
  if( ns6 )
	var box = document.getElementById(b).style;
  else
    var box = document.layers[b];
  if (on) {
    if (ns6) { // moderne Browser
	  box.left = x+"px";	// MSIE will die Einheit, sonst muss man "style.pixelLeft" verwenden
	  box.top = y+"px";	// MSIE will die Einheit, sonst muss man "style.pixelLeft" verwenden
	  box.visibility = "visible";	
    } else { // fuer alten Netscape4
	  box.left = x;
	  box.top = y;
	  box.visibility = "show";	
    }
  } else {
    if (ns6) {
      box.visibility = "hidden";
    } else {
      box.visibility = "hide";
    }
  }
}

function Nascondi() {
  for(i=1; i<=boxnum; i++) {
    var box = "sub"+i;
    Mostra(box,0,0,false);
  }
}

function NascondiPiano() {
  differita = setTimeout("Nascondi()",500);
}

function AnnullaNascondi(){
  if (window.differita)
	clearTimeout(differita);
}

function Apri(box,x,y,par) {
  var p = document.getElementById(par);    
  var posX = TrovaPosX(p)+x;
  var posY = TrovaPosY(p)+y;
  if (window.differita)
	clearTimeout(differita);
  Nascondi();
  Mostra(box,posX,posY,true);
}

function TrovaPosX(obj) {
	var posx = 0;
	if (obj.offsetParent) {
		while (obj.offsetParent) {
			posx += obj.offsetLeft
			obj = obj.offsetParent;
		}
	}
	else if (obj.x)
		posx += obj.x;
	return posx;
}

function TrovaPosY(obj) {
	var posy = 0;
	if (obj.offsetParent) {
		while (obj.offsetParent) {
			posy += obj.offsetTop
			obj = obj.offsetParent;
		}
	}
	else if (obj.y)
		posy += obj.y;
	return posy;
}
