﻿// JScript File
var ConceptSelectedTab;
var ConceptVisibility = 0;
var GlobalExpandedNavItemID = '';
var Global_SemanticTreeHolderID;
var ShowPublicCategory = 1;
var HasLeftHandSideCategories = 0;
var m_navCtlInitLoadCounter = 0;

function KGNavigationControl_InitialLoad_Wrapped(_categoryNavBar, _conceptNavBar, _srmIndex)
{
  //if(navigator.appName == "Microsoft Internet Explorer")
	{
		try
		{
			// set default clientID
			Global_SemanticTreeHolderID = _conceptNavBar.ClientControlId + '_' + _conceptNavBar.ClientControlId + '_p1';
			if (Global_SemanticTreeHolderID == 'undefined_undefined_p1' || !_conceptNavBar.get_items)
		  {
		    if (m_navCtlInitLoadCounter < 10)
		    {
		      setTimeout(KGNavigationControl_InitialLoad,250)
		      m_navCtlInitLoadCounter++;
		    }
		    return;
		  }
		  m_navCtlInitLoadCounter = 0;
		  
			KGNavigationControl_SetRepopulationHiddenFields();
	        
			var cItems = _categoryNavBar.get_items();
	    
			if(cItems.get_length() == 0)
			{
					ShowPublicCategory = 0;
			}else
			{
				HasLeftHandSideCategories = 1; 
			}
	          
			for (var ni = 0; ni < cItems.get_length(); ni++)
			{
				var cItem = cItems.getItem(ni);
				if(cItem.Expanded)
				{
					// populate
					KGNavigationControl_NavBarSelected(null, null, cItem, _srmIndex);
				}
			}
	    
			var pItem = _conceptNavBar.get_items().getItem(0);
			if(pItem != null && ConceptVisibility == 1 && pItem.Expanded)
			{
					// populate
					KGNavigationControl_NavBarSelected(null, null, pItem, _srmIndex);
			}
	    
			// override the ComponentArt NavBar js function to fix the expand error
			window._q134= KGNavBar_q134;
		}
		catch (e) 
		{
			alert("An exception occurred in the script. Error name: " + e.name + ". Error message: " + e.message); 
			debugger;
		}
	}
}

function KGNavigationControl_KeyConceptBtnOnClick_Wrapped(_categoryNavBar, _conceptNavBar, _srmIndex, _keyConceptBtn)
{
   var keyConceptImage = _keyConceptBtn;
   
   // Switch Images between ShowAllConcepts and JustKeyConcepts
   if(keyConceptImage != null)
   {
     if(keyConceptImage.className != null && keyConceptImage.className.indexOf('_AllConcepts',0) > -1)
     {
       keyConceptImage.className= "ButtonToolbar_KeyConcepts";//.src = 'Images/JustKeyConcepts.png';
       SetSessionProperty('KGNavigationControl_ShowKeyConcepts', '0');
     }
     else 
     {
       keyConceptImage.className= "ButtonToolbar_AllConcepts";//.src = 'Images/ShowAllConcepts.png';
       SetSessionProperty('KGNavigationControl_ShowKeyConcepts', '1');
     }
   }
            
   // repopulate NavigationControl and Semantic Tree
		KGNavigationControl_InitialLoad_Wrapped(_categoryNavBar, _conceptNavBar, _srmIndex);
   //KGNavigationControl_TreeNavBarRePopulate();
}

// Show or hide semantic tree check box cell
function KGNavigationControl_ShowHideSemanticTreeCheckBox_Wrapped(_status, _treeCheckBoxClientID)
{
   var cb = document.getElementById(_treeCheckBoxClientID);
   if(cb != null)
   {
      if(_status == 1)
        cb.className = 'NavBarCheckBoxCell';
      else
        cb.className = 'NavBarCheckBoxCellHidden';
   }
}


// Client Side On NavBar Close
function KGNavigationControl_NavBarClosed(sender, eventArgs, _navItem, _srmIndex)
{
  //debugger;
  if(eventArgs != null)
  {
     try {_srmIndex = SrmControl_SetInitial('KGNavigationControl_NavBarClosed');}
     catch(e){}   
     _navItem = eventArgs.get_item();
  }     
  if(_navItem != null)
  {
      SetSessionProperty('KGNavigationControl_CloseNavBar', _navItem.ID);
  }
}

