
function addLoadEventVis(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      oldonload();
      func();
    }
  }
}

function collapse_network() {
  
var newagt = navigator.userAgent.toLowerCase();

// Top
var div_banner_top = document.getElementById("advtop");
var div_header_top = document.getElementById("topheader");
var div_ge_network = document.getElementById("ge-network");
var div_ge_network_top = document.getElementById("ge-network-top");
var div_ge_network_bottom = document.getElementById("ge-network-bottom");

if (newagt.indexOf("msie") != -1) {
	if (div_banner_top != null) { altezza_top = div_banner_top.offsetHeight; }
} else {
	if (div_banner_top != null) { altezza_top = document.defaultView.getComputedStyle(div_banner_top, '').getPropertyValue("height"); }
	if (div_banner_top != null) { check_altezza_top = altezza_top.split('px'); }
	if (div_banner_top != null) { altezza_top = check_altezza_top[0]; }
}

// Top
if ((div_banner_top != null) && (altezza_top < 25)) {
	div_banner_top.style.display = "none";
  if( div_ge_network != null ) {
  	div_ge_network.style.height = "auto";
  	div_ge_network.style.width = "auto";
  	div_ge_network.style.background = "none";
  }
  
  if (div_header_top != null) {
  	div_header_top.style.backgroundColor = "#e6e6e6";
  	div_header_top.style.paddingBottom = "3px";
  }
  
  if (div_ge_network_top != null)	{ div_ge_network_top.style.marginTop = "12px"; }
} 

}



function setDefaults() {
	// Create global variables for elements:
	supportNav = document.getElementById('tabsNav');
	theTabs = supportNav.getElementsByTagName("a");
	marginesotto = 0;
	// Set class for default tab:
	theTabs[0].className = "activeTab";
	var container = document.getElementById('boxcont');

	
////// SPESSORE E COLORE BORDI BOX //////////////////////////
	
	// Determine height of included tables to adjust 
	// margin-bottom for breadcrumbs calculated on togglePanes:
	// Set the position value for panes:
	thePanes = container.getElementsByTagName('div');
	for (var i = 0; i < thePanes.length; i++) {
		thePanes[i].style.borderLeft = "1px solid #c25c29";
		thePanes[i].style.borderBottom = "1px solid #c25c29";
		thePanes[i].style.borderRight = "1px solid #c25c29";
}
	// Hide all but default pane:
	for (var j = 1; j < thePanes.length; j++) {
		thePanes[j].style.display = "none";
	}
	// Show the default pane:
	thePanes[0].style.display = "block";
	// Set global value for default tab:
	defaultTab = 0;
//   	container.style.marginBottom = (document.getElementById("strillorot1").offsetHeight) + "px";	

}
    
function prepareToggle() {
	for (var i = 0; i < theTabs.length; i++) {
		theTabs[i].onclick = function() {
			return togglePanes(this);
		}
	}
}

function togglePanes(clickedTab) {
	var container = document.getElementById('boxcont');
	for (var i = 0; i < theTabs.length; i++) {
		if (i != defaultTab && theTabs[i] == clickedTab) {
			thePanes[i].style.display = "block";
			theTabs[i].className = "activeTab";
			// Toggle the default tab:
			thePanes[defaultTab].style.display = "none";
			theTabs[defaultTab].className = "";	
            var pid = "strillorot" + (i+1);
//		   	container.style.marginBottom = (document.getElementById("strillorot" + (i+1)).offsetHeight) + "px";  
			defaultTab = i;
		
			return false;
		} else if (i == defaultTab && theTabs[i] == clickedTab){
			return false;
		}
	}
}

//spalla
addLoadEventVis(collapse_network);
addLoadEventVis(setDefaults);
addLoadEventVis(prepareToggle);
addLoadEventVis(togglePanes);
