
function addLoadEventVis(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      oldonload();
      func();
    }
  }
}
function cambiabrand(stato) {
	cba = document.getElementById('cambiabrand');
	cbb = cba.style.backgroundColor;
	//alert(cbb);
	if (stato == 0) {
		 cba.style.backgroundPosition = "100% 0";
		} else {
		 cba.style.backgroundPosition = "100% -999px";
		}
	}

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');

	
	// 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 #298FC2";
		thePanes[i].style.borderBottom = "1px solid #298FC2";
		thePanes[i].style.borderRight = "1px solid #298FC2";
}
	// 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(setDefaults);
addLoadEventVis(prepareToggle);