var thisTraining=new Object();var econtioTraining=new Object();econtioTraining.unitStack=new Array();econtioTraining.initTraining=function(){var a=$("c_unit_"+idUnit);a=!a?$("c_page_"+idUnit):a;if(!!a){aE=a.getElementsByClassName("timelineClassic");for(i=0;i<aE.length;i++){thisTraining[idUnit]=new econtioTraining[aE[i].className](aE[i]);thisTraining[idUnit].init();}}if(!!customer.initTraining){customer.initTraining();}};econtioTraining.sendCommandToAllPlayers=function(f,g,a,c){c=idUnit;debuglog("sendCommandToAllPlayers: "+f+"("+g+")"+(a?"/remove":"")+"{");var b="//player[ancestor::lesson[@id= '"+idLesson+"']]";aSelection=cms.oAjax[c].selectNodes(b);for(var d=0;d<aSelection.length;d++){var e=aSelection[d].getAttribute("id")+"_"+idLesson;debuglog(e);if(!!ePlayerList[e]&&!!ePlayerList[e].p){if(a){debuglog("removing "+e+"...");ePlayerList[e].destroy();delete ePlayerList[e];}else{ePlayerList[e].sendPlayerCommand(f,g);}}else{debuglog(e+" does not exist!");}debuglog("}");}};econtioTraining.sendPlayerCommand=function(a,b,c){debuglog("sendPlayerCommand: "+a+", "+b);for(pl in ePlayerList){if(pl!=a&&!!ePlayerList[pl]&&ePlayerList[pl].playStateCode==3&&b=="SETTC"){ePlayerList[pl].pause();}}if(!!ePlayerList[a]){ePlayerList[a].sendPlayerCommand(b,c);}};econtioTraining.timelineJump=function(a,b,c){this.sendCommandToAllPlayers("PAUSE","",false);this.sendPlayerCommand(a,b,c);this.renderContent("","_overlayVideo","","off");};econtioTraining.enableOverlayVideoElement=function(c,b){var a=$("c_page_"+idUnit).getElementById("c_overlayVideo");if(!!a){if(!c||b=="off"){$fx(a).setDisplay(false);return;}else{var d=$fx("playerContainer_"+b+"_"+idLesson);$fx(a).move(Coordinates.northwestOffset(d,true));a.setDisplay(true);a.setSize(d.offsetWidth,d.offsetHeight);}}return a;};econtioTraining.renderContent=function(c,f,d,e,b,a,h){f="c"+f;if(f=="c_overlayVideo"){f=econtioTraining.enableOverlayVideoElement(e!="off");if(!f){return false;}}else{f=$("c_page_"+idUnit).getElementById(f);}if(c!="self"){debuglog("rendering "+c+" to "+f);var g=new rbmAjax(d.substr(0,3)=="xml");g.target=f;g.done=function(){rbmWindow3.init(this.target);};g.getXML(c,null,true);}else{cms.oAjax[b].target=f;h=econtioTraining.fillinXPathPlaceholders(h);cms.oAjax[b].query(h,a);}};econtioTraining.fillinXPathPlaceholders=function(a){a=a.replace(/%idLesson%/g,""+idLesson);return a;};econtioTraining.removeLessonHTML=function(a){p=$("c_unit_"+a);if(!!p&&!!p.onEnd){p.onEnd();}rbmXML.clearTarget(p.parentNode,true);};econtioTraining.gotoLevel=function(c,b){rnd="_"+(""+Math.random()).substr(3,6);cms.history.pushHistory(b+rnd,econtioTraining.gotoLevel.bind(econtioTraining,idLesson,b));cms.history.pushHistory(b+rnd,econtioTraining.gotoLevel.bind(econtioTraining,c,b));b=!b?"framework":b;debuglog("gotoLevel "+c);this.renderContent("","_overlayVideo","","off");this.sendCommandToAllPlayers("STOP","",true,b);var a="//lesson[@id = '"+idLesson+"']";aSelection=cms.oAjax[b].selectNodes(a);if(aSelection.length==0){alert("gotoLevel: current Lesson not found: //lesson[@id = '"+idLesson+"']");return;}aSelection[0].setAttribute("selected","0");var a="//lesson[@id = '"+c+"']";aSelection=cms.oAjax[b].selectNodes(a);if(aSelection.length==0){alert("gotoLevel: target Lesson not found: //lesson[@id = '"+c+"']");return false;}aSelection[0].setAttribute("selected","1");var d=$("c_unit_"+idUnit);if(!d){d=$("c_page_"+idUnit);}cms.oAjax[b].renderToDoc(d,false);cms.oAjax.framework.onRenderingCompleted(null,true);cms.history.setHistory(0,"l=1&a=2&at=2&ac=21&c="+idUnit.substr(idUnit.indexOf("_")+1)+"&ct="+aSelection[0].getAttribute("IDObjectType"));};econtioTraining.addUnit=function(a,c,d,f,b,e){cms.createAjax(a,c_Customer+"/xsl/lesson.xsl");rnd="_"+(""+Math.random()).substr(3,6);cms.history.pushHistory(a+rnd,customer.selectMenu.bind(customer,"closeMenu","close"));cms.history.pushHistory(a+rnd,econtioTraining.addUnit.bind(econtioTraining,a,c,d,f,b,e));e=!e?"":e;f=!f?0:f;b=!b?0:b;customer.handleSmallScreen();d=!d?"mainWrapper":d;debuglog("addLesson "+a);this.sendCommandToAllPlayers("PAUSE","",false);cms.oAjax[a].render=false;cms.oAjax[a].target=d;cms.oAjax[a].bappend=true;cms.oAjax[a].done=function(){var h="//lesson[@id = '"+idLesson+"']";var k=cms.oAjax.framework.selectNodes(h);if(k.length==0){alert("gotoLevel: current Lesson not found: //lesson[@id = '"+idLesson+"']");return;}var g=k[0];k[0].setAttribute("selected","0");k=this.selectNodes("//unit");if(k.length==0){alert("addUnit: Unit source not found: //unit");return false;}var l=k[0];l.setAttribute("init","1");l.setAttribute("bodyY",rbmWindow.bodyDimensions.y);k=this.selectNodes("//lesson[1]");if(k.length==0){alert("addLesson: Lesson source not found: //lesson");return false;}k[0].setAttribute("selected","1");k=this.selectNodes("//data");if(k.length==0){alert("addLesson: data element not found");return false;}var m=k[0].cloneNode(true);g.appendChild(m);this.oXML=cms.oAjax.framework.oXML;this.renderToDoc();cms.oAjax.framework.onRenderingCompleted(null,true);customer.adjustFullscreen();if(this.setHistory){alert("setHistory is true!!");cms.history.setHistory();this.setHistory=false;}var j=0;k=this.selectNodes("//configure");if(k.length!=0){j=k[0].getAttribute("IDObjectType");}cms.userLog.add("l=1&a=2&at=1&ac=21&c="+f+"&ct="+j);};cms.oAjax[a].getXML(cms.dispatcher+"?mode=ajax&lang="+selLanguage+"&action="+cms.c_Show+"&id="+f+"&page="+a+"&user="+strUser+(!e?"":"&"+e)+(!b?"":"&did="+b),null,true);};econtioTraining.scrollUnit=function(a,b){b=(!b||b==0)?1200:b;var c=$("c_unit_"+a);if(!!c){c.fx=new rbmFX.shiftV(c,-1,b,2,null,null,-b);c.fx.onEnd=function(){if(!cms.oAjax[a]){cms.oAjax[a]=cms.oAjax.p_DemoLesson;}var d="//unit[@init = 1]";aSelection=cms.oAjax[a].selectNodes(d);if(aSelection.length==0){alert("shiftUnit: unit init reset failed");return false;}aSelection[0].setAttribute("init","0");};c.fx.go(1);}};econtioTraining.popUnit=function(){if(econtioTraining.unitStack.length>0){cms.userLog.add("l=1&a=2&at=0&ac=21&c="+idUnit.substr(idUnit.indexOf("_")+1)+"&ct=0");var a=econtioTraining.unitStack.pop();idUnit=a[0];idLesson=a[1];lessonPath=a[2];if(typeof(a[3])=="function"){a[3]();}}};econtioTraining.returnFromSubUnit=function(){debuglog("returning from sublesson "+idLesson);this.sendCommandToAllPlayers("STOP","",true);if(this.unitStack.length>0){p=$("c_unit_"+idUnit);if(!!p){p.idUnit=idUnit;econtioTraining.popUnit();p.fx.onEnd=function(){econtioTraining.removeLessonHTML(this.parent.idUnit);aNodes=cms.oAjax.framework.selectNodes("//data[@dataType='"+this.parent.idUnit+"']");if(aNodes.length>0){aNodes[0].parentNode.removeChild(aNodes[0]);}else{alert("returnFromSubUnit: unable to remove XML for unit "+this.parent.idUnit);}};p.fx.start=0;p.fx.go(-1);}}else{alert("returnFromSubLesson: End of Training!");}};function restartPractice(){if(!!customer.practice&&!!cms.oAjax.f_Object){cms.oAjax.f_Object.rebuildClone("//framework","dummy","c_page_f_Object_"+customer.practice.idObject,"//data","//rbmWindow");}}econtioPractice=function(a,b){this.idObject=a;this.totalPoints=b;this.questionCollection=new Object();this.getPoints=function(){var c=0;for(q in this.questionCollection){c+=this.questionCollection[q].resultPoints;}return c;};this.transferResult=function(c){customer.transferResult(this.idObject,this.getPoints(),this.totalPoints,c);};};questionType=new Object();answerType=new Object();questionType.multipleChoice=function(b,d,c,a){this.questionType="multipleChoice";this.totalPoints=parseInt(b);this.resultPoints=0;this.bAllowNegativePoints=(a==1)?true:false;this.bDone=false;this.maxAnswers=parseInt(d);this.answerCounter=0;this.answerCollection=[];this.bAutoComplete=!!c;this.calcPoints=function(e){this.resultPoints+=e;};this.limitPoints=function(){var e=this.resultPoints;if(e>this.totalPoints){e=this.totalPoints;}if(e<0&&!this.bAllowNegativePoints){e=0;}this.resultPoints=e;};this.checkAnswer=function(e){this.bDone=true;for(var f=0;f<this.answerCollection.length;f++){this.calcPoints(this.answerCollection[f].getPoints(this));this.displayResult($("MCAnswer"+e+"_"+f),f,e);}this.limitPoints();$fx("practiceSolve"+e).setDisplay(false);$fx("practiceNext"+e).setDisplay(true);};this.displayResult=function(f,g,e){iconSRC=f.style.backgroundImage;f.style.backgroundImage=iconSRC.replace(/answerX/g,"answer"+(this.answerCollection[g].checkAnswer()?0:1));};this.setAnswer=function(g,h,e,f){if(!this.bDone){this.answerCounter++;this.answerCollection[h].isAnswer=!this.answerCollection[h].isAnswer;if(this.answerCollection[h].isAnswer){$fx(g).addClass("MCAnswerSelected");}else{$fx(g).removeClass("MCAnswerSelected");}if(this.maxAnswers==this.answerCounter&&this.bAutoComplete){this.checkAnswer(f);}}};this.onQuestionResult=function(e){};};answerType.multipleChoice=function(c,b,a){this.answerType="multipleChoice";this.nr=c;this.points=parseInt(b);this.aValues=a;this.isAnswer=false;this.checkAnswer=function(d){return(this.aValues[0]==1);};this.getPoints=function(d){return(this.isAnswer)?this.points:0;};};questionType.gaps=function(b,d,c,a){this.element=null;this.questionType="multipleChoice";this.totalPoints=parseInt(b);this.resultPoints=0;this.bAllowNegativePoints=(a==1)?true:false;this.bDone=false;this.maxAnswers=parseInt(d);this.answerCounter=0;this.answerCollection=[];this.bAutoComplete=!!c;this.bAltGr=false;this.bShift=false;this.specialKeys=new Object();this.calcPoints=function(e){this.resultPoints+=e;};this.limitPoints=function(){var e=this.resultPoints;if(e>this.totalPoints){e=this.totalPoints;}if(e<0&&!this.bAllowNegativePoints){e=0;}this.resultPoints=e;};this.checkAnswer=function(g,e){e=!!e;var f=true;for(var j=0;j<this.answerCollection.length;j++){if(e){var h=$("GapsAnswer"+g+"_"+j);this.setAnswer(h,j,h.getElementsByTagName("input")[0].value,g,true,e);}this.calcPoints(this.answerCollection[j].getPoints(this));f=f&&this.answerCollection[j].bDone;}this.limitPoints();this.bDone=f;if(this.bDone){$fx("practiceSolve"+g).setDisplay(false);}$fx("practiceNext"+g).setDisplay(true);};this.displayResult=function(g,h,f,e){this.element=g;var j=e?0:1;g.style.backgroundImage=g.style.backgroundImage.replace(/answerX/g,"answer"+j);g.style.backgroundImage=g.style.backgroundImage.replace(/answer1/g,"answer"+j);};this.setAnswer=function(j,k,g,h,l,f){this.element=j;g=g.trim();if(!this.bDone&&!this.answerCollection[k].bDone&&(g.length>0||l)){inputElement=j.getElementsByTagName("input")[0];var e;if((e=this.answerCollection[k].checkAnswer(this,g,f))||this.answerCollection[k].bDone){this.answerCounter++;inputElement.disabled="disabled";$fx(j.getElementsByTagName("img")[0]).show(false);}this.displayResult(j,k,h,e);if(this.maxAnswers==this.answerCounter&&this.bAutoComplete){this.checkAnswer(h);}}};this.keyUp=function(h,f,g){var e=h.keyCode;switch(e){case 16:this.bShift=false;break;case 17:this.bAltGr=false;break;default:break;}return false;};this.keyDown=function(h,f,g){var e=h.keyCode;switch(e){case 16:this.bShift=true;break;case 17:this.bAltGr=true;break;default:e=!this.bShift?e+32:e;if(this.bAltGr){if(!!this.specialKeys[String.fromCharCode(e)]){f.value+=this.specialKeys[String.fromCharCode(e)];}}break;}return false;};this.onQuestionResult=function(e){};};answerType.gaps=function(c,b,a){this.answerType="multipleChoice";this.nr=c;this.userResult="";this.points=parseInt(b);this.aValues=a;this.isAnswer=false;this.bDone=false;this.answerCounter=0;this.maxTrials=0;this.checkAnswer=function(h,e,d){d=!!d;this.answerCounter++;if(!!e){this.userResult=e;}for(var f=0;f<this.aValues.length;f++){if(this.aValues[f]==this.userResult){this.isAnswer=true;}}if(!this.isAnswer){this.points=Math.round(this.points/2,0);if((this.maxTrials>0&&this.answerCounter>=this.maxTrials)||d){this.bDone=true;}}else{this.bDone=true;}var g=$(h.element).getElementById("gapsHint");if(!this.isAnswer&&this.hintCharacters>0&&!this.bDone){g.innerHTML="&#160;("+this.aValues[0].substr(0,this.hintCharacters*this.answerCounter)+((this.bDone=this.hintCharacters*this.answerCounter>=this.aValues[0].length)?"":"...")+")&#160;";}if(this.isAnswer){g.innerHTML="";}else{if(this.bDone){g.innerHTML="&#160;("+this.aValues[0]+")&#160;";}}return this.isAnswer;};this.getPoints=function(d){return(this.isAnswer)?this.points:0;};};econtioTraining.timelineClassic=function(a){this.me=a;this.myCountainer=null;this.type="timelineClassic";this.idCurrentSection=null;this.init=function(){myContainer=this.me.getElementById("timelineContainer");this.myContainer=myContainer;myContainer.parent=this.me;myContainer.eTraining=this;myContainer.selectSection=function(f){this.eTraining.idCurrentSection=f;var d=f.split("_");var e=d[d.length-1];this.fx.newPosition=e;this.fx.onEnd=function(){var g=this.parent.getElementsByClassName("section");for(i=0;i<g.length;i++){if(g[i].sel==1){g[i].sel=0;g[i].firstChild.className="timelineClassicSection0";g[i].getElementByClassName("timelineClassicSubSection1").className="timelineClassicSubSection0";g[i].style.backgroundImage=rbmWindow.replacePicName(g[i].style.backgroundImage,"bg_Timeline0");}if(i==this.newPosition){g[i].sel=1;g[i].firstChild.className="timelineClassicSection1";g[i].getElementByClassName("timelineClassicSubSection0").className="timelineClassicSubSection1";g[i].style.backgroundImage=rbmWindow.replacePicName(g[i].style.backgroundImage,"bg_Timeline1");}}this.bounding();this.onEnd=function(){this.bounding();};};if(e>-1*this.fx.position+1){this.nextButton.onclick();}else{if(e<-1*this.fx.position+1){this.prevButton.onclick();}else{this.fx.onEnd();}}};this.selectSection=function(d){this.myContainer.selectSection(d);};var c=myContainer.getElementsByClassName("section");myContainer.style.marginLeft="0px";if(c.length>1){this.idCurrentSection=c[1].id;sl=myContainer;sl.position=0;if(typeof(sl.fx)=="undefined"){sl.fx=new rbmFX.shift(sl,-1);myContainer.nextButton=this.me.getElementById("timelineNext");if(!!myContainer.nextButton){myContainer.nextButton.onclick=sl.fx.go.bind(sl.fx,-1);}myContainer.prevButton=this.me.getElementById("timelinePrev");if(!!myContainer.prevButton){myContainer.prevButton.onclick=sl.fx.go.bind(sl.fx,1);}sl.fx.onRightBorder=function(){$fx(myContainer.prevButton.firstChild).setOpacity(100);$fx(myContainer.nextButton.firstChild).setOpacity(50);};sl.fx.onLeftBorder=function(){$fx(myContainer.prevButton.firstChild).setOpacity(50);$fx(myContainer.nextButton.firstChild).setOpacity(100);};sl.fx.onMiddle=function(){$fx(myContainer.prevButton.firstChild).setOpacity(100);$fx(myContainer.nextButton.firstChild).setOpacity(100);};}sl.fx.elementCount=c.length-1;sl.fx.margin=(myContainer.position*200);sl.fx.delta=200;sl.fx.start=sl.fx.margin;sl.fx.d=-1;sl.fx.bounding();}this.me.getElementsByClassName("timelineClassicSection1")[0].parentNode.sel=1;var b=this.me.getElementsByClassName("section");for(i=0;i<b.length;i++){b[i].myContainer=myContainer;b[i].firstChild.onclick=function(){if(this.parentNode.sel!=1){this.parentNode.myContainer.selectSection(this.parentNode.id);var d=this.parentNode.id.split("_");$(this).getElementById("timelineClassicSectionLink_"+d[1]+"_"+d[2]).onclick();}};}};this.gotoNextSection=function(){var b=this.idCurrentSection.replace(/section_/g,"");aNodes=cms.oAjax.framework.selectNodes("//lesson[@id='"+idLesson+"']/descendant::section[@id='"+b+"']/following-sibling::section[1]");if(aNodes.length>0){this.selectSection("section_"+aNodes[0].getAttribute("id"));this.myContainer.getElementById("timelineClassicSectionLink_"+aNodes[0].getAttribute("id")).onclick();}};this.gotoPrevSection=function(){var b=this.idCurrentSection.replace(/section_/g,"");aNodes=cms.oAjax.framework.selectNodes("//lesson[@id='"+idLesson+"']/descendant::section[@id='"+b+"']/preceding-sibling::section[1]");if(aNodes.length>0){this.selectSection("section_"+aNodes[0].getAttribute("id"));this.myContainer.getElementById("timelineClassicSectionLink_"+aNodes[0].getAttribute("id")).onclick();}};};function dispatcher(e){debuglog("dispatcher: "+e);var b=new Object();var d=e.split(";");for(var c=1;c<d.length;c++){var a=d[c].split("=");b[a[0].toUpperCase()]=a[1];}switch(d[0].toUpperCase()){case"GOTOLEVEL":alert("gotolevel has changed!");parent.customer.levelSelect(b.LEVELID,b.LEVEL);break;case"ONSTART":console.log(b.FILE);var a=$("flashContainer_"+b.FILE);$fx(a.getElementById("progressbar")).setDisplay(false);a.style.width="100%";a.style.height="100%";document.getElementById("flash_"+b.FILE).parentNode.parentNode.onStart();break;}}function makeSWF(g,f,c){var a={};var e={};var b={};var d={};e.allowscriptaccess="always";e.allowfullscreen="false";b.name=f;b.id=f;oTarget=document.getElementById(c);swfobject.embedSWF(g,oTarget,"100%","100%","9.0.0",false,a,e,b);}