// Client Side On NavBar Select
function KGNavigationControl_NavBarSelected_Wrapped(navItem, _titleLabelID, _modeAlertCheck, _cbreference, _groupID, _hiddenfieldID, _srmIndex)
{
  //debugger;
  try
  {
    if(navItem != null)
    {
      //SetSessionProperty('KGNavigationControl_ExpandNavBar', navItem.ID);
      
      try
      {
        if (m_srmGetTimes!= null && m_srmGetTimes == "True" && _srmIndex != null)
          m_srmAction[_srmIndex] += ',' + navItem.ID;
      }
      catch(e){}
      
      //debugger;
      var repopulateStatus = document.getElementById(_hiddenfieldID);
      if (repopulateStatus != null && repopulateStatus.value.indexOf(navItem.ID + '|') > -1)
      {
        repopulateStatus.value = repopulateStatus.value.replace(navItem.ID + '|', '');
        
        if(navItem.ID == 'SemanticTree' && global_ConceptTabbedControl_CurrentlySelectedTab.indexOf('CS_') != -1)
        {
            //Show loading icon (bug 2856)
            var holder = document.getElementById(Global_SemanticTreeHolderID + '_TopicsPage');
            if(holder != null)
            {
              holder.innerHTML = '<table width=\"100%\"><tr><td align=\"center\" style=\"font-size: xx-small\"><br/><img src=\"Images/loadingbar.gif\" /> Loading...</td></tr></table>';
            }
        }
        var args = 'Action=RepopulateNavBar|NavItemID=' + navItem.ID + '|SrmIndex=' + _srmIndex;
        eval(_cbreference);
        
        
        //if(navItem.ID.indexOf('CS_') > -1 && GlobalExpandedNavItemID == navItem.ID)
        //{
          
          //navItem.ParentNavBar.render();
        //}

      } // end if repopulate status true
      GlobalExpandedNavItemID = '';
            
      if (window.MapViewDefaultFocus)
        MapViewDefaultFocus();

      if (window.HomeContentControl_CallbackTrigger)
        HomeContentControl_CallbackTrigger();
    } 
    return true; //end navItem null if
  }
  catch (e) 
  {
    alert("An exception occurred in the script. Error name: " + e.name + ". Error message: " + e.message); 
    debugger;
  }
} //end function

// SetRepopulationHiddenFields
function KGNavigationControl_SetRepopulationHiddenFields_Wrapped(_hiddenfieldID, _statusInfo) 
{
  //debugger;
  try
  {
    var repopulateStatus = document.getElementById(_hiddenfieldID);
    if (repopulateStatus != null) 
    {
      var statusInfo = '';
      // set status
      statusInfo = statusInfo + _statusInfo;
      repopulateStatus.value = statusInfo;
    } // end if repopulate status is not null
  }
  catch (e) 
  {
    alert("An exception occurred in the script. Error name: " + e.name + ". Error message: " + e.message); 
    debugger;
  }
} //end function

// UpdateRepopulationHiddenFields
function KGNavigationControl_UpdateRepopulationHiddenFields_Wrapped(_hiddenfieldID, _statusInfo) 
{
  //debugger;
  
  if(_statusInfo.length > 0 && _statusInfo.lastIndexOf('|') == (_statusInfo.length - 1))
    _statusInfo = _statusInfo.substring(0,_statusInfo.length-1);
  
  try
  {
    var repopulateStatus = document.getElementById(_hiddenfieldID);
    if (repopulateStatus != null && repopulateStatus.value.indexOf(_statusInfo + '|')== -1) 
    {
      var statusInfo = repopulateStatus.value + _statusInfo + '|';
      // set status
      repopulateStatus.value = statusInfo;
    } // end if repopulate status is not null
  }
  catch (e) 
  {
    alert("An exception occurred in the script. Error name: " + e.name + ". Error message: " + e.message); 
    debugger;
  }
} //end function


