
var promoIntervalId = null;
var promoTab = 0;
var promoFrame = -1;
var promoTabCount = 6;
var promoRotate = true;

function promoNavTabber(tabNumber){
	if(tabNumber>0){
		promoTab = tabNumber;
		promoFrame = -1;
	}else{
		tabNumber = promoTab;
	}
	
	tabContainer = document.getElementById('pnTabContainer');

	for (loop = 0; loop < tabContainer.childNodes.length; loop++)
	{
		if (tabContainer.childNodes[loop].tagName == 'DIV')
		{
			currentTab = tabContainer.childNodes[loop];
			currentTab.setAttribute('class', 'tab_button');
			currentTab.className = 'tab_button';
		}
	}
	
	contentContainer = document.getElementById('contentContainerB');
	for (loop = 0; loop < contentContainer.childNodes.length; loop++)
	{
		if (contentContainer.childNodes[loop].tagName == 'UL')
		{
			currentContent = contentContainer.childNodes[loop];
			currentContent.setAttribute('class', 'hidden');
			currentContent.className = 'hidden';
		}
	}
	
	tableContainer = document.getElementById('promonavContainer');
	tableContainer.style.background = 'transparent url(skins/chromana.com/resources/promonav/background' + tabNumber + '.jpg) bottom left no-repeat';
	
	clickedTab = document.getElementById('pnTab' + tabNumber);
	clickedTab.setAttribute('class', clickedTab.getAttribute('class') + ' tab_active');
	clickedTab.className = clickedTab.className + ' tab_active';
	
	contentB = document.getElementById('pnContent' + tabNumber + 'b');
	contentB.setAttribute('class', 'shown');
	contentB.className = 'shown';
}

function promoAuto(){	
	if(promoRotate /*&& (promoFrame >= 100 || promoFrame==-1)*/){
		promoFrame = -1;
		if(++promoTab > promoTabCount)
			promoTab = 1;
	}
	
	for(var i = 1; i < promoTabCount+1; i++){
		var tab = document.getElementById("pnContent"+i+"b");
		if(!tab)
			continue;
		
		if(i == promoTab){
			tab.style.className = "shown";
			
			//if(tab.style.opacity < 1){
			//	tab.style.opacity=(+tab.style.opacity)+0.25;
			//	document.getElementById("promonavContainer").style.opacity = tab.style.opacity;
			//}
		}else if(tab.style.opacity > 0){
			//tab.style.opacity=0;//(+tab.style.opacity)-0.1;
		}else tab.style.className = "hidden";
	}
	
	promoNavTabber();
	
	if(promoRotate)
		promoFrame++;
	//promoIntervalId = setInterval('if(document.currentTab+1 > 6){ document.currentTab=0; }; document.currentTab++; promoNavTabber(document.currentTab);', 5000);
}

function promoInit(){
	/*for(var i = 1; i < promoTabCount+1; i++){
		var tab = document.getElementById("pnContent"+i+"b");
		if(!tab)
			continue;
		tab.style.opacity = 0;
	}*/
	
	promoIntervalId = setInterval("promoAuto()", 5000);
	
	//document.getElementById('promonav').onmouseover = function catchOnMouse1(){ 
	//	clearInterval(document.promoInterval);
	//};
	//document.getElementById('promonav').onmouseout = function catchOnMouse2(){
	//	promoAuto();
	//};
	promoAuto();
}
				 

