/*
 *  © 2000-2010 deviantART, Inc. All rights reserved.
 */
if(!window.AutoExec){AutoExec=[]}function Task(B,A){if(typeof B=="object"&&B.TASK instanceof Array){this.f=B.TASK[0];A=B.TASK[1];this.f_args=B.TASK.slice(2)}else{if(typeof B=="function"){this.f=B;this.f_args=Task.argSlice(arguments,2)}else{DRE.assert(arguments.length<=1);A=B}}this.owner=A||Task.master_owner;this.listeners=[];this.reset();this.clearHistory();this.history_limit=Task.DEFAULT_HISTORY_LIMIT;this.station_end=[this.wait_f,this]}Task.argSlice=function(B,D){var C,A;A=[];for(C=D||0;C<B.length;C++){A.push(B[C])}return A};Task.master_owner=Task;Task.DEFAULT_HISTORY_LIMIT=10;Task.big_red_button=function(A){DRE.warning("Failed task on default level: "+A);DRE.halt("Failed task")};Task.prototype={reset:function(){this.status={}},clearHistory:function(){this.history={}},listen:function(B,A){this.listeners.push({f:B,f_this:A,f_args:Task.argSlice(arguments,2)});this.cc_shout(this.listeners.length-1);return this.listeners.length-1},listenOnce:function(B,A){this.listeners.push({f:B,f_this:A,f_args:Task.argSlice(arguments,2),expires:true});this.cc_shout(this.listeners.length-1)},nullListen:function(A){this.listeners[A]=null},report:function(A,B){if(A!=undefined&&A!=null){this.status.progress=A}if(B!=undefined&&B!=null){this.status.eta=B}},milestone:function(A){if(A=="complete"){this.status.result=arguments[1]}this.status.milestone=A;if(!this.history[A]){this.history[A]=[]}else{if(this.history[A].length>this.history_limit){this.history[A].pop()}}this.history[A].unshift(Task.argSlice(arguments,1));this.cc_shout()},done:function(A){this.milestone("complete",A)},abort:function(A){(this.big_red_button||this.owner.big_red_button||Task.master_owner.big_red_button).call(this.owner,this,A);this.reset()},cbDiFi:function(B,A){if(this.owner&&this.owner._KP_dead){this.off();return }if(!B){return this.abort(A.response.content)}return this.done(A.response.content)},cbRawDiFi:function(B,A){if(!B){return this.abort(A)}return this.done(A)},wait:function(){var A;A=Task.argSlice(arguments,0);A.push([this.wait_f,this]);Task.station.apply(Task.station,A)},wait_f:function(){this.done.apply(this,Task.station.data)},waitB:function(){var A;A=Task.argSlice(arguments,0);A.push([this.waitB_f,this]);Task.station.apply(Task.station,A)},waitB_f:function(){this.done.apply(this,Task.station.data.reverse())},cc_shout:function(D){var B,C,A;if(this.status.milestone!=undefined){C=[this.status.milestone,this.history[this.status.milestone]].concat(this.history[this.status.milestone][0]);for(B=(D||0);B!=this.listeners.length;B++){A=this.listeners[B];if(!A){continue}if(A.expires==true){this.nullListen(B)}if(A.f instanceof Task){A.f.milestone.apply(A.f_this||A.f,C.concat(A.f_args))}else{if(A.f.TASK_filter){if(A.f.TASK_filter==this.status.milestone){A.f.apply(A.f_this,C.slice(1).concat(A.f_args))}}else{A.f.apply(A.f_this,C.concat(A.f_args))}}if(D!=undefined){break}}}},run:function(){var B,A;if(this.status.active===true){return 0}if(this.status.active==2){DRE.assert(this.needs);for(B=0;this.needs[B];B++){if("result" in this.needs[B].status){continue}return 0}this.f_args=this.f_args.concat(Task.station.data.reverse());this.status.active=true}else{this.status.active=true;if(this.needs&&this.needs.length){DRE.assert(this.f,"Can't need nothin' if y'ain't gonn' deliva");this.status.active=2;Task.station.apply(Task.station,this.needs.concat(this));return 1}}if(this.f){DRE.assert(this.f_args instanceof Array);A=this.f.apply(this.owner,[this].concat(this.f_args,Task.argSlice(arguments,0)))}if(A==undefined){return 1}else{return A}},stop:function(){DRE.halt("Not implemented")},retry:function(){this.reset();return this.run.apply(this,arguments)},off:function(){this.milestone("shutdown");this.listeners=[];Task.destroy(this)}};Task.station=function(A){var B,D,C;if(typeof this=="object"&&this.data&&this.milestones){C=this;DRE.assert(C.data&&C.milestones,"Task.station wants sensible THIS")}else{if(arguments.length==0){return }C={data:[],milestones:[]};if(typeof this=="object"){C.owner=this;C.owner_index=GUID.get();DRE.assert(C.owner.owns_stations,"We mean business or we mean bust");C.owner.owns_stations[C.owner_index]=C}}D=[];for(B=1;B<arguments.length;B++){D.push(arguments[B])}while(A instanceof Array){C.milestones.unshift("function_call");C.data.unshift(A[0].apply(A[1],A.slice(2)));Task.station.milestones=C.milestones;Task.station.data=C.data;if(D.length&&C.owner!=0){A=D.shift()}else{if(C.owner==0){Bug.bump("Tasks discontinued")}else{if(C.owner){delete C.owner.owns_stations[C.owner_index];C={}}}return }}if(C.owner!=0){A.listenOnce.apply(A,[Task.station_next,C].concat(D));A.run()}else{Bug.bump("Tasks discontinued")}};Task.station_next=function(F,E,D,C){var A,H,G,B;if(typeof C=="string"){G=4;B=C}else{G=3;B="complete"}if(F!=B){return }this.milestones.unshift(F);this.data.unshift(D);Task.station.milestones=this.milestones;Task.station.data=this.data;H=[];for(A=G;A<arguments.length;A++){H.push(arguments[A])}if(H.length){Task.station.apply(this,H)}else{if(E.owner){delete this.owner.owns_stations[this.owner_index];this.owner=null}}};Task.station.milestones=[];Task.station.data=[];Task.destroy=function(A){delete A};Task.DiFi=function(B,A){DRE.assert(B==DiFi.pushPublicGet||B==DiFi.pushPrivateGet||B==DiFi.pushPost||window.DiFi3);task=new Task(Task.DiFiHelp,A);B.apply(DiFi,Task.argSlice(arguments,2).concat(task.cbDiFi,task));return task};Task.DiFiHelp=function(A){DiFi.timer(1)};Task.Ani=function(A){return new Task(Task._AniHelp,A,Task.argSlice(arguments,1))};Task._AniHelp=function(A,B){Station.push.apply(Station,B.concat(bind(A,A.done)))};Task.Delay=Task.Yield=function(A){return new Task(Task._DelayHelp,null,A||1)};Task._DelayHelp=function(A,B){setTimeout(bind(A,A.done,null),B)};if(window.DWait){DWait.run("jms/lib/task.js")}function TakeOver(D,B,A){if(B._takeover_f1){try{Bug.update("Double takeover","so there")}catch(C){}}f2=new Function("var r;if (arguments.callee._takeover_f1)arguments.callee._takeover_f1.apply(this, arguments); r = arguments.callee._takeover_f2.apply(this, arguments); if (arguments.callee._takeover_f3)arguments.callee._takeover_f3.apply(this, arguments); return r;");f2._takeover_f1=D;f2._takeover_f2=B;f2._takeover_f3=A;return f2}if(window.DWait){DWait.run("jms/lib/takeover.js")}function Refunction(D,C){var E,B,A;DRE.assert(C,"Gonna need a function");E=Refunction.get(D,C);if(!E){E=new Function("return arguments.callee._refunction_f.apply(arguments.callee._refunction_obj, arguments.callee._refunction_args || arguments)");E._refunction_obj=D;E._refunction_f=C;A=[];for(B=2;B<arguments.length;B++){A.push(arguments[B])}if(A.length){E._refunction_args=A}if(A.length||this=="run once"){return E}Refunction.lookup.push([D,C,E])}return E}Refunction.runOnce=function(B,A){return Refunction.call("run once",B,A)};Refunction.lastCall=function(B,A){return Refunction.get(B,A,true)};Refunction.get=function(E,D,C){var B,A;for(B=0;A=Refunction.lookup[B];B++){if(A[0]==E&&A[1]==D){if(C){Refunction.lookup.splice(B,1)}return A[2]}}return null};Refunction.timeout=function(C,A,B){var D;D=new Function("return arguments.callee._refunction_f.apply(arguments.callee._refunction_obj, arguments.callee._refunction_args || arguments)");D._refunction_obj=C;D._refunction_f=A;args=[];for(i=2;i<arguments.length;i++){args.push(arguments[i])}if(args.length||this=="run once"){D._refunction_args=args;return D}};Refunction.lookup=[];if(window.DWait){DWait.run("jms/lib/refunction.js")}Keeper2={register:function(){var A},unregister:function(){},broadcaster_on:function(){if(!Keeper2.broadcaster){Keeper2.broadcaster=new Task()}},master_on:function(){var targets,i,client,eax,storage_id,name;if(window.deviantART){Page=deviantART.pageData;Page.deviant=deviantART.deviant||{};if(!Page.deviant.username){Page.deviant.username="";Page.deviant.symbol="";Page.deviant.usericon=0}}else{DRE.notice("deviantART.pageData unavailable")}targets=document.getElementsByTagName("keeper2");for(i=0;targets[i];i++){DRE.assert(targets[i].getAttribute("for"));name=targets[i].getAttribute("for");if(!window[name]){continue}client=eval(name);if(typeof client=="function"){if(targets[i].parentNode.getAttribute("keeper_done")){continue}client=new client(targets[i].parentNode);DRE.assert(typeof client.off=="function",'Keep destructor ("off" function) required')}else{DRE.assert(client&&typeof client.on=="function"&&typeof client.off=="function");client.on.call(client,targets[i].parentNode)}storage_id=GUID.get();Keeper2.keeper_index[storage_id]=client;targets[i].parentNode.setAttribute("keeperkeeper",String(storage_id))}},master_off:function(){for(x in Keeper2.keeper_index){Keeper2.keeper_index[x].off()}Keeper2.keeper_index={}},deleteOne:function(B){var A;for(A in Keeper2.keeper_index){if(Keeper2.keeper_index[A]==B){Keeper2.keeper_index[A].off();delete Keeper2.keeper_index[A];break}}},keeper_index:{},fromNode:function(B){var A;A=B.getAttribute("keeperkeeper");return A?this.keeper_index[A]:null},get:function(B,C){var A;if(typeof B!="string"){C=B;B=null}do{if(C.getAttribute("keeperkeeper")){A=Keeper2.fromNode(C);DRE.assert(A);if(B){DRE.assert(B==A.debug_label,"MEGA HACK :)")}return A}}while((C=C.parentNode)&&C.nodeType!=9);return null},classRegistry:{},getClass:function(lookup){DRE.assert(lookup.match(/^[a-zA-Z0-9_\$]+$/));return Keeper2.classRegistry[lookup]||eval(lookup)},make:function(H,B,A){var G,E,D,I,F,C;I=typeof H=="function"?H:Keeper2.getClass(H);Keeper2.infect(I.prototype);G=new I(new Function);A=A||{};for(E in A){if(typeof A[E]=="function"&&G[E]){G[E]=TakeOver(E=="off"?A[E]:null,G[E],E=="off"?null:A[E])}else{if(E=="spawnHooks"){if(!G[E]){G[E]=[]}for(D=0;A[E][D];D++){DRE.assert(typeof A[E][D]=="function");G[E].push(A[E][D])}}else{if(E=="nodeMap"||E=="taskMap"||E=="modeMap"||E=="propMap"||E=="mutations"){if(!G[E]){G[E]={}}DRE.assert(typeof A[E]=="object");for(D in A[E]){G[E][D]=A[E][D]}}else{if(E=="template"){}else{G[E]=A[E]}}}}}if(A.template||G.template){C=Tree.createFragment(A.template||G.template,true);if(!C){}F=GUID.get();Keeper2.keeper_index[F]=G;C.setAttribute("keeperkeeper",String(F));G.node=C}G.owner=B;B._KP_owns.push(G);G._KP_owner_index=B._KP_owns.length-1;G.on();return G},megaGet:function(B,H,A,C){var G,E,D,I,F;if(!H){H=B.getAttribute("keeper");DRE.assert(H)}G=Keeper2.fromNode(B);if(!G){I=Keeper2.getClass(H);if(!I.prototype._KP_on){Keeper2.infect(I.prototype)}G=new I(new Function);F=GUID.get();Keeper2.keeper_index[F]=G;B.setAttribute("keeperkeeper",String(F));G.node=B;G.owner=A;A._KP_owns.push(G);G._KP_owner_index=A._KP_owns.length-2;if(C){for(E in C){if(typeof C[E]=="function"&&G[E]){G[E]=TakeOver(E=="off"?C[E]:null,G[E],E=="off"?null:C[E])}else{if(E=="nodeMap"||E=="taskMap"||E=="modeMap"||E=="propMap"||E=="stuff"){DRE.assert(G[E],"Maps should all be pre-infected");DRE.assert(typeof extras[E]=="object");for(D in extras[E]){DRE.assert(!G[E][D],"Cannot overwrite");G[E][D]=C[E][D]}}else{DRE.assert(!G[E],"Cannot overwrite");G[E]=C[E]}}}}G.on()}if(A){DRE.assert(G.owner==A,"Owner mismatch")}return G},registerClass:function(A,B){DRE.assert(B);Keeper2.classRegistry[A]=B},infect:function(B){var A;if(B._KP_on){return false}DRE.assert(typeof B.on=="function");DRE.assert(typeof B.off=="function");for(A in Keeper2.infection){DRE.assert(!B[A],"Keeper infection will not overwrite "+A);B[A]=Keeper2.infection[A]}B.on=TakeOver(B._KP_on,B.on,B._KP_start);B.off=TakeOver(null,B.off,B._KP_off)},infection:{_KP_on:function(){var A,C,B,D;this._KP_dead=false;this.guid=GUID.get();if(!this.constructor._KP_mc){this.constructor._KP_mc={}}this._KP_owns=[];this.owns_stations={};this._KP_node_cache={};this._KP_prop_cache={};this._KP_task_cache={};this._KP_peekers={};if(this.receiver){DRE.assert(typeof this.receiver=="function","ff r");this.receiver.TASK_filter="broadcast";Keeper2.broadcaster_on();this._KP_receiver=Keeper2.broadcaster.listen(this.receiver,this)}if(this.propMap){D=this.propMap;for(C in D){if(D[C].watches_props){for(B in D[C].watches_props){this.watchProp(B,D[C].watches_props[B])}}}}},_KP_start:function(){if(this.nodeMap){items=this._KP_getByRenderFlag(KEEPER_RENDER_IMMEDIATE,this.nodeMap);for(i=0;items[i];i++){this.getNode(items[i])}}if(this.propMap){items=this._KP_getByRenderFlag(KEEPER_RENDER_IMMEDIATE,this.propMap);for(i=0;items[i];i++){this.getProp(items[i])}}},_KP_off:function(){var A;if(this._KP_dead){DRE.halt(this.debug_label+"'s off() called twice")}for(A=0;A!=this._KP_owns.length;A++){if(this._KP_owns[A]){this._KP_owns[A].off();this._KP_owns[A]=null}}for(A in this.owns_stations){this.owns_stations[A].owner=0;delete this.owns_stations[A]}for(A in this.prop_cache){this.prop_cache[A].off();delete this.prop_cache[A]}if(this._KP_receiver){Keeper2.broadcaster.nullListen(this._KP_receiver)}if(this.node){delete Keeper2.keeper_index[this.node.getAttribute("keeperkeeper")];this.node.setAttribute("keeperkeeper","");this.node.removeAttribute("keeperkeeper");if(!this.node.parentNode){Bug.log("Keeper2","Possible failure to clean up "+this.debug_label+this.guid+" by "+this.owner.debug_label+this.owner.guid)}else{if(!this._KP_keep_node){this.node.parentNode.removeChild(this.node)}}}if(this._KP_owner_index>=0){this.owner._KP_owns[this._KP_owner_index]=null}this._KP_dead=true},_KP_gets:function(B){var C,A;A=[];for(C=0;C!=this._KP_owns.length;C++){if(this._KP_owns[C]&&(this._KP_owns[C] instanceof B)){A.push(this._KP_owns[C])}}return A},_KP_clear:function(A){var C,B;if(typeof A=="string"){B=Tree.gets(this.node,A);while(C=B.pop()){if(C.parentNode){C.parentNode.removeChild(C)}}}else{for(C=0;C!=this._KP_owns.length;C++){if(this._KP_owns[C]&&(!A||this._KP_owns[C] instanceof A)){this._KP_owns[C].off();this._KP_owns[C]=null}}}},_KP_getByRenderFlag:function(D,E){var C,B,A;A=[];for(C in E){if(E[C].render==D){A.push(C)}}return A},reboot:function(B,A){setTimeout(Refunction(Keeper2,Keeper2.rebootAssistant,this.owner,this.node.parentNode,this.node.nextSibling,B,A),10);this.off()},spawn:function(A,C){var B;if(this.spawnHooks){DRE.assert(this.spawnHooks instanceof Array);for(B=0;this.spawnHooks[B];B++){C=this.spawnHooks[B].call(this,A,C||{});DRE.assert(C,"Spawn hook busted!")}}return Keeper2.make(A,this,C)},broadcast:function(){Bug.log("broadcast",this.debug_label+this.guid+" / "+Task.argSlice(arguments).join(", "));Keeper2.broadcaster_on();Keeper2.broadcaster.milestone.apply(Keeper2.broadcaster,["broadcast",this].concat(Task.argSlice(arguments)));Keeper2.broadcaster.reset()},mc:function(A,B){if(!A){return this.constructor._KP_mc}if(B!==undefined){if(B==null){delete this.constructor._KP_mc[A]}else{this.constructor._KP_mc[A]=B}}else{}return this.constructor._KP_mc[A]},get:function(){this.peek.apply(this,arguments).run()},peek:function(){var D,G,C,H,F,B,E,A;Bug.log("kp3","Peeking "+this.debug_label+this.guid+" "+Task.argSlice(arguments).join(" "));if(!this.stuff){Bug.log("Failure",Task.argSlice(arguments,0).join(", "));return }B=[];G=this.stuff;for(D=0;D!=arguments.length;D++){DRE.assert(!A,"whaaat?");switch(typeof arguments[D]){case"function":DRE.assert(B.length==0,"Object upups must be at start");G=this.owner;while(!(G instanceof arguments[D])){if(!G){Bug.log("No such ancestor",arguments[D].constructor);break}G=G.owner}DRE.assert(G.stuff,"This keper doesn't have any stuff!");DRE.assert(D==0);return arguments.callee.apply(G,Task.argSlice(arguments,D+1));case"object":DRE.assert(B.length==0,"Object refs must be at start");DRE.assert(arguments[D],"No dud objects");if(arguments[D].stuff){DRE.assert(D==0);return arguments.callee.apply(arguments[D],Task.argSlice(arguments,D+1))}Bug.log("Not getter object",D+" :: "+Task.argSlice(arguments,0).join(", "));return null;case"string":B.push(arguments[D]);if(G[arguments[D]]){G=G[arguments[D]];if(G.get||G.think){D++;A=true;break}continue}Bug.log("No such getter",D+"::"+this.debug_label+this.guid+"::"+Task.argSlice(arguments,0).join(", "));return null;default:DRE.halt("Can't do type: "+(typeof arguments[D])+" :: "+Task.argSlice(arguments,0).join(", "));return null}if(A){break}}DRE.assert(typeof (G.get||G.think)=="function","base is function");DRE.assert(!G._KP_on,"Base should never be a keeper");B=B.join("/");if(this._KP_peekers[B]){E=this._KP_peekers[B]}else{E=this._KP_peekers[B]={}}if(G.get){DRE.assert(!G.think,"One or the other");DRE.assert(D>=arguments.length,"No args for gets");H=[];if(G.parameters&&!E.parameter_hooked){for(D=0;G.parameters[D];D++){DRE.assert(typeof G.parameters[D]=="string","gotta be a string");this.watchProp(G.parameters[D],Refunction(this,this._KP_paramKill,E))}E.parameter_hooked=true}if(E.get_cached){return E.get_cached}else{if(G.parameters){for(D=0;G.parameters[D];D++){H.push(this.getProp(G.parameters[D]))}}F=G.get}}else{DRE.assert(G.think,"At least one");DRE.assert(!G.parameters,"No parameters for thinkers");F=G.think;H=Task.argSlice(arguments,D)}F.ebx=G;C=new Task({TASK:[F,this].concat(H)});if(G.failure){DRE.assert(typeof G.failure=="function");C.big_red_button=G.failure}if(G.needs){DRE.assert(G.needs instanceof Array);C.needs=[];if(typeof G.needs[0]=="string"){G.needs[0]=[G.needs[0]]}for(D=0;G.needs[D];D++){C.needs.push(this.peek.apply(this,G.needs[D]))}}if(G.get){E.get_cached=C}return C},_KP_paramKill:function(A){A.get_cached=null},_KP_mainTask:function(A){A.wait(this.needs)},_KP_lastTask:function(A){DRE.assert(this.that&&this.call&&this.needs&&this.params);this.call.apply(this.that,[A].concat(Task.station.data.reverse()).concat(this.params))},getNode:function(A){var F,B,E,C,D;DRE.assert(this._KP_node_cache);DRE.assert(arguments.length==1,"Sweeper getNode requires 1 argument");E=A;if((C=this._KP_node_cache[E])==undefined){D=(this.nodeMap||{})[A]||{};F=D.get||this._KP_defaultGetNodeMethod;if(C=F.call(this,A)||null){if((this.nodeMap||{})[A]&&(this.nodeMap||{})[A].renderCall){(this.nodeMap||{})[A].renderCall.call(this,A,C)}if(D.watches_props){if(D.invalidate==KEEPER_INVALIDATE_ALWAYS){throw new Error("No watch_props on non-caching nodes")}for(B in D.watches_props){this.watchProp(B,D.watches_props[B])}}}if(D.invalidate!=KEEPER_INVALIDATE_ALWAYS){this._KP_node_cache[E]=C}}return C},_KP_defaultGetNodeMethod:function(A){return Tree.get(this.node,"*."+A)},uiPut:function(A,C,D){var B;B=this.getNode(A);if((C==undefined&&D==undefined)||typeof D=="string"||typeof C=="string"){if(D){DRE.assert(!C,"Don't be greedy");B.innerHTML=D}else{while(B.firstChild){B.removeChild(B.firstChild)}B.appendChild((this.node.ownerDocument||this.node.document).createTextNode(C))}}else{DRE.assert(C&&C.nodeType);while(B.firstChild){B.removeChild(B.firstChild)}B.appendChild(C)}},mode:function(D,G,C){var B,F,A,E;if(!this._KP_current_modes){this._KP_current_modes={}}DRE.assert(D,"Provide a mode namespace");DRE.assert(this.modeMap[D],"No such node namespace: "+D);B=this.modeMap[D];F=typeof this._KP_current_modes[D]=="string"?this._KP_current_modes[D]:"default";if(G==undefined){return F=="default"?"":F}G=G||"default";if(G==F&!C){return }DRE.assert(G.indexOf(" ")<0,"Mode labels cannot contain spaces");E=F+" to "+G;if(B[E]){B[E].call(this,F,G)}else{if(B[F]&&B[F].off){DRE.assert(typeof B[F].off=="function");B[F].off.call(this)}else{if(F!="default"){}}if(B[G]&&B[G].on){DRE.assert(typeof B[G].on=="function");B[G].on.call(this,F,G)}else{}}this._KP_current_modes[D]=G},getTask:function(A){DRE.assert(this.taskMap);if(!this._KP_task_cache[A]){DRE.assert(typeof this.taskMap[A]=="function","Owner must support "+A+" task");this._KP_task_cache[A]=new Task(this.taskMap[A],this,A)}return this._KP_task_cache[A]},getPropHistory:function(A){return this._KP_getPropTask(A).history.data||[]},_KP_getPropTask:function(A){if(!this._KP_prop_cache[A]){DRE.assert(this.propMap[A],"Owner must support "+A+" prop");DRE.assert(typeof this.propMap[A].get=="function","Owner must have "+A+" prop getter");this._KP_prop_cache[A]=new Task(this._KP_tasker_for_getProp,this,A);if(this.propMap[A].change){DRE.assert(typeof this.propMap[A].change=="function");this.watchProp(A,this.propMap[A].change)}}return this._KP_prop_cache[A]},_KP_tasker_for_getProp:function(B,C,D){var A;A=this.propMap[C].get.call(this,C);if(B.history.data&&B.history.data[0]&&B.history.data[0][0]==A){return }Bug.log("K2","got prop: "+C);B.milestone("data",A,D,C)},getProp:function(C){var B,A;DRE.assert(this.propMap);if(arguments.length>1){try{DRE.halt("Mistake? getProp() called with > 1 args")}catch(D){}}B=this.propMap[C].invalidate==KEEPER_INVALIDATE_ALWAYS;A=this._KP_getPropTask(C);if(A.status.milestone!="data"||B){A.run("get")||A.retry("get");DRE.assert(A.history.data&&A.history.data.length>0,"Data task must call back immediately")}return A.history.data[0][0]},setProp:function(B,C,D){var A;A=this._KP_getPropTask(B);if(A.history.data&&A.history.data[0]&&A.history.data[0][0]==C){Bug.log("Not setting prop",B+" / "+C);return }Bug.log("Milestone from setprop",B+" := "+C+" ("+A.listeners.length+" listening)");A.milestone("data",C,D||"set",B)},invalidateProp:function(B){var A;if(B!="film_play_format"){Bug.log("inv","Invalidate "+B)}A=this._KP_getPropTask(B);A.reset();if(A.listeners.length>0){setTimeout(Refunction(A,A.run,"invalidate"),1)}},watchProp:function(C,D,B){var A;D.TASK_filter="data";A=this._KP_getPropTask(C);return A.listen(D,B||this,C)},unwatchProp:function(B,A){return this._KP_getPropTask(B).nullListen(A)},up:function(B,C){var A;A=this;C=C||0;DRE.assert(C>=0);while(A=A.owner){if(A instanceof B){if(C==0){return A}C--}}return null}},rebootAssistant:function(A,E,D,C,B){Tree.insertBefore(A.spawn(C,B).node,D,E)}};$j(Keeper2.master_on);KEEPER_RENDER_PRERENDERED=0;KEEPER_RENDER_IMMEDIATE=1;KEEPER_RENDER_ONSCROLL=2;KEEPER_RENDER_TEMPLATE=4;KEEPER_INVALIDATE_MANUAL=0;KEEPER_INVALIDATE_ALWAYS=1;if(window.DWait){DWait.run("jms/lib/keeper2.js")}Tree2={giveClass:function(B,E,A){var D,F,C;F=Tree2.depth(B,E);C=B.getElementsByTagName(E.tagName);for(D=0;C[D];D++){if(C[D]==E){if(Tree.hasClass(E,A)){return }else{Tree.addClass(E,A)}}else{if(Tree2.depth(B,C[D])==F){Tree.removeClass(C[D],A)}}}},depth:function(A,C){var B;B=0;while(C!=A){B++;C=C.parentNode}return B},getsByAttribute:function(E,C,B,H,A){var D,G,F;F=[];D=Tree.gets(E,C);for(G=0;G!=D.length;G++){if(D[G].getAttribute(B)&&((!H)||(H==D[G].getAttribute(B)))){F.push(D[G]);if(G==A){break}}}return F},getByAttribute:function(C,B,A,D){return Tree2.getsByAttribute(C,B,A,D,1)[0]}};if(window.DWait){DWait.run("jms/lib/tree2.js")}window.App=function(){this.node=document.documentElement;Keeper2.infect(this);this.on()};App.startup=[];App.prototype={debug_label:"App",on:function(){this._KP_keep_node=true},off:function(){},stuff:{data:{}}};App.startup=function(){var targets,i,client,eax,storage_id;App.instance=new App();if(window.deviantART&&!window.Page){Page=deviantART.pageData;Page.deviant=deviantART.deviant||{};if(!Page.deviant.username){Page.deviant.username="";Page.deviant.symbol="";Page.deviant.usericon=0}}targets=document.getElementsByTagName("keeper3");for(i=0;targets[i];i++){DRE.assert(targets[i].getAttribute("for"));client=eval(targets[i].getAttribute("for"));DRE.assert(typeof client=="function");client=App.instance.spawn(client,{node:targets[i].parentNode,domData:targets[i],_KP_keep_node:true});storage_id=GUID.get();Keeper2.keeper_index[storage_id]=client;client.node.setAttribute("keeperkeeper",String(storage_id))}};App.bios=function(){if(Browser.isIE){try{document.documentElement.doScroll("left")}catch(A){setTimeout(arguments.callee,50);return }}App.startup()};App.COMMENTS_PER_PAGE=25;DWait.ready(".domready",App.bios);if(window.DWait){DWait.run("jms/lib/app.js")}App.prototype.stuff.data.moods={get:function(A){A.wait(Task.DiFi(DiFi.pushPublicGet,this,"Mood","getMoodsFlattened",[]));DiFi.timer(1)}};if(window.DWait){DWait.run("jms/lib/app.js.moods.js")}COMMENT_DEVIATION=1;COMMENT_GALLERIES=20;COMMENT_FAVCOLLECTIONS=21;App.prototype.stuff.data["deviations by id"]={think:function(A){var B,F,D,E,C;if(!App.deviations_by_id_cache){App.deviations_by_id_cache={}}C=false;F=[];D=[];E={};for(B=1;B<arguments.length;B++){D.push(arguments[B]);if(!E[arguments[B]]&&(App.deviations_by_id_cache[arguments[B]]==0||App.deviations_by_id_cache[arguments[B]]===undefined)){Bug.log("Let's get",arguments[B]);E[arguments[B]]=1;if(App.deviations_by_id_cache[arguments[B]]==0){Bug.log("WARNING","Double Di-Fi fetching deviation "+arguments[B])}App.deviations_by_id_cache[arguments[B]]=0;F.push(new Task);C=true;DiFi.pushPublicGet("Stream","thumb",[arguments[B]],arguments.callee.ebx.rackitup,F[F.length-1])}}if(Browser.isKHTML&&!Browser.isSafari3){F.push(Task.Delay(1))}F.push([function(H){var G;G={};for(B=0;H[B];B++){if(App.deviations_by_id_cache[H[B]]){G[B]=App.deviations_by_id_cache[H[B]]}}A.done(G)},this,D.slice(0)]);Task.station.apply(Task.station,F);if(C){DiFi.timer(90)}},rackitup:function(C,B){var A;DRE.assert(this instanceof Task);if(!C){Bug.update("boo don't got","got got "+((B.request||{}).args||{})[0]);this.abort(B.response.content);return }App.deviations_by_id_cache[B.request.args[0]]=B.response.content;this.done()}};App.prototype.stuff.data["deviations by query"]={think:function(A,C,D,B){if(!this.deviations_by_query_cache){this.deviations_by_query_cache={}}D=Number(D);if(this.deviations_by_query_cache[Number(D)+"."+C]){if(Browser.isKHTML&&!Browser.isSafari3){setTimeout(Refunction(A,A.done,this.deviations_by_query_cache[Number(D)+"."+C]),1)}else{A.done(this.deviations_by_query_cache[Number(D)+"."+C])}}else{Task.station(Task.DiFi(DiFi.pushPublicGet,A,"Stream","thumbs",[C,D,B]),[function(){var E;if(!(Task.station.data[0] instanceof Array)){for(E in Task.station.data[0]){App.deviations_by_id_cache[E]=Task.station.data[0][E]}}A.done(this.deviations_by_query_cache[Number(D)+"."+C]=Task.station.data[0])},this])}}};App.prototype.stuff.data["resource views by rid"]={think:function(A,B,I,L){var F,D,G,H,J,E,K,C;if(!App.resources_by_rid_cache){App.resources_by_rid_cache={}}H=false;D=[];G={};C=[];for(F in L){C.push(F+":"+Number(L[F]))}C.sort();C=C.join(",");K=[];for(F=0;F<B.length;F++){J=B[F];if(!J){continue}E=J[0]+":"+J[1]+":"+I+":"+C;K.push(E);if(!G[E]&&(App.resources_by_rid_cache[E]==0||App.resources_by_rid_cache[E]===undefined)){Bug.log("Let's get",J);G[E]=1;if(App.resources_by_rid_cache[E]==0){Bug.log("WARNING","Double Di-Fi fetching resource "+J)}App.resources_by_rid_cache[E]=0;D.push(new Task);H=true;Bug.log("woof MISS",E);DiFi.pushPublicGet("Resources","htmlFromRID",[J[0],J[1],I,C],arguments.callee.ebx.rackitup,D[D.length-1])}else{Bug.log("woof READ",E)}}if(Browser.isKHTML&&!Browser.isSafari3){D.push(Task.Delay(1))}D.push([function(M){var O,N;O=[];for(F=0;M[F];F++){if(App.resources_by_rid_cache[M[F]]){O.push(App.resources_by_rid_cache[M[F]])}}A.done(O)},this,K.slice(0)]);Task.station.apply(Task.station,D);if(H){DiFi.timer(90)}},rackitup:function(D,B){var A,C;DRE.assert(this instanceof Task);if(!D){Bug.update("boo don't got","got got "+((B.request||{}).args||{})[0]);this.abort(B.response.content);return }C=B.request.args.join(":");App.resources_by_rid_cache[C]=B.response.content;this.done()}};App.prototype.stuff.data["resource views by query"]={think:function(A,G,C,F,H,I){var D,E,B;B=[];for(E in I){B.push(E+":"+Number(I[E]))}B.sort();B=B.join(",");DiFi.pushPublicGet("Resources","htmlFromQuery",[G,C,F,H,B],arguments.callee.ebx.rackitup,A);DiFi.timer(1)},rackitup:function(E,D){var A,C,B;if(E){if(!App.resources_by_rid_cache){App.resources_by_rid_cache={}}B=[];for(A=0;C=D.response.content.resources[A];A++){Bug.log("woof+PUT",C[0]+":"+C[1]+":"+D.request.args[3]+":"+D.request.args[4]);App.resources_by_rid_cache[C[0]+":"+C[1]+":"+D.request.args[3]+":"+D.request.args[4]]=C[2];B.push(C[2])}this.done({total:D.response.content.total,more:D.response.content.more,resources:B})}else{this.abort()}}};App.cacheResourceView=function(D,G,B,C,F){var H,E,A;if(typeof C=="string"){A=C}else{A=[];for(E in C){A.push(E+":"+Number(C[E]))}A.sort();A=A.join(",")}H=D+":"+G+":"+B+":"+A;if(!App.resources_by_rid_cache){App.resources_by_rid_cache={}}if(F!==undefined){if(F==0&&!A){DRE.breakpoint()}Bug.log("cache","PUT "+H+" ("+String(F).substr(0,9)+")");App.resources_by_rid_cache[H]=F}else{Bug.log("cache",(App.resources_by_rid_cache[H]?"HIT":"MISS")+" "+H);return App.resources_by_rid_cache[H]}};if(window.DWait){DWait.run("jms/lib/app.js.deviations.js")}PHP={$GLOBALS:{urls:{avatarurl:"http://a.deviantart.com/avatars"}},image_type_to_extension:function(F,A){var C;var E=1;var D=2;var B=3;F=Number(F);if(A==undefined){A=true}if(!F){return false}C=A?".":"";switch(F){case E:return C+"gif";case D:return C+"jpg";case B:return C+"png";default:return C+F}},subdirize:function(F,D,C){var E,B,A;if(D==undefined){D=3}if(C==undefined){C=false}E=F;if(D>F.length){D=F.length}B=F.indexOf(".");if(B>0&&D>B){D=B}if(D<1){return false}F=F.replace(/[^A-Za-z0-9]/g,"_");A="";if(C){F=strrev(F)}for($i=0;$i<D;$i++){A+=F.substr($i,1)+"/"}A+=E;return A},userurl:function(A){return"http://"+A.toLowerCase()+".deviantart.com"},userlink:function(B,D,A){var C;if(D==undefined){D=""}if(A==undefined){A="/"}if(typeof B=="object"){D=B.symbol;B=B.username}if(!B){return"<em>Nobody</em>"}C='<a class="u" href="'+PHP.userurl(B)+A+'">'+B+"</a>";if(D){C=D+C}return C},usericon:function(E,D,B,C){var A;if(D==undefined){D=1}if(B==undefined){B=false}if(C==undefined){C=false}E=E.toLowerCase();A=(C)?' style="float:left; padding-right: 2px; padding-bottom: 2px;"':"";return('<a href="'+PHP.userurl(E)+'/"><img class="avatar"'+A+' src="'+PHP.usericonurl(E,D)+'" width="50" height="50" alt=":icon'+E+':" title="'+E+'"/></a>')},usericonlink:function(C,D,B){var A;if(B==undefined){B=1}A=PHP.userlink(C,D);A=A.replace("</a>",'<img class="avatar" src="'+PHP.usericonurl(C,B)+'" width="50" height="50" alt=":icon'+C+':"/></a>');return A},usericonurl:function(C,B){var A;if(B==undefined){B=1}$cachebuster=(B>>2)&15;if(B){A=PHP.subdirize(C.toLowerCase(),2)+PHP.image_type_to_extension(B&3)}else{A="default.gif"}if($cachebuster){A+="?"+$cachebuster}return PHP.$GLOBALS.urls["avatarurl"]+"/"+A}};if(window.DWait){DWait.run("jms/lib/php.js")}Surfer2={create:function(B,C){var D,A;D=Tree.create("div.surfer2",{});D.className="surfer2";document.body.appendChild(D);D={node:D,o:C||DDD.p_down};Surfer2.update(D,B);return D},update:function(F,D){var C,E,B,A;A=Browser.isIE?2:0;B={};C=Ruler.document.pointer(D);E=F.o;B.x=C.x>E.x?E.x:C.x;B.x2=C.x>E.x?C.x:E.x;B.y=C.y>E.y?E.y:C.y;B.y2=C.y>E.y?C.y:E.y;Station.apply(F.node,"left",B.x);Station.apply(F.node,"top",B.y);Station.apply(F.node,"width",Math.max(B.x2-B.x,1)+A);Station.apply(F.node,"height",Math.max(B.y2-B.y,1)+A);return B},clear:function(A){A.node.parentNode.removeChild(A.node)}};if(window.DWait){DWait.run("jms/lib/surfer2.js")}COMMENT_ATTRIBUTE_HIDDEN=1;COMMENT_ATTRIBUTE_HIDDEN_BY_ADMIN=2;COMMENT_ATTRIBUTE_VIOLATION=4;COMMENT_ATTRIBUTE_LOCKED=2048;COMMENT_ATTRIBUTE_PRIVATE=8192;function Mooder(){}Mooder.prototype={template:'<div class="mood-space ch"><i class="tl c"><b></b></i><i class="c tr"><b></b></i><i class="c bl"><b></b></i><i class="c br"><b></b></i><div></div></div>',debug_label:"Mooder",on:function(){this.get("html")},stuff:{html:{needs:[[TalkTower,"data","moods"],[TalkTower,"data","mood counts"]],get:function(B,G,F){var E,D,C,H,A;E=[];E.push('<table align="center" class="f moods"><tr>');for(D in F){if(D==this.mood){E.push('<td class="f active">')}else{E.push('<td class="f">')}if(F[D]>0){E.push('<a href="#" moodmood="'+(D==this.mood?0:D)+'">')}else{E.push("<del>")}H=null;for(C in G){if(C==D){H=G[C];break}}DRE.assert(H,"Mood mismatch: "+D);E.push('<span><img src="http://e.deviantart.com/emoticons/moods/'+H.icon+'" alt=""/></span>');switch(H.text.toLowerCase()){case"sadness":E.push("sad");break;case"surprise":case"wow!":E.push("wow");break;case"anger":E.push("mad");break;case"neutral":E.push("<small>neutral</small>");break;default:E.push(H.text.toLowerCase())}E.push('<strong class="t">'+F[D]+"</strong>");E.push('<strong class="tt">'+F[D]+"</strong>");if(F[D]>0){E.push("</a>")}else{E.push("</del>")}E.push("</td>")}E.push("</tr></table>");Tree.get(this.node,"div").innerHTML=E.join("");A=Tree.gets(this.node,"a");for(D=0;A[D];D++){Events.hook(A[D],"click",Refunction(this,this.clicked,Number(A[D].getAttribute("moodmood"))))}}}},off:function(){},clicked:function(A){this.owner.setProp("mood",A);return false}};$j(function(){MenuTraffic.overrides.commentcontrol=MenuTraffic.overrides.commentcontrol2=MenuTraffic.overrides.commentcontrolme=MenuTraffic.overrides.commentcontrolme2=function(A){var C,B;C=A.split("/");B=[];if(C[0].indexOf("2")>0){B.push({title:"Reveal this Comment",path:C.concat("unhide"),children:null})}else{B.push({title:"Hide this Comment",path:C.concat("hide"),children:null})}MenuTraffic.got(true,A,{all:null,title:null,path:C,children:B});return true}});function TalkTower(A){A()}TalkTower.prototype={debug_label:"TalkTower",on:function(){DRE.assert(this.comments);DRE.assert(this.typeid);DRE.assert(this.itemid);if(!window.Page){Page=deviantART.pageData||{}}if(this.owner_control){Tree.addClass(this.node,"tower-commentcontrol")}this.comment_nodes={};this.thread_mode=this.thread_mode||"nest";this.get("ui","comments")},off:function(){},STRING_header_a:"Comments",STRING_empty:"No comments yet!",STRING_header_b:"Devious Thoughts?",stuff:{ui:{comments:{parameters:["mood","page"],get:function(B,H,F,A){var H,C,F,D,I,E,G;this.comment_nodes={};this._KP_clear(TalkBit);this._KP_clear(HTMLPager);C=[];if(this.thread_mode=="nest"){thread=this.makeThread(this.comments,F,this.thread_mode,H);for(D=0;thread[D];D++){E=this.spawn(TalkBit,{comment:thread[D]});this.comment_nodes[thread[D].commentid]=E.node;this.node.appendChild(E.node)}if(thread.page_count>1){this.node.appendChild(this.spawn(HTMLPager,{page:F,pages:thread.page_count}).node)}}else{DRE.halt("Unimplemented: thread_mode == "+this.thread_mode)}B.done(this.comment_nodes);this.adjust();Task.station.apply(Task.station,C)}}},data:{moods:{think:function(A){A.wait(this.up(window.Film&&this.up(Film)?Film:App).peek("data","moods"))}},"mood counts":{needs:[["data","moods"]],get:function(A,D){var C,B,E;D=Task.station.data[0];B={};for(C in D){if(!Number(D[C].parentid)){B[Number(C)]=0}}for(C in this.comments){E=(this.comments[C].attributes&2040)>>>3;if(Number(E)){while(Number(D[E].parentid)){E=D[E].parentid}DRE.assert(E in B,E+" is a rogue?");B[E]++}}A.done(B)}}}},adjust:function(){var B,A;this._KP_clear(Mooder);this._KP_clear(TalkPost);this._KP_clear("div.talk-blank");this._KP_clear("h2");if(Tree.gets(this.node,"div.talk").length>0){Tree.insertBefore(this.spawn(Mooder,{mood:this.getProp("mood")}).node,this.node.firstChild,this.node);if(this.STRING_header_a){Tree.insertBefore(Tree.create("h2.v",{},this.STRING_header_a),this.node.firstChild,this.node)}}else{if(this.STRING_empty){Tree.insertBefore(Tree.create("div.talk-blank",{},this.STRING_empty),this.node.firstChild,this.node);Tree.insertBefore(Tree.create("h2.v",{},this.STRING_header_a),this.node.firstChild,this.node)}}if(this.STRING_header_b){this.node.appendChild(Tree.create("h2.v",{},this.STRING_header_b),B);if(!Page.deviant||!Page.deviant.username){this.node.appendChild(Tree.createFragment('<div class="lesportwide"><a href="http://www.deviantart.com/join" class="a f">Sign up to leave a message for this deviant! <img src="http://e.deviantart.com/emoticons/h/heart.gif" alt="<3"/></a></div>',true))}this.node.appendChild(this.spawn(TalkPost,{comment:{typeid:this.typeid,itemid:this.itemid,time_index:this.time_index}}).node)}},propMap:{mood:{get:function(){return 0}},page:{get:function(){return 0}}},template:'<div class="talk-tower"></div>',nodeMap:{"Hi, I'm the coolest hack in the universe":{get:function(){return this.node},watches_props:{mood:function(B,A){this.setProp("page",0);if(B.length>1){this.get("ui","comments")}},page:function(B,A){if(B.length>1){this.get("ui","comments")}}},render:KEEPER_RENDER_IMMEDIATE}},modeMap:{},taskMap:{},makeThread:function(G,K,F,M){var D,B,A,E,I,C,O,N,J,H,L;DRE.assert(F=="nest");if(this.nest_cache&&!M){I=this.nest_cache}else{if(M){L=(window.Film&&this.up(Film)?this.up(Film):this.up(App)).peek("data","moods").status.result;DRE.assert(L,"Mood filter without preloaded moods? whut?")}I=[];for(D in G){E=G[D];DRE.assert(D==E.commentid);if(M){O=(E.attributes&2040)>>>3;if(Number(O)){while(Number(L[O].parentid)){O=L[O].parentid}}if(O!=M){continue}E.depth=0;I.push(E)}else{if(Number(E.parentid)){C=0;O=E;while(Number(O.parentid)){C++;O=G[O.parentid];if(!O){E.parentid=0;C=0;DRE.notice("Invalid parentid from "+E.commentid);break}}E.depth=C;for(B=0;B!=I.length;B++){if(E.parentid==I[B].commentid){I.splice(B+1,0,E);break}}if(B==I.length){DRE.notice("Couldn't find comment parent: "+E.commentid+" -> "+E.parentid);I.push(E)}}else{E.depth=0;I.push(E)}}}if(!M){this.nest_cache=I}}if(K!=undefined){J=[];H=0;B=0;for(D=0;D!=I.length;D++){if(I[D].depth==0&&B>=(window.App?App.COMMENTS_PER_PAGE:Film.COMMENTS_PER_PAGE)){H++;B=0}if(H==K){J.push(I[D])}B++}J.page_count=H+1;return J}return I},add:function(D){var B,C,A;C=0;DRE.assert(D.depth==undefined,"Only I have the brains to determine comment depth");B=D.parentid;while(Number(B)){if(!this.comments[B]){Bug.log("Warning","Leaky parent id: "+D.parentid);break}B=this.comments[B].parentid;C++}D.depth=C;this.comments[D.commentid]=D;this.nest_cache=null;this.peek("data","mood counts").reset();this.storage_handle.total++;comment=this.spawn(TalkBit,{comment:D});Station.apply(comment.node,"opacity",0.01);this.comment_nodes[D.commentid]=comment.node;Tree.insertBefore(comment.node,D.parentid?this.comment_nodes[D.parentid].nextSibling:null,this.node);this.adjust();if(window.Film&&this.up(Film)){this.get(Film,"ui","annotation map")}Station.push(comment.node,"opacity",{from:0.01,to:Browser.isKHTML?0.99:1,time:400,f:Interpolators.sineCurve})}};function TalkBit(){}TalkBit.prototype={debug_label:"TalkBit",template:'<div class="talk"><span class="mood"></span><div class="meta"><span class="name"></span><span class="time"></span></div><div class="files"></div><div class="text ch"><span class="commentcontrol"><img src="http://s.deviantart.com/minish/film/commentcontrol.gif" alt="[V]" title=""/></span><div class="text-ii ch"></div><a class="control-reply" href="#">Reply</a></div></div>',on:function(){var A;DRE.assert(this.comment);Events.hook(this.getNode("commentcontrol"),"click",Refunction(this,this.controlClick));Events.hook(this.getNode("control-reply"),"click",Refunction(this,this.replyClick));this.node.setAttribute("comment",this.comment.typeid+"/"+this.comment.itemid+"/"+this.comment.commentid+"/"+((this.comment.attributes&4294901760)>>>16));this.uiPut("time",null,'<a href="http://comments.deviantart.com/'+this.comment.typeid+"/"+this.comment.itemid+"/"+this.comment.commentid+'">'+time_string(this.comment.ts)+"</a>");this.uiPut("name",null,PHP.usericonlink(this.comment.username,this.comment.symbol,Number(this.comment.usericon)));this.get("ui","mood");this.get("ui","files");if(this.comment.attributes&(COMMENT_ATTRIBUTE_HIDDEN|COMMENT_ATTRIBUTE_HIDDEN_BY_ADMIN)){this.mode("hidden",this.comment.attributes&COMMENT_ATTRIBUTE_HIDDEN_BY_ADMIN?"admin":"hidden")}else{this.mode("text","loading");this.get("ui","text")}if(this.comment.depth){this.node.style.marginLeft=(30*this.comment.depth)+"px"}},off:function(){Events.unhook(this.getNode("commentcontrol"),"click",Refunction.lastCall(this,this.controlClick));Events.unhook(this.getNode("control-reply"),"click",Refunction.lastCall(this,this.replyClick))},stuff:{ui:{mood:{needs:[["data","moods"]],get:function(A,C){var D,B;D=(this.comment.attributes&2040)>>>3;if(D){if(C[D]){this.getNode("mood").appendChild(Tree.create("img",{alt:"",src:"http://e.deviantart.com/emoticons/moods/"+C[D].icon,title:C[D].text}))}else{Bug.log("Unrecognised mood",D)}}A.done()}},files:{get:function(){var B,A,C;if(this.comment.files){Tree.addClass(this.node,"talk-withfiles");for(B=0;A=this.comment.files[B];B++){if(A.download){this.getNode("files").appendChild(Tree.create("a.download",{href:A.url},((A.url.split("/").pop().split(".").slice(1)||[""]).pop()||"FILE")+" Download"))}else{this.getNode("files").appendChild(C=Tree.create("a",{href:A.url},Tree.create("img",{src:A.thumb})));Events.hook(C,"click",Refunction(this,arguments.callee.ebx.pictureClick,A))}}}},pictureClick:function(file){var popup;popup=window.open("",null,"toolbar = 0, scrollbars = 0, location = 0, statusbar = 0, menubar = 0, resizable = 0, width= "+file.width+", height= "+file.height);if(!popup){return true}with(popup.document){open();write('<html><body style="padding:0;margin:0;background:#76827B url('+file.url+') no-repeat top left">&nbsp;</body></html>');close()}popup.focus();return false}},text:{needs:[["data","text"]],think:function(A){this.mode("text","ready",true)}}},data:{moods:{think:function(A){A.wait(this.up(window.Film&&this.up(Film)?Film:App).peek("data","moods"))}},text:{get:function(A){if("text" in this.comment){}else{if(this.mc("body"+this.comment.commentid)){this.comment.text=this.mc("body"+this.comment.commentid);this.comment.signature=""}else{A.wait(Task.DiFi(DiFi.pushPublicGet,A,"Comments","getBodies",[this.comment.commentid,this.comment.typeid,this.comment.itemid,this.comment.userid]),[arguments.callee.ebx.extractText,this]);return }}A.done(this.comment.text)},failure:function(A){this.owner.mode("text","broken")},extractText:function(){this.mc("body"+this.comment.commentid,Task.station.data[0].text);this.comment.text=Task.station.data[0].text;this.comment.signature=Task.station.data[0].signature;return this.comment.text}}}},modeMap:{text:{ready:{on:function(){if(this.comment.attributes&COMMENT_ATTRIBUTE_VIOLATION){this.uiPut("text-ii",null,'<em style="color:#300">This comment violates deviantART policy, and might contain offensive material</em><br/><br/><input value="Show It" type="button" onclick="Keeper2.get(this).toggleViolation(this)"/><br/><br/><div style="display:none">'+this.comment.text+"</div>")}else{this.uiPut("text-ii",null,this.comment.text)}}},loading:{on:function(){DRE.assert(Tree.hasClass(this.node,"talk"));Tree.addClass(this.node,"talk-loading");this.uiPut("text-ii","")},off:function(){DRE.assert(Tree.hasClass(this.node,"talk"));Tree.removeClass(this.node,"talk-loading")}},broken:{on:function(){this.uiPut("text-ii",null,'<img src="about:blank" class="broken" onclick="Keeper2.get(this).get(\'ui\', \'text\')"/>')}}},busy:{busy:{on:function(A){Station.apply(this.node,"opacity",0.5)},off:function(){Station.apply(this.node,"opacity",1)}}},hidden:{hidden:{on:function(A){Tree.addClass(this.node,"talk-hidden");this.uiPut("text-ii","[comment hidden]")},off:function(){Tree.removeClass(this.node,"talk-hidden");this.mode("text","loading");this.get("ui","text")}},admin:{on:function(A){Tree.addClass(this.node,"talk-hidden");this.uiPut("text-ii","[hidden by administrator]");this.getNode("commentcontrol").style.visibility="hidden"},off:function(){Tree.removeClass(this.node,"talk-hidden");this.getNode("commentcontrol").style.visibility="hidden";this.mode("text","loading");this.get("ui","text")}}},select:{electric:{on:function(){if(this.comment.attributes&(COMMENT_ATTRIBUTE_HIDDEN|COMMENT_ATTRIBUTE_HIDDEN_BY_ADMIN)){this.mode("hidden","")}Tree.addClass(this.node,"talk-electric")},off:function(){if(this.comment.attributes&COMMENT_ATTRIBUTE_HIDDEN){this.mode("hidden","hidden")}else{if(this.comment.attributes&COMMENT_ATTRIBUTE_HIDDEN_BY_ADMIN){this.mode("hidden","admin")}}Tree.removeClass(this.node,"talk-electric")}}}},nodeMap:{},controlClick:function(){var C,B,A,D;if(this.mode("busy")){return }if(this.comment.username.toLowerCase()==Page.deviant.username){if(this.mode("hidden")){A="commentcontrolme2/"+this.comment.commentid}else{A="commentcontrolme/"+this.comment.commentid}}else{if(this.mode("hidden")){A="commentcontrol2/"+this.comment.commentid}else{A="commentcontrol/"+this.comment.commentid}}D=A.split("/");if(!this.control_menu_popup){B=Pager.create({rootri:A,href_base:"",theme:Tree.hasClass(document.body,"bubble")?"light":"deviant",callback:this.controlMenuBack,callback_object:this});Pager.loadPage(B,A);C=Popup.create({className:"commentcontrol"});C.node.appendChild(B.node);this.control_menu_popup=C}Popup.show(this.control_menu_popup,Ruler.screen.node(this.getNode("commentcontrol")))},controlMenuBack:function(B,A){var C;if(B!=""&&!this.mode("busy")){Pager.select(A,"");C=B.split("/").pop();Popup.complete(A.node);switch(C){case"hide":this.mode("busy","busy");DiFi.pushPost("CommentAttributes","hide",[this.comment.commentid,this.comment.itemid,this.comment.typeid],this.hideDone,this);break;case"unhide":this.mode("busy","busy");DiFi.pushPost("CommentAttributes","unhide",[this.comment.commentid,this.comment.itemid,this.comment.typeid],this.unhideDone,this);break;case"block":this.mode("busy","busy");DiFi.pushPost("CommentAttributes","block",[this.comment.commentid,this.comment.itemid,this.comment.typeid],this.unhideDone,this);break;default:alert("This tool is currently unavailable.")}DiFi.timer(1)}},hideDone:function(B,A){this.mode("busy","");if(B){this.control_menu_popup=null;this.comment.attributes|=COMMENT_ATTRIBUTE_HIDDEN;this.mode("hidden","hidden")}else{alert("The Hide Comment tool is currently unavailable.\n\nPlease try again soon.")}},unhideDone:function(B,A){this.mode("busy","");if(B){this.control_menu_popup=null;this.mode("busy","");this.comment.attributes&=~COMMENT_ATTRIBUTE_HIDDEN;this.mode("hidden","")}else{alert("The Reveal Comment tool is currently unavailable.\n\nPlease try again soon.")}},blockDone:function(B,A){alert("Jackass removed yay "+B);this.mode("busy","")},toggleViolation:function(B){var A;A=Tree.get(B.parentNode,"div");A.style.display=A.style.display=="block"?"none":"block"},replyClick:function(){var B,A;if(this.comment.attributes&COMMENT_ATTRIBUTE_LOCKED){alert("Replies to this comment have been disallowed.");return false}if(this.node.nextSibling&&(A=Keeper2.get(this.node.nextSibling))){if(A instanceof TalkPost){A.focus();return false}}B={typeid:this.comment.typeid,itemid:this.comment.itemid,parentid:this.comment.commentid,time_index:(this.comment.attributes&4294901760)>>>16,depth:this.comment.depth+1};A=this.spawn(TalkPost,{comment:B});Tree.insertBefore(A.node,this.node.nextSibling,this.node.parentNode);A.focus();return false}};if(window.DWait){DWait.run("jms/pages/comments.js")}DWait.ready(["jms/lib/popup.js","jms/lib/pager.js"],function(){Popup.clicks.menu={create:function(C,D){var B,A,E;A=D.getAttribute("menuri");E=A.split("/");B=Pager.create({rootri:D.getAttribute("popuprootri")||E[0],href_base:D.getAttribute("popuphref")||D.getAttribute("href"),more_links:E[0]=="mood",master_links:E[0] in {art:1,gallery:1},theme:"dark",icon_set:A=="deviate"?"deviate":null,input:D.getAttribute("for")?document.getElementById(D.getAttribute("for")):null,callback:this.callback,callback_object:D});Pager.loadPage(B,A);DiFi.send();return B.node},callback:function(B,A){return Popup.complete(A.node,B)}};if(window.DWait){DWait.run("jms/lib/popup.js.menu.js")}});function pluralize(C,A,B){return(C?C:"no")+" "+A+(C==1?"":(B||"s"))}function htmlspecialchars(A){return A.replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/\&/g,"&amp;").replace(/"/g,"&quot;")}function time_string(J,K){var A,E,M,B,H,N,D,F,G,L,I,C;if(!Number(J)){return""}E={minutes:1000*60,hours:1000*60*60,days:1000*60*60*24,weeks:1000*60*60*24*7,months:1000*60*60*24*(365.25/12),years:1000*60*60*24*365.25};H=new Date();H.setTime(Number(J)*1000);B=new Date();L=B.valueOf()-H.valueOf();if(L<0){return"Moments ago"}if(L>3*(E.days)){C=true}A=["January","February","March","April","May","June","July","August","September","October","November","December"];M=["th","st","nd","rd","th"];N=H.getDate();I=A[H.getMonth()].substr(0,3)+" "+N+", "+H.getFullYear()+", "+((H.getHours()%12)||12)+":"+(H.getMinutes()>=10?"":"0")+H.getMinutes()+" "+(H.getHours()<12?"AM":"PM");D=[];for(G in E){if(L>E[G]){D.push(G);continue}}if(D.length==0){return"Moments ago"}D=D.slice(Math.max(D.length-(K||2),0));F=[];while(G=D.pop()){N=Math.floor(L/E[G]);L%=E[G];if(N>0){F.push(N+" "+(N==1?G.substr(G,G.length-1):G))}}F=F.join(", ")+" ago";return'<span title="'+(C?F:I)+'">'+(C?I:F)+"</span>"}if(window.DWait){DWait.run("jms/lib/formatting.js")}DWait.count();