﻿// JScript File
var m_contextString;
var m_dblClick = new Boolean(false);

function KGGoGlobalControl_CallbackTrigger_Wrapped(_cbreference, _treeID)
{
//debugger;
	if(m_contextString == "" || m_contextString == null)
		GrabHighlightedContext(_treeID);
	var args = 'Action=' + m_contextString + '|ConceptID=' + _treeID.SelectedNode.Value;
	m_contextString = "";
	eval(_cbreference);
}

function GrabHighlightedContext(_treeID)
{
	m_contextString = "";
  var aTreeView = null;
  var aTreeNode = null;
  var nodeId = _treeID.SelectedNode.ID;
  var treeId = _treeID.TreeViewID;
  
  if(treeId != null && treeId !='' && treeId != '-1' && eval('window.'+ treeId+'!=null'))
    aTreeNode = eval(treeId + '.FindNodeById(\'' + nodeId + '\')');

  if(aTreeNode != null)
  { 
    aTreeView = aTreeNode.ParentTreeView;
    
    if(aTreeNode.ID != null && aTreeNode.ID != '')
      conceptTreeControl_preTreeNodeID = aTreeNode.ID;
    
    if(aTreeView != null && aTreeView.TreeViewID != '')
      conceptTreeControl_preTreeViewID = aTreeView.TreeViewID;
  }

  while(aTreeNode != null)
  {
    aTreeNode.SaveState();
    m_contextString = aTreeNode.Text + " " + m_contextString;
    aTreeNode = aTreeNode.ParentNode;
  }
    
} // end function

function KGGoGlobalControl_CallbackDone_Wrapped(args, context, tableID)
{
  // Check for a session time out before completing the callback
  if (CheckSessionTimeout())
    return;
  
	var domainTableId = tableID + "_GoGlobalTable";
  m_DomainTable = document.getElementById(domainTableId);
  if(m_DomainTable == null)
		m_DomainTable = document.getElementById("GoGlobalTable");
  SetOuterHtml(m_DomainTable,args);
  ShowKGGoGlobalControl();
}

function KGGoGlobalControl_ProcessCallBackError_Wrapped(args, context)
{
  // Here we are dealing with authentication timeout before callback, 
  // the message from the server is 'elogin' signify an error with 
  // authentication. The response will be trimmed to form the args 
  // 'login' here..... 
  if(args == 'login')
  {
    window.location='home.aspx';
  }
  else
  {
  	document.getElementById(_thisClientID).innerHTML = '<tr><td>An error has occurred in RegisterJavaScript() of KGSuggestionControl.</td></tr>';
  }
}