tabbedBoxPresent =  true;
tabbedBoxCreated =  false;

var tabArray = new Array();

var tabLock = false;

function showTab(ev) {
	if(tabLock == false) {
	
	tabLock = true;
	//this checks if the browser is IE or not and gives us the tab we just clicked on - more specifically the tabs anchor link
	if(!window.event) {
		obj = ev.currentTarget;
	} else {
		obj = window.event.srcElement;
	}

	//for ease's sake loop through all the tabs and hide all the ".listMore" divs
	
	
	
	for(k=0;k<tabCount;k++) {
		
		tabArray[k].className = '';
		tabArray[k].getElementsByTagName('div')[0].style.display = "none"

		//alert(tabArray[k].className);
	}

	//then we need to go up to the tab li level and set the class as active and display block
	
	//parentNodes are: h4 > li 
	
	
	liTab = obj.parentNode.parentNode;
	
	//alert(liTab.nodeName)
	
	liTab.className = 'active';
	liTab.getElementsByTagName('div')[0].style.display = "block"
	
	//finally we set the height of the tab box by getting the height of the .listMore div and then adding on the space between that and the top of tabbed_box (headingSpace)
	
	document.getElementById('tabbed_box').style.height = Math.ceil(((liTab.getElementsByTagName('div')[0].offsetHeight + headingSpace))) + "px";
	
	//function in move ads
	cynUpdateAllAds = true;
	setAds()
	tabLock = false;
	return false;
	}
}

function tabbed_box() {
	
	//check that the tabbed box container has loaded properly
	
	if(document.getElementById('tabbed_box') && document.getElementById('minibanner4_container') && document.getElementById('minibanner1_container')) {

		here = document.getElementById('tabbed_box');
		
		headings = here.getElementsByTagName('h4');
		
	
		
		offsetH4 = 0;
		
		tabCount = headings.length;
		
		for(i=0;i<tabCount;i++) {
			
			tabArray.push(headings[i].parentNode);
			
			link = headings[i].getElementsByTagName('a');
			
			link[0].onclick = showTab;

			headings[i].style.marginLeft = offsetH4+'px';
			
			offsetH4 = offsetH4 + link[0].offsetWidth+5;
			
			tabArray[i].className = '';
			tabArray[i].getElementsByTagName('div')[0].style.display = "none"
			
		}

		tabArray[0].className = 'active';
		
		var holderDiv = tabArray[0].getElementsByTagName('div')[0]
		
		holderDiv.style.display = "block";
		
		var hereOff = findPos(here);
		
		//findPos function in panel-wait.js
		var holderDivOff = findPos(holderDiv);
		
		headingSpace = holderDivOff[1]- hereOff[1]
		
		here.style.height = (tabArray[0].getElementsByTagName('div')[0].offsetHeight + headingSpace)+'px';

		tabbedBoxCreated = true
		
		clearInterval(tabbedBoxInt);
	}
}

tabbedBoxInt = setInterval('tabbed_box()',100);


$(window).resize(function() {
	jQuery.each(jQuery.browser, function(i) {
	  if($.browser.msie && jQuery.browser.version.substr(0,1)=="6" && $('#content_secondary > #tabbed_box').children().length){
	  } else {
	     tabbed_box()
	  }
	});
})