///tabs.js

// Liberamente inspirato ad apple.com/support/ :)
// Federico Parrella

/* SPALLA ROTANTE */

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;
		}
	}
}

//onload
function addLoadEvent(func) {
	var oldonload = window.onload;
	if (typeof window.onload != 'function') {
		window.onload = func;
	} else {
		window.onload = function() {
			oldonload();
			func();
		}
	}
}

//spalla
if(document.getElementById('tabsNav')) {
	addLoadEvent(setDefaults);
	addLoadEvent(prepareToggle);
	addLoadEvent(togglePanes);
}


function sport_setDefaults() {
	// Create global variables for elements:
	sport_supportNav = document.getElementById('sport_tabsNav');
	if(!sport_supportNav) return 1;
	sport_theTabs = sport_supportNav.getElementsByTagName("a");
	marginesotto = 0;
	// Set class for default tab:
	sport_theTabs[0].className = "sport_activeTab";
	var sport_container = document.getElementById('sport_boxcont');

	
	// Determine height of included tables to adjust 
	// margin-bottom for breadcrumbs calculated on togglePanes:
	// Set the position value for panes:
	sport_thePanes = sport_container.getElementsByTagName('div');
	for (var i = 0; i < sport_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 < sport_thePanes.length; j++) {
		thePanes[j].style.display = "none";
	}
	// Show the default pane:
	sport_thePanes[0].style.display = "block";
	// Set global value for default tab:
	sport_defaultTab = 0;
//   	container.style.marginBottom = (document.getElementById("strillorot1").offsetHeight) + "px";	

}
    
function sport_prepareToggle() {
	for (var i = 0; i < sport_theTabs.length; i++) {
		sport_theTabs[i].onclick = function() {
			return sport_togglePanes(this);
		}
	}
}

function sport_togglePanes(clickedTab) {
	var sport_container = document.getElementById('sport_boxcont');
	for (var i = 0; i < sport_theTabs.length; i++) {
		if (i != sport_defaultTab && sport_theTabs[i] == clickedTab) {
			sport_thePanes[i].style.display = "block";
			sport_theTabs[i].className = "sport_activeTab";
			// Toggle the default tab:
			sport_thePanes[sport_defaultTab].style.display = "none";
			sport_theTabs[sport_defaultTab].className = "";	
            var pid = "strillorot" + (i+1);
//		   	container.style.marginBottom = (document.getElementById("strillorot" + (i+1)).offsetHeight) + "px";  
			sport_defaultTab = i;
		
			return false;
		} else if (i == sport_defaultTab && sport_theTabs[i] == clickedTab){
			return false;
		}
	}
}


//spalla
if (document.getElementById('sport_tabsNav')) {
	addLoadEvent(sport_setDefaults);
	addLoadEvent(sport_prepareToggle);
	addLoadEvent(sport_togglePanes);
}