var currentTab = 0;
var currentPlayerRunning = null;
var tabSwapInterval = 0;

function expandthis(divName,currentDiv,showDiv,showDivContent,count,timed) {			
    if (!timed) {
		currentTab = parseInt(currentDiv.substring(3));
		sendToActionScript(currentPlayerRunning, "stop", "null");
		clearInterval(tabSwapInterval);
	}
	// Removes display:none from tab
	document.getElementById(showDivContent).style.display = "";
    // Makes current tab active
	document.getElementById(currentDiv).className = "active-tab";
	document.getElementById("tabbed-nav").style.backgroundImage = 'url(lib/images/tab-bg' + (parseInt(currentDiv.substring(3)) + 1)+ '.jpg)';
    var i = 0;
    while (i < count) 	{
        if(document.getElementById(showDiv + i) != document.getElementById(showDivContent)) {
            document.getElementById(showDiv + i).style.display = "none";
            document.getElementById(divName + i).className = "inactive-tab";
        }
        i++;
    }
}
/* =========================================================================================== PRELOAD IMAGES */
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

//alert("Set interval");
tabSwapInterval = setInterval ( "swapTabs()", 8000 );

function swapTabs()
{
	//alert("Swapping tab");
	currentTab++;
	if(currentTab >= 3) {
		currentTab = 0;
	}
	expandthis('tab','tab'+ currentTab,'tabcontent','tabcontent' + currentTab,'3',true);
}

function stopSwappingTabs() {
	currentPlayerRunning = currentTab;
	var temp = clearInterval(tabSwapInterval);
	return temp;	
}