// RePopulateCallbackDone - Also used when Subscription changed as well
function KGNavigationControl_RepopulateNavBarCallbackDone_Wrapped(args, context, _categoryNavBar, _conceptNavBar)
{
  //debugger;
  try
  {
    // Check for a session time out before completing the callback
    if (CheckSessionTimeout())
      return;
    
    if(args.indexOf('Status=Error') > -1)
    {
      var statusInfo = args.split('[@|@]'); 
      var status = statusInfo[0].split('=');
      if(status[1]=='Error')
      {
        var holderID = statusInfo[1].split('=');
        var exception = statusInfo[2].split('=');
        var callbackerror = holderID[1] + '=' + exception[1];
        KGNavigationControl_ProcessCallBackError(callbackerror, '');
      }
    }
    else
    {
      var scriptToCall = args.split('[@|@]');
      var selectedTab = scriptToCall[3];
            
      var scriptFunction = scriptToCall[0].split('=');
      if(scriptFunction[1].length > 0)
      {
        var newArgs = args.substring(args.indexOf('[@|@]') + 5);
        newArgs = newArgs.replace(selectedTab + '[@|@]', '');
        eval(scriptFunction[1] + '(newArgs, context)');
      }
      else
      {
        KGNavigationControl_ProcessCallBackError('Script function not found.', '');
      }
    }
        
    var lastRootNodeHiddenFieldClientID;
    var lastRootNodeHiddenField;
    if (selectedTab == 'Results')
    {
      if (window.SearchResult_GetLastRootNodeHiddenFieldID)
      {
        lastRootNodeHiddenFieldClientID = SearchResult_GetLastRootNodeHiddenFieldID();
        lastRootNodeHiddenField = document.getElementById(lastRootNodeHiddenFieldClientID);
      }
    }
    else if (selectedTab.indexOf('CS') > -1)
    {
      if (window.Topic_GetLastRootNodeHiddenFieldID)
      {
        lastRootNodeHiddenFieldClientID = Topic_GetLastRootNodeHiddenFieldID();
        lastRootNodeHiddenField = document.getElementById(lastRootNodeHiddenFieldClientID);
      }
    }
    else if (selectedTab == 'Personal')
    {
      if (window.PersonalLibrary_GetLastRootNodeHiddenFieldID)
      {
        lastRootNodeHiddenFieldClientID = PersonalLibrary_GetLastRootNodeHiddenFieldID();
        lastRootNodeHiddenField = document.getElementById(lastRootNodeHiddenFieldClientID);
      }
    }

    if (lastRootNodeHiddenField != null)
    {
      if(args.indexOf('lastRootNodeID:') > -1)
      {
        var subLastRootNodeID = args.split('lastRootNodeID:');
        lastRootNodeHiddenField.value = subLastRootNodeID[1];
      }
      else
      {
        lastRootNodeHiddenField.value = null;
      }
      
    }
    
  }
  catch (e) 
  {
    alert("An exception occurred in the script. Error name: " + e.name + ". Error message: " + e.message); 
    debugger;
  }
}

function KGNavigationControl_RefocusTreeView_wrapped(_itemID,
                                                    _itemName,
                                                    _conceptNavBar,
                                                     _titleLabelClientID, 
                                                     _tabContextSeparator,
                                                    _MapViewDisplayModeKGMapView,
                                                    _cbreference,
                                                    _isBackButtonPress,
                                                    _srmIndex)
{
  //debugger;
  try
  {
    if (window.CancelEdit)
      CancelEdit(true);
    
    var navBar = eval(_conceptNavBar);
    var nItem = _conceptNavBar.get_items().getItem(0);
    if (nItem != null)
    {
      if(ConceptSelectedTab == 'Library')
        SetSessionProperty('GlobalLibrary_NewRootConceptID', _itemID);
      else if(ConceptSelectedTab == 'Personal')
        SetSessionProperty('PersonalLibrary_NewRootConceptID', _itemID);
      else if(ConceptSelectedTab == 'Results')
        SetSessionProperty('SearchResult_NewRootConceptID', _itemID);
      else if(ConceptSelectedTab.indexOf('Topic') > -1)
        SetSessionProperty('Topic_NewRootConceptID', _itemID);             
      
      var currentLocation = window.location.href;
      var currentPage = currentLocation.substring(currentLocation.lastIndexOf('/')+1, currentLocation.length).toLowerCase();
      var hostURL = currentLocation.substring(0, currentLocation.lastIndexOf('/') + 1);
      
      // refocus tree
      if (_isBackButtonPress == true)
        var args = 'Action=Refocus|NavItemID='+nItem.ID+'|BackButtonPress=true';
      else
        var args = 'Action=Refocus|NewRootConceptID='+_itemID+'|NavItemID='+nItem.ID+'|SrmIndex='+_srmIndex;
      eval(_cbreference);
      
      try
      {
        if (m_srmGetTimes!= null && m_srmGetTimes == "True" && _srmIndex != null)
        {
          m_srmAction[_srmIndex] += ',' + currentPage + ',' + currentTabID;
          m_srmCallbacks[_srmIndex] = 2;
        }
      }
      catch(e){}
      
      if(!(_isBackButtonPress == true && (_itemID == 0 || _itemID == -1)))
      {
        if (window.MapViewControl1_CallbackTrigger_IfVisible)
        {
          SetSessionProperty('MapViewDisplayMode', _MapViewDisplayModeKGMapView);
          MapViewControl1_CallbackTrigger_IfVisible(_srmIndex);
        }
       // if (window.KGTabbedWindowsControl_CallbackTrigger)
       //   KGTabbedWindowsControl_CallbackTrigger('ConceptSelected', _srmIndex);
      }
    }
  }
  catch (e) 
  {
    alert("An exception occurred in the script. Error name: " + e.name + ". Error message: " + e.message); 
    debugger;
  }
}

