function altezzaDiv (elmID) {
if(document.getElementById(elmID).clientHeight) {
return document.getElementById(elmID).clientHeight;
}
else {
if(document.getElementById(elmID).offsetHeight) {
return document.getElementById(elmID).offsetHeight;
}
}
}

function setHeight (cosa,altezza) {
	document.getElementById(cosa).style.height = altezza+'px';

}
	
	
function fai() {
	alt = altezzaDiv('centrale');
	setHeight('bordoSx',alt + 71);
	setHeight('bordoDx',alt + 71);
	setHeight('bottomRight',(alt- 396));


}

window.onload = function () {
	nascondiSubMenu();
	fai();

}
var active;




function addEvent(obj, evType, fn, useCapture){
  if (obj.addEventListener){
    obj.addEventListener(evType, fn, useCapture);
    return true;
  } else if (obj.attachEvent){
    var r = obj.attachEvent("on"+evType, fn);
    return r;
  } else {
    alert("Handler could not be attached");
  }
}


function nascondiSubMenu () {
var nn = 0;
	$$('div.SezMenu').each( function(p) {
									
		if(p.id != 'espanso') {
				p.id = nn;	
				$(p).observe('mouseover', function(){		
		var nnu = getY(this) + 1;
	  for (i=0; i<this.childNodes.length; i++){
						if(this.childNodes[i].className == "submenu") {							
								this.childNodes[i].className = "submenuFuori";
								$(this.childNodes[i]).setStyle({
									  position: 'absolute',
									  left: '213px',
									  top: nnu+'px'
									  
								  
								});
								nnu = nnu +18;
								Element.show(this.childNodes[i]);
						}

				}

		
		
	});
				
				$(p).observe('mouseout', function(){	
						  for (i=0; i<this.childNodes.length; i++){
						if(this.childNodes[i].className == "submenuFuori") {							
								this.childNodes[i].className = "submenu";
			
				
								Element.hide(this.childNodes[i]);
						}

				}

		
		
	});							  
				nn = nn + 1;
				for (i=0; i<p.childNodes.length; i++){
						if(p.childNodes[i].className == "submenu") {							
								p.childNodes[i].style.height = '0px';
								Element.hide(p.childNodes[i]);
							
						}

				}
		}

		nn = nn +1;		
	});

  }
  
  
  function getY( oElement )  {
		var iReturnValue = 0;
		while( oElement != null ) {
		iReturnValue += oElement.offsetTop;
		oElement = oElement.offsetParent;
		}
		return iReturnValue;
}



  function fuoriMenu (num) {
	  
	  var padre = document.getElementById(num);
		
	  var nnu = getY(padre) + 1;
	  for (i=0; i<padre.childNodes.length; i++){
						if(padre.childNodes[i].className == "submenu") {							
								padre.childNodes[i].className = "submenuFuori";
								$(padre.childNodes[i]).setStyle({
									  position: 'absolute',
									  left: '213px',
									  top: nnu+'px'
									  
								  
								});
								nnu = nnu +18;
								Element.show(padre.childNodes[i]);
						}

				}

	 if(active!=num && active != null) {
		  var attivo = document.getElementById(active);
		  for (i=0; i<attivo.childNodes.length; i++){
						if(attivo.childNodes[i].className == "submenuFuori") {
							attivo.childNodes[i].className = "submenu";
							Element.hide(attivo.childNodes[i]);
						}
		  }
	 }
	 active = num;
  }
  
