//======================================================================
//  Activating jquery compatibility mode
//======================================================================

if(jQuery){
	var $j = jQuery.noConflict();
}

//======================================================================
//  Knowledge Force Accelerator Global Functions
//======================================================================

var TTPortal = {

	Version: '6.9.0.1',

	Core : {

		m_objRootWindow : null,
		m_objGlobalValues : null,

		/***********************************************************************
		  lookupRootWindow
		***********************************************************************/
		lookupRootWindow : function() {

			if( this.m_objRootWindow != null ) {
				return this.m_objRootWindow;
			}

			var fObjectResolver = function( objWindow ) {
				if( !objWindow ) {
					return( null );
				}

				var isRootWindow = false;
				try {
					isRootWindow = ( objWindow.document.getElementById("ttPortalFrameset") != null );
				}
				catch (e) {
					return null;
				}

				return isRootWindow ? objWindow : null;
			};
			try {
				this.m_objRootWindow = TTPortal.Utils.lookupObject( fObjectResolver, window, 10 );
			    if( !this.m_objRootWindow && window.opener ) {
				    this.m_objRootWindow = TTPortal.Utils.lookupObject( fObjectResolver, window.opener, 10 );
			    }

			    return this.m_objRootWindow;
            } catch (e) {
                TTPortal.Logging.logException("Could not lookup root window", e);
                return null;
            }
		},

		/***********************************************************************
		 * lookupNavpaneApi
		***********************************************************************/
		lookupNavpaneApi : function() {

			if (this.m_objRootWindow != null) {
				return this.m_objRootWindow;
			}

			var fObjectResolver = function( objWindow ) {
				if( objWindow.ACCELERATOR_NAVPANE_API ) {
					return( objWindow.ACCELERATOR_NAVPANE_API );
				}
				return( null );
			};
            try {
			    this.m_objRootWindow = TTPortal.Utils.lookupObject( fObjectResolver, window, 10 );
			    if( !this.m_objRootWindow && window.opener ) {
				    this.m_objRootWindow = TTPortal.Utils.lookupObject( fObjectResolver, window.opener, 10 );
			    }

			    return this.m_objRootWindow;
            } catch (e) {
                TTPortal.Logging.logException("Could not lookup navpane API", e);
                return null;
            }
		},

		/***********************************************************************
		 * lookupGlobalValueObject
		***********************************************************************/
		lookupGlobalValueObject : function() {

			if( this.m_objGlobalValues != null ) {
				return this.m_objGlobalValues;
			}

			var fObjectResolver = function( objWindow ) {
				if( objWindow && objWindow.TT_GLOBAL_VALUES ) {
					return objWindow.TT_GLOBAL_VALUES;
				}
				return null;
			};
            try {
			    this.m_objGlobalValues = TTPortal.Utils.lookupObject( fObjectResolver, window, 10 );
			    if( !this.m_objGlobalValues && window.opener ) {
				    this.m_objGlobalValues = TTPortal.Utils.lookupObject( fObjectResolver, window.opener, 10 );
			    }
			    return this.m_objGlobalValues;
            } catch (e) {
                TTPortal.Logging.logException("Could not lookup global values", e);
                return null;
            }
		},

		/***********************************************************************
		 * setGlobalValue
		***********************************************************************/
		setGlobalValue : function( sId, value ) {

			if (!sId || sId.length === 0 || value == null) {
				return false;
			}

			var objGlobalValues = this.lookupGlobalValueObject();
			if( !objGlobalValues ) {
				return false;
			}

			try {
				return objGlobalValues.set(sId, value);
			}
			catch(objError) {}

			return false;
		},

		/***********************************************************************
		 * getGlobalValue
		***********************************************************************/
		getGlobalValue : function( sId ) {

			if (!sId || sId.length === 0) {
				return null;
			}

			var objGlobalValues = this.lookupGlobalValueObject();
			if (!objGlobalValues) {
				return null;
			}

			try {
				return objGlobalValues.get(sId);
			}
			catch(objError) {}

			return null;
		}
	},

	Url : {
		/***********************************************************************
		 * getParam
		************************************************************************
		  gets a specified html-parameter from the current location-url
		***********************************************************************/
		getParam : function( sParamName, sParameterList ) {

			if (!sParamName || sParamName.length === 0) {
				return("");
			}

			var sParams = (typeof sParameterList !== "undefined" && sParameterList != null && sParameterList.length > 0) ? sParameterList : location.search;
			if (sParams.length === 0) {
				return "";
			}

			var rxParam = new RegExp( "[\&,\?]" + sParamName + "=([^&#]*)","i" );
			rxParam.lastIndex = 0;
			if(rxParam.test(sParams)) {
				rxParam.lastIndex = 0;
				rxParam.exec(sParams);
				if( (rxParam.lastIndex > -1) && RegExp.$1 ) {
					return RegExp.$1;
				}
			}

			return "";
		}
	},

	Browser : {

		Info : {

			name : window.navigator.appName.toLowerCase(),
			userAgent : window.navigator.userAgent.toLowerCase(),

			IsMobileBrowser : function() {
				var a = navigator.userAgent || navigator.vendor || window.opera;
				return(/android|avantgo|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i.test(a) || /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|e\-|e\/|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(di|rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|xda(\-|2|g)|yas\-|your|zeto|zte\-/i.test(a.substr(0,4)) );
			},

			IsIPadBrowser : function() {
				if (this.name !== "netscape") {
					return false;
				}

				if( this.userAgent.indexOf("applewebkit") <= 0 ) {
					return false;
				}

				if( this.userAgent.indexOf("ipad") <= 0 ) {
					return false;
				}

				return	true;
			},

			IE : (function () {
				var actualVersion,
					jscriptVersion,
					jscriptMap = {
						"5.5": 5,
						"5.6": 6,
						"5.7": 7,
						"5.8": 8
					};

				jscriptVersion = new Function("/*@cc_on return @_jscript_version; @*/")();

				if (jscriptVersion === undefined) {
					return null;
				}

				actualVersion = (Number(jscriptVersion) < 9) ? jscriptMap[jscriptVersion] : Number(jscriptVersion);

				return {
					"actualVersion": actualVersion
				};
			}())
		},

		/***********************************************************************
		 * browser fixes
		***********************************************************************/
		Fix : {
			IETableLayout : function( sTableId) {
				if (navigator.appName.indexOf("Internet Explorer") == -1) {
					return;
				}

				var fixIETableLayout = function(e) {
					var objTable = $(sTableId);
					if( !objTable ) {
						return;
					}
					objTable.style.display = "inline-table";

					window.setTimeout( function(){
							var objTable = $(sTableId);
							if( !objTable ) {
								return;
							}
							objTable.style.display = "";
						},
						0
					);
				};

				var objRootWindow = TTPortal.Core.lookupRootWindow();
				if( objRootWindow && objRootWindow.document ) {
					Event.observe( objRootWindow.document, "rootwindow:resized", fixIETableLayout );
					Event.observe( window, "load", fixIETableLayout );
				}
			}
		},

		/***********************************************************************
		 * resizeBrowserWindow
		 *
		 * applies a new size to the given browser window
		***********************************************************************/
		resizeBrowserWindow : function ( objWin, nWidth, nHeight ) {
			if (objWin === null) {
				return;
			}

			try	{
				objWin.innerWidth = nWidth;
				objWin.innerHeight = nHeight;

				var currentSize = this.getCurrentWindowSize(objWin),
					widthDiff = currentSize.width > 0 ? nWidth - currentSize.width : 0,
					heightDiff = currentSize.height > 0 ? nHeight - currentSize.height : 0;

				objWin.resizeBy(widthDiff, heightDiff);
			}
			catch (objError) {
				alert(objError);
			}
		},

		/**
		 * @param objWin
		 * @returns {{width: number, height: number}}
		 */
		getCurrentWindowSize : function(objWin) {
			var size = {
				"width" : 0,
				"height" : 0
			};

			// Most browsers
			size.width = jQuery(objWin).width();
			size.height = jQuery(objWin).height();
			if (size.width > 0 && size.height > 0) {
				return size;
			}

			// Fallback for older IEs
			size.height = objWin.document.body.clientHeight;
			size.width = objWin.document.body.clientWidth;

			return size;
		},

		/***********************************************************************
		 * closeBrowserWindow
		 *
		 * closes the current browser window
		***********************************************************************/
		closeBrowserWindow : function () {
			var currentWindow = window;

			if( Prototype.Browser.IE ) {

				if( navigator.appVersion.toLowerCase().indexOf("msie 7") != -1 ) {
					// NUR IE 7 ...
					try {
						currentWindow.open('', '_parent', '');
						currentWindow.close();
					}
					catch(objError) {}
				}
				else {
					// ALLE ANDEREN IEs ...
					try {
						self.opener = currentWindow;
						setTimeout('self.close()',1);
					}
					catch(objError) {}
				}
			}
			else {
				try {
					// TODO: geht nicht im FF 2.0 (nur FF 1.5) !!! ...
					currentWindow.open('', '_parent', '');
					currentWindow.close();
				}
				catch(objError) {}
			}
		}
	},

	MobileLearning : {
		m_objMobileApi : null,

		lookupMobileApi : function() {
			if( this.m_objMobileApi != null ) {
				return this.m_objMobileApi;
			}

			var fObjectResolver = function( objWindow ) {
				try {
					if (objWindow.MobileApp) {
						return objWindow.MobileApp;
					}
				}
				catch(e) {}

				return null;
			};

			this.m_objMobileApi = TTPortal.Utils.lookupObject( fObjectResolver, window, 10 );
			if( !this.m_objMobileApi && window.opener ) {
				this.m_objMobileApi = TTPortal.Utils.lookupObject( fObjectResolver, window.opener, 10 ); }

			return( this.m_objMobileApi );
		},

		isRunningInMobileApp : function() {
			return (this.lookupMobileApi() != null ? true : false);
		},

		isRunningInMobileAppWithDataHandling : function() {
			var objMobileAPI = this.lookupMobileApi();
			if( objMobileAPI == null ) {
				return( false );
			}

			if (typeof objMobileAPI.PlayerBridge === "undefined" || !objMobileAPI.PlayerBridge ) {
				return false;
			}

			if (typeof objMobileAPI.PlayerBridge.setScoData === "undefined") {
				return false;
			}

			if (typeof objMobileAPI.PlayerBridge.getScoData == "undefined") {
				return false;
			}

			return true;
		},

		isRunningOnIPad : function() {
			var bRunningOnIPad = (window.navigator.userAgent.toLowerCase().indexOf("ipad") > 0);
			return bRunningOnIPad;
		}
	},

	WindowManager : {
		documentWindowDecoration : "left=0,top=0,width=720,height=510,menubar=yes,resizable=yes,scrollbars=yes",
		documentInstanceWindowDecoration : "left=0,top=0,width=750,height=600,menubar=no,resizable=yes,scrollbars=yes",
		certificateWindowDecoration : "left=0,top=0,width=660,height=800,menubar=yes,resizable=yes,scrollbars=no",
		glossaryWindowDecoration : "left=0,top=0,width=900,height=700,menubar=yes,resizable=yes,scrollbars=yes",
		guidanceWindowDecoration : "left=0,top=0,width=460,height=900,menubar=yes,resizable=yes,scrollbars=yes",

		/***********************************************************************
		  openAcceleratorWindow
		************************************************************************
		  opens a popupwindow with to displays the given uri and decoration
		***********************************************************************/
		openAcceleratorWindow : function( uri, name, decoration ) {
			return( window.open( uri, name, decoration ) != null );
	    },

		/***********************************************************************
		  openDocumentWindow
		************************************************************************
		  opens a window with document-decoration and displays the given uri
		***********************************************************************/
	    openDocumentWindow : function (uri) {
			return( this.openAcceleratorWindow( uri, "documentview", window.documentWindowDecoration ? window.documentWindowDecoration : this.documentWindowDecoration ) );
	    },

	    /***********************************************************************
		  openDocumentInstanceWindow
		************************************************************************
		  opens a window for a document-instance
		***********************************************************************/
	    openDocumentInstanceWindow : function ( id, bForceRedirect ) {
			return this.openInstanceWindow(id, bForceRedirect, this.documentInstanceWindowDecoration);
	    },

		/***********************************************************************
		 openGuidanceInstanceWindow
		 ************************************************************************
		 opens a window for a guide-instance
		 ***********************************************************************/
		openGuidanceInstanceWindow : function( id, bForceRedirect ) {
			return this.openInstanceWindow(id, bForceRedirect, this.guidanceWindowDecoration);
		},

		openInstanceWindow : function(id, bForceRedirect, decoration) {
			var sUri = this.getUriFromAnchor(id),
				sTarget = this.getTargetFromAnchor(id),
				objDocWindow;

			if (sUri === "" || sTarget === "") {
				return false;
			}

			if (bForceRedirect) {
				location.replace(sUri);
				return true;
			}

			objDocWindow = this.openAcceleratorWindow( sUri, sTarget, decoration);
			return objDocWindow != null;

		},

		getUriFromAnchor : function(id) {
			var objAnchor = $(id),
				sUri;

			if (!objAnchor) {
				return "";
			}

			sUri = objAnchor.href;
			if (!sUri || sUri.length === 0) {
				return "";
			}
			return sUri;
		},

		getTargetFromAnchor : function(id) {
			var objAnchor = $(id),
				sTarget;

			if (!objAnchor) {
				return "";
			}

			sTarget = objAnchor.target;
			if (!sTarget || (sTarget.length === 0)) {
				sTarget = "documentinstanceview";
			}

			// if the current window name equals the target name, the url will be redirected
			// to force a popup window, the name will be extendet by popup postfix
			if (sTarget === window.name) {
				sTarget += "popup";
			}
			return sTarget;
		},


		/***********************************************************************
		  openCertificateWindow
		************************************************************************
		  opens a window with certificate-decoration and displays the given uri
		***********************************************************************/
		openCertificateWindow : function (uri) {
	        return( this.openAcceleratorWindow( uri, "certificateview", window.certificateWindowDecoration ? window.certificateWindowDecoration : this.certificateWindowDecoration ) );
	    },

		/***********************************************************************
		  openGlossaryWindow
		************************************************************************
		  opens a window with glossary-decoration and displays the given uri
		***********************************************************************/
	    openGlossaryWindow : function (uri) {
	        return( this.openAcceleratorWindow( uri, "glossaryview", window.glossaryWindowDecoration ? window.glossaryWindowDecoration : this.glossaryWindowDecoration ) );
		},

		/***********************************************************************
		  openFullscreen
		************************************************************************
		  shows the current page in fullscreen view
		***********************************************************************/
		openFullscreen : function( sUri ) {
			if (!sUri || (sUri.length() === 0)) {
				sUri = document.location.href;
			}
			sUri += (sUri.indexOf("?") === -1) ? "?" : "&";
			sUri += "fullscreen=true";
			var sParams = "screenx=0,screeny=0,top=0,left=0,toolbar=yes,menubar=yes,statusbar=yes,scrollbars=yes,resizable=yes,width=" + (screen.width-10) + ",height=" + (screen.height-146);
			window.open( sUri, "bdfullscreen", sParams );
		},

		/***********************************************************************
		  goHome
		************************************************************************
		  shows the current page in fullscreen view
		***********************************************************************/
		goHome : function( objDoc ) {
			if( objDoc == null ) {
				objDoc = document;
			}
		  objDoc.location.replace(".");
		},

		/***********************************************************************
		  jumpToAnchor
		************************************************************************
		  jumps to a given anchor
		***********************************************************************/
		jumpToAnchor : function( anchor, win ) {
			var w = (win && win != null) ? win : window;
			if(jQuery) {
				var anchorElem = jQuery('a[name='+anchor+']', w.document);

				var y = 0;
				if (anchorElem.height() === 0) {
					y = anchorElem.next(':not(:empty)').offset().top;
				}
				else {
					y = anchorElem.offset().top;
				}

				jQuery('html, body', w.document).animate({
					scrollTop: y
				}, 200);
			} else {
				w.location.hash = anchor;
			}
		}
	},

	Print : {
		/***********************************************************************
		  togglePrintButton
		***********************************************************************/
		togglePrintButton : function( href, printButton ) {
			var contentUrl = href.split(/\?/)[0];
			if (contentUrl.lastIndexOf('.pdf') === (contentUrl.length - 4)) {
				printButton.style.display = 'none';
			}
			else {
				printButton.style.display = '';
			}
		},

		/***********************************************************************
		  printFrame
		***********************************************************************/
		printFrame : function( name ) {
			try {
				var f = eval( "window" + (typeof name === "undefined" ? "" : "." + name) );
				if (typeof f.ttdoccontent === "object" ) {
					f = f.ttdoccontent;
				}
				f.focus();
				f.print();
	        }
	        catch(objError) {}
		}
	},

	Tree : {
		/***********************************************************************
		  syncTree
		***********************************************************************/
		syncTree : function( objParams ) {

			if (!objParams || objParams.preview || !objParams.nodeId) {
				return;
			}

			try {
				if (objParams.navpane) {
					var objNavpaneApi = TTPortal.Core.lookupNavpaneApi();
					if (objNavpaneApi) {
						var objNavpaneViewport = objNavpaneApi.getNavpaneViewport(objParams.navpane);
						if (objNavpaneViewport && objNavpaneViewport.syncTree) {
							objNavpaneViewport.syncTree(objParams.nodeId);
						}
					}
				}
				else if (objParams.frame) {
					if (parent[objParams.frame] || top[objParams.frame]) {
						var treeWindow = window.open("", objParams.frame);
						if (treeWindow && treeWindow.syncTree && objParams.nodeId) {
							treeWindow.syncTree(objParams.nodeId);
						}
					}
				}
			}
			catch(e) {}

		}
	},

	/***********************************************************************
	************************************************************************
	  Log Service
	************************************************************************
	***********************************************************************/
	Logging : {
		m_bLog : true,
		m_asLog : [],
		m_objLogApi : null,
		m_sWindowId : "",

		initLogApi : function () {

			var fObjectResolver = function( objWindow ) {
		    	if (objWindow && objWindow.TT_LOG_WINDOW && typeof objWindow.TT_LOG_WINDOW.LOG_API !== "undefined") {
		    		return objWindow.TT_LOG_WINDOW.LOG_API;
		    	}
		    	return null;
			};

			var objLogApi = TTPortal.Utils.lookupObject( fObjectResolver, window, 10 );
			if (!objLogApi && window.opener) {
				objLogApi = TTPortal.Utils.lookupObject( fObjectResolver, window.opener, 10 );
			}

			if( objLogApi ) {
				this.setLogApi( objLogApi );
		    }
		},

		setLogApi : function( objLogApi ) {
			if(objLogApi) {
				this.m_objLogApi = objLogApi;
				this.m_bLog = true;
				this.m_sWindowId = window.name;
			}
		},

		log : function( sMsg, sType, sSender ) {
			if( this.m_bLog ) {

				if( this.m_sWindowId ) {
					sSender = this.m_sWindowId + ((sSender != null) ? ("::" + sSender) : "");
				}

				if( this.m_objLogApi ) {
					this.m_objLogApi.log( sMsg, sSender, sType );
				}

				var sLogEntry = sType + ": " + sSender + " -> " + sMsg;
				this.m_asLog.push( sLogEntry );
				if( this.m_asLog.length > 100 ) {
					this.m_asLog.shift();
				}
			}
		},

		logInfo : function( sSender, sMsg ) {
			this.log( sMsg, "info", sSender );
		},

		logWarning : function( sSender, sMsg ) {
			this.log( sMsg, "warning", sSender );
		},

		logError : function( sSender, sMsg ) {
			this.log( sMsg, "error", sSender );
		},

		logDebug : function( sSender, sLogEntry ) {
			this.log( sMsg, "debug", sSender );
		},

		logException : function(sSender, e ) {
			if (window.console && window.console.log) {
				window.console.log(sSender+": "+e);
				//window.console.log("Stacktrace: "+e.stack);
			}
            this.logError(sSender, "Exception: "+e);
		},

		alertLog : function() {
			if( this.m_bLog ) {
				var sLogOutput = "";
				for( var i=0; i< this.m_asLog.length; i++ ) {
					sLogOutput += this.m_asLog[i] + "\n";
				}
				alert( sLogOutput );
			}
		},

		clear : function() {
			if( this.m_objLogApi ) {
				this.m_objLogApi.clear();
			}
			this.m_asLog = [];
		}
	},

	Utils : {
		/***********************************************************************
		  preloadImages
		***********************************************************************/
		preloadImages : function( asFilenames ) {
			if( !asFilenames ) {
				return;
			}

	        for( var i = 0; i < asFilenames.length; i++ ) {
	             new Image().src = asFilenames[i];
			}
		},

		/***********************************************************************
		  findWindow
		***********************************************************************/
		lookupObject : function( fObjectResolver, objLookupWindow, nMaxDepth ) {
			try {
				if (fObjectResolver == null || typeof fObjectResolver !== "function") {
					return null;
				}
				if (objLookupWindow == null) {
					objLookupWindow = window;
				}

				if ((nMaxDepth == null) || (nMaxDepth <= 0)) {
					nMaxDepth = 10;
				}

				var nCurrentSearchDepth = 0,
					currentWindow = objLookupWindow;

				while (currentWindow) {
					var objResolved = fObjectResolver(currentWindow);
					if (objResolved != null) {
						return objResolved;
					}

					// frameElement returns the element (such as <iframe> or <object>) in which the window is embedded, or
					// null if the element is either top-level or is embedded into a document with a different script
					// origin; that is, in cross-origin situations.
					if (currentWindow.frameElement === null) {
						break;
					}

					nCurrentSearchDepth++;
					if (nCurrentSearchDepth > nMaxDepth) {
						break;
					}

					currentWindow = currentWindow.parent
				}

				return null;
			}
			catch(e) {
				TTPortal.Logging.logWarning("TTPortal.Utils.lookupObject", "Exception: " + e);
				return null;
			}
		}
	}
};

if (typeof onELearningStart === "undefined" ) {
	var onELearningStart = function( sequenceId, usecase, elementId )	{
		return( !TTPortal.WindowManager.openDocumentInstanceWindow(elementId) );
	};
}

var switchLanguage = function (language) {
	var currentURI = window.location.href;
	var newURI = currentURI.replace( /(.*)(language=)[^\&]*(.*)/, "$1$2" + language + "$3" );
	location.href = newURI;
};

var closeBrowserWindow = function () { TTPortal.Browser.closeBrowserWindow(); };
