/* Menu_a_Linguette */

function setDefaults() {
	// Create global variables for elements:
	supportNav = document.getElementById('tabsNav');
	theTabs = supportNav.getElementsByTagName("a");
	marginesotto = 1;
	//BottomMargin = 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 = "0px solid #ACAFBE ";
		thePanes[i].style.borderBottom = "0px solid #ACAFBE";
		thePanes[i].style.borderRight = "0px solid #ACAFBE";
}
	// 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 = "linguetta" + (i+1);
//		   	container.style.marginBottom = (document.getElementById("linguetta" + (i+1)).offsetHeight) + "px;";  
			defaultTab = i;
		
			return false;
		} else if (i == defaultTab && theTabs[i] == clickedTab){
			return false;
		}
	}
}

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

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

//Menu_a_Linguette
addLoadEvent(setDefaults);
addLoadEvent(prepareToggle);
addLoadEvent(togglePanes);



