function getIframeDocument(el) {    var oIframe = Ext.get('center-iframe').dom;    var oDoc = oIframe.contentWindow || oIframe.contentDocument;        return ( typeof oDoc.document == "object" ) ? oDoc.document : oDoc;}function navigateTo( aDocUniqueID ) {  var iframeDoc = getIframeDocument();  if ( typeof iframeDoc == "undefined" ) return;      var navButton = Ext.DomQuery.selectNode( "#navto_button", iframeDoc );  if ( !( navButton == null ) ) {    setCookie( "TMNavigateTo", aDocUniqueID, false, "/" );    navButton.click();  }  navButton, iframeDoc = null;  }function updatePanel( panelURL, region, panelID ) {     if ( typeof panelID == 'undefined' ) panelID = ( region ? region : '' ) + '-content-panel';     if ( panelID == 'center-iframe-panel' ) {       //iframeDoc = getIframeDocument('center-iframe');       targetWindow = Ext.get('center-iframe').dom.contentWindow;     }          if ( region == 'center' ) {     //       layout.getRegion('east').purgeListeners();         layout.getRegion('center').hide();         layout.getRegion('east').hide();	//       layout.getRegion('north').hide();      }            if ( typeof targetWindow == 'undefined' ) targetWindow = window;             var db = Ext.nd.Session.CurrentDatabase;              // check to see if the passed panelURL value is reserved	  switch( panelURL) {		case 'Back' : panelURL = targetWindow.PreviousUrl; break;		case 'LastViewURL' :			  var viewNameCookie = getCookie( db.WebFilePath + ":ViewName" );			  var viewStateCookie = getCookie( db.WebFilePath + ":ViewState" );			  panelURL = db.WebFilePath + ( viewNameCookie ? ( viewNameCookie  + "?OpenView" ) : '' ) + ( viewStateCookie ? ( viewStateCookie  + "?OpenView" ) : '' );			  break;		case 'Reset' : panelURL = db.WebFilePath; break;          case 'Refresh' : panelURL = 'refresh'; break;          case 'Focus' : panelURL = null; break;          case 'Login' : panelURL = db.WebFilePath + "login"; break;          case 'Logout' : panelURL = db.WebFilePath + "?logout"; break;	  }	// get the region and panel to work with	var reg = layout.getRegion( region );		if ( reg == 'east' ) reg.activePanel.hide();	var panel = panelID ? reg.getPanel( panelID ) : reg.activePanel;	if ( panel == null ) {       panel = new Ext.ContentPanel( panelID, { fitToFrame:true, title: panelID, closable: false } );       layout.add( region, panel );     }          // get the update manager	var updater = panel.getUpdateManager();	updater.purgeListeners();		updater.loadScripts = true;	     if ( typeof panelURL == 'undefined' || panelURL == null || panelURL.length < 1 ) {          // don't load any url, just set focus      }      else if ( panelURL == 'refresh' ) { 		if ( panelID == 'center-iframe-panel' ) {             if ( layout.getRegion('east') != null ) layout.getRegion('east').hide();                        targetWindow.location.reload();          }          else {              updater.refresh();              Ext.get('top_body').unmask();          }     }     else if ( region == 'center' ) {   	  if ( panelID == 'center-iframe-panel' ) {         if ( targetWindow.CurrentUrl ) targetWindow.PreviousUrl = targetWindow.CurrentUrl;	    targetWindow.CurrentUrl = panelURL;                  Ext.get('top_body').mask();         //iframeDoc.hide();         Ext.get('center-iframe').hide();	    Ext.get('center-iframe').dom.src = panelURL;       }       else {         updater.update( panelURL );         Ext.get('top_body').unmask();       }	}	else if ( region == 'east' ) {	     updater.on( "update", function() { if ( typeof window.top.cepMakeCurrentActive == "function" ) { window.top.cepMakeCurrentActive(); } layout.getRegion('east').show(); }, this, {single: true} );//	     updater.on( "update", function() { if ( typeof window.top.cepMakeCurrentActive == "function" ) { window.top.cepMakeCurrentActive(); } }, this, {single: true} );	     updater.update( panelURL );	}		reg.showPanel( panelID );     // clean up object references to avoid memory leaks	panel, reg, updater = null;}    window.top.cepMakeCurrentActive = function() {      if ( typeof Ext != "object" ) return;      var currentID = window.top.cepCurrentID;            var activeLink = Ext.select( '.cep-current' );      if ( activeLink != null ) {        for ( var n = 0; n < activeLink.length; n++ ) {          activeLink[n].removeClass( 'cep-current' );        }      }            var cepLink = Ext.select( '#cep-' + currentID );      if ( cepLink != null ) cepLink.addClass( 'cep-current' );            activeLink, cepLink = null;            var viewEntries = null;      var activeId = "";            viewEntries = Ext.select( '.cep-entrywrapper', true );      if ( viewEntries != null && viewEntries.elements.length ) {        for ( var n = 0; n < viewEntries.elements.length; n++ ) {          activeId = viewEntries.elements[n].id;          var splitLength = activeId.split(".").length;          if ( splitLength > 0 ) {            viewEntries.elements[n].addClass( 'cep-level-' + ( splitLength - 1 ) );          }        }      }     activeId, viewEntries = null;            var viewBody = Ext.get('east').select( '.embeddedview_body' );        if ( viewBody != null ) {        //viewBody.each( function() { this.show(); } );        viewBody.show();      }            viewBody = null;            return true;    }     window.top.tocMakeVisitedActive = function() {     if ( typeof Ext != "object" ) return;     	var visitedLinks = window.top.tocVisitedLinks;	var currentID = window.top.tocCurrentID;		for ( x in visitedLinks ){		var tocLinkID = visitedLinks[x];		var domNode;				var tocLink = Ext.select( '#toc-' + tocLinkID );          if ( tocLink != null ) {		  domNode = Ext.DomQuery.selectNode( '#toc-' + tocLinkID );		  if ( visitedLinks[x] == currentID ) {			  tocLink.addClass( "toc-current" );			  tocLink.removeClass( "toc-active" );            }		  else {			  tocLink.addClass( "toc-active" );			  tocLink.removeClass( "toc-current" );		  }		  if ( domNode != null ) domNode.href = "javascript:navigateTo(\"" + tocLinkID + "\");";		  //tocLink.href = "javascript:navigateTo(\"" + tocLinkID + "\");";		  		  // cleanup		  tocLink, domNode = null;		}	  	}  	visitedLinks, currentID = null;  	return true;  }  	window.top.logout = function(){		var db = Ext.nd.Session.CurrentDatabase.WebFilePath		setCookie ( db+':TRMSLoginInfo', "", false, "/", false, false, true );		window.location.href ='/';	}
