var tabs = new Array("tab1","tab2","tab3");
var currentTab = 0;
var allowSwitch = 1;
var rotationTime = 10000;

var timer = setTimeout("switchTab()", rotationTime);

function switchTab(i)
{
	if (i > 0)
	{
		clearTimeout(timer);
		hideAllTabs();
		currentTab = i - 1;
		if (currentTab > tabs.length - 1) { currentTab = 0; }		
		document.getElementById(tabs[currentTab]).className = "tab visible";
		document.getElementById("link-" + tabs[currentTab]).className = "current";

    
		timer = setTimeout("switchTab()", rotationTime);
	}
	else
	{
		if (allowSwitch == 1)
		{
			hideAllTabs();
			currentTab = currentTab + 1;
			if (currentTab > tabs.length - 1) { currentTab = 0; }
			document.getElementById(tabs[currentTab]).className = "tab visible";
			document.getElementById("link-" + tabs[currentTab]).className = "current";

           
			timer = setTimeout("switchTab()", rotationTime);
		}
		else
		{
			timer = setTimeout("switchTab()", rotationTime);
		}
	}
}

function hideAllTabs()
{
	for(var a in tabs)
	{
    	    if (isNaN(a)) continue;
		document.getElementById(tabs[a]).className = "tab";
		document.getElementById("link-" + tabs[a]).className = "";
	}

}

function disallowSwitchFunc() {
	allowSwitch = 0;
}

function allowSwitchFunc() {
	allowSwitch = 1;
}
function preloadImage( src ) {
    var pic = new Image(); 
    pic.src = src;
}