﻿
		//Set debugging mode here:
		var c_bLogFlow = false;		//true: generates a lot of output and may cause performance loss. 
		var cmsXSLDebug = false;		//For development: true forces econtioCMS to reload XSL-Files on every rendering process


		var bTinyMCE_DoNotWaitForDOM = true;		//tinymce is loaded on demand so there is no need to wait for any domLoaded-Event in tinymce
		var strTinyMCE_baseURL = "";

		var globalVolume = 100;
	
		var timeLines = new Object();


//		the language will be set in the framework template at rendering
		var selLanguage = null;
		mecoLang = null;


		var strUser = "";

//		idLesson is the page name and will be set in the framework template
		var idLesson = null;


		var imgPreLoad = new Object()
	
		var meco;
		var ePlayer;
		var mainDebug;
		var systemOK;
		
		var nDVDactive;
	
	
		function myOnLoad()	{
	
			strTinyMCE_baseURL = c_Customer + "/_js/tiny_mce";

			cms.init();
	
			createEventListener($("main"), "keydown", debugKey);	
			
	//		setFullScreen(1);
	
			mainDebug = new econtioDebug("debugArea");
			var msg = "<b>" + browserDetect.browser + "</b>";
			msg += "<br><b>Version: </b>" + browserDetect.version;
			msg += "<br><b>OS: </b>" + browserDetect.OS;
			msg += "<br><br>" + location.href;
			debuglog(msg);
	
			if(typeof(mecoOffline) != "undefined")
				meco = new mecoOffline();
			else
				meco = new mecoOnline();
	
			meco.init();
	
			mecoVariables["VIDEO_DRIVE"] = "";
/*			mecoVariables["VIDEO_PATH"] = "composeCMS/";
			mecoVariables["STREAMING_PROVIDER"] = "nacamar";
			mecoVariables["STREAMER"] = "streamer=rtmp://fms.edge.newmedia.nacamar.net/linguatv";
*/
	
			mecoVariables["STREAMING_PROVIDER"] = "interlake";

			mecoVariables["STREAMER"] = new Object();
			mecoVariables["STREAMER"]["WMV"] = "http://streaming.interlake.net/asx.cfm?a=20081209181607/"
			mecoVariables["STREAMER"]["FLASH"] = "config=http://streaming.interlake.net/fms;20081209181557;";
			mecoVariables["STREAMER"]["PROGRESSIVE"] = "./";
			
			mecoVariables["VIDEO_PATH"] = new Object();
			mecoVariables["VIDEO_PATH"]["WMV"] = "Woterfitz/";
			mecoVariables["VIDEO_PATH"]["FLASH"] = "Woterfitz/";
			mecoVariables["VIDEO_PATH"]["PROGRESSIVE"] = "video/";
			
			mecoVariables["STREAMING_PATH"] = "Woterfitz/";


	
			meco.switchDVD = function(volumeName, bChanged)	{
				abortSwitchDVD();
			}
	
			
			rbmWindow3.init();
			rbmWindow3.createFader();
	
			customer.onload();
	
			systemOK = systemTest();
			systemOK = true;
			if(!systemOK)	{
				$fx("JSactiv").setDisplay(false);
				rbmWindow3.allWindows["wndSystest"].open((document.body.offsetWidth - 500) / 2 , 100, 500, 600, false, true, true, false);	//800x620
				return;
			}

//etracker:
			try	{
				if(typeof(et_eC) == "function") 	{
 					et_eC( 'SYVF5E' );
 				}
 			}
 			catch(e) {}

			meco.execScript("pageScript", false, initPage);	
	
		}


		function initPage()	{
	

			if(!!mecoVariables["DVDACTIVE"] && mecoVariables["DVDACTIVE"] == "2")	{
				nDVDactive = 2;		
			}
			else{
				nDVDactive = 1;
			}

			cms.history.pushHistory("framework", customer.selectMenu.bind(customer, 'mainMenu', 'home'));
			cms.history.pushHistory("framework", customer.selectMenu.bind(customer, 'mainMenu', 'home'));
			cms.history.setHistory();

				
			//attention: requestXMLContent is located in index.php and might be unavailable in html mode!
			requestXMLContent();
	
		}
		


	var customer = new Object();

	//set defaults for resizing
	customer.marginLeft = 200;
	customer.topHeight = 133;
	customer.bottomHeight = 45;
	customer.bScrollPage = true;
	//if bScrollPage is true we have to define the area that scrolls here (either ''(empty) for body or 'c_page_main')
	customer.resizeArea = "main";	//main
	customer.minBodyWidth = 998;
	customer.bLimitWidth = true;
	customer.limitWidth = 798; 
	
	customer.fullscreenMode = "";
	
	customer.flashVideoPlayer = "jwplayer45econtio.swf";
	
	customer.setFlashPlayerVars = function(playerVars, previewPicture)	{
		
		playerVars = playerVars.replace(/~logo/g, "|logo~" + c_Customer + "/images/ltv_playerlogo.png");
		playerVars = playerVars.replace(/~displayclick/g, "|dispalyclick~true");
		playerVars = playerVars.replace(/~autostart/g, "|autostart~true");
		playerVars = playerVars.replace(/~stretching/g, "|stretching~fill");
		
		if(!!previewPicture)	{
			playerVars += "|image~" + previewPicture;
		}
		playerVars = playerVars.substr(0, 1) == "|" ? playerVars.substring(1, playerVars.length) : playerVars;
		return playerVars;
	}
	
		
	customer.serverMode = ".php";

	customer.checkForm = new Object();



	customer.onload = function()	{
			rbmWindow.bScrollPage = this.bScrollPage;
	}
	
	customer.getDevJSCode = function(f, target)	{
		var oAjax = new rbmAjax();	
		//oAjax.render = false;
		oAjax.XMLeval = false;
		//oAjax.debug = true;
		oAjax.target = target;
		oAjax.getXML(f, null, true);
	}
	

	
	
	customer.levelSelect = function(lessonCode, dataType, nLevel) {


		if(!!lessonCode)	{

			econtioTraining.gotoLevel(lessonCode, dataType);
		}
		else	{ //only do this if we are not going to unload...
			//reset all Buttons
//			aTabButtons = $("c_unit_" + idUnit).getElementById("c_tab").getElementsByClassName("tabButton");
//			for(i = 0; i<aTabButtons.length; i++)	{
//				aTabButtons[i].sel = false;
//				aTabButtons[i].src = imgPreLoad[aTabButtons[i].id].src;
//			}
			
//			myButton = $("c_unit_" + idUnit).getElementById("b_level" + nLevel);
//			myButton.sel = true;

//			myButton.src = imgPreLoad[myButton.id + "_sel"].src;
					
		}
	}
		
	
	customer.startPractice = function(idObject, idObjectType)		{
		
		switch(idObjectType)	{
			case 401:		//Practice Style
				cms.showData("object_" + idObject, idObject, "window_Area", "", true);
				break;
			case 502:
				this.scrollPage();
				cms.showData("object_" + idObject, idObject, "c_contentInner", "", true);
				break;
			
			default:		//Unit style
				econtioTraining.addUnit("object_" + idObject);
				break;
		}
		
	}
	
	
	

	//this function is called on page reloads e.g. language chages etc.
	customer.initAfterInitialRendering = function()	{

		this.oContent = new rbmAjax();
		this.oContent.bRender = false;

		customer.initMenus();

/*
		if(!!customer.currentPage)	{
			econtioMenu.menuList["menu_mainMenu"].selectMenu(customer.currentPage);
//			customer.selectMenu(idLesson, "mainMenu", customer.currentPage, true);
		}
		else	{
			customer.currentPage = "";
			var aMenuSelected = oLesson.selectNodes("//menu[@id = 'mainMenu']/descendant::menuItem[@selected = 1]");
			
			if(aMenuSelected.length > 0)
				econtioMenu.menuList["menu_mainMenu"].selectMenu(aMenuSelected[0].getAttribute("id"));
		}
*/

	
		//XXX:do not forget to update this on lesson Changes!!
		customer.contentInner = $("c_page_" + idUnit).getElementById("c_contentInner");

//check for screen size
//		if(mecoVariables["SCREEN_HEIGHT"] < 850)	{
//			alert("Your screen height is less then 850 pixel.\n\nPlease press F11 to switch you Browser into the fullscreen mode!");
//		}

		this.setPageWLimit(this.bLimitWidth);
		this.resize();

		
	}
	
	customer.setPageWLimit = function(bLimit)	{
	
		if(bLimit)	{
			var change = $("c_page_framework");
			change.style["width"] = this.limitWidth + "px";
			var change = $("maintemplate");
			change.style["width"] = (this.limitWidth) + "px";
		}
		else	{
			var change = $("c_page_framework");
			change.style["width"] = "auto";
			var change = $("maintemplate");
			change.style["width"] = "auto";
		}

		this.bLimitWidth = bLimit;
		this.resize();
	}

	customer.scrollPageDefault = function()	{
		var change = $("c_contentArea");
//		change.style["height"] = "auto";
		var change = $("main");
		change.scrollTop = 0;
//		change.style["overflow"] = "hidden";
		change.style["height"] = "auto";
		document.getElementsByTagName("body")[0].style["overflow"] = "hidden";
		document.getElementsByTagName("body")[0].style["height"] = "auto";
		document.getElementsByTagName("body")[0].scrollTop = 0;
	}
	
	customer.resize = function()	{

			this.bodySize = rbmWindow.getBodyDimensions(this.bScrollPage);
		
			var mainElement = "mainWrapper";	//mainWrapper
				
			if(this.bodySize.x > this.minBodyWidth)	{
				$(mainElement).style["marginLeft"]=  "10%";
				if(!this.bLimitWidth)	{
					$(mainElement).style["width"]=  "90%";
					$(mainElement).style["marginLeft"]=  "5%";
					$(mainElement).style["marginRight"]=  "5%";
				} 
				else	{
					$(mainElement).style["marginLeft"]=  "10%";
				}
			}
			else	{
				$(mainElement).style["width"]=  "auto";
				$(mainElement).style["overflow"]=  "auto";
				$(mainElement).style["marginLeft"]="20px";
				$(mainElement).style["marginRight"]=  "0px";
			}
			
			if(this.bScrollPage)	{

//xXX: for testing purposes with live switching only: 

				this.resizeArea = this.resizeArea == '' ? document.getElementsByTagName("body")[0] : this.resizeArea;
				var myPage=$(this.resizeArea);
				if(!!myPage && typeof(myPage.resize)=="function")	{	
					myPage.style["overflow"] = "auto";
					myPage.resize(this.bodySize.y);
				}
				else	{	
					myPage.style["overflow"] = "auto";
					myPage.style["height"]= (this.bodySize.y) + "px";
				}

			}
			else	{
				$(mainElement).style["overflow"]=  "hidden";
				$("main").style["overflow"] = "hidden";
				var myPage=$("c_contentArea");
				if(!!myPage && typeof(myPage.resize)=="function")	{	
					myPage.resize(this.h);
				}
				else	{	
					myPage.style["height"]= (this.bodySize.y - this.topHeight - this.bottomHeight - 5) + "px";
	//				myPage.style["width"]= this.bodySize.y + "px";
				}
			}			
			rbmWindow.resizeFader(this.bodySize.y);
	
			rbmWindow.bodyResize();
			
			this.h = this.bodySize.y;	//this is a tribute to older code that still uses this.h 
			
			return this.bodySize;
	}

	
	
	customer.setHistory  = function()	{
	}


	
	customer.initMenus = function()	{
		econtioMenu.initAllMenus("c_unit_" + idUnit);

	}


	customer.selectMenu = function (idMenu, idItem, bDoNotCallPage, bNoHistory)	{
		
		bNoHistory = !!bNoHistory;
		
		if(strPageMode != "ajax")
			return true;						//we are in html mode so we do not have to evaluate the menu

		if(!econtioMenu.menuList["menu_" + idMenu])	{
			return false;
		}


		if(idMenu != "languageMenu" && !bNoHistory)	{
			cms.history.pushHistory("framework_" + idMenu + "_" + idItem, customer.selectMenu.bind(customer, idMenu, idItem, bDoNotCallPage));
			cms.history.setHistory();
		}
		//console.log("selectMenu: menu_" + idMenu + " - " + idItem);
		//returns an array [href, dataType, action, param, id, target]
		aSelectPage = econtioMenu.menuList["menu_" + idMenu].selectMenu(idItem, bDoNotCallPage);

		if(aSelectPage === true)	{
			return true;
		}

		if(idMenu != "languageMenu" && idMenu != "closeMenu")
			this.currentPage = idItem;

		if(!bDoNotCallPage)	{



			
			this.oContent.bRender = false;
			if(!!aSelectPage && typeof(aSelectPage)=="object" && !!aSelectPage[2] && !!aSelectPage[1] && !!cms[aSelectPage[2]])	{
				cms[aSelectPage[2]](aSelectPage[1], (!!aSelectPage[4] ? aSelectPage[4] : 0), (!!aSelectPage[5] ? aSelectPage[5] : customer.contentInner), (!!(aSelectPage[3]) ? aSelectPage[3].replace(/&amp;/gi, "&") : ""), true);
			}
			else	{
//				$("c_contentInner").innerHTML = "<br/>empty<br/>">
				if(c_bLogFlow) console.warn("Unable to complete Menu action! Missing data: aSelectPage:" + aSelectPage);
			}
		}			
		
		if(idMenu == "mainMenu")
			this.scrollPage(0);
		
		return false;				//suppress href in the menu link
	}


