/* Parchment ========= Built: 2013-04-18 Copyright (c) 2008-2013 The Parchment Contributors BSD licenced https://github.com/curiousdannii/parchment */ (function(){"use strict";var t,e,n=0,r=/xyz/.test(function(){})?/\b_super\b/:/.*/;for(e in{toString:1})t=1;Object.subClass=function(e){var i,o,s,a=this.prototype,c=!/native code/.test(""+e.toString)&&e.toString,h=function(t,e){return function(){var n,r=this._super;return this._super=a[t],n=e.apply(this,arguments),this._super=r,n}};n=1,i=new this,n=0;for(o in e)i[o]="function"==typeof e[o]&&"function"==typeof a[o]&&r.test(e[o])?h(o,e[o]):e[o];return!t&&c&&(i.toString=r.test(c)?h("toString",c):c),s=i.init?function(){n||this.init.apply(this,arguments)}:function(){},s.prototype=i,s.constructor=s,s.subClass=Object.subClass,s},window.Class=Object})(),function(){function t(t,e){return t[e]<<24|t[e+1]<<16|t[e+2]<<8|t[e+3]}function e(t){return[255&t>>24,255&t>>16,255&t>>8,255&t]}function n(t,e){return String.fromCharCode(t[e],t[e+1],t[e+2],t[e+3])}function r(t){return[t.charCodeAt(0),t.charCodeAt(1),t.charCodeAt(2),t.charCodeAt(3)]}var i=Object.subClass({init:function(e){if(this.type="",this.chunks=[],e){if("FORM"!=n(e,0))throw Error("Not an IFF file");this.type=n(e,8);for(var r=12,i=e.length;i>r;){var o=t(e,r+4);if(0>o||o+r>i)throw Error("IFF: Chunk out of range");this.chunks.push({type:n(e,r),offset:r,data:e.slice(r+8,r+8+o)}),r+=8+o,o%2&&r++}}},write:function(){for(var t=r(this.type),n=0,i=this.chunks.length;i>n;n++){var o=this.chunks[n],s=o.data,a=s.length;t=t.concat(r(o.type),e(a),s),a%2&&t.push(0)}return r("FORM").concat(e(t.length),t)}});i.num_from=t,i.num_to_word=e,i.text_from=n,i.text_to_word=r,window.IFF=i}();var extend=function(t,e){for(var n in e)t[n]=e[n];return t},rBadBackground=/inh|tra|(\d+, ?){3}0/,$window=$(window),$doc=$(document),$body,bodylineheight;$(function(){$body=$("body");var t=$(" ").appendTo($body);bodylineheight=t.height(),t.remove()}),extend($.cssHooks,{bgcolor:{get:function(t){var e=$(t),n=e.css("background-color");return rBadBackground.test(n)?e.parent().css("bgcolor"):n},set:function(t,e){var n=$(t),r=n.parent();n.css("background-color",e),rBadBackground.test(r.css("background-color"))&&r.css("bgcolor",e)}}});var scrollPages=window.scrollByPages||function(t){var e=document.documentElement.clientHeight,n=e-Math.min(e/10,2*bodylineheight);scrollBy(0,n*t)},selection=window.getSelection||function(){return document.selection?document.selection.createRange().text:""},TextInput=Object.subClass({init:function(t){var e=this,n=$("",{"class":"TextInput",autocapitalize:"off",keydown:function(t){var n,r=e.keyCode=t.which;if("line"==e.mode)return 38==r&&(e.prev_next(1),n=1),40==r&&(e.prev_next(-1),n=1),33==r&&(scrollPages(-1),n=1),34==r&&(scrollPages(1),n=1),13==r&&(e.submitLine(),n=1),t.stopPropagation(),n?!1:void 0},keypress:function(t){return"char"==e.mode?(e.charCode=t.which,e.submitChar(),!1):void 0},keyup:function(){"char"==e.mode&&e.submitChar()}});e.lastinput=$('').appendTo(t),$doc.on("click.TextInput keydown.TextInput",function(t){if("INPUT"!=t.target.nodeName&&""==selection())if($window.scrollTop()+$window.height()-n.offset().top>-60)window.scrollTo(0,9e9),t.target=n[0],n.focus().trigger(t),t.stopPropagation();else if("keydown"==t.type&&8==t.which)return!1}),e.history=[],e.input=n,e.container=t,e.statuswin=$("
"),e.scrollParent=$.browser.webkit?$body:$("html")},die:function(){$doc.off(".TextInput")},scroll:function(){this.scrollParent.scrollTop(this.lastinput.offset().top-this.statuswin.height()-bodylineheight)},getLine:function(t){var e,n=t.target.children().last(),r=this.input;this.order=t,this.mode="line",this.current=0,this.mutable_history=this.history.slice(),this.mutable_history.unshift(""),e=/^([\s\S]+
)(.+?)$/.exec(n.html()),e?(n.html(e[1]),e=n.clone().html(e[2]).appendTo(n)):e=n,r.width(20).val("").appendTo(e).width(t.target.offset().left+t.target.width()-r.offset().left),this.scroll()},submitLine:function(){var t=this.input.val();this.lastinput.appendTo(this.input.parent()),this.input.detach(),t!=this.history[0]&&/\S/.test(t)&&this.history.unshift(t),$doc.trigger({type:"TextInput",mode:"line",input:t}),this.mode=0,this.order.response=t,this.order.terminator=13,this.callback(this.order)},prev_next:function(t){var e=this.input,n=this.mutable_history,r=this.current,i=r+t;n.length>i&&i>=0&&(n[r]=e.val(),e.val(n[i]),this.current=i)},getChar:function(t){this.order=t,this.mode="char",this.keyCode=this.charCode=0,this.input.addClass("CharInput").appendTo(this.container),this.scroll()},submitChar:function(){var t=this.keyCode,e=this.charCode,n={keyCode:t,charCode:e};(t||e)&&(this.input.detach().removeClass("CharInput"),$doc.trigger({type:"TextInput",mode:"char",input:n}),this.mode=0,this.order.response=n,this.callback(this.order))}}),TextGrid=Object.subClass({init:function(t,e){var n=this;this.elem=t.addClass("TextGrid").on("stream",function(t){return n.stream(t.order.data),!1}).css("bgcolor","inherit"),this.lineheight=e.env.charheight,this.io=e,e.TextInput.statuswin=this.elem,this.lines=[],this.styles=[],this.cursor=[0,0]},stream:function(t){var e,n,r,i,o,s,a,c=this.elem,h=this.cursor[0],l=this.cursor[1],u=this.lines,d=this.styles,p=this.io.env,f=u.length;for(r=0;t.length>r;r++){if(e=t[r],n=e.code,"height"==n){for(;e.lines>u.length;)this.addline();if(e.lines").addClass("box").prependTo(this.io.target),window.scrollTo(0,9e9),s.css({top:$window.scrollTop()+this.lineheight*e.lines,left:s.offset().left-1}),this.write(s,u.slice(e.lines),d.slice(e.lines))}u.length=e.lines,d.length=e.lines,h>e.lines-1&&(h=0,l=0)}}if("clear"==n){for(i=0;u.length>i;)this.addline(i++);h=0,l=0}if("cursor"==n)for(h=e.to[0],l=e.to[1],0>h&&(h=0),0>l&&(l=0);h>=u.length;)this.addline();if("get_cursor"==n&&(e.pos=[h,l],this.io.input(e)),"stream"==n){for(;h>=u.length;)this.addline();for(a=void 0,e.css&&(a=$("").appendTo(c).css(e.css).attr("style"),a&&(a=' style="'+a+'"')),o=e.text,i=0;o.length>i;)s=o.charAt(i++),"\r"!=s&&(u[h][l]=s,d[h][l++]=a),("\r"==s||l==p.width)&&(h++,l=0,h>=u.length&&o.length>i&&this.addline())}if("eraseline"==n)for(i=l;p.width>i;i++)u[h][i]=" ",d[h][i]=void 0}this.cursor=[h,l],this.write(c,u,d),u.length!=f&&$(".main").css("padding-top",c.height())},write:function(t,e,n){for(var r,i,o,s="",a=0;e.length>a;){for(i="",o=n[a][0],r=0;e[a].length>r;r++)n[a][r]==o?i+=e[a][r]:(s+=""+i+"",o=n[a][r],i=e[a][r]);s+=""+i+"",++a")}t.html(s)},addline:function(t){var e=this.io.env.width,n=[],r=0;for(t=t||this.lines.length;e>r++;)n.push(" ");this.lines[t]=n,this.styles[t]=Array(e)}}),basic_stream_handler=function(t){var e=t.order,n=t.io.structures[e.name]||{node:"span"},r=e.node||n.node,i=e.text,o=$("<"+r+">").appendTo(t.target).addClass(e.name).css(e.css||{}).text(i?i.replace(/\r/g,"\n"):"");return n.func&&n.func(o,t.io),!1};StructIO=Object.subClass({init:function(t){t=extend({},t),this.env=t;var e=$(t.container),n=$("00000").appendTo(e),r=n.height(),i=n.width()/5,o=Math.min(Math.floor(e.width()/i),t.width||80);n.remove(),extend(t,{charheight:r,charwidth:i,width:o,fgcolour:e.css("color"),bgcolour:e.css("bgcolor")}),e.width(o*i+2),this.container=e,this.target=e,e.on("stream",basic_stream_handler),this.TextInput=new TextInput(e),this.structures={main:{node:"div"},status:{node:"div",func:function(t,e){new TextGrid(t,e)}}}},event:function(t){var e,n,r,i,o=this.target,s=this.TextInput;for(r=0;t.length>r;r++){if(e=t[r],n=e.code,"structures"==n&&(e.code=void 0,$.extend(this.structures,e)),"find"==n&&(this.target=o=$("."+e.name)),"stream"==n&&(e.to?$("."+e.to):o).trigger({type:"stream",io:this,order:e}),"clear"==n){var i=e.name?$("."+e.name):o;i.empty(),e.css&&e.css["background-color"]&&("main"==e.name?$body:i).css("background-color",e.css["background-color"])}"read"==n&&(e.target=o,s.getLine(e)),"char"==n&&s.getChar(e),"quit"==n&&s.scroll()}}}),function(t){t.StructIO=StructIO,StructIO.TextInput=TextInput}(window,jQuery);var Runner=Object.subClass({init:function(t,e){var n=this;e=window.engine=this.e=new window[e],this.io=new StructIO(t),this.toEngine=this.io.TextInput.callback=function(t){e.inputEvent(t)},e.outputEvent=function(t){n.fromEngine(t)}},fromParchment:function(t){var e=t.code;"load"==e&&(t.env=this.io.env),this.toEngine(t)},fromEngine:function(t){var e,n,r,i=(this.e,0);for(this.io.event(t);t.length>i;i++){if(e=t[i],n=e.code,"quit"==n)return;("save"==n||"restore"==n)&&this.toParchment(e),"restart"==n&&(this.io.target=this.io.container.empty(),r=1),"tick"==n&&(r=1)}r&&this.toEngine(e)}});(function(t,e){"use strict";jQuery.ajaxSetup({cache:1,converters:{"* binary":!0}}),jQuery.ajaxPrefilter("script",function(t){t.isLocal&&(t.crossDomain=1)});var n={options:{container:"#parchment",lib_path:"lib/",page_title:1,panels:["search","url","about"],proxy_url:"http://zcode.appspot.com/proxy/"},lib:{}},r=function(t){var e,n=0,r={};for(""==t[0]&&n++;t.length>n;)e=/([^=]+)(=(.*))?/.exec(t[n++]),r[e[1]]=e[3]?unescape(e[3]):!0;return r}(location.search.slice(1).split(/[&;]/g));(function(e){t.FatalError=function(t){this.message=t,this.traceback=this._makeTraceback(arguments.callee),this.onError(this),e(".load").length>0&&e(".load").detach()},FatalError.prototype={onError:function(n){var r=n.message;e("#parchment").append('
An error occurred:
'+r+"\n\n"+n.traceback+"
"),t.console&&console.error(r)},_makeTraceback:function(t){for(var e="",n=0,r=100;null!=t&&r>n;){var i=""+t;if(i){var o=i.match(/function (\w*)/);e=o&&o[1]?"\n "+o[1]+e:"\n (anonymous function)"+e}else e="\n (anonymous function)"+e;try{t=t.caller}catch(s){t=null}n++}return n==r&&(e="..."+e),"Traceback (most recent call last):\n"+e}}})(jQuery),function(t,e){function r(t,n){e.ajax(t,{dataType:"binary"}).success(function(t,e,r){n(r.responseArray)})}t.execScript&&execScript("Function VBCStr(x)\nVBCStr=CStr(x)\nEnd Function\nFunction VBLastAsc(x)\nDim l\nl=LenB(x)\nIf l mod 2 Then\nVBLastAsc=AscB(MidB(x,l,1))\nElse\nVBLastAsc=-1\nEnd If\nEnd Function","VBScript");var i=/chrome\/(\d+)/i.exec(navigator.userAgent),o=i&&parseInt(i[1])>4,s=function(t,e){var n,e=e||[],r=0;for(n=t.length%8;n>r;++r)e.push(255&t.charCodeAt(r));for(n=t.length;n>r;)e.push(255&t.charCodeAt(r++),255&t.charCodeAt(r++),255&t.charCodeAt(r++),255&t.charCodeAt(r++),255&t.charCodeAt(r++),255&t.charCodeAt(r++),255&t.charCodeAt(r++),255&t.charCodeAt(r++));return e},a=function(t,e){return(e||"")+String.fromCharCode.apply(1,t)},c="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",h=function(){for(var t=[],e=0;c.length>e;e++)t[c.charAt(e)]=e;return t}(),l=function(e,n){if(t.atob)return s(atob(e),n);for(var r,i,o,a,c,l,u,n=n||[],d=0,p=e.length;p>d;)a=h[e.charAt(d++)],c=h[e.charAt(d++)],l=h[e.charAt(d++)],u=h[e.charAt(d++)],r=(a<<2)+(c>>4),i=((15&c)<<4)+(l>>2),o=((3&l)<<6)+u,n.push(r,i,o);return 64==u&&n.pop(),64==l&&n.pop(),n},u=function(e,n){if(t.btoa)return btoa(a(e,n));for(var r,i,o,s,h,l,u,n=n||"",d=0,p=e.length;p>d;)r=e[d++],i=e[d++],o=e[d++],s=r>>2,h=((3&r)<<4)+(i>>4),l=((15&i)<<2)+(o>>6),u=63&o,n+=c.charAt(s)+c.charAt(h)+c.charAt(l)+c.charAt(u);return isNaN(i)?n=n.slice(0,-2)+"==":isNaN(o)&&(n=n.slice(0,-1)+"="),n},d=function(t){for(var e,n=VBCStr(t),r=VBLastAsc(t),i=[],o=0,s=n.length%4;s>o;)i.push(255&(e=n.charCodeAt(o++)),e>>8);for(s=n.length;s>o;)i.push(255&(e=n.charCodeAt(o++)),e>>8,255&(e=n.charCodeAt(o++)),e>>8,255&(e=n.charCodeAt(o++)),e>>8,255&(e=n.charCodeAt(o++)),e>>8);return r>-1&&i.push(r),i},p=jQuery.ajaxSettings.xhr(),f={binary:!p.overrideMimeType||e.browser.opera&&10.5>parseFloat(e.browser.version)?"responseBody"in p?"responseBody":0:"charset"},m=function(n,r,i){var o,a;n=e.trim(n),"base64"==i.mode?t.atob?(a=atob(n),o=s(a)):o=l(n):o="charset"==i.mode?s(n):d(i.xhr.responseBody),i.responseArray=o,i.responseText=a};p=void 0,e.ajaxPrefilter("binary",function(t,r,i){var s=t.isLocal&&!t.crossDomain&&o?0:f.binary,a=t.xhr;return t.xhr=function(){return i.xhr=a.apply(t)},t.binary=s,i.done(m),t.jsonp=!1,t.jsonpCallback="processBase64Zcode",i.mode="base64",".js"==t.url.slice(-3).toLowerCase()?"jsonp":s&&!t.crossDomain?"text":t.legacy?(t.url=t.legacy,"jsonp"):(t.data="url="+t.url,t.url=n.options.proxy_url,s&&e.support.cors?"text":(t.data+="&encode=base64&callback=pproxy",t.jsonpCallback="pproxy","jsonp"))}),e.ajaxPrefilter("text",function(t,e,n){n.mode=t.binary,"charset"==n.mode&&(t.mimeType="text/plain; charset=x-user-defined")}),t.file={text_to_array:s,array_to_text:a,base64_decode:l,base64_encode:u,support:f},t.file.download_to_array=r}(t,jQuery),function(t){var e='

'+t.desc+"

"};n.lib.UI=Object.subClass({init:function(e){this.library=e,this.panels={},this.load_indicator=t('

Parchment is loading.

> _

')},stylesheet_add:function(){var e,n=arguments;for(e=1;n.length>e;e++)document.createStyleSheet?document.createStyleSheet(n[e]):t("",{rel:"alternate stylesheet",href:n[e],title:n[0],type:"text/css"}).appendTo("head")[0].disabled=!0},stylesheet_switch:function(e,n){t('link[rel*="stylesheet"][title="'+e+'"]').each(function(){this.disabled=!n})},load_panels:function(){var e,i,o,s=n.options.panels,a=function(){var n=RegExp(i.val().replace(" ","( )?"),"i"),s=t.grep(e,function(t){return n.test(t.path+t.desc)});s=s.slice(0,30),o.html(t.map(s,r).join(""))};-1!=t.inArray("search",s)&&(this.panels.search=t(''),i=this.panels.search.find("input"),o=i.next(),i.keydown(function(){i.unbind("keydown"),t.getJSON("stories/if-archive.json").done(function(t){e=t,i.keyup(a),a()})})),-1!=t.inArray("url",s)&&(this.panels.url=t('
')),this.library.container.append(this.panels[s[0]]),this.panels.active=s[0]}})}(jQuery),function(t,e){var i=/([-\w\s_]+)(\.[\w]+(\.js)?)?$/,o=/\.js$/,s=function(){throw new FatalError("Parchment could not load the story. Check your connection, and that the URL is correct.")},a=function(r){e(".load").detach();var i=t.runner=new(t[r[2].vm.runner]||Runner)(n.options,r[2].vm.engine),o=location.hash;i.toParchment=function(t){r[2].library.fromRunner(i,t)},i.fromParchment({code:"load",data:new n.lib.Story(r[2].responseArray).data}),o&&"#"!=o?i.fromParchment({code:"restore",data:file.base64_decode(o.slice(1))}):i.fromParchment({code:"restart"})};n.lib.Story=IFF.subClass({init:function(t,n){if(this.title=n,9>t[0])this._super(),this.chunks.push({type:"ZCOD",data:t}),this.data=t;else if("Glul"==IFF.text_from(t,0))this._super(),this.chunks.push({type:"GLUL",data:t}),this.data=t;else if("FORM"==IFF.text_from(t,0)&&(this._super(t),"IFRS"==this.type))for(var r=0,i=this.chunks.length;i>r;r++){var o=this.chunks[r].type;if("ZCOD"!=o||this.zcode)if("GLUL"!=o||this.glulx){if("IFmd"==o){this.metadata=file.array_to_text(this.chunks[r].data);var s=e(this.metadata);s&&(e("title",s)&&(this.title=e("title",s).text()),e("ifid",s)&&(this.ifid=e("ifid",s).text()),e("release",s)&&(this.release=e("release",s).text()))}}else this.data=this.chunks[r].data;else this.data=this.chunks[r].data}}});var c=Object.subClass({add:function(t){this[t.ifid]=t,t.url&&(this.url[t.url]=t)},url:{}}),h=Object.subClass({init:function(){this.container=e(n.options.container),this.ui=new n.lib.UI(this)},load:function(){var o,s,a=this,c=n.options,h=r.story,l=r.vm,u=0;if(c.lock_story){if(h=c.default_story,!h)throw new FatalError("Story file not specified")}else{if(!c.default_story&&!h)return this.ui.load_panels();h=h||c.default_story}if(e("#about").remove(),e("body").append(a.ui.load_indicator),e.isArray(h)||(h=[h,0]),s=h[0],a.url=s,o=i.exec(s),o=o?o[1]+" - Parchment":"Parchment",c.page_title&&(t.document.title=o),l)l=n.vms[l];else for(;n.vms.length>u;u++)if(n.vms[u].match.test(s)){l=n.vms[u];break}if(!l)throw new FatalError("File type is not supported!");try{this.launch(l,h)}catch(d){throw new FatalError(d)}},launch:function(t,r){var i=this,c=[e.ajax(r[0],{dataType:"binary",legacy:r[1]}).done(function(e,n,r){r.library=i,r.vm=t}).fail(s)],h=[e.Deferred()],l=function(){if(0==t.files.length)return h[0].resolve(),void 0;var r=n.options.lib_path+t.files.shift();o.test(r)?e.getScript(r,l):(n.library.ui.stylesheet_add(t.id,r),l())};t.loaded||(t.loaded=1,l(),c[1]=e.when.apply(1,h)),e.when.apply(1,c).done(a)},fromRunner:function(t,e){var n=e.code,r=location.hash;"save"==n&&(location.hash=file.base64_encode(e.data)),"restore"==n&&r&&"#"!=r&&(e.data=file.base64_decode(r.slice(1))),t.fromParchment(e)},stories:new c,savefiles:{}});n.lib.Library=h,n.vms=[],n.add_vm=function(t){n.vms.push(t),n.vms[t.id]=t}}(t,jQuery),n.add_vm({id:"quixe",match:/(ulx|glb|(g|glulx.+)(blorb|blb))(.js)?$/i,files:["prototype.min.js","glkote.min.js","quixe.min.js","glkote.min.css"],runner:"QuixeRunner"}),n.add_vm({id:"zvm",match:/(z[58]|zlb|(z|zcode.+)(blorb|blb))(.js)?$/i,files:["zvm.min.js"],engine:"ZVM"}),n.add_vm({id:"gnusto",match:/(z[1-8]|zlb|(z|zcode.+)(blorb|blb))(.js)?$/i,files:["gnusto.min.js"],runner:"GnustoRunner"}),e(function(){var i;t.parchment_options&&e.extend(n.options,parchment_options),!n.options.lock_options&&r.options&&e.extend(n.options,e.parseJSON(r.options)),n.options.debug=r.debug,i=new n.lib.Library,n.library=i,i.load(),-1!=location.href.indexOf("iplayif.com")&&e.getScript("http://google-analytics.com/ga.js",function(){_gat._getTracker("UA-7949545-3")._trackPageview()})})})(this,jQuery);