"use strict";

// will not be obfuscated
onload = function () {
	if (typeof GetParameter !== "function") {
		return false;
	}
	var sLanguage = GetParameter("lang");
	if (sLanguage) {
		g_objCrossBrowserModel.LoadJavaScriptFile(sLanguage + "/player.help2." + sLanguage + ".js");
	}
	return true;
};

function TEXT_POOL_LOADED(sLanguage) {
	if (typeof TTAPI === "undefined" || !TTAPI) {
		CUSTOM_TEXT_POOL_LOADED(sLanguage);
	} else {
		var sCustTexts = TTAPI.GetProperty("helpcustomtexts" + "." + sLanguage.replace("-", "_"));
		if (sCustTexts) {
			g_objCrossBrowserModel.LoadJavaScriptFile(TTAPI.GetPathByProperty("helpcustomtexts") + sCustTexts);
		} else {
			CUSTOM_TEXT_POOL_LOADED(sLanguage);
		}
	}
}

function CUSTOM_TEXT_POOL_LOADED(sLanguage) {
	// FRAMES hier laden:
	var objTopFrame = g_objCrossBrowserModel.FindFrameByFrameId(window, "menuFrame");
	if (objTopFrame) {
		// Menu-HTML laden:
		g_objCrossBrowserModel.LoadFrame("menuFrame", "player.help2.menu.htm?active=" + "menuItemNavigationelements" + "&lang=" + sLanguage, Help2OnAfterMenuLoaded);
		g_objCrossBrowserModel.LoadFrame("contentFrame", "player.help2.navigationelements.htm?lang=" + sLanguage, null);
	}
}

function Help2OnAfterMenuLoaded() {
	var objAccCtrl = TTAPI.GetListener("id_AccessibilityControl");
	if (objAccCtrl) {
		var win = document.getElementById("menuFrame");
		objAccCtrl.Add("menuFrame", win, g_objCrossBrowserModel.GetFrameFromWindow(window, "menuFrame").document);
		objAccCtrl.AddParentOffset("menuFrame", [window.parent.frameElement, g_objCrossBrowserModel.FindPrecedingParentFrame(window)]);
	}
}

onunload = function () {
	var objAccCtrl = TTAPI.GetListener("id_AccessibilityControl");
	if (objAccCtrl) {
		objAccCtrl.Remove("menuFrame");
	}
	g_objCrossBrowserModel.LoadFrame("menuFrame", "about:blank", null);
	g_objCrossBrowserModel.LoadFrame("contentFrame", "about:blank", null);
};