// DisplaySearchResult Callback scripts
function KGNavigationControl_CallbackTrigger_Wrapped(_itemID, _itemType, _itemName, _rootPhraseName,  _titleLabelClientID, _tabContextSeparator, _MapViewDisplayModeKGMapView, _cbreference, _srmIndex, _conceptNavBar)
{
  //debugger;
  try
  {
    //Show loading icon (bug 2856)
    var holder = document.getElementById(Global_SemanticTreeHolderID + '_ResultsPage');
    if(holder != null)
    {
      holder.innerHTML = '<table width=\"100%\"><tr><td align=\"center\" style=\"font-size: xx-small\"><br/><img src=\"Images/loadingbar.gif\" /> Loading...</td></tr></table>';
    }

    SetSessionProperty('PageSession_LibrarySelectedItemID', _itemID);
    SetSessionProperty('PageSession_LibrarySelectedItemTypeID', _itemType);
    SetSessionProperty('PageSession_LibrarySelectedITemName', _itemName);
        
    var currentLocation = window.location.href;
    var currentPage = currentLocation.substring(currentLocation.lastIndexOf('/')+1, currentLocation.length).toLowerCase();
    
    // Update Mapview and TabbedWindow controls
    if(window.MapViewControl1_CallbackTrigger_IfVisible)
    {
      SetSessionProperty('MapViewDisplayMode', _MapViewDisplayModeKGMapView);
      MapViewControl1_CallbackTrigger_IfVisible(_srmIndex);
    }
    //if (window.KGTabbedWindowsControl_CallbackTrigger)
    //  KGTabbedWindowsControl_CallbackTrigger('ConceptSelected', _srmIndex);
    
    var pItem = _conceptNavBar.get_items().getItem(0);
    if(pItem != null && ConceptVisibility == 1 && pItem.Expanded)
    {
      var args = 'Action=DisplaySearchResult|ItemID='+_itemID+'|'+'ItemType='+_itemType+'|'+'ItemName='+_itemName+'|SrmIndex='+_srmIndex;
      eval(_cbreference);
    }
  }
  catch (e) 
  {
    alert("An exception occurred in the script. Error name: " + e.name + ". Error message: " + e.message); 
    debugger;
  }
}

function KGNavigationControl_CallbackDone_Wrapped(args, context)
{
  //debugger;
  try
  {
    // Check for a session time out before completing the callback
    if (CheckSessionTimeout())
      return;
          
    var s = args.split('='); 
    var ids = s[0].split('@');
    
    var holder = document.getElementById(ids[0]);
    if(holder != null)
    {
      holder.innerHTML = args.substring(args.indexOf('=')+1);
      // need to redeclare the storage and the main function before calling it
      // therefore get the text of it
      // storage first
      var pos1 = args.indexOf('![CDATA[');
      if ( pos1 > - 1)
      {
        var string2 = args.substring(pos1, args.length);
        var pos2 = string2.indexOf('[[');
        var pos3 = string2.indexOf('//]]>');
        if ( pos2 > -1 && pos3 > -1 )
        {
          var storageString = string2.substring(pos2, pos3);
          var evalStorageString = 'window.ComponentArt_Storage_' + ids[1] + '_ResultTree = ' + storageString;
          // eval the string
          eval(evalStorageString);
          // now the init string
          var pos4 = string2.lastIndexOf('![CDATA[');
          if ( pos4 > -1 )
          {
            var string3 = string2.substring(pos4, string2.length);
            var pos5 = string3.indexOf('{');
            var pos6 = string3.lastIndexOf('}');
            if ( pos5 > -1 && pos6 > -1 )
            {
              var initString = string3.substring(pos5, pos6 + 1);
              var evalInitString = 'window.ComponentArt_Init_' + ids[1] + '_ResultTree = function()' + initString;
              // eval the string
              eval(evalInitString);
              // now execute it now that we've redefined it
              eval('ComponentArt_Init_' + ids[1] + '_ResultTree()');
            } // end if pos5 and pos6
          } // end if pos4
        } // end if pos2 and pos3
      } // end if pos1
      
      // Highlisht Selected TreeNode
      if(ids[2] != null && ids[3] != null)
      {
        var nodeId = ids[2];
        var treeId = ids[3];
        var aTreeNode = null;
        var aTreeView = null;
        
        if(treeId != null && treeId !='' && treeId != '-1' && eval('window.'+ treeId+'!=null'))
          aTreeNode = eval(treeId + '.FindNodeById(\'' + nodeId + '\')');
          
        if(aTreeNode != null) 
        {
          aTreeView = aTreeNode.ParentTreeView;
          
          if(aTreeView!= null && aTreeView.TreeViewID != null && aTreeView.TreeViewID != '')
            conceptTreeControl_preTreeViewID = aTreeView.TreeViewID;
          
          if(aTreeNode.ID != null && aTreeNode.ID != '')
            conceptTreeControl_preTreeNodeID = aTreeNode.ID;
          
          aTreeView.SelectedNode = aTreeNode;
        } 
        
      } 
    }
    else
    {
      KGNavigationControl_ProcessCallBackError('Content Cell not found.', '');
    }
    
    var searchResultsTreeLastRootNodeHiddenFieldClientID = SearchResult_GetLastRootNodeHiddenFieldID();
    var searchResultLastRootNodeHiddenField = document.getElementById(searchResultsTreeLastRootNodeHiddenFieldClientID);
    searchResultLastRootNodeHiddenField.value = null;
    
    //var tabStrip = _tabStripClientID;
    //var tab = tabStrip.GetSelectedTab();
    //ConceptTabbedView_ChangeBackButtonMode(ShowBackButton(tab));
    m_treeViewIsLoaded = true;
		setPaneWidths();
  }
  catch (e) 
  {
    alert("An exception occurred in the script. Error name: " + e.name + ". Error message: " + e.message); 
    debugger;
  }
  try
  {
    var srmIndex = ids[4];
    SrmControl_RecordTimes(srmIndex);
  }
  catch(e){}
};

