

function showTab(tabNumber)
{
	hide_content_tabs();
	clearMainTabs();
	// show the selected tab area
	var tabToShowDiv = document.getElementById("main_tab" + tabNumber);
	if (tabToShowDiv == null) return;
	tabToShowDiv.style.display = "block";
	
	// turn the selected tab image on
	var tabToShow = document.getElementById("headlinetab" + tabNumber);	
	
	if(tabNumber < window.tabNumber)
	{
		tabToShow.className = "tabShadowOn";		
	}
	else // this is the last tab
	{
		tabToShow.className = "tabShadowEndOn";		
	}
	
	var innerTabs = tabToShow.getElementsByTagName("div");
	for(var x=0; x < innerTabs.length; x++)
	{
		if(innerTabs[x].className == "tabContainer2_off")
		{
			innerTabs[x].className = "tabContainer2_on";
		}
	}
	
	// check or uncheck the default view checkbox.
	var checkbox = document.getElementById("checkbox_main_tab" + tabNumber);
	var cookieName = getPageCookieName();
	
	if(getCookie(cookieName) == tabNumber)
	{		
		checkbox.checked = true;
	}
	else
	{
		checkbox.checked = false;
	}
	
	// show the tab's default list
	showDefaultListTab();
	// TODO: turn on tab style
}

/**
 * Updates the cookie information for the user's selected favorite cookie.
 * If the method finds the user unchecked, the cookie will be removed. 
 **/
function updateTabCookie(tabNumber)
{
	// check the state of the checkbox clicked.
	var checkbox = document.getElementById("checkbox_main_tab" + tabNumber);
	if(checkbox == null) return;
	
	var cookieName = getPageCookieName();
	
	if(checkbox.checked)
	{
		setCookie(cookieName, tabNumber, 60);
	}
	else
	{
		clearCookie(cookieName);	
	}
}


/* List tabs */
function hide_video_list(listDiv)
{	
	// turn off tabs
	
	
	if (listDiv == null) return;
	
	var videoLists = listDiv.childNodes;
	
	var tempDiv = null;
	for(var i = 1; i <= videoLists.length  ; i++)
	{
		tempDiv = document.getElementById("videoList" + i);
		if (tempDiv == null)
		{
			return;
		}
		else
		{
			tempDiv.style.display = "none";
		}
	}
}

function showDefaultListTab()
{	
	clearListTabs();
	showListTab(1);
	var defaultListDiv = document.getElementById("videoList1");
	if(defaultListDiv != null)
	{		
		defaultListDiv.style.display = "block";
	}
}

function showListTab(tabNum)
{	
	var listToShow = document.getElementById("videoList" + tabNum);
	if(listToShow != null) 
	{
		hide_video_list(listToShow.parentNode);
	}
	
	clearListTabs();
	
	if(document.getElementById("listTabs") != null)
	{
		document.getElementById("listTabs").childNodes[tabNum - 1].className = "on";
	}
	
	if(listToShow != null)
	{
		listToShow.style.display = "block";
	}
}

// turns off video list tabs
function clearListTabs()
{
	var tabsContainer = document.getElementById("listTabs");	
	if (tabsContainer == null) return;
	var tabs = tabsContainer.childNodes;
	
	for(var i=0; i < tabs.length; i++)
	{
		tabs[i].className = "";
	}
}

window.videoWin = null;

function popVideo(videoURL)
{
	if(window.videoWin == null || window.videoWin.closed)
	{
		window.videoWin = window.open(videoURL, "beloVideoWindow", "width=400,height=500");
	}
	else
	{
		window.videoWin.focus();
	}
	
	return false;
	
}


