var kInteractive={preRender:function(e,t){var n,a=(t=t||{}).singleElem,i=e||document;a?(n=[e],i=document):n=i.getElementsByClassName("kInteractive"),"undefined"!=typeof isKotobee&&(kInteractive.absoluteURL=t.chapterUrl?t.chapterUrl:angular.element(document.body).scope().data.book.chapter.absoluteURL);for(var r=n.length;r--;){var o=n[r];this.hasClass(o,"gallery")&&kInteractive.gallery.preRender(o,i,r),this.hasClass(o,"questions")&&kInteractive.questions.preRender(o,i,r),!this.hasClass(o,"image")&&"img"!=o.nodeName.toLowerCase()||kInteractive.image.preRender(o,i,r),this.hasClass(o,"link")&&kInteractive.link.preRender(o,i,r),this.hasClass(o,"container")&&kInteractive.container.preRender(o,i,r)}},postRender:function(t,e){var n=(e=e||{}).singleElem;"undefined"!=typeof isKotobee&&(kInteractive.absoluteURL=e.chapterUrl?e.chapterUrl:angular.element(document.body).scope().data.book.chapter.absoluteURL),kInteractive.videoIsFullscreen=!1,kInteractive.timestamp=new Date,kInteractive.currentVideo=kInteractive.currentAudio=null,kInteractive.clearAudioVideo(t);var a,i=t||document;n?(a=[t],i=document):a=i.getElementsByClassName("kInteractive");for(var r=a.length;r--;){var o=a[r];this.hasClass(o,"container")?kInteractive.container.postRender(i,o,r,e):this.hasClass(o,"questions")?kInteractive.questions.postRender(i,o,r,e):this.hasClass(o,"widget")?kInteractive.widget.postRender(i,o,r,e):this.hasClass(o,"video")?kInteractive.video.postRender(i,o,r):this.hasClass(o,"audio")?kInteractive.audio.postRender(i,o,r):this.hasClass(o,"threed")?kInteractive.threed.postRender(i,o,r,e):this.hasClass(o,"gallery")?kInteractive.gallery.postRender(i,o,r):this.hasClass(o,"image")&&kInteractive.image.postRender(i,o,r)}this.firstRun&&(window.addEventListener("resize",function(e){kInteractive.resizeEvent(t,n)}),this.firstRun=!1),kInteractive.resizeEvent(t,n)},actionEvent:function(e){kInteractive.action(e.target)},action:function(e,t){if("undefined"==typeof editorMode||!editorMode){"undefined"!=typeof isKotobee&&(kInteractive.absoluteURL=angular.element(document.body).scope().data.book.chapter.absoluteURL);for(var n=e;!this.hasClass(n,"kInteractive");){if(!n.parentNode)return;if((n=n.parentNode)==document.body)return}this.hasClass(n,"questions")?kInteractive.questions.action(n,e):this.hasClass(n,"widget")?kInteractive.widget.action(n):this.hasClass(e,"link")?kInteractive.link.action(n,e):this.hasClass(e,"image")?kInteractive.image.action(n,e):this.hasClass(n,"gallery")?kInteractive.gallery.action(n,e):this.hasClass(n,"audio")?kInteractive.audio.action(n,e):this.hasClass(n,"video")?kInteractive.video.action(n,e):this.hasClass(n,"threed")&&kInteractive.threed.action(n,e)}},trigger:function(e,t){this.action(t,e)},resizeEvent:function(e,t){var n=e||document;t&&(n=document);for(var a=n.getElementsByClassName("kInteractive"),i=a.length;i--;){var r=a[i];this.hasClass(r,"image")?kInteractive.image.resize(r):this.hasClass(r,"gallery")?kInteractive.gallery.resize(r):this.hasClass(r,"container")?kInteractive.container.resize(r):this.hasClass(r,"video")?kInteractive.video.resize(r):this.hasClass(r,"widget")&&kInteractive.widget.resize(r)}},vQueue:[],youTubeReady:!1,firstRun:!0};if("undefined"==typeof isKotobee){kotobee={};var kotobeeListeners=[];function getKotobeeListener(e){if(e)for(var t=kotobeeListeners.length;t--;)if(kotobeeListeners[t].event==e)return kotobeeListeners[t]}function clearKotobeeListeners(e){for(var t=kotobeeListeners.length;t--;)e&&kotobeeListeners[t].event!=e||kotobeeListeners.splice(t,1)}function dispatchKotobeeEvent(){}function kInteractionStart(){this.log=function(e){},kInteractive.setDOMParser(),kInteractive.preRender(),kInteractive.postRender()}function kInteractionStartSingleElem(e){kInteractive.setDOMParser(),kInteractive.preRender(e,{singleElem:!0}),kInteractive.postRender(e,{singleElem:!0})}document.addEventListener("DOMContentLoaded",function(e){"undefined"!=typeof kotobeeReady&&kotobeeReady(e),document.dispatchEvent(new Event("kotobeeReady")),document.dispatchEvent(new Event("kotobeeChapterLoaded")),kotobee.dispatchEvent("ready"),kotobee.dispatchEvent("chapterLoaded"),document.addEventListener("scroll",function(e){kotobee.dispatchEvent("scrolled",e)})}),kotobee.addEventListener=function(){if(!(arguments.length<2)){var e,t=arguments[0],n={};e=2==arguments.length?arguments[1]:(n=arguments[1],arguments[2]),n.unique&&clearKotobeeListeners(t);var a={event:t,cb:e};kotobeeListeners.push(a)}},kotobee.dispatchEvent=function(e,t){if(e){var n=getKotobeeListener(e);n&&n.cb&&n.cb.apply(this,[t])}};try{document.addEventListener("DOMContentLoaded",kInteractionStart,!1)}catch(e){window.addEventListener("load",kInteractionStart,!1)}}kInteractive.audio={preRender:function(e,t){},postRender:function(e,t,n){var a=e.createDocumentFragment(),i=kInteractive.readData(t);t.setAttribute("id","ki-audio-"+n),t.innerHTML="";var r=document.createElement("div");r.setAttribute("id","ki-audio-"+n+"-container"),r.className="container";var o=document.createElement("a");o.className="playBtn ki-btn",o.appendChild(document.createElement("span")),"undefined"==typeof isKotobee&&o.addEventListener("click",kInteractive.actionEvent);var s=document.createElement("div");i.style&&kInteractive.c.addClass(s,i.style),a.appendChild(o),a.appendChild(r),s.appendChild(a),t.appendChild(s)},action:function(e){kInteractive.stopCurrentMedia();var t=kInteractive.readData(e);if(t){t.audioType||(t.audioType=t.type);e.getAttribute("id");e.getElementsByClassName("playBtn")[0].className="playBtn ki-btn hide";var n=t.src;if("file"==t.audioType&&(n="undefined"==typeof isKotobee?t.audio:t.relToRoot?ph.join(bookPath,t.audio):ph.join(kInteractive.absoluteURL,t.audio)),kInteractive.scorm){var a={};a.id=kInteractive.getScormId(e.getAttribute("id"),n),a.description="Played audio: "+n,a.type="other",a.learnerResponses="Played",a.objective=t.options?t.options.objective:null,a.timestamp=new Date,kInteractive.scorm.setInteractions([a])}var i=document.createElement("audio");i.setAttribute("controls","true"),i.setAttribute("autoplay","true"),i.setAttribute("data-tap-disabled","false");var r=document.createElement("source");r.src=n,i.appendChild(r),i.appendChild(document.createTextNode("Your browser does not support the audio element")),i.className="ki-noHighlight",i.oncanplay=function(){kInteractive.currentAudio==e&&kInteractive.tinCan({verb:"played",activity:"Audio: "+n})},e.getElementsByClassName("container")[0].appendChild(i),i.play(),kInteractive.currentAudio=e,kInteractive.c.addClass(kInteractive.currentAudio,"playing")}}};var log=console.log,kInteractiveCommon={checkResponsiveFloat:function(e,t){if(e&&e.disableWrapForMobile&&"none"!=e.float){var n=t.parentNode;t.offsetWidth>.6*n.offsetWidth&&.4*(n.offsetWidth-t.offsetWidth)<100?kInteractive.c.addClass(t,"fullRow"):kInteractive.c.removeClass(t,"fullRow")}},openFrame:function(u){var m=document.getElementById("kInteractiveFrame"),p=document.getElementById("kiDarkOverlay"),v="";if(u.dict||(u.dict={}),u.width&&(v+="width:"+u.width+"px;max-width:"+u.width+"px;"),u.height&&(v+="height:"+u.height+"px;max-height:"+u.height+"px;"),m||((p=document.createElement("div")).id="kiDarkOverlay",document.body.appendChild(p),p.style.display="none",p.style.position="fixed",p.addEventListener("click",kInteractive.closeFrame),(m=document.createElement("div")).id="kInteractiveFrame"),u.pos||(u.pos="top"),"none"!=u.pos){var e=document.createElement("a"),t="closeBtn";u.pos&&(t+=" "+u.pos),e.className=t;var n=u.dict.close?u.dict.close:"Close";try{n=angular.element(document.body).scope().translit("close")}catch(e){}"side"!=u.pos&&(e.innerHTML=n),e.addEventListener("click",kInteractive.closeFrame),m.appendChild(e)}var h=u.class?u.class:"";function a(){p.style.display="block",p.className="show";var e=window.innerHeight||document.documentElement.clientHeight||document.getElementsByTagName("body")[0].clientHeight,t=window.innerWidth||document.documentElement.clientWidth||document.getElementsByTagName("body")[0].clientWidth;e-=20,t-=20;var n=1;if(u.width&&u.height){var a=t/u.width,i=e/u.height;1<(n=a<i?a:i)&&(n=1)}var r="display:block;";r+=v;var o=u.width||u.height?"-50%,-50%":"0%,0%";r+="-webkit-transform:translate("+o+") scale("+n+");-moz-transform:translate("+o+") scale("+n+");transform:translate("+o+") scale("+n+");",r+="position:fixed;","undefined"==typeof isKotobee&&"-50%,-50%"==o&&(r+="top:"+Math.round(window.innerHeight/2)+"px;",r+="left:"+Math.round(window.innerWidth/2)+"px;"),m.style.cssText=r,m.className=h+" ready";var s=m.getElementsByClassName("closeBtn");if(s.length){var c=s[0],d=1/n,l="-50%";kInteractive.hasClass(c,"side")&&(l="0%"),c.style.cssText="-webkit-transform: translate("+l+",0%) scale("+d+");-webkit-transform-origin: 50% 50%;-moz-transform: translate("+l+",0%) scale("+d+");-moz-transform-origin: 50% 50%;transform: translate("+l+",0%) scale("+d+");transform-origin: 50% 50%;"}}(u.width||u.height)&&(h+=" fixed"),m.style.display="block",m.className=h,document.body.appendChild(m),kInteractive.frameIsOpen=!0,kInteractive.frameOb=u,kInteractive.openFrame.resized=a,window.addEventListener("resize",a),setTimeout(function(){a(),u.cb&&u.cb(m)},100)},closeAlert:function(e){e&&e.stopPropagation();var t=document.getElementById("kiSystemAlertBox"),n=document.getElementById("kiSystemAlertBackdrop");t.parentNode.removeChild(t),n.parentNode.removeChild(n),kInteractive.alertIsOpen=!1,window.removeEventListener("resize",kInteractive.alert.resized),kInteractive.alert.resized=null},closeFrame:function(){var e=document.getElementById("kInteractiveFrame"),t=document.getElementById("kiDarkOverlay");kInteractive.frameIsOpen=!1,window.removeEventListener("resize",kInteractive.openFrame.resized),kInteractive.openFrame.resized=null,kInteractive.c.removeClass(e,"ready");var n=kInteractive.frameOb,a="";n.width&&(a+="width:"+n.width+"px;max-width:"+n.width+"px;"),n.height&&(a+="height:"+n.height+"px;max-height:"+n.height+"px;"),e.style.cssText=a,t.className="",setTimeout(function(){e.innerHTML="",e.style.display=t.style.display="none",n.closed&&n.closed(),kInteractive.frameOb=null},300)},stopCurrentMedia:function(){if(kInteractive.currentVideo){var e=kInteractive.currentVideo.getAttribute("id")+"-container";if(t=document.getElementById(e))t.parentNode.removeChild(t),(n=document.createElement("div")).setAttribute("id",e),n.className="container",kInteractive.currentVideo.getElementsByClassName("playBtn")[0].className="playBtn ki-btn",kInteractive.c.removeClass(kInteractive.currentVideo,"playing"),kInteractive.currentVideo.appendChild(n)}var t,n;if(kInteractive.currentAudio)if(e=kInteractive.currentAudio.getAttribute("id"))e+="-container",(t=document.getElementById(e))&&(t.parentNode.removeChild(t),(n=document.createElement("div")).setAttribute("id",e),n.className="container",kInteractive.currentAudio.getElementsByClassName("playBtn")[0].className="playBtn ki-btn",kInteractive.c.removeClass(kInteractive.currentAudio,"playing"),kInteractive.currentAudio.appendChild(n));else try{var a=kInteractive.currentAudio.getElementsByTagName("audio");a.length&&(a[0].pause(),a[0].src=""),kInteractive.currentAudio.pause&&(kInteractive.currentAudio.pause(),kInteractive.currentAudio.src="");for(var i=document.getElementsByClassName("kiAudioLoader"),r=i.length;r--;)i[r].parentNode.removeChild(i[r])}catch(e){}},hasClass:function(e,t){if(e&&e.className)for(var n=e.className.trim().split(" "),a=0;a<n.length;a++)if(n[a]&&n[a].trim()==t)return!0},appendAfterDelay:function(e,t){setTimeout(function(){e.appendChild(t)},30)},replaceHTML:function(e,t){var n="string"==typeof e?document.getElementById(e):e,a=n.cloneNode(!1);return a.innerHTML=t,n.parentNode.replaceChild(a,n),a},tinCan:function(e){if("undefined"!=typeof isKotobee)try{angular.element(document.body).scope().tinCanShortcut(e)}catch(e){}},setDOMParser:function(){!function(e){"use strict";var t=e.prototype,r=t.parseFromString;try{if((new e).parseFromString("","text/html"))return}catch(e){}t.parseFromString=function(e,t){if(/^\s*text\/html\s*(?:;|$)/i.test(t)){var n,a=document.implementation.createHTMLDocument(""),i=a.documentElement;return i.innerHTML=e,n=i.firstElementChild,1===i.childElementCount&&"html"===n.localName.toLowerCase()&&a.replaceChild(n,i),a}return r.apply(this,arguments)}}(DOMParser)},compareVersions:function(e,t){if(e==t)return 0;if(null==e)return 1;if(null==t)return-1;var n=e.split("."),a=t.split(".");return a.length?n.length?Number(n[0])>Number(a[0])?1:Number(a[0])>Number(n[0])?-1:(n.shift(1),a.shift(1),kInteractive.compareVersions(n.join("."),a.join("."))):-1:1},readData:function(e){try{var t=e.getAttribute("data-kotobee");t=t||e.getAttribute("data");var n=1;return JSON.parse(decodeURI(kInteractive.XORCipher(n).decode("kotobee%%author",t)))}catch(e){try{return JSON.parse(kInteractive.XORCipher(n).decode("kotobee%%author",t))}catch(e){}}},writeData:function(e,t,n){n=n||1;var a=encodeURI(JSON.stringify(t)),i=e.hasAttribute("data-kotobee")?"data-kotobee":"data";e.setAttribute(i,kInteractive.XORCipher(n).encode("kotobee%%author",a))},XORCipher:function(e){var u="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";return{encode:function(e,t){return function(e){var t,n,a,i,r,o,s,c,d=0,l="";if(!e)return e;for(;t=e[d++],n=e[d++],a=e[d++],i=(s=t<<16|n<<8|a)>>12&63,r=s>>6&63,o=63&s,l+=u.charAt(s>>18&63)+u.charAt(i)+u.charAt(r)+u.charAt(o),d<e.length;);return((c=e.length%3)?l.slice(0,c-3):l)+"===".slice(c||3)}(t=function(n,e){return i(e,function(e,t){return e.charCodeAt(0)^a(n,t)})}(e,t))},decode:function(e,t){return function(n,e){return i(e,function(e,t){return String.fromCharCode(e^a(n,t))}).join("")}(e,t=function(e){var t,n,a,i,r,o,s,c,d=0,l=[];if(!e)return e;e+="";for(;i=u.indexOf(e.charAt(d++)),r=u.indexOf(e.charAt(d++)),o=u.indexOf(e.charAt(d++)),s=u.indexOf(e.charAt(d++)),t=(c=i<<18|r<<12|o<<6|s)>>16&255,n=c>>8&255,a=255&c,l.push(t),64!==o&&(l.push(n),64!==s&&l.push(a)),d<e.length;);return l}(t))}};function a(e,t){return e.charCodeAt(Math.floor(t%e.length))}function i(e,t){for(var n=[],a=0;a<e.length;a++)n[a]=t(e[a],a);return n}},getScormId:function(e,t){return e+(t=t?"-"+t.replace(/[^a-zA-Z0-9]/g,"-").substr(0,80):"")},confirm:function(e){kInteractive.alert(e)},alert:function(e){if(e){var t=document.createElement("div");if(t.setAttribute("id","kiSystemAlertBox"),e.raw&&(t.className="raw"),t.style.position="fixed","undefined"==typeof isKotobee&&(t.style.top=Math.round(window.innerHeight/2)+"px",t.style.left=Math.round(window.innerWidth/2)+"px"),e.raw)t.innerHTML=e.content.replace(" "," ");else{var n=document.createElement("div");n.innerHTML=e.content.replace(" "," "),n.className="content",t.appendChild(n)}if(e.title){var a=document.createElement("div");a.innerHTML=e.title.replace(" "," "),a.className="header",t.insertBefore(a,t.firstChild)}kInteractive.alertIsOpen=!0;var i=document.createElement("a");if(!e.raw){var r=document.createElement("div");r.className="footer";var o="OK";try{o=angular.element(document.body).scope().translit("ok")}catch(e){}if(e.okBtn&&(o=e.okBtn),i.innerHTML=o.replace(" "," "),i.className="okBtn",i.addEventListener("click",kInteractive.closeAlert),e.cb&&i.addEventListener("click",e.cb),r.appendChild(i),e.noBtn){var s=document.createElement("a");s.innerHTML=e.noBtn,s.className="cancelBtn",s.addEventListener("click",kInteractive.closeAlert),r.appendChild(s)}t.appendChild(r)}var c=document.createElement("div");e.noBackdrop||(c.setAttribute("id","kiSystemAlertBackdrop"),c.addEventListener("click",kInteractive.closeAlert),c.style.position="fixed",document.body.appendChild(c)),document.body.appendChild(t),i.focus(),kInteractive.alert.resized=d,window.addEventListener("resize",d),setTimeout(function(){kInteractive.c.addClass(t,"show"),kInteractive.c.addClass(c,"show")},50)}function d(){"undefined"==typeof isKotobee&&(t.style.top=Math.round(window.innerHeight/2)+"px",t.style.left=Math.round(window.innerWidth/2)+"px")}},c:{addClass:function(e,t){var n=e.className.trim();if(t instanceof Array){for(var a=!0,i=0;i<t.length;i++)-1==n.indexOf(t[i])&&(a=!1,n+=(""==n?"":" ")+t[i]);if(a)return}else{if(0<=n.indexOf(t))return;n+=(""==n?"":" ")+t}e.className=n},toggleClass:function(e,t){this.strHasClass(e.className,t)?this.removeClass(e,t):this.addClass(e,t)},hasClass:function(e,t){return this.strHasClass(e.className,t)},strHasClass:function(e,t){for(var n=(e=e||"").trim().split(" "),a=0;a<n.length;a++)if(n[a]==t)return!0;return!1},removeClass:function(e,t){var n=e.className;if(t instanceof Array){for(var a=!0,i=0;i<t.length;i++)0<=n.indexOf(t[i])&&(a=!1,n=n.replace(t[i],""));if(a)return}else{if(-1==n.indexOf(t))return;n=(n=n.replace(t,"")).replace(/ {2,}?/g," ")}""==(n=n.trim())?e.removeAttribute("class"):e.className=n},removeHash:function(e){return-1==e.indexOf("#")?e:e.substring(0,e.lastIndexOf("#"))},removeFilename:function(e){var t=kInteractive.c.normalizedArray(e);return-1==t[t.length-1].indexOf(".")?e:(t.splice(t.length-1,1),t.join("/"))},normalizedArray:function(e){for(var t=(e=e.replace(/\\/g,"/")).split("/"),n=t.length;n--;)t[n]?".."==t[n]&&0<n&&".."!=t[n-1]&&(t.splice(n,1),t.splice(n-1,1)):t.splice(n,1);return t[0].match(/http[s]?:$/g)&&(t[0]+="//"+t[1],t.splice(1,1)),"file:"==t[0]&&(t[0]+="///"+t[1],t.splice(1,1)),t},shuffleArray:function(e){e.sort(function(){return Math.random()-.5})},allowDrop:function(e){e.preventDefault()},drag:function(e){e.dataTransfer&&e.dataTransfer.setData("text",e.target.id),dragged=e.target},drop:function(e){e.preventDefault(),e.target.hasAttribute("ondragover")&&e.target.appendChild(e.view.dragged)}},escapeHtml:function(e){var t={"&":"&","<":"<",">":">",'"':""","'":"'"};return e.replace(/[&<>"']/g,function(e){return t[e]})},getChildIndex:function(e){for(var t=0;null!=(e=e.previousSibling);)t++;return t},isAbsolutePath:function(e){if(e)return 0==e.trim().indexOf("http://")||(0==e.trim().indexOf("https://")||(0==e.trim().indexOf("//")||(0==e.trim().indexOf("data:")||void 0)))},isMobile:function(e){if(/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent))return!0;try{if(0<window.location.href.indexOf("?preview")){var t=window.location.href.split("?");t=t[1].split("&");for(var n={},a=0;a<t.length;a++){var i=t[a].split("=");n[i[0]]=i[1]}if(n.mobile)return!0}}catch(e){}},closeFullscreenVideo:function(){kInteractive.currentVideo&&(kInteractive.currentVideo.webkitExitFullscreen?kInteractive.currentVideo.webkitExitFullscreen():kInteractive.currentVideo.mozCancelFullScreen?kInteractive.currentVideo.mozCancelFullScreen():document.webkitExitFullscreen?document.webkitExitFullscreen():document.mozCancelFullScreen&&document.mozCancelFullScreen(),kInteractive.videoIsFullscreen=!1)},getWidgetHome:function(e,t){return{},e.path?"undefined"==typeof isKotobee?e.path:ph.join(angular.element(document.body).scope().data.book.chapter.absoluteURL,e.path):"undefined"==typeof isKotobee?"../js/widgets/":bookPath+"EPUB/js/widgets/"},getWidgetUrl:function(e,t){var n=kInteractive.getWidgetHome(e,t)+"/"+e.name+"/"+e.src;if("undefined"!=typeof isKotobee){var a=angular.element(document.body).scope().data.user;a&&a.email&&a.signatures&&a.signatures.bookwidgets&&e.id&&0==e.id.indexOf("com.kidimedia")&&(n+="?oauth_signature="+a.signatures.bookwidgets.signature,n+="&oauth_nonce="+a.signatures.bookwidgets.nonce,n+="&oauth_timestamp="+a.signatures.bookwidgets.timestamp,n+="&oauth_consumer_key="+a.signatures.bookwidgets.key,n+="<i_version=LTI-1p0",n+="&oauth_signature_method=HMAC-SHA1",n+="&oauth_version=1.0",n+="&tool_consumer_info_product_family_code=kotobee",n+="&lis_person_contact_email_primary="+a.email,n+="&lis_person_name_full="+(a.name?a.name:""),n+="&user_id="+a.id,n+="<i_message_type=basic-lti-launch-request",angular.element(document.body).scope().refreshSignatures&&angular.element(document.body).scope().refreshSignatures())}return n},clearAudioVideo:function(e){var t=e||document;kInteractive.stopCurrentMedia();for(var n=t.getElementsByTagName("audio"),a=n.length;a--;)try{if(n[a].hasAttribute("data-dontclose"))continue;n[a].pause(),n[a].children.length||(n[a].src="")}catch(e){}var i=t.getElementsByTagName("video");for(a=i.length;a--;)i[a].pause(),i[a].children.length||(i[a].src="")}};for(var item in kInteractiveCommon)kInteractive[item]=kInteractiveCommon[item];kInteractive.container={preRender:function(e,t){kInteractive.readData(e)},postRender:function(e,t,n){var a=kInteractive.readData(t);if(a&&(kInteractive.isMobile()&&"cScroll"==a.type&&"undefined"!=typeof isKotobee&&angular.element(document.body).scope().applyNativeScroll(t),a.path)){var i=a.path;"undefined"!=typeof isKotobee&&(i=ph.join(kInteractive.absoluteURL,a.path));var r=t.getAttribute("style");t.setAttribute("style",r+' background-image:url("'+i+'");')}},action:function(e){},resize:function(){var e=kInteractive.readData(item);e&&kInteractive.checkResponsiveFloat(e,item)}},kInteractive.gallery={preRender:function(e,t){var n=t.createDocumentFragment(),a=kInteractive.readData(e);if(a){e.innerHTML="";var i=document.createElement("div");i.className="imgMask";var r=document.createElement("div");r.className="images "+a.scale,i.appendChild(r);for(var o=0;o<a.imgs.length;o++){var s=document.createElement("div");s.className="imgContainer"+(o?"":" selected");var c="undefined"==typeof isKotobee?a.imgs[o].path:ph.join(kInteractive.absoluteURL,a.imgs[o].path);s.setAttribute("style","background-color:"+a.bgColor+";background-image:url('"+c+"')"+(o?"":";display:block")),a.imgs[o].caption&&s.setAttribute("data-caption",a.imgs[o].caption),r.appendChild(s)}n.appendChild(i);var d=document.createElement("div");d.className="imgCaption";var l=document.createElement("div");l.className="inner",l.style.display="none",a.imgs[0]&&a.imgs[0].caption&&(l.innerHTML=a.imgs[0].caption,l.style.display=null),d.appendChild(l),n.appendChild(d);var u=document.createElement("a");u.className="next btn ki-btn",1==a.imgs.length&&(u.className+=" disable"),n.appendChild(u);var m=document.createElement("a");m.className="prev btn ki-btn disable",n.appendChild(m),"undefined"==typeof isKotobee&&(u.addEventListener("click",kInteractive.actionEvent),m.addEventListener("click",kInteractive.actionEvent));var p=document.createElement("div");a.style&&kInteractive.c.addClass(p,a.style),p.appendChild(n),e.appendChild(p)}},postRender:function(e,t,n){},action:function(e,t){var n=e.getElementsByClassName("images")[0],a=(n.children.length,e.getElementsByClassName("selected")[0]),i=Number(a.style.left.slice(0,-2)),r=Number(n.style.left.slice(0,-2));if(kInteractive.hasClass(t,"next")){var o=a.nextSibling;if(!o)return;kInteractive.c.removeClass(a,"selected"),kInteractive.c.addClass(o,"selected"),o.style.left=i+n.offsetWidth+"px",o.style.display="block",n.style.left=r-n.offsetWidth+"px",o.nextSibling?kInteractive.c.removeClass(t,"disable"):kInteractive.c.addClass(t,"disable"),kInteractive.c.removeClass(e.getElementsByClassName("prev")[0],"disable"),a=o}else if(kInteractive.hasClass(t,"prev")){var s=a.previousSibling;if(!s)return;kInteractive.c.removeClass(a,"selected"),kInteractive.c.addClass(s,"selected"),s.style.left=i-n.offsetWidth+"px",s.style.display="block",n.style.left=r+n.offsetWidth+"px",s.previousSibling?kInteractive.c.removeClass(t,"disable"):kInteractive.c.addClass(t,"disable"),kInteractive.c.removeClass(e.getElementsByClassName("next")[0],"disable"),a=s}var c=e.getElementsByClassName("imgCaption");if(c.length){var d=(c=c[0]).getElementsByClassName("inner");d.length&&((d=d[0]).style.display="none",a.hasAttribute("data-caption")&&(d.innerHTML=a.getAttribute("data-caption"),d.style.display=null))}},resize:function(e){var t=kInteractive.readData(e);t&&kInteractive.checkResponsiveFloat(t,e)}},kInteractive.image={preRender:function(e,t){var n=kInteractive.readData(e);n&&(n.style&&kInteractive.c.addClass(e,n.style),e.parentNode&&kInteractive.hasClass(e.parentNode,"link")||"undefined"==typeof isKotobee&&e.addEventListener("click",kInteractive.actionEvent))},postRender:function(e,t,n){kInteractive.readData(t)},action:function(e,a,t){if(a.parentNode&&kInteractive.hasClass(a.parentNode,"kInteractive")&&kInteractive.hasClass(a.parentNode,"link"))kInteractive.action(a.parentNode,event);else{var n=kInteractive.readData(a);if(n){var i=n.behavior;if("none"!=i)s(a,"none"),c(a,"none"),d(a,"none"),setTimeout(function(){"wiggle"==i?(s(a,"wiggle"),c(a,"0.5s"),d(a,"1")):"jump"==i?(s(a,"jump"),c(a,"0.7s"),d(a,"1")):"scale"==i&&(s(a,"scale"),c(a,"0.5s"),d(a,"1"));var n=function(){var e,t=document.createElement("fakeelement"),n={animation:"animationend",OAnimation:"oAnimationEnd",MozAnimation:"animationend",WebkitAnimation:"webkitAnimationEnd"};for(e in n)if(void 0!==t.style[e])return n[e]}();n&&a.addEventListener(n,function e(t){s(a,"none"),c(a,"none"),d(a,"none"),a.removeEventListener(n,e)})}),kInteractive.tinCan({verb:"clicked",activity:i+"image: "+a.getAttribute("src")});else if(n.popup){var r={class:"image"},o=document.createElement("img");o.src=n.path,kInteractive.isAbsolutePath(n.path)||"undefined"!=typeof isKotobee&&(o.src=ph.join(kInteractive.absoluteURL,n.path)),r.width=o.naturalWidth,r.height=o.naturalHeight,r.pos="side",r.cb=function(e){e.appendChild(o)},r.closed=function(){},kInteractive.openFrame(r)}}}function s(e,t){e.style.webkitAnimation=e.style.mozAnimation=e.style.animation=t}function c(e,t){e.style.webkitAnimationDuration=e.style.mozAnimationDuration=e.style.animationDuration=t}function d(e,t){e.style.webkitAnimationIterationCount=e.style.mozAnimationIterationCount=e.style.animationIterationCount=t}},resize:function(e){var t=kInteractive.readData(e);t&&kInteractive.checkResponsiveFloat(t,e)}},kInteractive.link={preRender:function(e,t){var n=kInteractive.readData(e);if(n&&("undefined"==typeof editorMode||!editorMode)){if("div"==e.nodeName.toLowerCase()){var a=document.createElement("a");a.setAttribute("href","popup"==n.type?"":e.getAttribute("href")),a.setAttribute("target",n.target),a.setAttribute("style",e.getAttribute("style")),a.setAttribute("data-kotobee",e.getAttribute("data-kotobee")),a.className=e.className,a.id=e.id?e.id:n.id,kInteractive.c.addClass(a,"btn"),a.style.opacity=Number(n.transparency)/100,e.parentNode.replaceChild(a,e),e=a}"undefined"==typeof isKotobee&&("popup"!=n.type&&"audio"!=n.type&&"action"!=n.type||e.setAttribute("onclick","return false;"),e.addEventListener("click",kInteractive.actionEvent))}},postRender:function(e,t,n){},action:function(e,t,n){var a=kInteractive.readData(t);if(a){if("popup"==a.type){var i="<div class='kbAlertScroll'>"+a.msg+"</div>";if(i=i.replace(/src="(.*?)"/g,function(){var e=arguments[1];return"undefined"!=typeof isKotobee&&(e=ph.join(kInteractive.absoluteURL,e)),'src="'+e+'"'}),"image"==a.popupMode){var r=a.popupImg;"undefined"!=typeof isKotobee&&(r=ph.join(kInteractive.absoluteURL,r)),i="<img src='"+r+"'/>"}kInteractive.alert({content:i}),kInteractive.scorm&&setTimeout(function(){var e={};e.id=kInteractive.getScormId("popup",a.msg),e.description="Shown popup message: "+a.msg,e.type="other",e.learnerResponses="Shown",e.timestamp=new Date,kInteractive.scorm.setInteractions([e])},800)}else if("action"==a.type){var o=a.asset,s=a.action;if(o.remote){if("widget"==o.type){var c=document.createElement("div");c.className="kInteractive widget kbHidden",c.setAttribute("data-kotobee",o.data),document.body.appendChild(c),kInteractive.trigger("click",c)}return}for(var d=document.getElementsByClassName(o.classname),l=0;l<d.length;l++)if(kInteractive.hasClass(d[l],"kInteractive")&&kInteractive.hasClass(d[l],o.type))if("activate"==s)if("gallery"==o.type){var u=d[l].getElementsByClassName("next");kInteractive.trigger("click",u[0])}else if("questions"==o.type){for(var m=d[l].getElementsByClassName("ki-btn"),p=0;p<m.length;p++)if("submit"==m[p].type){kInteractive.trigger("click",m[p]);break}}else kInteractive.trigger("click",d[l]);else"visibility"==s&&kInteractive.c.toggleClass(d[l],"kbHidden")}else if("audio"==a.type){kInteractive.stopCurrentMedia();var v,h=document.createElement("audio"),f=a.src;function g(){v||(kInteractive.c.addClass(y,"hide"),v=!0)}"file"==a.audioType&&(f="undefined"==typeof isKotobee?a.audio:ph.join(kInteractive.absoluteURL,a.audio)),h.setAttribute("src",f);var k=document.createElement("div");k.className="kiAudioLoader",k.style.transform=k.style.webkitTransform=k.style.mozTransform="scale(1)";var y=document.createElement("div");if(y.className="kiAudioSpinner",k.appendChild(y),t.parentNode.insertBefore(k,t),h.onplaying=g,setTimeout(g,5e3),h.play(),kInteractive.currentAudio=h,kInteractive.tinCan({verb:"played",activity:"Audio: "+f}),kInteractive.scorm){var b={};b.id=kInteractive.getScormId(t.textContent,f),b.description="Played audio link: "+f,b.type="other",b.learnerResponses="Played",b.objective=a.options?a.options.objective:null,b.timestamp=new Date,kInteractive.scorm.setInteractions([b])}}else if("attachment"==a.type){var I=a.file;"undefined"!=typeof isKotobee&&(I=ph.join(kInteractive.absoluteURL,a.file));var C=document.createElement("a");document.body.appendChild(C),C.setAttribute("style","display: none"),C.href=I,C.target="_blank",C.download=a.file.split("/")[a.file.split("/").length-1],C.setAttribute("onclick","");var E=document.createEvent("MouseEvents");E.initMouseEvent("click"),C.dispatchEvent(E),C.remove()}return!1}}},kInteractive.questions={preRender:function(e,t,n,a){var i=t.createDocumentFragment(),r=kInteractive.readData(e);if(r){var o=r.dict,s=r.userDict;if(o=o||{},s=s||o,r.options||(r.options={}),e.id||(e.id="ki-qs-"+n+"-"+Math.ceil(1e3*Math.random())),e.innerHTML="",r.layout&&r.layout.popup&&!kInteractive.hasClass(e,"inpopup")){var c=document.createElement("img"),d=r.layout.popupImg;return c.src=d,i.appendChild(c),"undefined"==typeof isKotobee&&c.addEventListener("click",kInteractive.actionEvent),void e.appendChild(i)}if(r.options.randomize){for(var l=0;l<r.q.length;l++)r.q[l].origin=l;for(var u,m,p=r.q.length;0!==p;)m=Math.floor(Math.random()*p),p-=1,u=r.q[p],r.q[p]=r.q[m],r.q[m]=u}if(r.options.questionsDisplayed){var v=Number(r.options.questionsDisplayed);r.q=r.q.slice(0,v)}if(r.title){var h=document.createElement("span");h.innerHTML="<h4>"+kInteractive.escapeHtml(r.title)+"</h4>",i.appendChild(h)}for(l=0;l<r.q.length;l++){var f=r.q[l],g=document.createElement("div");if(g.className="ques",null!=f.origin&&g.setAttribute("data-o",f.origin),f.q||(f.q=""),g.innerHTML="<p><strong>"+(r.options.numbering?"<span class='no'>"+(l+1)+"</span>":"")+kInteractive.escapeHtml(" "+f.q)+"</strong></p>",f.path){var k=document.createElement("img");k.src=f.path,g.appendChild(k)}if(g.classList.add(f.type),"sa"==f.type){var y=f.lines?f.lines:1,b=document.createElement(1<y?"textarea":"input");b.name="sa-"+l,1==y?b.type="text":b.rows=f.lines?f.lines:1,b.className="ans txtfield";var I="ki-sa-"+n+"-"+l;b.id=I,document[e.id]&&document[e.id].preserve&&document[e.id].q&&document[e.id].q[l]&&(b.value=document[e.id].q[l]),g.appendChild(b)}else if("mcq"==f.type||"mmcq"==f.type)for(var C=f.c,E=0;E<C.length;E++){I="ki-mcq-"+n+"-"+l+"-"+E;var w=document.createElement("input");"mmcq"==f.type?(w.name="name",w.type="checkbox"):(w.name="mcq-"+l,w.type="radio"),w.className="ans",w.id=I,(V=document.createElement("label")).htmlFor=I,V.innerHTML=" "+kInteractive.escapeHtml(C[E].t),V.className="ki-noHighlight",(A=document.createElement("div")).className="answer",document[e.id]&&document[e.id].preserve&&document[e.id].q&&document[e.id].q[l]&&(w.checked=document[e.id].q[l][E],r.options&&r.options.highlightCorrect&&r.q[l].c[E].a&&kInteractive.c.addClass(A,"correct")),A.appendChild(w),A.appendChild(V),g.appendChild(A)}else if("tf"==f.type)for(E=0;E<2;E++){I="ki-tf-"+n+"-"+l+"-"+E;var N=document.createElement("input");N.type="radio",N.name="tf-"+l,N.className="ans",N.id=I,(V=document.createElement("label")).htmlFor=I,f.choice1&&f.choice2?V.innerHTML=kInteractive.escapeHtml(" "+(0==E?f.choice1:f.choice2)):V.innerHTML=" "+(0==E?"True":"False"),V.className="ki-noHighlight";var A=document.createElement("div");document[e.id]&&document[e.id].preserve&&document[e.id].q&&document[e.id].q[l]&&(N.checked=document[e.id].q[l][E],r.options&&r.options.highlightCorrect&&(0==E&&r.q[l].a||1==E&&!r.q[l].a)&&kInteractive.c.addClass(A,"correct")),A.appendChild(N),A.appendChild(V),g.appendChild(A)}else if("dd"==f.type){var x=document.createElement("div");x.className="categoryContainer";var L=[];for(E=0;E<f.k.length;E++){var T=f.k[E],R=E,q=document.createElement("div");q.className="dCategory ki-noHighlight ki-dd-category-"+R,q.setAttribute("ondragover","kInteractive.c.allowDrop(event)"),q.setAttribute("ondrop","kInteractive.c.drop(event)");var B=document.createElement("div");B.innerHTML=T.category.name,B.className="qTitle",q.appendChild(B);for(var H=0;H<T.category.answers.length;H++)L.push(T.category.answers[H].t);x.appendChild(q)}g.appendChild(x);var M=document.createElement("div");M.className="ki-dd-clearfix",g.appendChild(M);var S=document.createElement("div");S.setAttribute("ondragover","kInteractive.c.allowDrop(event)"),S.setAttribute("ondrop","kInteractive.c.drop(event)"),S.className="ki-dd-answers ki-noHighlight";var O=[];for(E=0;E<L.length;E++){R=E,A=L[E];var D=document.createElement("div");I="ki-dd-"+n+"-"+l+"-"+R;D.id=I,D.innerHTML="<span></span>",D.children[0].innerText=A,D.className="ans ki-noHighlight",D.draggable=!0,D.setAttribute("ondragstart","kInteractive.c.drag(event)"),O.push(D)}kInteractive.c.shuffleArray(O);for(E=0;E<O.length;E++)S.appendChild(O[E]);g.appendChild(S)}if((U=document.createElement("p")).className="separator",g.appendChild(U),document[e.id]&&document[e.id].preserve&&document[e.id].q&&document[e.id].q[l]){if(r.q[l].exp)if(!g.getElementsByClassName("explanation").length){var z=document.createElement("p");z.className="explanation",z.innerHTML=kInteractive.escapeHtml(r.q[l].exp),kInteractive.appendAfterDelay(g,z)}if(r.q[l].ref)if(!g.getElementsByClassName("reference").length){var F=document.createElement("a");F.className="reference",F.innerHTML=s.learnMode?s.learnMode:"Learn more",F.setAttribute("href",kInteractive.escapeHtml(r.q[l].ref)),F.setAttribute("target","_blank"),kInteractive.appendAfterDelay(g,F)}}i.appendChild(g)}if(r.options.emailForm){var K=document.createElement("div");K.setAttribute("class","emailForm"),function(e,t,n){var a=document.createElement("div");a.className="address",a.innerHTML="<p><strong>"+e+"</strong><em>"+t+"</em></p>";var i=document.createElement("input");i.name=n,i.type="text",i.className="txtfield",a.appendChild(i);var r=document.createElement("p");r.className="separator",a.appendChild(r),K.appendChild(a)}(s.recipientEmail?s.recipientEmail:"Recipient email",s.separateEmails?s.separateEmails:"Separate multiple emails with commas","recipientEmail"),i.appendChild(K)}var j=null;if("none"!=r.action){var P="ki-"+n+"-btn";(j=document.createElement("input")).type="submit",j.value=s.submit?s.submit:"Submit Answers",j.id=P,j.className="btn ki-btn ki-mcq"}var U,W=null,_=null;if(r.options&&(r.options.clearAnswers&&((W=document.createElement("input")).type="submit",W.value=s.clear?s.clear:"Clear Answers",W.className="btn ki-btn ki-questions questions-clear","undefined"==typeof isKotobee&&W.addEventListener("click",kInteractive.actionEvent)),r.options.addToNotebook&&((W=document.createElement("input")).type="submit",W.value=s.notebook?s.notebook:"Save to Notebook",W.className="btn ki-btn ki-questions questions-notebook","undefined"==typeof isKotobee&&W.addEventListener("click",kInteractive.actionEvent)),r.options.preserveAnswers)){(_=document.createElement("div")).style.marginTop="5px";var V,Q=document.createElement("input");Q.type="checkbox",Q.name="preserveAnswers",Q.className="ki-btn ki-questions questions-preserve",Q.id="ki-"+n+"-preserveAnswersBtn",document[e.id]&&(Q.checked=document[e.id].preserve),_.appendChild(Q),(V=document.createElement("label")).htmlFor=Q.id,V.innerHTML=" "+(s.preserve?s.preserve:"Preserve submitted answers"),V.className="ki-noHighlight",_.appendChild(V),"undefined"==typeof isKotobee&&Q.addEventListener("change",kInteractive.actionEvent)}"undefined"==typeof isKotobee&&j&&j.addEventListener("click",kInteractive.actionEvent),j&&i.appendChild(j),i.appendChild(document.createTextNode(" ")),W&&i.appendChild(W),_&&i.appendChild(_),(U=document.createElement("p")).className="separator",i.appendChild(U),r.options.rtl?(e.style.direction="rtl",kInteractive.c.addClass(e,"rtl")):e.style.direction="ltr";var Y=document.createElement("div");r.style&&kInteractive.c.addClass(Y,r.style),Y.appendChild(i),e.appendChild(Y)}},postRender:function(e,t,n){var a=kInteractive.readData(t);if(a){var i=a.dict,r=a.userDict;i=i||{},r=r||i;for(var o=t.getElementsByClassName("ques"),s=t.getElementsByClassName("explanation"),c=s.length;c--;)s[c].parentNode.removeChild(s[c]);var d=t.getElementsByClassName("reference");for(c=d.length;c--;)d[c].parentNode.removeChild(d[c]);for(var l=0;l<o.length;l++){var u=o[l].getElementsByClassName("ans"),m=(u.length,l);if(a.options.randomize&&(m=Number(o[l].getAttribute("data-o"))),document[t.id]&&document[t.id].preserve&&document[t.id].q&&document[t.id].q[m]){if(a.q[m].exp)if(!o[l].getElementsByClassName("explanation").length){var p=document.createElement("p");p.className="explanation",p.innerHTML=kInteractive.escapeHtml(a.q[m].exp),kInteractive.appendAfterDelay(o[l],p)}if(a.q[m].ref)if(!o[l].getElementsByClassName("reference").length){var v=document.createElement("a");v.className="reference",v.innerHTML=r.learnMode?r.learnMode:"Learn more",v.setAttribute("href",kInteractive.escapeHtml(a.q[m].ref)),v.setAttribute("target","_blank"),kInteractive.appendAfterDelay(o[l],v)}}for(c=0;c<u.length;c++)if(kInteractive.c.removeClass(u[c].parentNode,"correct"),0<=u[c].getAttribute("id").indexOf("ki-tf-"))document[t.id]&&document[t.id].preserve&&document[t.id].q&&document[t.id].q[m]&&(document[t.id].q[m][c]?u[c].setAttribute("checked",!0):u[c].removeAttribute("checked"),a.options&&a.options.highlightCorrect&&(0==c&&a.q[m].a||1==c&&!a.q[m].a)&&kInteractive.c.addClass(u[c].parentNode,"correct"));else if(0<=u[c].getAttribute("id").indexOf("ki-dd-")){if(document[t.id]&&document[t.id].preserve&&document[t.id].q&&document[t.id].q[m])for(var h=0;h<document[t.id].q[m].length;h++){var f=document[t.id].q[m][h];try{for(var g=document.getElementById(f.id),k=g;!kInteractive.c.hasClass(k,"ques");)k=k.parentNode;k.getElementsByClassName("categoryContainer")[0].children[f.category].appendChild(g)}catch(e){}}}else 0<=u[c].getAttribute("id").indexOf("ki-sa-")?document[t.id]&&document[t.id].preserve&&document[t.id].q&&document[t.id].q[m]&&(u[c].removeAttribute("value"),document[t.id].q[m]&&u[c].setAttribute("value",document[t.id].q[m])):document[t.id]&&document[t.id].preserve&&document[t.id].q&&document[t.id].q[m]&&(document[t.id].q[m][c]?u[c].setAttribute("checked",!0):u[c].removeAttribute("checked"),a.options&&a.options.highlightCorrect&&a.q[m].c[c].a&&kInteractive.c.addClass(u[c].parentNode,"correct"));if(document[t.id]){var y=t.getElementsByClassName("questions-preserve");y.length&&(document[t.id].preserve?y[0].setAttribute("checked",!0):y[0].removeAttribute("checked"))}}}},action:function(p,t,e){var n=kInteractive.readData(p);if(n){var a=n.dict,i=n.userDict;if(a=a||{},i=i||a,n.layout&&n.layout.popup&&!kInteractive.hasClass(p,"inpopup")&&"img"==t.nodeName.toLowerCase()){function r(e){for(var t=0;e=e.previousSibling;)"#text"!=e.nodeName&&8!=e.nodeType&&t++;return t}var o=document.getElementById("epubContent");o&&p.setAttribute("data-loc",function(e,t){for(var n="";e!=t;){n=r(e)+"."+n,e=e.parentNode}return""==n?"":n.substr(0,n.length-1)}(p,o));var v=document.createElement("iframe");return v.setAttribute("nwdisable","true"),v.setAttribute("nwfaketop","true"),n.cb=function(e){var t,n=document.createElement("head");if("undefined"==typeof isKotobee){for(var a=document.getElementsByTagName("link"),i=0;i<a.length;i++){var r=a[i];if(0<=r.getAttribute("href").indexOf("base.css")){var o=r.getAttribute("href").split("/");delete o[o.length-1],t=o.join("/");break}}if(!t)return}var s="undefined"==typeof isKotobee?t+"../xhtml/":bookPath+"EPUB/xhtml/";n="<head>";if(n+='<base href="'+kInteractive.c.removeFilename(kInteractive.c.removeHash(window.location.href))+"/"+s+'"/>',n+='<link rel="stylesheet" type="text/css" href="../css/base.css" />',n+='<link rel="stylesheet" type="text/css" href="../css/global.css" />',n+='<link rel="stylesheet" type="text/css" href="../css/kotobeeInteractive.css" />',n+='<script type="text/javascript" src="../js/kotobeeInteractive.js"><\/script>',n+='<script type="text/javascript" src="../js/global.js"><\/script>',"undefined"!=typeof isKotobee){var c=clone(config);c.kotobee.email=angular.element(document.body).scope().data.user.email,n+='<script type="text/javascript">var config='+JSON.stringify(c)+";<\/script>"}n+='<meta charset="utf-8" />',n+="</head>";var d=p.outerHTML;d=(d=(d=(d=(d=(d=d.replace("<img",'<img style="display:none"')).replace(/([;\s]*?height:)(.*)?;/i,"$1auto")).replace(/([;\s]*?width:)(.*)?;/i,"$1auto")).replace(/([;\s]*?top:)(.*)?;/i,"$1auto")).replace(/([;\s]*?left:)(.*)?;/i,"$1auto")).replace('class="','class="inpopup ');var l="<html>"+n+"<body>"+(d+='<div class="vSpace20"></div>')+"</body></html>";v.setAttribute("srcdoc",l);var u="javascript: window.frameElement.getAttribute('srcdoc');";function m(){if("undefined"!=typeof isKotobee){var e={};e.root=v.contentDocument.documentElement.ownerDocument.body,e.rootIndex=p.getAttribute("data-loc"),angular.element(document.body).scope().getNotebookShortcut(e,function(){})}}v.setAttribute("src",u),v.contentWindow&&(v.contentWindow.location=u),e.appendChild(v),v.addEventListener?v.addEventListener("load",m,!0):v.attachEvent&&v.attachEvent("onload",m)},n.closed=function(){},n.pos=n.layout.pos,kInteractive.openFrame(n),kInteractive.tinCan({verb:"opened",activity:"Questions: "+n.title}),void(kInteractive.scorm&&setTimeout(function(){var e={};e.id=kInteractive.getScormId("question",n.title),e.description="Opened question popup: "+n.title,e.learnerResponses="Opened",e.type="other",e.timestamp=new Date,kInteractive.scorm.setInteractions([e])},800))}var s="Untitled questions",c=p.getElementsByTagName("h4");c.length&&(s=c[0].textContent||c[0].data);var d=0,l=p.getElementsByClassName("ques"),u=l.length,m="";if(!kInteractive.hasClass(t,"kInteractive"))if(kInteractive.hasClass(t,"questions-clear")){for(var h=p.getElementsByClassName("ans"),f=[],g=0;g<h.length;g++)h[g].checked=!1,h[g].value=null,kInteractive.c.removeClass(h[g].parentNode,"correct"),kInteractive.c.removeClass(h[g],"incorrect"),kInteractive.c.hasClass(h[g].parentNode,"dCategory")&&f.push(h[g]);for(g=0;g<f.length;g++)f[g].parentNode.parentNode.parentNode.getElementsByClassName("ki-dd-answers")[0].appendChild(f[g]);for(g=(T=p.getElementsByClassName("explanation")).length;g--;)T[g].parentNode.removeChild(T[g]);for(g=(R=p.getElementsByClassName("reference")).length;g--;)R[g].parentNode.removeChild(R[g]);document[p.id]=null}else{if(kInteractive.hasClass(t,"questions-notebook")){var k,y=n.layout&&n.layout.popup&&kInteractive.hasClass(p,"inpopup");if("undefined"==typeof isKotobee&&!y)return void kInteractive.alert({content:a.kotobeeOnly,title:i.sorry?i.sorry:"Sorry"});var b={elem:p};if("undefined"!=typeof isKotobee)k=angular.element(document.body).scope();else{try{k=window.parent.getGlobal()}catch(e){return void kInteractive.alert({content:a.kotobeeOnly,title:i.sorry?i.sorry:"Sorry"})}b.rootIndex=p.getAttribute("data-loc"),b.root=p}return kInteractive.c.addClass(t,"busy"),void k.questionsAddToNotebookShortcut(b,function(){kInteractive.c.removeClass(t,"busy"),kInteractive.alert({content:i.savedToNotebook?i.savedToNotebook:"Saved to notebook!"})})}if(kInteractive.hasClass(t,"questions-preserve"))return document[p.id]||(document[p.id]={}),void(document[p.id].preserve=t.checked);var I=0,C=0,E=[];for(g=0;g<l.length;g++){var w=0<(h=l[g].getElementsByClassName("ans")).length,N=n.q[g];if(n.options.randomize&&(N=n.q[Number(l[g].getAttribute("data-o"))]),kInteractive.scorm&&n.options&&n.options.answerOnce&&kInteractive.scorm.interactionExists(kInteractive.getScormId(p.id+"-"+(g+1),N.q))){var A="<p style='text-align:center'>"+(i.alreadySubmitted?i.alreadySubmitted:"This test has already been submitted!")+"</p>";return void kInteractive.alert({content:A})}var x={},L=h[0].getAttribute("id");E.push(x),x.id=kInteractive.getScormId(p.id+"-"+(g+1),N.q),x.qid=p.id,0<=L.indexOf("ki-tf-")?x.type="true-false":0<=L.indexOf("ki-mcq-")||L.indexOf("ki-mmcq-")?x.type="choice":0<=L.indexOf("ki-dd-")?x.type="drag-drop":0<=L.indexOf("ki-sa-")&&(x.type="short-answer"),x.objective=n.options?n.options.objective:null,x.timestamp=kInteractive.timestamp,x.latency=Math.round(((new Date).getTime()-kInteractive.timestamp.getTime())/1e3),x.description=N.q;for(var T,R,q=[],B=0;B<h.length;B++)if(0<=h[B].getAttribute("id").indexOf("ki-tf-"))0==B&&N.a?x.correctResponses=N.choice1:1!=B||N.a||(x.correctResponses=N.choice2),h[B].checked?(x.learnerResponses=B?N.choice2:N.choice1,0!=B||N.a?1==B&&N.a&&(w=!1):w=!1):0==B&&N.a?w=!1:1!=B||N.a||(w=!1),n.options&&n.options.highlightCorrect&&(0==B&&N.a||1==B&&!N.a)&&kInteractive.c.addClass(h[B].parentNode,"correct");else if(0<=h[B].getAttribute("id").indexOf("ki-sa-")){se=(se=h[B].value.toLowerCase())&&se.trim(),w=!0;for(var H="",M=0;M<N.k.length;M++){var S=N.k[M].t;if(!S){w=!1;break}H&&(H+="+"),H+=S=S.toLowerCase();for(var O=S.split(","),D=!1,z=0;z<O.length;z++)if(0<=se.indexOf(O[z].trim())){D=!0;break}if(!D){w=!1;break}}x.correctResponses=H,x.learnerResponses=se}else if(0<=h[B].getAttribute("id").indexOf("ki-dd-")){kInteractive.c.removeClass(h[B],"incorrect");var F=h[B].id.split("-")[4],K=N.answers[F].forCategory,j=l[g].getElementsByClassName("dCategory")[K],P={};if(P.correct=h[B].innerText+" -> "+j.children[0].innerText,kInteractive.c.hasClass(h[B].parentNode,"ki-dd-answers"))kInteractive.c.addClass(h[B],"incorrect"),w=!1,P.learner=h[B].innerText+" unassigned";else{var U=h[B].parentNode,W=U.children[0].innerText,_=kInteractive.getChildIndex(U);P.learner=h[B].innerText+" -> "+W,_!=K&&n.options&&n.options.highlightCorrect&&(w=!1,kInteractive.c.addClass(h[B],"incorrect"))}q.push(P)}else N.c[B].a&&(x.correctResponses=N.c[B].t),h[B].checked&&(x.learnerResponses=N.c[B].t),h[B].checked&&!N.c[B].a?w=!1:!h[B].checked&&N.c[B].a&&(w=!1),n.options&&n.options.highlightCorrect&&N.c[B].a&&kInteractive.c.addClass(h[B].parentNode,"correct");if(q.length)for(var V=0;V<q.length;V++)x.correctResponses&&(x.correctResponses+="; "),x.learnerResponses&&(x.learnerResponses+="; "),x.correctResponses+=q[V].correct,x.learnerResponses+=q[V].learner;if(x.result=0,null!=N.weight&&(I+=N.weight,w&&(C+=N.weight,x.result=N.weight)),x.scoreMax=n.options?Number(n.options.totalScore):null,N.exp)if(!l[g].getElementsByClassName("explanation").length)(T=document.createElement("p")).className="explanation",T.innerHTML=kInteractive.escapeHtml(N.exp),kInteractive.appendAfterDelay(l[g],T);if(N.ref)if(!l[g].getElementsByClassName("reference").length)(R=document.createElement("a")).className="reference",R.innerHTML=i.learnMode?i.learnMode:"Learn more",R.setAttribute("href",kInteractive.escapeHtml(N.ref)),R.setAttribute("target","_blank"),kInteractive.appendAfterDelay(l[g],R);var Q=i.question?i.question.replace("[no]",g+1):"Question "+(g+1);w?(m+="<span style='border-bottom: dotted 1px #aaa;' title='"+N.q.replace(/'/g,"'")+"'>"+Q+".</span> <span style='color:#366c20'>"+i.correct+"</span><br/>",d++):m+="<span style='border-bottom: dotted 1px #aaa;' title='"+N.q.replace(/'/g,"'")+"'>"+Q+".</span> <span style='color:#7a1818'>"+i.incorrect+"</span><br/>"}for(g=0;g<E.length;g++)E[g].weighting=Math.round(1e3*n.options.totalScore/I)/1e3;var Y,J=n.action;if(n.options.totalScore&&I&&(Y=Math.round(10*n.options.totalScore*C/I)/10),"selfAnswer"==J||"selfAnswerReport"==J){var X="";"ar"==n.options.language&&(X=' direction="rtl"');A="";if(i.scoreWeight){if(null!=Y){var G="";n.options.passScore&&(Y>=n.options.passScore||Y==n.options.totalScore?G+=i.pass:G+=i.fail),G&&(G+=". "),A+="<h3"+X+">"+(G||"")+i.scoreWeight.replace("[score]",Y).replace("[total]",n.options.totalScore)+"</h3>"}A+="<p"+X+">"+i.score.replace("[correct]",d).replace("[total]",u)+"</p>"}else A="You scored "+d+" question(s) out of "+u;"selfAnswerReport"==J&&(A="<p"+X+"><strong>"+A+"</strong></p><p><strong>"+(i.details?i.details:"Details")+"</strong></p><p class='kbAlertScroll'>"+m+"</p>"),kInteractive.alert({content:A}),ue()}if("email"==J||n.options.reportEmail||n.options.emailForm){var $="selfAnswer"!=J&&"selfAnswerReport"!=J&&"email"!=J;try{if(!config.kotobee.cloudid)return void($&&kInteractive.alert({content:a.cloudOnly,title:i.sorry?i.sorry:"Sorry"}))}catch(e){return void($&&kInteractive.alert({content:a.cloudOnly,title:i.sorry?i.sorry:"Sorry"}))}var Z={};Z.ans=new Array;for(B=0;B<l.length;B++)for(h=l[B].getElementsByClassName("ans"),g=0;g<h.length;g++)h[g].checked&&Z.ans.push({q:B,index:g,label:h[g].nextSibling.textContent||h[g].nextSibling.data});Z.title=s;var ee={};if(ee.recipient=n.address,n.options.reportEmail&&(ee.recipient=n.options.reportEmail),ee.content=JSON.stringify(Z),ee.mode=config.kotobee.mode,ee.cloudid=config.kotobee.cloudid,ee.email=config.kotobee.email?config.kotobee.email:angular.element(document.body).scope().data.user.email,n.options.emailForm){var te=document.getElementsByName("recipientEmail");te.length&&(ee.recipient=ee.recipient?ee.recipient+","+te[0].value:te[0].value)}var ne=t.value;t.value=i.submitting?i.submitting:"Submitting ..",t.setAttribute("disabled","true");var ae=new XMLHttpRequest;ae.onreadystatechange=function(){try{if(4===ae.readyState&&200===ae.status){if(t.value=ne,t.removeAttribute("disabled"),!$)return;JSON.parse(ae.responseText).success?kInteractive.alert({content:i.submitted?i.submitted:"Answers submitted!"}):kInteractive.alert({content:i.errorSubmitting?i.errorSubmitting:"An error has occurred while sending answers to the server"})}}catch(e){if(t.value=ne,t.setAttribute("value",t.value),t.removeAttribute("disabled"),!$)return;kInteractive.alert({content:i.errorSubmitting?i.errorSubmitting:"An error has occurred while sending answers to the server"})}};var ie=config.kotobee.liburl?config.kotobee.liburl:"http://www.kotobee.com/";ie+="library/report/questions",ae.open("POST",ie),ae.setRequestHeader("Content-type","application/x-www-form-urlencoded");var re="a=a";for(var oe in ee){var se;null!=(se=ee[oe])&&"object"!=typeof se&&("string"==typeof se&&(se=encodeURIComponent(se)),"boolean"==typeof se&&(se=se?1:0),re+="&"+oe+"="+se)}ae.send(re),ue()}document[p.id]||(document[p.id]={}),document[p.id].q=[];var ce=p.getElementsByClassName("ques");for(B=0;B<ce.length;B++){var de=B;n.options.randomize&&(de=Number(ce[B].getAttribute("data-o"))),document[p.id].q[de]=[];var le=ce[B].getElementsByClassName("ans");for(g=0;g<le.length;g++)kInteractive.hasClass(le[g],"txtfield")?document[p.id].q[de][g]=le[g].value:le[g].type&&"checkbox"==le[g].type.toLowerCase()?document[p.id].q[de][g]=le[g].checked:le[g].type&&"radio"==le[g].type.toLowerCase()?document[p.id].q[de][g]=le[g].checked:kInteractive.c.hasClass(le[g].parentNode,"dCategory")&&(document[p.id].q[de][g]={id:le[g].id,category:kInteractive.getChildIndex(le[g].parentNode)})}kInteractive.scorm&&setTimeout(function(){kInteractive.scorm.setInteractions(E)},500)}}function ue(){var e="Questions: "+s+". Score: "+d+" questions out of "+u;e+=". Action: "+J,"selfAnswerReport"==J&&(e+=". Details: "+m),kInteractive.tinCan({verb:"solved",activity:e})}}},kInteractive.threed={preRender:function(e,t){},postRender:function(e,t,n,a){var i=e.createDocumentFragment(),r=kInteractive.readData(t);if(r){t.innerHTML="";var o=t.getAttribute("style");if(r.inter.placeholderPath)o+="background-image:url('"+("undefined"==typeof isKotobee?r.inter.placeholderPath:ph.join(kInteractive.absoluteURL,r.inter.placeholderPath))+"');";t.setAttribute("style",o);var s=document.createElement("a");r.inter.includeMsg?(s.innerHTML=kInteractive.escapeHtml(r.inter.msg),s.className="msgBtn ki-btn"):s.className="invisibleBtn ki-btn",i.appendChild(s),"undefined"==typeof isKotobee&&s&&s.addEventListener("click",kInteractive.actionEvent),t.appendChild(i)}},action:function(a,e,t){var f=kInteractive.readData(a);if(f){"inPanel"==f.inter.target?kInteractive.c.addClass(a,"running"):a.innerHTML="";var g=document.createElement("div");if(g.className="loading",a.appendChild(g),"undefined"==typeof THREE){var n,i=document.getElementsByTagName("head")[0],r=i.getElementsByTagName("script");if("undefined"!=typeof isKotobee)n=bookPath+"EPUB/js/kotobeeInteractive3D.js";else for(var o=0;o<r.length;o++)if(0<=r[o].src.indexOf("kotobeeinteractive.js")){n=r[o].src.replace("kotobeeinteractive.js","kotobeeinteractive3D.js");break}if(!n)return;var s=document.createElement("script");s.type="text/javascript",s.src=n,s.onload=c,s.onreadystatechange=function(){"complete"==this.readyState&&c()},i.appendChild(s)}else c()}function c(){var h,e=a;if("inPanel"==f.inter.target){var t={class:"threed",cb:function(e){var t=document.createElement("div");t.className="container",e.appendChild(t),n(t)},closed:function(){kInteractive.c.removeClass(a,"running")}};kInteractive.openFrame(t)}else n(e);function n(t){var n;kInteractive.scorm&&setTimeout(function(){var e={};e.id=kInteractive.getScormId("_3D",f.name?f.name:"Model"),e.description="Opened 3D model: "+(f.name?f.name:"No name"),e.learnerResponses="Viewed",e.type="other",e.timestamp=new Date,kInteractive.scorm.setInteractions([e])},800),h&&cancelAnimationFrame(h),n=function(){try{var e=document.createElement("canvas");return!(!window.WebGLRenderingContext||!e.getContext("webgl")&&!e.getContext("experimental-webgl"))}catch(e){return!1}}()?new THREE.WebGLRenderer({precision:"highp"}):new THREE.CanvasRenderer;var e=t.offsetWidth,a=t.offsetHeight,i=new THREE.PerspectiveCamera(f.camera.viewAngle,e/a,f.camera.near,f.camera.far),c=new THREE.Scene;null!=f.scene.bgColor&&n.setClearColor(f.scene.bgColor,1),c.add(i),i.position.x=f.camera.x,i.position.y=f.camera.y,i.position.z=f.camera.z,n.setSize(e,a),f.scene.floor&&(floor=new THREE.Mesh(new THREE.PlaneGeometry(500,500,1,1),new THREE.MeshPhongMaterial({color:f.scene.floorColor?f.scene.floorColor:10066329})),floor.applyMatrix((new THREE.Matrix4).makeRotationX(-Math.PI/2)),floor.position.y=-80,floor.receiveShadow=!0,c.add(floor));var d=new THREE.LoadingManager;d.onProgress=function(e,t,n){},function r(o){if(!(o>=f.objects.length)){var s=f.objects[o],e="undefined"==typeof isKotobee?s.path:ph.join(kInteractive.absoluteURL,s.path);new THREE.OBJLoader(d).load(e,function(i){g&&g.parentNode&&g.parentNode.removeChild(g),n.domElement.parentNode||t.appendChild(n.domElement),i.position.set(s.x,s.y,s.z),i.traverse(function(n){if(n instanceof THREE.Mesh){var a=n==i.children[i.children.length-1];if(s.textPath){var e=new THREE.ImageLoader(d),t="undefined"==typeof isKotobee?s.textPath:ph.join(kInteractive.absoluteURL,s.textPath);e.load(t,function(e){var t=new THREE.Texture;t.image=e,t.needsUpdate=!0,n.material.map=t,a&&c.add(i),r(++o)},function(){},function(e){})}else a&&c.add(i),r(++o)}})},function(e){e.lengthComputable&&(e.loaded,e.total)},function(e){})}}(0),new THREE.OrbitControls(i,n.domElement).target=new THREE.Vector3(0,0,0);for(var r=0;r<f.lights.length;r++)if("pointLight"==f.lights[r].type){var o=new THREE.PointLight(f.lights[r].color);o.position.set(f.lights[r].x,f.lights[r].y,f.lights[r].z),c.add(o)}else if("directionalLight"==f.lights[r].type){var s=new THREE.DirectionalLight(f.lights[r].color,f.lights[r].intensity);s.position.set(f.lights[r].x,f.lights[r].y,f.lights[r].z),c.add(s)}else if("hemisphereLight"==f.lights[r].type){var l=new THREE.HemisphereLight(f.lights[r].sky,f.lights[r].ground,f.lights[r].intensity);l.position.set(f.lights[r].x,f.lights[r].y,f.lights[r].z),c.add(l)}else if("spotLight"==f.lights[r].type){var u=new THREE.SpotLight(f.lights[r].color,f.lights[r].intensity,f.lights[r].distance,f.lights[r].angle,f.lights[r].exponent,f.lights[r].decay);u.position.set(f.lights[r].x,f.lights[r].y,f.lights[r].z),c.add(u)}else if("ambientLight"==f.lights[r].type){var m=new THREE.AmbientLight(f.lights[r].color);c.add(m)}else if("areaLight"==f.lights[r].type){var p=new THREE.AreaLight(f.lights[r].color,f.lights[r].intensity);c.add(p)}var v=new THREE.Clock;!function e(){try{n.render(c,i)}catch(e){return}v.getDelta();h=requestAnimFrame(e)}()}}}},kInteractive.video={preRender:function(e,t){},postRender:function(e,t,n){var a=e.createDocumentFragment(),i=kInteractive.readData(t);if(i){var r="";if(i.splash&&(r="undefined"==typeof isKotobee?i.splash:ph.join(kInteractive.absoluteURL,i.splash)),r){t.style.backgroundImage=null;var o=t.style.cssText;t.setAttribute("style","background-image:url('"+r+"');"+o)}t.setAttribute("id","ki-video-"+n),t.innerHTML="";var s=document.createElement("div");s.setAttribute("id","ki-video-"+n+"-container"),s.className="container";var c=document.createElement("div");i.style&&kInteractive.c.addClass(c,i.style);var d=document.createElement("a");d.className="playBtn ki-btn",d.appendChild(document.createElement("span")),"undefined"==typeof isKotobee&&d.addEventListener("click",kInteractive.actionEvent),a.appendChild(d),a.appendChild(s),c.appendChild(a),t.appendChild(c),i.autoplay&&kInteractive.action(t)}},action:function(r){var o=kInteractive.readData(r);if(o){var e=r.getAttribute("id")+"-container",s=r.getElementsByClassName("playBtn")[0];if(!(0<=s.className.indexOf("loading"))){if(kInteractive.stopCurrentMedia(),s.className="playBtn ki-btn loading",o.autoplay&&(s.className="playBtn ki-btn hide"),kInteractive.scorm){var t={};t.id=kInteractive.getScormId(r.getAttribute("id"),o.src),t.description="Played video: "+o.src,t.type="other",t.learnerResponses="Played",t.objective=o.options?o.options.objective:null,t.timestamp=new Date,kInteractive.scorm.setInteractions([t])}if("file"==o.type){l("undefined"==typeof isKotobee?o.video:ph.join(kInteractive.absoluteURL,o.video))}else{var n,a=new URL(o.src);if(a.origin.includes("youtube.com")||a.origin.includes("youtu.be")){if(!(n=a.origin.includes("youtube.com")?a.searchParams.get("v"):a.pathname.split("/")[1]))return;if(window&&window.iBooks)return setTimeout(function(){s.className="playBtn ki-btn"},1500),void(window.location.href=o.src);var i={videoId:n,playerVars:{autoplay:1,rel:"0"},events:{onReady:function(){},onStateChange:function(e){e.data==YT.PlayerState.PLAYING&&kInteractive.tinCan({verb:"played",activity:"Video: "+o.src})}}};if(kInteractive.youTubeStatus)if("loading"==kInteractive.youTubeStatus){if(kInteractive.vQueue)return;kInteractive.vQueue=function(){s.className="playBtn ki-btn hide",new YT.Player(e,i)}}else"ready"==kInteractive.youTubeStatus&&(s.className="playBtn ki-btn hide",new YT.Player(e,i));else{window.onYouTubePlayerAPIReady=function(){kInteractive.youTubeStatus="ready",kInteractive.vQueue(),kInteractive.vQueue=null};var c=document.createElement("script");c.src="https://www.youtube.com/player_api";var d=document.getElementsByTagName("script")[0];d.parentNode.insertBefore(c,d),kInteractive.youTubeStatus="loading",kInteractive.vQueue=function(){s.className="playBtn ki-btn hide",new YT.Player(e,i)}}}else l(o.src)}kInteractive.currentVideo=r,kInteractive.c.addClass(kInteractive.currentVideo,"playing")}}function l(e){var t,n=document.createElement("video");n.setAttribute("width","100%"),n.setAttribute("height","100%"),n.setAttribute("src",e),n.setAttribute("autoplay","true"),n.setAttribute("data-tap-disabled","false"),0!=e.indexOf("http://")&&0!=e.indexOf("https://")||(t=!0),t&&n.setAttribute("crossorigin","anonymous");var a=!1;try{a=-1<navigator.userAgent.toLowerCase().indexOf("android")}catch(e){}a||n.setAttribute("type","video/mp4"),n.setAttribute("webkit-playsinline","true"),n.setAttribute("controls","true"),n.className="ki-noHighlight",o.hideDownloadBtn&&(n.className+=" hideDownloadBtn"),n.innerHTML="Your browser doesn't support HTML5 video.",t&&(n.crossOrigin="anonymous"),n.oncanplay=function(){kInteractive.currentVideo==r&&(s.className="playBtn ki-btn hide",kInteractive.tinCan({verb:"played",activity:"Video: "+e}))},n.addEventListener("error",function(e){kInteractive.stopCurrentMedia()}),n.addEventListener("webkitfullscreenchange",function(e){var t=null!==document.webkitFullscreenElement;kInteractive.videoIsFullscreen=t});var i=r.getElementsByClassName("container")[0];i.setAttribute("data-tap-disabled","true"),i.appendChild(n)}},resize:function(e){var t=kInteractive.readData(e);t&&(kInteractive.checkResponsiveFloat(t,e),t.maintainRatio&&"px"==t.widthUnit&&t.height&&t.width&&(e.style.height=e.offsetWidth*(t.height/t.width)+"px"))}},kInteractive.widget={preRender:function(e,t){},postRender:function(e,t,n,a){a=a||{};var i=e.createDocumentFragment(),r=kInteractive.readData(t);if(r){var o=r.name,s=(r.src,r.width),c=r.height;if("page"==r.mode){if(t.children.length)return;var d=document.createElement("div");d.className="cover",i.appendChild(d),r.interaction&&(d.style.pointerEvents="none");var l=document.createElement("div");l.className="iframeContainer";var u=document.createElement("iframe");if(u.setAttribute("nwdisable","true"),u.setAttribute("nwfaketop","true"),u.setAttribute("sandbox","allow-same-origin allow-scripts allow-forms allow-modals"),u.setAttribute("width",t.style.width?t.style.width:s+r.widthUnit),u.setAttribute("height",t.style.height?t.style.height:c+"px"),u.src=kInteractive.getWidgetUrl(r,a),"undefined"!=typeof kotobee&&-1!==u.src.indexOf(".amazonaws.com")){var m=document.createElement("a");m.href=u.src,u.addEventListener("load",function(e){e.target.contentWindow.postMessage({user:{name:kotobee.user.name?kotobee.user.name:"",email:kotobee.user.email?kotobee.user.email:"",loggedIn:kotobee.user.loggedIn},book:kotobee.book.meta.dc.identifier,chapter:kotobee.currentChapter.url.split("EPUB/xhtml/")[1]},m.protocol+"//"+m.hostname)})}l.appendChild(u),i.appendChild(l);var p=t.style.width,v=t.style.height;0<=p.indexOf("px")&&(r.widthUnit="px"),0<=p.indexOf("%")&&(r.widthUnit="%");try{r.widthUnit?r.width=Number(p.split(r.widthUnit)[0]):r.width=Number(p)}catch(e){r.width=Number(p)}try{r.height=Number(v.split("px")[0])}catch(e){r.height=Number(v)}kInteractive.writeData(t,r)}else{if(!t.children.length&&!t.innerHTML.trim()){var h=document.createElement("img");h.src=kInteractive.getWidgetHome(r,a)+"/"+o+"/Icon.png?c="+Math.round(9999*Math.random()),h.className="wdgtIcon",i.appendChild(h)}"undefined"==typeof isKotobee&&t.addEventListener("click",kInteractive.actionEvent)}t.appendChild(i)}},action:function(e){var t=kInteractive.readData(e);if(t){var n=kInteractive.getWidgetUrl(t),a=document.createElement("iframe");a.setAttribute("nwdisable","true"),a.setAttribute("nwfaketop","true"),a.setAttribute("sandbox","allow-same-origin allow-scripts allow-forms allow-modals"),t.cb=function(e){a.src=n,e.appendChild(a)},t.cb1="yes",t.closed=function(){},t.responsive&&(t.width=t.height=null),kInteractive.openFrame(t),kInteractive.tinCan({verb:"opened",activity:"Widget: "+t.name}),kInteractive.scorm&&setTimeout(function(){var e={};e.id=kInteractive.getScormId("widget",t.name),e.description="Opened popup widget: "+t.name,e.learnerResponses="Opened",e.type="other",e.timestamp=new Date,kInteractive.scorm.setInteractions([e])},800)}},resize:function(e){var t=kInteractive.readData(e);if(t&&"page"==t.mode&&"px"==t.widthUnit){var n=t.width,a=t.height,i=e.parentNode;if(i)if(n>i.offsetWidth){var r=i.offsetWidth/n,o=e.children.length-1;e.children[o].style.transform=e.children[o].style.webkitTransform=e.children[o].style.mozTransform="scale("+r+")",e.children[o].style.transformOrigin=e.children[o].style.webkitTransformOrigin=e.children[o].style.mozTransformOrigin="0 0",e.style.maxWidth=e.style.width,e.style.height=Math.round(a*r)+"px"}else{for(o=0;o<e.children.length;o++)e.children[o].style.transform=e.children[o].style.webkitTransform=e.children[o].style.mozTransform=e.children[o].style.transformOrigin=e.children[o].style.webkitTransformOrigin=e.children[o].style.mozTransformOrigin=null;e.style.maxWidth=null,e.style.height=a+"px"}}}};