// ProcessCallBackError
// this will return message in case of error
function KGNavigationControl_ProcessCallBackError(args, context)
{
  //debugger;
  try
  {  
    // 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
    {
      if(args.indexOf('=') > -1)
      {
        var s = args.split('='); 
        var holder = document.getElementById(s[0]);
        if(holder != null)
        {
          holder.innerHTML = 'An error has occurred. ' + s[1];
        }
        else
        {
          alert('Exception occurred. '+ s[1]);
        }
      }
      else
      {
        alert('Exception occurred. '+ args);
      }
    }
  }
  catch (e) 
  {
    alert("An exception occurred in the script. Error name: " + e.name + ". Error message: " + e.message); 
    debugger;
  }
}

// Check box javascripts
function KGNavigationControl_SubscriptionModeChanged_Wrapped(_cb, _cbreference)
{
  //debugger;
  try
  {
		var optiondiv = document.getElementById('KGOptionControlID1');
    var loginview = "Library_LoginView_";
    try
    {
      loginview = "Library_LoginView_";
      var check = document.getElementById(loginview + "KGOptionControl_ImageNumber0").src = "Images/newGeneOption.png";
    }
    catch(Exception)
    {
      loginview = "";
    }
    
    if(_cb == false)
    {
      SetSessionProperty('ConceptTabbedView_AllowSubscripton', true);
      var args = 'Action=SubscriptionModeChanged|Value=' + true;
      eval(_cbreference);
      document.getElementById(loginview + "KGOptionControl_ImageNumber4").src = "Images/LeftSubsOn.png";        
      document.getElementById(loginview + "KGOptionControl_CellNumber4").onclick = function(){KGNavigationControl_SubscriptionModeChanged(true)};     
      document.getElementById(loginview + "KGOptionControl_CellNumber4").onmouseover = function(){this.style.cursor='pointer'};
    }
    else
    {
      SetSessionProperty('ConceptTabbedView_AllowSubscripton', false);
      var args = 'Action=SubscriptionModeChanged|Value=' + false;
      eval(_cbreference);
      document.getElementById(loginview + "KGOptionControl_ImageNumber4").src = "Images/LeftSubsOff.png";        
      document.getElementById(loginview + "KGOptionControl_CellNumber4").onclick = function(){KGNavigationControl_SubscriptionModeChanged(false)};     
      document.getElementById(loginview + "KGOptionControl_CellNumber4").onmouseover = function(){this.style.cursor='pointer'};
    }
  }
  catch (e) 
  {
    alert("An exception occurred in the script. Error name: " + e.name + ". Error message: " + e.message); 
    debugger;
  }
} //end function