/*
	customer.selectMenu = function (idMenu, idItem, bDoNotCallPage)	{
		
		
		if(strPageMode != "ajax")
			return true;						//we are in html mode so we do not have to evaluate the menu

		//console.log("selectMenu: menu_" + idMenu + " - " + idItem);
		//returns an array [href, dataType, action, param, id, target]
		aSelectPage = econtioMenu.menuList["menu_" + idMenu].selectMenu(idItem);

		if(aSelectPage === true)	{
			return true;
		}

		if(idMenu != "languageMenu" && idMenu != "closeMenu")
			this.currentPage = idItem;

		if(!bDoNotCallPage)	{
			
			this.oContent.bRender = false;
			if(!!aSelectPage && typeof(aSelectPage)=="object" && !!aSelectPage[2] && !!aSelectPage[1] && !!cms[aSelectPage[2]])	{
				cms[aSelectPage[2]](aSelectPage[1], (!!aSelectPage[4] ? aSelectPage[4] : 0), (!!aSelectPage[5] ? aSelectPage[5] : customer.contentInner), (!!(aSelectPage[3]) ? aSelectPage[3].replace(/&amp;/gi, "&") : ""), true);
			}
			else	{
//				$("c_contentInner").innerHTML = "<br/>empty<br/>">
				console.warn("Unable to complete Menu action! Missing data: aSelectPage:" + aSelectPage);
			}
		}	

		this.scrollPage(0);
				
		return false;				//suppress href in the menu link
	}
*/	
	customer.scrollPage = function(pos)	{

		pos = !pos ? 0 : pos;

		var m = $("main");
		m.gotoTop = new rbmFX.scrollTo(m, 1, 0, 5);
		m.gotoTop.go();

	}

	customer.selectLanguage = function(mode, newLanguage)	{
		switch(mode)	{
			case "combo":
				newLanguage = $("languageCombo").value;
				break;
			case "flag":
				break;
			default:
				break;
		}
		if(selLanguage != newLanguage)	{
//	this is for in place changing if we have all information in one xml file
			selLanguage = newLanguage;
			var aNodes = oLesson.selectNodes("//data")
			if(aNodes.length == 0)	{
				alert("customer.selLanguage: unit not found!");
				return false;
			}
			aNodes[0].setAttribute("language", newLanguage);

			oLesson.bInitialRendering = true;
			oLesson.renderToDoc();
//			customer.initAfterInitialRendering();

//			selLanguage = newLanguage;
//			cms.showData("framework", 0, "main", "framework=1", true);

		}
	}
	
	
	customer.doLogin = function(sourceForm, target, nAction)	{
		
		nAction = (!nAction) ? 0 : 1;	//0: do login, 1: request password
	
		//after sucessfully logging in the template login[@result='ok'] might do another submit of the userForm to make the session persistent against reloads
	
		this.oContent.bRender = false;
		this.oContent.target = $("c_unit_" + idUnit).getElementById(target);
		this.oContent.done = function()	{	//für Aktionen nach asynchronem Transfer
			rbmWindow3.allBlur();
			var target = this.target;
			oLesson.renderToDoc(target, false, this.oXML);							//render using oLesson-XSL
			
		}
		this.oContent.target = target;
		sourceForm = $("c_unit_" + idUnit).getElementById(sourceForm);
		this.oContent.getXML("p_Login" + this.serverMode + "?lang=" + selLanguage + "&user=" + strUser + "&action=" + nAction, sourceForm, true);
	}
	
	
	
		customer.specialKey = function(keyCode)	{


		var bHandle = false;
	
		if(keyCode == 122)	//F11
		{
			meco.toggleFullscreen();
//			bHandle = true;  			//do not handle fullscreen in a browser!!
		}

		if(keyCode == 120)	//F9
		{
			reloadCSS();
			customer.getDevJSCode('devJSCode.php', 'devJS_Area')
			bHandle = true;
		}

	
		if(keyCode == 119)	//F8
		{
			var hl = $("bgHiLighter")
			if(hl)
				hl.setDisplay(false);
			bHandle = true;
		}

		if(keyCode == 118)	//F7
		{
			if(mainDebug)
				mainDebug.adjustDisplay();
			bHandle = true;
		}

/*
		if(keyCode == 117)	//F6
		{
			if(mecoVariables["VIDEO_RES"] != "75")	{
				if(ePlayer)
					ePlayer.toggleVideoRes();
				bHandle = true;
			}
		}
*/
		
		if(keyCode == 27)	//ESC
		{
			customer.abortAll();
			bHandle = true;
		}

/*
		if(keyCode == 35)	//Ende
		{
			mainDebug.adjustDisplay();
			bHandle = true;
		}
*/
		
		return bHandle;	
	
	}
	
	
	customer.abortAll = function()	{
	
		alert("customer.abortAll");	
	}



	customer.updateXMLCaption = function(dataType, idClip, idMedia)	{
		//XXX to do: use insert XML instead of this function
		
			sXPath = "//clip[@id = '" + idClip + "']/descendant::setCaption";

			aNodeSet = cms.oAjax[dataType].selectNodes(sXPath);
			if(aNodeSet.length > 0)	{
				var myParent = aNodeSet[0].parentNode;
				
				var oCaption = new rbmAjax();
				oCaption.render = false;
				
				oCaption.done = function()	{
					
					if(!!this.oXML)	{	//there was no file
						aNodes = this.selectNodes("//setCaption");
						
						//remove the existing nodes only if we have new ones!!
						if(aNodes.length > 0)	{
							var c = aNodeSet.length;
							while(c > 0)	{
								myParent.removeChild(aNodeSet[--c]);
							}
	
							var oNode;
							for(c = 0; c < aNodes.length; c++)	{
								oNode = aNodes[c].cloneNode(true);
								myParent.appendChild(oNode);
							}
						}
					}
					else	{
						alert(cms.getText("CMS_t_Object_Configuration", selLanguage, "noCaptionFile"));

					}
					
					if(cms.aUpdateSequence.length > 0)
						cms.aUpdateSequence.pop()();
					
					
				}
				oCaption.getXML("100/video/" + idMedia + "/subtitle_" + idMedia + ".xml", null, true);
				
			}
		
	}



	



	customer.makeSWF = function (fileName, objectName, targetID)	{
					
		      var flashvars         =   {};
		      var params            =   {};
		      var attributes        =   {};
		      var defaults          =   {};
		      	
	        params.allowscriptaccess = 'always';
	        params.allowfullscreen   = 'false';
		        

		
	        attributes.name          =  objectName;
	        attributes.id            =  objectName;
		
			oTarget = document.getElementById(targetID);
		
		
		     swfobject.embedSWF(fileName, oTarget, '100%', '100%', '9.0.0', false, flashvars, params, attributes);			
		        
		}




	customer.initTraining = function()	{

		var t = $("c_unit_" + idUnit);
		t = !t ? $("c_page_" + idUnit) : t;	//on previews from CMS_t_ObjectConfiguration we do not have a wrapping unit div!

		if(t.getElementById("def-iframe"))	{
			if(document.addEventListener)	{
				t.addEventListener('mouseup', translatewidgetGetWord, false)
			}
			else	{	
				t.onmouseup=translatewidgetGetWord
			}
		}
	}

		translatewidgetLast=1;
		translatewidgetLastSelection="";
		translatewidgetClickInDef=false;
		
		translatewidgetGetWord = function(e)	{

			var t = $("c_unit_" + idUnit);
			t = !t ? $("c_page_" + idUnit) : t;	//on previews from CMS_t_ObjectConfiguration we do not have a wrapping unit div!


			var myTarget = t.getElementById("def-iframe");
			if(myTarget)	{
				if(window.event)	{
					e=[];
					e.pageX = event.clientX + document.body.scrollLeft;
					e.pageY=event.clientY + document.body.scrollTop
				}
				
				translatewidgetLast=translatewidgetLast+1;
				var a='';
				var b='';
		
				if(window.getSelection)	{
					a=window.getSelection();
					b='window.getSelection()'
				}
				else if(document.getSelection)	{
					a=document.getSelection();
					b='document.getSelection()'
				}
				else if(document.selection)	{
					a=document.selection.createRange().text;
					b='document.selection.createRange()'
				}
				else return;
		
				a=a+"";
	/*			if((a.length<2)||(a.length>45)||("X"+a)==this.translatewidgetLastSelection)	{
					document.getElementById("output-div").style.visibility="hidden";
					return
				};
	*/	
				this.translatewidgetLastSelection="X"+a;
				trackURL='http://syn.dict.cc/dcc-gadget.php';
				var c='s='+encodeURIComponent(a);
				
				t.getElementById("def-iframe").src = trackURL+'?'+c;
		}
	}



	customer.injectPoints = function(myFrame, idObject)	{
		//this injects the points.js into static html practices:
		
		if(myFrame.src.indexOf("swfWrapper") == -1 )	{
			var myDoc = myFrame.contentWindow.document;
			a = myDoc.createElement("script");
			a.setAttribute("type","text/javascript");
			a.setAttribute("src", "../../_js/points.php?id=" + idObject);
	
			myFrame.contentWindow.document.getElementsByTagName("head")[0].appendChild(a);
	
			a = myDoc.createElement("link");
			a.setAttribute("type","text/css");
			a.setAttribute("rel","stylesheet");
			a.setAttribute("href", "../../_css/htmlPractice.css");
	
			myFrame.contentWindow.document.getElementsByTagName("head")[0].appendChild(a);

		}		
	
	}


	customer.transferResult = function(idObject, points, maxPoints, target)	{
		alert(points);
		cms.storeData("t_ClientCompetence", 0, target, '', true, true, null, null, "points=" + points + "&idobject=" + idObject + "&mpoints=" + maxPoints)	
	}





	customer.checkInputCharacters = function(myInput)	{
	
		var cursorPosStart = myInput.selectionStart;
		var cursorPosEnd = myInput.selectionEnd;
		var myRE = new RegExp("\'", "g");
		if(myRE.test(myInput.value))	{
			myInput.value = myInput.value.replace(myRE, "’");
			myInput.selectionStart = cursorPosStart;
			myInput.selectionEnd = cursorPosEnd;
			myInput.scrollIntoView(false);
		}
		
	/*
		myInput.value = myInput.value.replace(/\\\\'/g, "\\'");
		myInput.value = myInput.value.replace(/“/g, "\\\"");
		myInput.value = myInput.value.replace(/”/g, "\\\"");
		myInput.value = myInput.value.replace(/\„/g, "b");
	*/
	}
	
	
	customer.skipBack = function(ePlayer)	{
		
		console.log(ePlayer.timeLine.eventCounter);
		var ec = ePlayer.timeLine.eventCounter - 2;
		if(!!ePlayer.timeLine.oEventList[ec])	{
			console.log(ePlayer.timeLine.oEventList[ec].tc);
			ePlayer.setTC(ePlayer.timeLine.oEventList[ec].tc, -1);
		}
	};


	customer.skipForward = function(ePlayer)	{
		console.log(ePlayer.timeLine.eventCounter);
		var ec = ePlayer.timeLine.eventCounter + 1;
		if(!!ePlayer.timeLine.oEventList[ec])	{
			console.log(ePlayer.timeLine.oEventList[ec].tc);
			ePlayer.setTC(ePlayer.timeLine.oEventList[ec].tc, -1);
		}
	};	
	
	customer.toggleFullScreen = function()		{
		var t = $("c_unit_" + idUnit);
		if(!!t)	{	//no unit = no fullscreen
			var maintemplate = t.getElementById("maintemplate");
			if(maintemplate.className.indexOf("fullscreen") == -1)	{
				maintemplate.className += " fullscreen" + customer.fullscreenMode;
			}
			else	{
				strR = "fullscreen" + customer.fullscreenMode;
				var r = new RegExp(strR, "g");
				maintemplate.className = maintemplate.className.replace(r, "");
			}
		}
		
	}


	customer.handleSmallScreen = function()	{
//		alert("handleSmallScreen(): " + rbmWindow.bodyDimensions + "\nScreen-Höhe: " + mecoVariables["SCREEN_HEIGHT"]);
		if(rbmWindow.bodyDimensions.y < 740)	{
			if(mecoVariables["SCREEN_HEIGHT"] > 910)	{	
				alert(cms.getText("_general", selLanguage, "adjustWindow"));
				customer.fullscreenMode = "";
			}
			else {
				alert(cms.getText("_general", selLanguage, "adjustFullscreen"));
				customer.fullscreenMode = "768";
			}
		}
	}

	customer.adjustFullscreen = function()	{
		//if we start a template in fullscreen we should adjust the fullscreen to the reduced mode if there is
		//a cusomer.fullscreenMode set:
		var t = $("c_unit_" + idUnit);
		if(!!t)	{	//no unit = no fullscreen
			var maintemplate = t.getElementById("maintemplate");
			if(maintemplate.className.indexOf("fullscreen") != -1 && customer.fullscreenMode != "")	{
				strR = "fullscreen"; 
				var r = new RegExp(strR, "g");
				maintemplate.className = maintemplate.className.replace(r, "fullscreen" + customer.fullscreenMode);
			}
		}
	}


	customer.setSubtitleSpeaker = function(dataType, target, speaker, even_odd)	{
	
//		console.log(dataType + " - " + target);
		
		target = $(target);
		

		aNodeSet = cms.oAjax[dataType].selectNodes("//setCaption[count(preceding-sibling::*) mod 2 = " + even_odd + "]");
		var l = aNodeSet.length;
		for(var i = 0; i < l; i++)	{
			aNodeSet[i].setAttribute("speaker", speaker);
		}
		//console.dirxml(cms.oAjax[dataType].oXML);

		cms.oAjax[dataType].renderToDoc();
		
	}
	
	
	customer.shiftSubtitleSpeaker = function(dataType, target, id)	{
	
		target = $(target);

		aNodeSet = cms.oAjax[dataType].selectNodes("//setCaption[@ID >= " + id + "]");
		var l = aNodeSet.length;
		var lastSpeaker = "";
		var speaker;
			for(var i = 0; i < l; i++)	{
				speaker = aNodeSet[i].getAttribute("speaker");
				aNodeSet[i].setAttribute("speaker", lastSpeaker);
				lastSpeaker = speaker;
			}

		//console.dirxml(cms.oAjax[dataType].oXML);

		cms.oAjax[dataType].renderToDoc();
		
	}



	if(typeof(playerPanel) != "undefined")	{
		playerPanel["linguaTVTrainingBottom"] = playerPanel["simpleTrainingBottom"];
	}


	customer.trackAjax = function(dataType, strAction, id)	{
		if(dataType.substr(0, 3) != "CMS" && dataType.substr(0, 2) != "t_")	{
//			try	{
				if(typeof(pageTracker) == "object") 	{
					pageTracker._trackPageview(dataType + "/" + strAction + "/" + id);	
				}
//			}
//			catch(e)	{}
		}
		
	}

