

var g_bIsIE = false;


// ---- [Public] Based on passed in parameter, set up variables to keep track 
//					of user has rights to do Copy or not
function WBC_onLoadHandler( bFreshTree )
{
	g_bIsIE = (document.all != null);
	
	// only set Tree scrolling offset if it's IE and that it's not the first time the tree is being loaded
	if (g_bIsIE && !bFreshTree)
	{
		WBC_initTreeFrameScrollOffset();
	}
}

// ---- [Private] Initialize the scrolling offset attributes
function WBC_initTreeFrameScrollOffset()
{
	// write the current scrollTop value to a hidden field in the bottom frame
	var pTreeFrameDoc = window.top.frames['WBC_frameShowChannelTree'].document;
	var pBottomFrameDoc = window.top.frames['WBC_frameShowChannelName'].document;
	if (pTreeFrameDoc.body)
	{
		pTreeFrameDoc.body.scrollTop = pBottomFrameDoc.forms['NC_ChannelNameForm'].WBC_hidCacheTreeFrameScrollTop.value;
		pTreeFrameDoc.body.scrollLeft = pBottomFrameDoc.forms['NC_ChannelNameForm'].WBC_hidCacheTreeFrameScrollLeft.value;
	}
}

// ---- [Public] Responds to TreeNodeClicked event; transfer content 
//				from the Tree to the textbox in the bottom frame
function WBC_onTreeNodeClicked(strURL)
{	
	window.parent.frames['WBC_frameShowChannelName'].WBC_setLinkSelectionField( strURL );
	return true;
}

// ---- [Public] Hook to intercept CNCTreeControl node expansion event
function WBC_onExpandTreeNode( strNodeID, strNodeName )
{
	if (g_bIsIE)
	{
		// write the current scrollTop value to a hidden field in the bottom frame
		var pTreeFrameDoc = window.top.frames['WBC_frameShowChannelTree'].document;
		var pBottomFrameDoc = window.top.frames['WBC_frameShowChannelName'].document;	
		pBottomFrameDoc.forms['NC_ChannelNameForm'].WBC_hidCacheTreeFrameScrollTop.value = pTreeFrameDoc.body.scrollTop;
		pBottomFrameDoc.forms['NC_ChannelNameForm'].WBC_hidCacheTreeFrameScrollLeft.value = pTreeFrameDoc.body.scrollLeft;
	}
	
	// let the event bubble up so that it can do the round-trip
	return true;
}

// ---- [Public] Hook to intercept CNCTreeControl node collapse event
function WBC_onCollapseTreeNode(  strNodeID, strNodeName )
{
	if (g_bIsIE)
	{
		// write the current scrollTop value to a hidden field in the bottom frame
		var pTreeFrameDoc = window.top.frames['WBC_frameShowChannelTree'].document;
		var pBottomFrameDoc = window.top.frames['WBC_frameShowChannelName'].document;
		pBottomFrameDoc.forms['NC_ChannelNameForm'].WBC_hidCacheTreeFrameScrollTop.value = pTreeFrameDoc.body.scrollTop;
		pBottomFrameDoc.forms['NC_ChannelNameForm'].WBC_hidCacheTreeFrameScrollLeft.value = pTreeFrameDoc.body.scrollLeft;
	}
	
	// let the event bubble up so that it can do the round-trip
	return true;
}