function KGNavigationControl_AlertSettingModeChanged_Wrapped(_cb, _cbreference, _srmIndex) 
{
  //debugger;
  try
  {
    if (m_srmGetTimes!= null && m_srmGetTimes == "True" && _srmIndex != null)
      m_srmAction[_srmIndex] += ',' + !_cb;
  }
  catch(e){}

  try
  {
    var optiondiv = document.getElementById('KGOptionControlID1');
    var loginview = "Library_LoginView_";
    
    try
    {
      loginview = "Library_LoginView_";
      var check = document.getElementById(loginview + "KGOptionControl_ImageNumber0").src = "Images/newGeneOption.png";
    }
    catch(Exception)
    {
      loginview = "";
    }

    if(_cb == false)
    {
      SetSessionProperty('ConceptTabbedView_AllowChangeAlertSetting', true);
      var args = 'Action=AlertSettingModeChanged|Value=' + true + '|SrmIndex=' + _srmIndex;
      eval(_cbreference);
      document.getElementById(loginview + "KGOptionControl_ImageNumber3").src = "Images/LeftAlertsOfn.png";        
      document.getElementById(loginview + "KGOptionControl_CellNumber3").onclick = function(){KGNavigationControl_AlertSettingModeChanged(true)};     
      document.getElementById(loginview + "KGOptionControl_CellNumber3").onmouseover = function(){this.style.cursor='pointer'};
    }
    else
    {
      SetSessionProperty('ConceptTabbedView_AllowChangeAlertSetting', false);
      var args = 'Action=AlertSettingModeChanged|Value=' + false + '|SrmIndex=' + _srmIndex;
      eval(_cbreference);
      document.getElementById(loginview + "KGOptionControl_ImageNumber3").src = "Images/LeftAlertsOff.png";        
      document.getElementById(loginview + "KGOptionControl_CellNumber3").onclick = function(){KGNavigationControl_AlertSettingModeChanged(false)};     
      document.getElementById(loginview + "KGOptionControl_CellNumber3").onmouseover = function(){this.style.cursor='pointer'};
    }
  }
  catch (e) 
  {
    alert("An exception occurred in the script. Error name: " + e.name + ". Error message: " + e.message); 
    debugger;
  }
} //end function


// Check box javascripts
function KGNavigationControl_ShowHideSemanticTree_Wrapped(_cb, _holderClientID, _conceptNavBar, _navImageHeader, _item) 
{
  //debugger;
  return;
  try
  {
    var holder = document.getElementById(_holderClientID);
    
    var navImageHeader = document.getElementById(_navImageHeader);
    
    var menuItem = _item;

    if(holder != null)
    {
        if(_cb.checked)
        {
          SetSessionProperty('KGNavigationControl_SemanticTreeVisible', true);
          ConceptVisibility = 1;
          holder.className = 'NavBarsCell';
          navImageHeader.className = 'NavBarTitleHidePic';

          var pItem = _conceptNavBar.get_items().getItem(0);
          if(pItem != null && ConceptVisibility == 1)
          {

              try {srmIndex1 = SrmControl_SetInitial('ShowSemanticTree');}
              catch(e){}
              // populate
              KGNavigationControl_NavBarSelected(null, null, pItem, srmIndex1);
          }
          
        }
        else
        {
          SetSessionProperty('KGNavigationControl_SemanticTreeVisible', false);
          ConceptVisibility = 0;
          holder.className = 'NavBarsCellHidden';

          navImageHeader.className = 'NavBarTitleShowPic_';  
          if(menuItem != null)
          {
            //if(_cb.disabled == true)
            if(menuItem.Text == "All")
            {
              SetInnerText(navImageHeader,"");
            }
            else
            {
              SetInnerText(navImageHeader,menuItem.Text);
            }
          }  
        }
    }
  }
  catch (e)
  {
    alert("An exception occurred in the script. Error name: " + e.name + ". Error message: " + e.message);
    //debugger;
  }
} //end function

function KGNavigationControl_UpdateSemanticTreeTitle_Wrapper(_tabID, _titleLabelClientID, _tabContextSeparator, _subfixName)
{
  
  try
  {
        // update title lable
        _titleLabelClientID = Global_SemanticTreeHolderID + '_ConceptTitleLabel';
        //_keyConceptBtn = Global_SemanticTreeHolderID + '_' + _keyConceptBtn;
        var titleLabel = document.getElementById(_titleLabelClientID);
        // var keyConceptImg = document.getElementById(_keyConceptBtn);
        
        var tabName = 'Categories';
        if(_tabID.indexOf('CS') == -1)
        {
          switch(_tabID)
          {
            case 'Personal':
              tabName = 'My Knowledge';
              break;
            case 'Results':
              tabName = 'Search';
              break;
          }
        }
        
        if(titleLabel != null)
        {
          if(_subfixName != null && _subfixName.length > 0)
          {
            titleLabel.innerHTML = tabName + _tabContextSeparator + _subfixName;
          }else
          {
            titleLabel.innerHTML = tabName;
          }
        }
        
  }
  catch (e) 
  {
    alert("An exception occurred in the script. Error name: " + e.name + ". Error message: " + e.message); 
    debugger;
  }
}

