
var gIsNS = document.layers;
var gTabSpacerWidth			= 4;
var gHorizontalTabHeight	= 16;
var gHorizontalTabWidth 	= 0;
var gHorizontalTabWidthDefault = 150; 

function getWindowWidth()
{
	return ((gIsNS) ? window.innerWidth - 16 : document.body.clientWidth);
}

function writeMandatoryTabs(mandTabArray, totalTabsWidth)
{
	var nTotalTabsWidth = totalTabsWidth;
	
	if (gHorizontalTabWidth == 0)
		gHorizontalTabWidth = gHorizontalTabWidthDefault;	
	
	// Mandatory tabs				
	for ( i = 0; i < mandTabArray.length; i++ )
	{
		var cellLength = gHorizontalTabWidth;
		
		// DAP comment: none of this code properly calculates with and we used fixed width anyway
		//if (navigator.appName == "Netscape") {
		//	cellLength = gHorizontalTabWidth;
		//} else {		
			// override
		//	if (gHorizontalTabWidth > 0)
		//	{
				// compute default value
		//		cellLength = gHorizontalTabWidth;		
		//	} else {
				// compute default value
		//		cellLength = (mandTabArray[i][0].length * 8);
		//	}
		//}
		
		if ( nTotalTabsWidth + gTabSpacerWidth + cellLength > getWindowWidth() ) {
			writeEndOfTable();
			writeSpacerTable();
			writeStartTable();
			nTotalTabsWidth = gTabSpacerWidth + cellLength;
		} else {
			nTotalTabsWidth += gTabSpacerWidth + cellLength;
		}
		var strTitle		= mandTabArray[i][0];
		var strToolTip		= mandTabArray[i][1]
		var strURL		= mandTabArray[i][2];
		writeSpacerCell();
		writeMandatoryTab(strTitle, strURL, strToolTip);					
		
	}				
}

function writeTabsRows(arMandTabArrayName)
{
	
	var mandTabArray	= arMandTabArrayName
		
	var i;
	
	writeSpacerTable();
	writeStartTable();
			
	if ( null != mandTabArray )
	{
		writeMandatoryTabs(mandTabArray, gTabSpacerWidth);
	}
	writeEndOfTable();
}

/*
   Event handler for mandatory tab mouseclick (Administration Tab)
*/
function manmenuTabClick(evt, strURL)
{	
	evt.cancelBubble = true;
	templateURLRedirect(strURL);
}

function mouseOver( el ) {
	el.className = "menu-button hover";

}

function mouseOut( el ) {
	el.className = "menu-button";
}
	
function writeMandatoryTab(strTitle, strURL, strToolTip)
{

	if (strTitle.length == strToolTip.length) {
		strToolTip = '';
	}

		
	document.write(	"<td class='navMidtabBtn' height='"+gHorizontalTabHeight+"'>"+
			"<a href='#'><table width='"+gHorizontalTabWidth+"' border='0' cellspacing='0' cellpadding='0'><tr>"+				
			"<td width='"+gHorizontalTabWidth+"' height='"+gHorizontalTabHeight+"' align='center' nowrap='nowrap' onclick='manmenuTabClick(event, \""+strURL+"\"); return false;'>"+
			"<span class='navMidtabText' title='"+strToolTip+"'>"+
				"<a href='#' onclick='manmenuTabClick(event, \""+strURL+"\"); return false;'>"+
				  "<span style='line-height: 15px;'>"+strTitle+"</span>"+
				"</a>"+
			"</span>"+
			"</td></tr></table></a>"+
		 	"</td>");
			
		
}

