M.mod_scormform={};M.mod_scormform.init=function(Y){var scormform=Y.one('#scormviewform');var cwidth=scormplayerdata.cwidth;var cheight=scormplayerdata.cheight;var poptions=scormplayerdata.popupoptions;var launch=scormplayerdata.launch;var currentorg=scormplayerdata.currentorg;var sco=scormplayerdata.sco;var scorm=scormplayerdata.scorm;var launch_url=M.cfg.wwwroot+"/mod/scorm/player.php?a="+scorm+"¤torg="+currentorg+"&scoid="+sco+"&sesskey="+M.cfg.sesskey+"&display=popup";var course_url=scormplayerdata.courseurl;var winobj=null;poptions=poptions+',resizable=yes';if((cwidth==100)&&(cheight==100)){poptions=poptions+',width='+screen.availWidth+',height='+screen.availHeight+',left=0,top=0'}else{if(cwidth<=100){cwidth=Math.round(screen.availWidth*cwidth/100)} if(cheight<=100){cheight=Math.round(screen.availHeight*cheight/100)} poptions=poptions+',width='+cwidth+',height='+cheight} var scormload=function(){if(scormform){scormform.hide()} var scormtoc=Y.one('#toc');if(scormtoc){scormtoc.hide()} var scormintro=Y.one('#intro');scormintro.setHTML(''+M.util.get_string('popuplaunched','scorm')+'')} var scormunload=function(){setTimeout(function(){if(winobj.closed){window.location=course_url}},800)} var scormredirect=function(winobj){Y.on('load',scormload,winobj);Y.on('unload',scormunload,winobj);setTimeout(function(){if(!winobj){var scormintro=Y.one('#intro');scormintro.setHTML(M.util.get_string('popupsblocked','scorm'))}},800)} var setlaunchoptions=function(){var mode=Y.one('#scormviewform input[name=mode]:checked');if(mode){var modevalue=mode.get('value');launch_url+='&mode='+(modevalue?modevalue:'normal')}else{launch_url+='&mode=normal'} var newattempt=Y.one('#scormviewform #a');launch_url+=(newattempt&&newattempt.get('checked')?'&newattempt=on':'')} if(launch==!0){setlaunchoptions();winobj=window.open(launch_url,'Popup',poptions);this.target='Popup';scormredirect(winobj);winobj.opener=null} if(scormform){Y.on('submit',function(e){setlaunchoptions();winobj=window.open(launch_url,'Popup',poptions);this.target='Popup';scormredirect(winobj);winobj.opener=null;e.preventDefault()},scormform)}}