function KGNavigationControl_SwitchTabs_Wrapper(_tabID, _titleLabelClientID, _tabContextSeparator, _subfixName, _groupNameHiddenField, _groupIDHiddenField)
{
  try
  {
  //debugger;
		ConceptSelectedTab = _tabID;
		var multipageID = Global_SemanticTreeHolderID + '_ConceptLibraryPages';
		var mp = eval(multipageID);
		var pageID = 'CategoriesPage';
		var pageIndex = 2;
		switch(_tabID)
		{
			case 'Results':
				pageID = 'SearchResultsPage';
				pageIndex = 1;
				break;
			case 'Personal':
				pageID = 'PersonalLibraryPage';
				pageIndex = 0;
				break;
			default:
				pageID = 'CategoriesPage';
				pageIndex = 2;
				break;
		}
    if(mp != null)
    {
      var mpageId = Global_SemanticTreeHolderID + '_' + pageID;
      var mselpageId = Global_SemanticTreeHolderID + '_' + mp.get_selectedPage().Id;
      mp.SetPageId(pageID);
      if(mpageId != mselpageId)
      {
        var mpageDiv = document.getElementById(mpageId);
        if(mpageDiv != null)
        {
          mpageDiv.style.display = 'block';
          var moldpageDiv = document.getElementById(mselpageId);
          if(moldpageDiv != null)
          {
            moldpageDiv.style.display = 'none';
          }
        }
      }
    }
    
    // Close the docked window if it is open.    
    var dockedWindow = document.getElementById('DockedHelpWindow');
    if(dockedWindow != null)
      CloseDockedKGHelpControl();
      
    // Close the pop up window
    if(window.HideKGHelpControl)
      HideKGHelpControl();
        
    // select current tab
    global_ConceptTabbedControl_CurrentlySelectedTab = _tabID;
   SetSessionProperty('ConceptTreeTabbedView_SelectedTab', _tabID);
    if(_subfixName != null && _subfixName.length > 0)
    {
      SetSessionProperty('KGNavigationControl_SemanticTreeTitleSubFix', _subfixName.replace('&','%26'));
    }else
    {
        SetSessionProperty('KGNavigationControl_SemanticTreeTitleSubFix', '');
    }
    
    KGNavigationControl_UpdateRepopulationHiddenFields('SemanticTree|');
    
    // updat tab text
    KGNavigationControl_UpdateSemanticTreeTitle(_tabID, _subfixName);

    // Set hidden fields
    var groupName = document.getElementById(_groupNameHiddenField);
    if(groupName != null)
    {
      groupName.value = "Temp Text";
    }
        
    var groupID = document.getElementById(_groupIDHiddenField);
    if(groupID != null)
    {
      groupID.value = _tabID;
    }

    var currentLocation = window.location.href;
		var hostURL = currentLocation.substring(0, currentLocation.lastIndexOf('/') + 1);
    if(window.location.href == hostURL + "PrivateSpaceAdmin.aspx" && _tabID.substr(0,3) != 'CS_')
    {
      window.location = "home.aspx";
    }
  }
  catch (e) 
  {
    alert("An exception occurred in the script. Error name: " + e.name + ". Error message: " + e.message); 
    debugger;
  }
}


