var DHTML_ARROW_MIN = 37;
var DHTML_ARROW_MAX = 40;
var DHTML_LEFT_ARROW = 37; 	// left-arrow
var DHTML_UP_ARROW = 38; 	// up-arrow
var DHTML_RIGHT_ARROW = 39;  // right-arrow
var DHTML_DOWN_ARROW = 40;   // down-arrow

function tabClick( nTab )
{
	
	event.cancelBubble = true;
	el = event.srcElement;

	try {
	
	for (i = 0; i < tabs.length; i++)
	{
		tabs[i].className = "clsTab";
		newsContent[i].style.display = "none";
	}
	newsContent[nTab].style.display = "block";
	tabs[nTab].className = "clsTabSelected";
	}
	catch(e){   // Create local variable e.
		alert('test');
	}
}

// TEST SourceSafe

function ToggleDisplay(oButton, oItems)
{
	//(oItems.style.display == "") || 
	if (oItems.style.display == "none")	{
		oItems.style.display = "block";
		
		oButton.src = "Images/minus.gif";
	}	else {
		oItems.style.display = "none";
		oButton.src = "Images/plus.gif";
	}
	return true;
}

function ToggleList(oLi)
{
	if (oLi.style.display == "none")	{
		oLi.style.display = "block";
	}	else {
		oLi.style.display = "none";
	}
	return true;
}

function leftnav_keyup()
{
	var iKey = window.event.keyCode;
	
	// BUGBUG: IE4 returns BODY instead of element with the focus. Use event object instead
	//var oActive = document.activeElement;
	var oActive = window.event.srcElement;
	
	if( DHTML_LEFT_ARROW == iKey || DHTML_RIGHT_ARROW == iKey )
	{
		if ('clsTocHead' == oActive.className)
		{
			// handle headings that expand/collapse
			HandleKeyForHeading(oActive, iKey);
		} 
		else if( "A" == oActive.tagName )
		{
			MoveFocus( oActive, iKey );
		}
	}
	
	return;
}


function MoveFocus( oActive, iKey )
{
	iSrcIndex = oActive.sourceIndex;
	
	if( iKey == DHTML_RIGHT_ARROW)
	{
		while( oItem = document.all[ ++iSrcIndex ] )
		{
			if( !leftNavTable.contains( oItem ) ) return;
			if( "A" == oItem.tagName )
			{
				oItem.focus();
				break;
			}

		}
	}
	else
	{
		while( oItem = document.all[ --iSrcIndex ] )
		{
			if( ( "clsTocHead" == oItem.className || "clsTocHead" == oItem.parentElement.className ) && "A" == oItem.tagName )
			{
				oItem.focus();
				break;
			}

		}
	}
}


// Handle keyboard action on a section
function HandleKeyForHeading(oActive, iKey)
{
	
	sActiveId = oActive.id;
	oItem = document.all[ sActiveId + "Items" ];
	oBtn = document.all[ sActiveId + "Btn" ];

	if( ( "block" != oItem.style.display ) ^ ( DHTML_LEFT_ARROW == iKey ) )
	{
		ToggleDisplay( oBtn ,oItem );
	}
	else
	{
		MoveFocus( oActive, iKey );		
	}
}


function handleMouseover() {
	eSrc = window.event.srcElement;
	eSrcTag=eSrc.tagName.toUpperCase();
	if (eSrcTag=="DIV" && eSrc.className.toUpperCase()=="CLSTOCHEAD")	eSrc.style.textDecoration = "underline";
	if (eSrcTag=="LABEL") eSrc.style.color="#003399";
}

function handleMouseout() {
	eSrc = window.event.srcElement;
	eSrcTag=eSrc.tagName.toUpperCase();
	if (eSrcTag=="DIV" && eSrc.className.toUpperCase()=="CLSTOCHEAD")	eSrc.style.textDecoration = "";
	if (eSrcTag=="LABEL") eSrc.style.color="";
}

function openSimpleWin(url, title, attr)
{
	var a_win;
	win_attri="toolbar=no,status=no,scrollbars=yes,resizable=yes,menubar=no" + attr;
	a_win=window.open(url,title,win_attri);
}

function openImageWin(url, title, width, height)
{
	var a_win;
	win_attri="toolbar=no,status=no,scrollbars=no,resizable=yes,menubar=no,width=" + width +",height=" + height;
	a_win=window.open(url,title,win_attri);
}

function activeUploadFrame(attUrl)
{
	parent.document.getElementById('upload').height='20%';
	parent.document.getElementById('upload').src=attUrl;
	parent.document.getElementById('content').height='80%';
}

function deactiveUploadFrame()
{
	parent.document.getElementById('upload').height='0%';
	parent.document.getElementById('content').height='100%';
}

function getFormElm(elmName)
{
	for (var i=0; i<form1.elements.length; i++)
	{
		if (form1.elements[i].name == elmName) {
			return form1.elements[i];
		}
	}
	return null;
}

function setFormElm(elmName, elmValue)
{
	var elm = getFormElm(elmName);
	if (elm != null) {
		elm.value = elmValue;
	}
	else
		alert("no form element to be set!");
}

function changeContentFrame(url)
{
	parent.document.getElementById('contentFrame').src=url;
}

function showHiddenTOC()
{
	parent.document.getElementById('tocFrame').src="toc_h.htm"
}

function hideHiddenTOC()
{
	parent.document.getElementById('tocFrame').src="toc.htm"
}

//document.onmouseover=handleMouseover;
//document.onmouseout=handleMouseout;