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();
    var div_banner_top = document.getElementById("advtop");
}

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');
    thePanes = container.getElementsByTagName('div');
    // 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);