function KGNavBar_q134(_28,_29,_2a,_2b)
{
//debugger;
if(_q135)
{return;}

if(_q130==_29)
{return;}

var _2c=_28.get_events().getHandler("itemBeforeExpand");

if(_2c)
{

var _2d=new ComponentArt.Web.UI.NavBarItemCancelEventArgs(_2a);
_2c(_28,_2d);
if(_2d.get_cancel()){return;}}
if(_28.ClientSideOnItemExpand&&(!(eval(_28.ClientSideOnItemExpand))(_2a))){return;}
if(_2a.AutoPostBackOnExpand)
{__doPostBack(_28.ControlId,"EXPAND "+_2a.PostBackID);return;}
if(_29.childNodes.length==0)
{_29.innerHTML=_2a.GetSubGroupHtml();}
var _2e=true;
var _2f=0;

if(_28.FullExpand&&_28.ExpandSinglePath)
{

  if(!_28.FullExpandHeight)
  {
    var _30=document.getElementById(_28.NavBarID);
    if(cart_browser_ie&&_30.currentStyle)
    {
    var _31=0;_31+=_30.currentStyle.paddingTop?parseInt(_30.currentStyle.paddingTop):0;_31+=_30.currentStyle.paddingBottom?parseInt(_30.currentStyle.paddingBottom):0;_28.FullExpandHeight=_30.offsetHeight-_30.scrollHeight-_31;
    }
    else{
      var _31=0;
      var _32=document.defaultView.getComputedStyle?document.defaultView.getComputedStyle(_30,""):_30.style;_31+=_32.getPropertyValue("border-top-width")?parseInt(_32.getPropertyValue("border-top-width")):0;_31+=_32.getPropertyValue("border-bottom-width")?parseInt(_32.getPropertyValue("border-bottom-width")):0;_31+=_32.getPropertyValue("padding-top")?parseInt(_32.getPropertyValue("padding-top")):0;_31+=_32.getPropertyValue("padding-bottom")?parseInt(_32.getPropertyValue("padding-bottom")):0;
      var _33=_30.lastChild;
      if(_33.previousSibling)
      {
      while(_33&&!(_33.id&&_33.id.indexOf(_28.NavBarID+"_item_")==0))
      {_33=_33.previousSibling;}
      }
      if(_33)
      {var _34=_q86(_33)+_33.offsetHeight;
      var _35=_q86(_30)+_30.offsetHeight;
      _28.FullExpandHeight=_35-_34-_31;}
      }
      if(_28.FullExpandHeight<=0)
      {_28.FullExpandHeight=_30.parentNode.offsetHeight-_30.offsetHeight-_31;}
      if(_28.FullExpandHeight<=0){_28.FullExpandHeight=document.body.offsetHeight-_30.offsetHeight-_31;}
      if(_28.FullExpandHeight<=0){_28.FullExpandHeight=document.body.offsetHeight;}
    }
    _2f=_28.FullExpandHeight;
  }
  else
  {
    if(_2a.SubGroupHeight>0)
    {_2f=_2a.SubGroupHeight;}
    else{var _36=_29.cloneNode(false);
    _36.style.visibility="hidden";
    _36.style.display="block";
    _36.style.height="";
    document.body.appendChild(_36);
    _2f=_36.offsetHeight;_qE7(_36);
    _2e=false;}
  }

  if(_2e)
  {_29.style.height=_2f+"px";}
  else{_29.style.height="";}

  _2a.SetProperty("Expanded",true);
  _q135=_29.parentNode;
  _q135.ParentNavBar=_28;
  _q135.ParentItem=_2a;
  _q135.style.height="1px";
  _q135.style.display="block";
  _q135.style.overflow="hidden";
  var _37=null;

  if(_28.ExpandSinglePath)
  {

      var _38;var _39=_2a.GetParentItem();
      if(_39)
      {_38=_39.Items();}
      else{_38=_28.Items();}

      for(var i=0;i<_38.length;i++)
      {
        if(_38[i].GetProperty("Expanded")&&_38[i].ChildItemArray.length>0&&_38[i].StorageIndex!=_2a.StorageIndex)
        {_38[i].Collapse(_2b);}}

        _37=document.getElementById(_28.NavBarID+"_item_"+_2a.StorageIndex);
        if(_37.onmouseout){_37.onmouseout();}
      }

      var _3b=_28.ExpandDuration;
      if(_2b){_3b=0;}
      if((_28.ExpandTransition>0||_28.ExpandTransitionCustomFilter)&&_3b>0&&cart_browser_transitions)
      {

      if(!_29.ExpandTransitionFilterDefined)
      {
        var _3c=ComponentArt_EffectiveTransitionString(_28.ExpandTransition,_28.ExpandTransitionCustomFilter);
        _29.ExpandTransitionFilterIndex=_29.filters.length;
        _29.ExpandTransitionFilterDefined=true;
        _29.runtimeStyle.filter=_29.currentStyle.filter+" "+_3c;
      }

      _29.style.visibility="hidden";
      _29.filters[_29.ExpandTransitionFilterIndex].apply();
      _29.style.visibility="visible";
      _29.filters[_29.ExpandTransitionFilterIndex].play(_3b/1000);

  }
  _q136=(new Date()).getTime();
  ComponentArt_NavBar_ExpandDivStep(_2f,_3b,_28.ExpandSlide,_2e);
  ComponentArt_ConsiderExpandedStyle(_28,_2a.StorageIndex);
  _2a.RememberExpandState();

}

