var moreFlag = false;
var tabCount = 5;
var cookieCurrentTab = "currentTab";

var tab1Expanded = true;
var tab2Expanded = true;
var tab3Expanded = true;
var tab4Expanded = true;
var tab5Expanded = true;

var tab1HasMore = true;
var tab2HasMore = true;
var tab3HasMore = true;
var tab4HasMore = true;
var tab5HasMore = true;

addLoadEvent(initSections);

function initSections()
{
	var cookieVal = null;
	
	cookieVal = Get_Cookie(cookieCurrentTab);
	
	if (cookieVal == null)
	{
		expandSection("tab1");
		expandSection("tab2");
		expandSection("tab3");
		expandSection("tab4");
		expandSection("tab5");
	}
	else
	{
		moreFlag = true;
		toggleSection(cookieVal);
	}
}

function toggleSection(tab)
{
	Set_Cookie( cookieCurrentTab, tab, 1, '', '', '' );

	if (moreFlag)
	{
		var currTab;
		
		expandSection(tab);

		if (window[tab + "HasMore"])
		{
			document.getElementById(tab + "_more_button").style.display="none";
			document.getElementById(tab + "_more").style.display="block";
		}
			
		for (var i = 1; i <= tabCount; i++)
		{
			currTab = "tab" + i;
		
			if (tab != currTab)
			{
				contractSection("tab" + i);
				window[currTab + "Expanded"] = false;
				document[currTab+'_arrow'].src = "http://www.sybase.com/image/Buttons/videobar_arrowdown.gif";
			}
			else
			{
				document[currTab+'_arrow'].src = "http://www.sybase.com/image/Buttons/videobar_arrowup.gif";
			}
		}
	}
	else
	{
		var currentTabExpanded = window[tab+'Expanded'];

		if (currentTabExpanded)
		{
			contractSection(tab);
			window[tab+'Expanded'] = false;
			document[tab+'_arrow'].src = "http://www.sybase.com/image/Buttons/videobar_arrowdown.gif";
		}
		else
		{
			expandSection(tab);
			window[tab+'Expanded'] = true;
			document[tab+'_arrow'].src = "http://www.sybase.com/image/Buttons/videobar_arrowup.gif";
		}
	}
	
	tabAnchor(tab);
}

function toggleMore(tab)
{
	var currTab;
	
	if (window[tab + "HasMore"])
	{
		document.getElementById(tab + "_more_button").style.display="none";
		document.getElementById(tab + "_more").style.display="block";
	}
	
	for (var i = 1; i <= tabCount; i++)
	{
		currTab = "tab" + i;
		
		if (tab != currTab)
		{
			contractSection("tab" + i);
			window[currTab + "Expanded"] = false;
		}
	}
	
	moreFlag = true;
	tabAnchor(tab);
}

function toggleLess(tab)
{
	if (window[tab + "HasMore"])
	{
		document.getElementById(tab + "_more").style.display="none";
		document.getElementById(tab + "_more_button").style.display="block";
	}
	
	tabAnchor(tab);
}


function expandSection(tab)
{
	document.getElementById(tab).style.display="block";
}

function contractSection(tab)
{
	document.getElementById(tab).style.display="none";
}

function tabAnchor(tab)
{
	window.location.href = "#" + tab + "_anchor";
}

