/*
 *  © 2000-2010 deviantART, Inc. All rights reserved.
 */
if(!window.AutoExec){AutoExec=[]}CSSVault={get:function(A){if(!this.vault[A]){this.vault[A]=Tree.create("style",{type:"text/css"},"");(Tree.get("head")||document.documentElement).appendChild(this.vault[A])}return this.vault[A]},vault:{},apply:function(C,B){var A;A=this.get(C);if(A.styleSheet){A.styleSheet.cssText=B}else{while(A.firstChild){A.removeChild(A.firstChild)}A.appendChild(document.createTextNode(B))}},free:function(B){var A;A=this.get(B);A.ownerNode.removeChild(A);delete this.vault[B]}};if(window.DWait){DWait.run("jms/lib/cssvault.js")}FEATURED_FOLDER_ATTRIBUTE_NO_SCRAPS_LINK=1;FEATURED_FOLDER_ATTRIBUTE_COLLECTIONS_SPECIAL=1;FEATURED_FOLDER_ATTRIBUTE_SWAP_SIDEBAR=2;FEATURED_FOLDER_ATTRIBUTE_SIDEBAR_NO_ICON=4;FEATURED_FOLDER_ATTRIBUTE_SIDEBAR_NO_TEXT=8;FEATURED_FOLDER_ATTRIBUTE_SIDEBAR_ICON_MASK=4|8;FOLDER_ATTRIBUTE_CUSTOM_ICON_MASK=1|2;FOLDER_ATTRIBUTE_ICON_FOREGROUND=16;FOLDER_ATTRIBUTE_SWAP_TEXT=32;FOLDER_ATTRIBUTE_CLIPBOARD=64;FOLDER_ATTRIBUTE_WITHOUT_HAT=512;FOLDER_ATTRIBUTE_HUGE_ART=1024;FOLDER_ATTRIBUTE_DISABLE_COMMENTS=2048;FOLDER_ATTRIBUTE_ICON_CACHE_MASK=61440;BITSHIFT_FOLDER_ATTRIBUTE_ICON_CACHE_MASK=12;GALLERY_DEFAULT_PRIVSET={"delete":true,rename:true,view:true,log:true,options_button:true,arrange_folders:true,edit_button:true,blue_buttons:true,create_folder:true};GALLERY_FEATURED_ID=-1;if(window.DWait){DWait.run("jms/pages/gallery/gallery_constants.js")}function Gallery(){}Gallery.prototype={debug_label:"Gallery",on:function(){this.node.setAttribute("keeper_done",1);this.typeid=this.domData.getAttribute("folder_api")=="Collections"?COMMENT_FAVCOLLECTIONS:COMMENT_GALLERIES;this.api_name=this.domData.getAttribute("folder_api")=="Collections"?"Collections":"Gallery";this.setProp("querybase",this.typeid==COMMENT_FAVCOLLECTIONS?"favby":"gallery");this.setProp("folder",this.typeid==COMMENT_FAVCOLLECTIONS?"Collection":"Folder");this.gallery_deviant=this.domData.getAttribute("gallery_deviant");this.gallery_symbol=this.domData.getAttribute("gallery_symbol");this.moduleid=Number(document.getElementById("full-module-aggmanager").getAttribute("mod-id"));this.pre3=Boolean(Number(this.domData.getAttribute("pre3")));this.delayed_difi_saves={};this.gallery_id=this.domData.getAttribute("gallery_id");this.is_group=document.getElementById("group")&&!document.getElementById("deviant");this.setProp("gallery_owner",Boolean(Number(this.domData.getAttribute("gallery_owner"))));this.setProp("subscription_features",Boolean(Number(this.domData.getAttribute("subscription_features"))));this.setProp("count_per_page",Number(this.domData.getAttribute("browse_limit")));this.setProp("daily_deviations",Number(this.domData.getAttribute("gallery_dds")));this.setProp("scraps",Number(this.domData.getAttribute("gallery_scraps")));Events.hook(window,"resize",Refunction(this,this.resized));this.resized();if(window.Popup){Popup.go(true)}else{Bug.log("BIG PROBLEM sista","no menus? how we gonna eat?")}this.get("ui","boot")},off:function(){if(this.navigation_watch_lookup){BackForward.removeListener(this.navigation_watch_lookup)}Events.unhook(window,"resize",Refunction.lastCall(this,this.resized));Tree.removeClass(this.node,"skin1");Tree.removeClass(this.node,"skin2");this._KP_keep_node=true;this.get("old ui","restore")},resized:function(){if(Tree.get(this.node,"table.gallery-master")){Tree.get(this.node,"table.gallery-master").style.height=Ruler.screen.rect().y2+"px"}},propMap:{page_loaded:{get:function(){return false}},ads:{get:function(){var A;A=Tree.get("#gallery-ads");return A?Tree.get(A,"div.iframe"):null}},ads2:{get:function(){var A;A=Tree.get("#gallery-ads-fallback");return A?Tree.get(A,"div.iframe"):null}},folder:{get:function(){return"Folder"}},querybase:{get:function(){return"gallery"}},difi_retry_mode:{get:function(){return null}},subscription_features:{get:function(){return false}},url_page:{get:function(){return 0}},url_section:{get:function(){return""}},url_browse:{get:function(){return"featured"}},url_master:{get:function(){},watches_props:{sectionid:tmp=function(history,current,method,name){var _section,sectionid,page,browse,edit_mode,base;if(method=="navigate"||method=="get"||method=="invalidate"){return }sectionid=this.getProp("sectionid");if(name=="sectionid"&&method!="navigate"){page=0}else{page=this.getProp("url_page")}browse=this.getProp("url_browse");edit_mode=this.getProp("edit_mode");base=edit_mode?"_edit_":"";if(sectionid){with(this.peek("data","current section")){reset();run();_section=status.result}if(!_section||_section.sectionid!=sectionid){Bug.log("WARNING","Unexpected missing section data");DRE.breakpoint();return }BackForward.load(base+_section.url_name+(page>1?"--"+page:""))}else{BackForward.load(base+"_"+browse+(page>1?"--"+page:""))}},url_page:tmp,url_browse:tmp,edit_mode:tmp}},sectionid:{get:function(){return 0},change:function(C,B,D){var A;if(C.length>1){A=this.getProp("edit_mode")?0:82;if(Browser.isGecko){document.documentElement.scrollTop=A}else{document.body.scrollTop=A}}this.peek("data","relevant sections").reset();if(!B){this.get("ui","browse")}else{this.get("ui","current section")}},watches_props:{url_section:function(B,A){Task.station(this.peek("data","sections"),[this.propMap.sectionid.url_section_process,this,A])}},url_section_process:function(B){var A,C;C=Task.station.data[0];for(A=0;C[A];A++){if(C[A].url_name==B){this.setProp("sectionid",C[A].sectionid,"navigate");return }}this.setProp("sectionid",0,"navigate")}},"section behavior":{get:function(){var _section;with(this.peek("data","current section")){run();_section=status.result}if(!_section){_section=this.featured_section_data}if(_section){return _section.behavior}try{console.log("No behaviour for: "+this.getProp("sectionod")+"!")}catch(e){}return{view:true,faux:true}},watches_props:{sectionid:function(B,A){this.invalidateProp("section behavior")}}},gallery_owner:{get:function(){return false}},daily_deviations:{get:function(){return 0}},scraps:{get:function(){return 0}},count_per_page:{get:function(){return 24}},edit_mode:{get:function(){return false},change:function(A,B){if(B){if(!this.getProp("gallery_owner")&&!this.is_group){this.setProp("edit_mode",false,"override");return }if(!Tree.get("#editmode")){editbit=Tree.create("div",{id:"editmode"},Tree.createFragment('<a href="" class="x"><img alt="[x]" title="Done" src="http://s.deviantart.com/styles/minimal/minish/close-dev.gif"/></a><span class="editstate">Editing</span>'));document.body.appendChild(editbit);Events.hook(Tree.get(editbit,"a"),"click",Refunction(this,this.editClick,0))}else{}if(!Tree.hasClass(document.body,"editmode")){Tree.addClass(document.body,"editmode")}if(Browser.isGecko){document.documentElement.scrollTop=0}else{document.body.scrollTop=0}}else{if(A.length>1){DiFi.cached={};if(Tree.get(Tree.get("#editmode"),".editstate").innerHTML.toLowerCase().indexOf("saving")>=0){Station.push(Tree.get(Tree.get("#editmode"),"span.editstate"),"opacity",{from:1,to:0.01,time:400,f:Interpolators.sineCurve},{from:0,to:1,time:400,f:Interpolators.sineCurve},{from:1,to:0.01,time:400,f:Interpolators.sineCurve},{from:0,to:1,time:400,f:Interpolators.sineCurve});DiFi.timer(5)}else{DiFi.timer(5);Tree.removeClass(document.body,"editmode");Tree.destroy(Tree.get("#editmode"));if(Browser.isGecko){document.documentElement.scrollTop=60}else{document.body.scrollTop=60}}}}}},sidebar_visibility:{get:function(){if(Tree.get(this.node,"td.gsmaster")){this.peek("data","relevant sections").reset();this.get("data","relevant sections");if((this.peek("data","relevant sections").status.result||[true])[0]){Tree.removeClass(Tree.get(this.node,"td.gsmaster"),"gsmaster-empty")}else{Tree.addClass(Tree.get(this.node,"td.gsmaster"),"gsmaster-empty")}}},change:function(){},watches_props:{edit_mode:function(){this.invalidateProp("sidebar_visibility")}},render:KEEPER_RENDER_IMMEDIATE},editbutton_visibility:{get:function(){var A;if(A=document.getElementById("togglable-gallery-edit-button")){A.style.display=this.getProp("section behavior").edit_button?"block":"none"}},change:function(){},watches_props:{"section behavior":function(B,A){this.invalidateProp("editbutton_visibility")}}},featured_attributes:{get:function(){return(this.featured_section_data||{attributes:0}).attributes},change:function(B,A){if(B.length>1){if((B[1][0]&FEATURED_FOLDER_ATTRIBUTE_SWAP_SIDEBAR)!=(A&FEATURED_FOLDER_ATTRIBUTE_SWAP_SIDEBAR)&&!this.getProp("sectionid")){this.get("ui","browse")}}if(this.typeid==COMMENT_FAVCOLLECTIONS){if((A&FEATURED_FOLDER_ATTRIBUTE_COLLECTIONS_SPECIAL)&&this.pre3){this.setProp("folder","devPack")}else{this.setProp("folder","Collection")}}}}},mutations:{thumbnail_editing:{ArtZone:{on:function(){this.prop_watcher=this.up(Gallery).watchProp("edit_mode",this.ownerPropChange,this);this.prop_watcherB=this.up(Gallery).watchProp("url_page",this.ownerPropChange,this)},off:function(){this.up(Gallery).unwatchProp("edit_mode",this.prop_watcher);this.up(Gallery).unwatchProp("url_page",this.prop_watcherB)},ownerPropChange:function(C,B,D,A){switch(A){case"edit_mode":this.setProp("edit_mode",B);break;case"url_page":Bug.log("DOING","This is url.page and you're watching "+B);this.setProp("page",Number(B)-1,"navigate");break}},propMap:{super_secret_url_hack:{get:function(){},watches_props:{page:function(B,A,C){if(C!="navigate"&&C!="get"){Bug.log("IT IS I","And I'm setting it to "+A);this.up(Gallery).setProp("url_page",Number(A)+1,C)}}},render:KEEPER_RENDER_IMMEDIATE}},receiver:function(E,D,F,J,A,L,H){var G,C,I,K,B;if(!(F=="section"&&J==this.sectionid&&(A=="resource"||A=="sectionid"||(A=="new")))){Bug.update("broadcast",this.sectionid+" ZoneSkipped "+Task.argSlice(arguments,1));return }if(A=="new"){if(arguments[5].name=="Featured"&&this.sectionid==GALLERY_FEATURED_ID){this.sectionid=arguments[5].sectionid}return }if(A=="sectionid"){this.sectionid=arguments[5];return }G=[];I=Tree.get(this.node,"div.stream").childNodes;for(C=0;I[C];C++){if(I[C].nodeType==1&&I[C].getAttribute("collect_rid")){G.push(I[C])}}K=this.getProp("page")*this.count_per_page;for(C=0;G[C];C++){if(G[C].getAttribute("collect_rid")==L.join(":")){if((C+K)==H){return }B=G[C].parentNode.removeChild(G[C]);G.splice(G,C,1);break}}if(H>=K&&H<(K+this.count_per_page)){if(!B){if(!this.resource_remove_hits){this.resource_remove_hits=1}else{this.resource_remove_hits++}if(this.resource_remove_hits==5){this.get("ui","resources delayed")}return }Tree.insertBefore(B,G[H-K],Tree.get(this.node,"div.stream"))}if(B&&H<0){this.backup_scroll_position=document.documentElement.scrollTop||document.body.scrollTop;this.invalidateProp("last_id_change");this.get("ui","resources delayed")}}}}},navigationWatcher:function(E,D){var B,C,A;if((D||"").match(/^\/d[0-9a-z]+$/)){return }if(E!="navigate"){return }DRE.assert(typeof D=="string","What is it, one string? How hard is this fuckin' instrument?");if(D.match(/\-\-\d+$/)){A=D.split("-");B=Number(A.pop());A.pop();C=A.join("-")}else{B=1;C=D}if(C.substring(0,6)=="_edit_"){C=C.substr(6);this.setProp("edit_mode",true,"navigate")}else{this.setProp("edit_mode",false,"navigate")}if(C.charAt(0)=="_"){if(C.substr(1)==String(Number(C.substr(1)))){this.setProp("sectionid",Number(C.substr(1)))}else{this.setProp("url_section","","navigate");this._KP_getPropTask("url_browse").milestone("data",C.substr(1),"navigate","url_browse")}}else{if(C){this.setProp("url_section",C,"navigate")}else{this.setProp("url_browse","featured","navigate");this.setProp("url_section","","navigate")}}this.setProp("url_page",B,"navigate")},editClick:function(A){this.setProp("edit_mode",Tree.hasClass(document.body,"editmode")?false:"gallery");return false},publishClick:function(){if(!window.WidgetUtils){return alert("WidgetsUtils JS not loaded.")}if(this.typeid==COMMENT_FAVCOLLECTIONS){WidgetUtils.modal("GrusersModules",GMI.query("Gruser")[0].gmi_args.id,"faves","favourites","publish",{set:this.getProp("sectionid")||this.featured_section_data.sectionid},{w:618,h:370})}else{WidgetUtils.modal("GrusersModules",GMI.query("Gruser")[0].gmi_args.id,"gallery","gallery","publish",{set:this.getProp("sectionid")||this.featured_section_data.sectionid},{w:618,h:370})}},newSectionClick:function(){var A;A={galleryid:this.gallery_id,type:this.typeid,sectionid:-GUID.get(),query:"",name:null,url_name:null,text:"",display_text:"",css:"",safe_css:"",parentid:this.getProp("sectionid"),attributes:0,behavior:GALLERY_DEFAULT_PRIVSET,ids:[]};this.broadcast("section",null,"new",A);return false},difiSave:function(C,B,A){var D;switch(C){case"delete":case"rename":case"reposition":case"add_resource":case"copy_resource":case"reposition_resource":case"remove_resource":case"set_text":case"set_css":case"set_attributes":if(B[3]<0){if(B[3]==GALLERY_FEATURED_ID){D=this.peek("data","featured section").status.result;if(D){Bug.update("Modifying section call",B[1]+" to "+D.sectionid);B[3]=D.sectionid;break}}if(!this.delayed_difi_saves[B[3]]){this.delayed_difi_saves[B[3]]=[]}Bug.update("Intercept "+C+" on "+B[3]);this.delayed_difi_saves[B[3]].push(arguments);if(B[3]==GALLERY_FEATURED_ID){this.get("data","featured section")}return }break}if(C!="create_featured"){if(Tree.get("#editmode")){Tree.setText(Tree.get(Tree.get("#editmode"),".editstate"),"Auto-saving changes...")}}Bug.update("Shipping "+C+" on "+B[0]);DiFi.pushPost("Aggregations",C,B,this.saver,A||this)},receiver:function(J,B,C,G,A,H,Q,D){var K,I,N,R,O,M,F,E,L,P;if(B!=this&&B.up(Gallery)!=this){Bug.log("broadcast","Rejected "+A);return }if(C=="sectionui"){I=G;N=A;switch(N){case"name":R=H;DRE.assert(I);DRE.assert(I!=GALLERY_FEATURED_ID,"Can't rename Featured");this.broadcast("section",I,"name",R);if(I<0){if(Number(Q.parentid)){this.difiSave("create_subfolder",[this.gallery_id,this.moduleid,this.typeid,R,50000,Q.parentid],{gallery:this,oldid:I})}else{this.difiSave("create",[this.gallery_id,this.moduleid,this.typeid,R,50000],{gallery:this,oldid:I})}DiFi.timer(5)}else{this.difiSave("rename",[this.gallery_id,this.moduleid,this.typeid,I,R]);DiFi.timer(6000)}break;case"delete":this.broadcast("section",I,"delete");this.difiSave("delete",[this.gallery_id,this.moduleid,this.typeid,I]);DiFi.timer(2000);break;case"position":this.broadcast("section",I,"position",H);this.difiSave("reposition",[this.gallery_id,this.moduleid,this.typeid,I,H]);DiFi.timer(4000);break;case"resource":E=Q;from_id=D;this.broadcast("section",I,"resource",H,E);DRE.breakpoint();if(E>=0){if(this.is_group){if(from_id&&from_id!=I){this.difiSave("copy_resource",[this.gallery_id,this.moduleid,this.typeid,I,from_id,H[0],H[1],E])}else{this.difiSave("reposition_resource",[this.gallery_id,this.moduleid,this.typeid,I,H[0],H[1],E])}}else{this.difiSave("add_resource",[this.gallery_id,this.moduleid,this.typeid,I,H[0],H[1],E])}}else{this.difiSave("remove_resource",[this.gallery_id,this.moduleid,this.typeid,I,H[0],H[1]])}DiFi.timer(6000);break;case"options":R=H.name&&Gallery.makeValidNameString(H.name);if(R){this.broadcast("section",I,"name",R);this.difiSave("rename",[this.gallery_id,this.moduleid,this.typeid,I,R])}if(H.text!==undefined){this.difiSave("set_text",[this.gallery_id,this.moduleid,this.typeid,I,H.text]);this.broadcast("section",I,"text",H.text)}if(H.css!==undefined){this.broadcast("section",I,"css",H.css);this.difiSave("set_css",[this.gallery_id,this.moduleid,this.typeid,I,H.css])}if(H.attributes!==undefined){this.broadcast("section",I,"attributes",H.attributes);this.difiSave("set_attributes",[this.gallery_id,this.moduleid,this.typeid,I,H.attributes])}DiFi.timer(1);break}}else{if(C=="section"){I=G;N=A;K=this.peek("data","sections").status.result;DRE.assert(K,"sections are definitely loaded at receive time");if(I&&I!=GALLERY_FEATURED_ID){for(O=0;K[O];O++){if(K[O].sectionid==I){F=O;break}}if(F===undefined){Bug.log("broadcast","Section not found: "+N+" "+I+".. weird, right?");return }}if(this.typeid==COMMENT_FAVCOLLECTIONS){document.cookie="lubfavexp="+Math.floor((new Date()).valueOf()/1000)+"; path=/; domain=.deviantart.com"}switch(N){case"new":K.push(H);Bug.log("broadcast","Done: new id "+H.sectionid);if(H.name=="Featured"){Bug.log("broadcast","It's a featured section!");this.peek("data","featured section").done(H)}this.get("data","url names");break;case"delete":DRE.assert(I,"sid0");K.splice(F,1);if(I==this.getProp("sectionid")){}break;case"position":DRE.assert(I,"sid0.4");E=H;Bug.log("broadcast","Got: position "+H);for(O=0;K[O];O++){if(K[O].sectionid==I){if(O==E){return }G=K.splice(O,1)[0];break}}DRE.assert(E>-1,"No section deletions by negative index");K.splice(E,0,G);break;case"sectionid":Bug.log("broadcast","Done: New sectionid: "+I+" -> "+H);DRE.assert(I,"sid1");K[F].sectionid=H;if(I<0){Bug.update("Released!",I+" to "+H);if(P=this.delayed_difi_saves[I]){for(O=0;P[O];O++){P[O][1][3]=H;this.difiSave.apply(this,P[O])}}DiFi.timer(1)}break;case"name":DRE.assert(I,"sid1.33");Bug.log("broadcast","Done: Named "+H);K[F].name=H;this.get("data","url names");break;case"attributes":DRE.assert(I,"sid1.1million");Bug.log("broadcast","New attributes "+N+": "+H);K[F].attributes=H;if(K[F].sectionid==GALLERY_FEATURED_ID||K[F].sectionid==(this.featured_section_data||{}).sectionid){this.setProp("featured_attributes",H)}break;case"text":case"css":DRE.assert(I,"sid2");Bug.log("broadcast","Done: Updated "+N+": "+H);K[F][N]=H;break;case"formattext":K[F].display_text=H;break;case"safecss":K[F].safe_css=H;break;case"rids":DRE.assert(I,"sid29");Bug.log("broadcast","Modifying all IDs: "+I+" ~ "+H.length);K[F].ids=H;break;case"resource":DRE.assert(I,"sid3");L=H;E=Q;Bug.log("broadcast","Modifying IDs: resource "+I+"."+H+" at: "+E);for(M=0;K[F].ids[M];M++){if(K[F].ids[M][0]==L[0]&&K[F].ids[M][1]==L[1]){if(M==E){Bug.log("broadcast","No modification (bug "+K[F].ids.guid+")");return }Bug.log("broadcast","Modified: (bug "+K[F].ids.guid+")");K[F].ids.splice(M,1)}}if(E>-1){K[F].ids.splice(E,0,L)}break}}}},saver:function(K,C){var D,L,J,A,C,H,G,B,I,F,E;E="Some changes were not saved because the deviantART server could not be reached";if(!K&&!C.request){if(this.getProp("edit_mode")){alert("Unable to edit gallery. Please check your internet connection.");Tree.setText(Tree.get(Tree.get("#editmode"),".editstate"),"Editing");this.setProp("edit_mode",false)}return }F=((this.gallery||{}) instanceof Gallery)?this.gallery:this;if(K){switch(C.request.method){case"create":case"create_subfolder":this.gallery.broadcast("section",this.oldid,"sectionid",C.response.content);break;case"create_featured":B=[];for(D=0;C.response.content.ids[D];D++){B.push([COMMENT_DEVIATION,C.response.content.ids[D]])}I=C.response.content.approx_total;while(Number(I)>B.length){B.push(null)}C={sectionid:C.response.content.galleryid,approx_total:I,type:this.typeid,galleryid:this.gallery_id,parentid:0,query:this.getProp("querybase")+":"+this.gallery_deviant+"/"+C.response.content.galleryid,name:"Featured",url_name:"featured",text:"",css:"",display_text:"",safe_css:"",attributes:0,behavior:GALLERY_DEFAULT_PRIVSET,ids:B};Bug.log("Here it is","And it's where it's AT "+B.guid);this.featured_section_data=C;this.setProp("featured_attributes",C.attributes);this.broadcast("section",GALLERY_FEATURED_ID,"new",C);if(H=this.delayed_difi_saves[GALLERY_FEATURED_ID]){for(D=0;H[D];D++){H[D][1][3]=edx;this.difiSave.apply(this,H[D])}}return ;case"set_text":this.broadcast("section",C.request.args[3],"formattext",String(C.response.content));break;case"set_css":console.log(C.response.content);if(C.response.content&&(typeof C.response.content.style)=="string"){this.broadcast("section",C.request.args[3],"safecss",C.response.content.style)}else{if(typeof C.response.content=="string"){this.broadcast("section",C.request.args[3],"safecss",C.response.content)}else{DRE.assert(typeof C.response.content=="object");this.broadcast("sectionmessage",C.request.args[3],"badcss",C.response.content)}}break;case"reset_featured":if(C.response.content&&C.response.content.rids){B=C.response.content.rids;I=Number(C.response.content.approx_total);while(I&&I>B.length){B.push(null)}}else{B=C.response.content}this.broadcast("section",this.featured_section_data.sectionid,"rids",B);break;case"sort_folder":if(C.response.content&&C.response.content.rids){B=C.response.content.rids;I=Number(C.response.content.approx_total);while(I&&I>B.length){B.push(null)}}else{B=C.response.content}this.broadcast("section",C.request.args[3],"rids",B);break}if(Tree.get("#editmode")){Tree.setText(Tree.get(Tree.get("#editmode"),".editstate"),"Auto-saved");if(!App.instance._KP_gets(Gallery)[0].getProp("edit_mode")&&Tree.hasClass(document.body,"editmode")){Tree.removeClass(document.body,"editmode");if(Browser.isGecko){document.documentElement.scrollTop=82}else{document.body.scrollTop=82}}}return }DRE.breakpoint();A=F.getProp("difi_retry_mode");if(C.response.content&&String(C.response.content.error).toLowerCase().indexOf("auth")>=0){E="Some changes were not saved because you do not have the necessary permission."}switch((C.request||{}).method){case"create":case"create_subfolder":if(String((C.response.content||{}).error).indexOf(" limit ")>=0){E="There is no room for new "+(F.typeid==COMMENT_FAVCOLLECTIONS?"collections":" gallery folders")+"."}break}if(A==null){A=confirm(E+"\n\nTry again?");F.setProp("difi_retry_mode",A);setTimeout(Refunction(F,F.invalidateProp,"difi_retry_mode"))}if(A){if(F.getProp("edit_mode")){Tree.setText(Tree.get(Tree.get("#editmode"),".editstate"),"Saving changes...")}DiFi.pushPost(C.request["class"],C.request.method,C.request.args,arguments.callee,this);DiFi.timer(100);return }Tree.setText(Tree.get(Tree.get("#editmode"),".editstate"),"Editing");switch(C.request.method){case"create":case"create_subfolder":F.broadcast("section",this.oldid,"delete");break;default:Bug.log("broadcast","Unknown failure: "+C.request.method);if(F.getProp("edit_mode")){Tree.setText(Tree.get(Tree.get("#editmode"),".editstate"),"Error: Some changes were not saved");F.setProp("edit_mode",true)}}},nodeMap:{ownerlink:{get:function(){DRE.halt("This won't work because there's no way to invalidate the node cache");return Tree.get()}}},stuff:{ui:{boot:{needs:[["data","sections"]],get:function(A){BackForward.IE_bypass_firstrun=true;this.navigation_watch_lookup=BackForward.addListener(bind(this,this.navigationWatcher));A.done()}},browse:{needs:[["ui","clear"],["data","sections"]],think:function(A,E,C){var B,D;this.node.appendChild(Tree.create("div.gallery"));B=this.spawn(GallerySwitch,{orientation:this.option_bar_horizontal?"horizontal":"vertical",data:C,uplink:null});if(this.option_bar_horizontal){Tree.addClass(B.node,"galleryswitch-tt");this.node.insertBefore(B.node,this.getNode("gallery"))}else{if(D=document.getElementById("gallery-sidebar-placeholder")){D.appendChild(B.node)}else{this.node.appendChild(Tree.createFragment('<table class="f full gallery-master"><tr><td class="f"></td><td class="f"></td></tr></table>'));if(this.featured_section_data&&this.featured_section_data.attributes&FEATURED_FOLDER_ATTRIBUTE_SWAP_SIDEBAR){Tree.addClass(Tree.gets(this.node,"td")[1],"galleryswitch-rr gsmaster");Tree.gets(this.node,"td")[1].appendChild(B.node);Tree.get(this.node,"td").appendChild(this.getNode("gallery"))}else{Tree.addClass(Tree.get(this.node,"td"),"galleryswitch-ll gsmaster");Tree.get(this.node,"td").appendChild(B.node);Tree.gets(this.node,"td")[1].appendChild(this.getNode("gallery"))}}}this.getNode("gallery").appendChild(this.spawn(BrowseBubble,{username:this.gallery_deviant}).node);this.invalidateProp("sidebar_visibility");setTimeout(Refunction(this,this.resized),1);A.done();if(Tree.get("td.gruze-sidebar")){Tree.get("td.gruze-sidebar").style.display=(Browser.isIE?"block":"table-cell")}}},clear:{needs:[["old ui","backup"],["old ui","clear"]],think:function(A){this._KP_clear(GallerySwitch);this._KP_clear(BrowseBubble);this._KP_clear(FolderView);Tree.addClass(this.node,"skin1");if(Tree.get(this.node,"table")){this.node.removeChild(Tree.get(this.node,"table"))}A.done()}},"current section":{needs:[["ui","clear"],["data","current section"]],think:function(B,A,C){this.node.appendChild(this.spawn(FolderView,{uplink:C}).node);if(Tree.get("td.gruze-sidebar")){Tree.get("td.gruze-sidebar").style.display="none"}}},ad:{think:function(B){var A,C;if(Tree.get("#gallery-admaster")){if(this.typeid==COMMENT_FAVCOLLECTIONS){A="right_wr_collections"}else{A="right_wr_usergallery"}}else{A=""}C=this.getProp("page_loaded");this.setProp("page_loaded",true);if(C&&window.pageTracker){pageTracker._setDomainName(".deviantart.com");pageTracker._trackPageview("/"+(this.typeid==COMMENT_GALLERIES?"usergallery":"usercollections")+"/difi/?"+String(window.location.hash).replace(/^#/,""))}if(!Tree.get("#gallery-admaster")){B.done(null);return }DiFi.pushPage(this.typeid==COMMENT_GALLERIES?"gallery":"favourites",{ad_frame:"atf_right_300x250",ad_keys:"Section:"+(this.typeid==COMMENT_GALLERIES?"usergallery":"usercollections"),ad_buster:(new Date()).valueOf(),ad_mature:Number(Boolean(Tree.get("a.ismature"))),nostat:true},bind(this,arguments.callee.ebx.dififrame,B))},dififrame:function(A,C,B){A.done(C?{frame:C,data:B}:null)}},access:{needs:[["data","sections"],["data","current section"]],think:function(A,D,C,I,H){var F,E,B,G;G=Number(this.getProp("sectionid"));GMAccess.show(GMI.query("Gruser")[0].gmi_args.id,this.typeid==COMMENT_FAVCOLLECTIONS?"favcollection":"galleryfolder",G?G:this.featured_section_data.sectionid,C=="view",G?"Group "+this.getProp("folder")+": "+H.name:"Group "+(this.typeid==COMMENT_FAVCOLLECTIONS?"Favourites":"Gallery: Featured"),D);A.done()}}},data:{"partial sections":{get:function(A){A.wait(Task.DiFi(DiFi.pushPublicGet,this,"Aggregations","get_galleries_initial",[this.gallery_id,this.typeid,this.getProp("gallery_owner")||this.is_group?0:1]))}},"full sections":{needs:[["data","partial sections"]],get:function(C,B){var E,A,D,F;A=[];if(!App.resources_by_rid_cache){App.resources_by_rid_cache={}}for(E=0;B[E];E++){F=Browser.isGecko?[]:Array(Number(B[E].approx_total));for(D=0;D!=B[E].top_resources.length;D++){if(Browser.isGecko){F.push([B[E].top_resources[D][0],B[E].top_resources[D][1]])}else{F[D]=[B[E].top_resources[D][0],B[E].top_resources[D][1]]}App.resources_by_rid_cache[B[E].top_resources[D][0]+":"+B[E].top_resources[D][1]+":stacktile:"]=(B[E].top_resources[D][2]||"").replace(/ collect_rid=/g," nop_rid=")||null}if(Browser.isGecko){while(F.length<Number(B[E].approx_total)){F.push(null)}}A.push({sectionid:B[E].galleryid,type:B[E].type,galleryid:this.gallery_id,parentid:B[E].parentid||0,query:"",name:B[E].title,url_name:null,text:undefined,css:"",attributes:B[E].attributes,behavior:B[E].behavior,ids:B[E].ids&&B[E].ids.length?Gallery.padArray(B[E].ids,B[E].approx_total):F});if(B[E].title=="Featured"){this.featured_section_data=A[A.length-1];this.setProp("featured_attributes",this.featured_section_data.attributes)}}C.done(A)}},sections:{needs:[["data","full sections"]],get:function(B,E){var G,D,C,A,F;if(!App.resources_by_rid_cache){App.resources_by_rid_cache={}}this.peek("data","url names").run(E);A=(this.typeid==COMMENT_FAVCOLLECTIONS?"":"artist:0");for(D=0;E[D];D++){G=DiFi.cached["Resources;htmlFromQuery;"+(this.typeid==COMMENT_FAVCOLLECTIONS?"favby":"gallery")+":"+this.gallery_deviant+"/"+E[D].sectionid+",0,"+this.getProp("count_per_page")+",thumb150,"+A];if(G&&G.response.status){for(C=0;F=G.response.content.resources[C];C++){App.resources_by_rid_cache[F[0]+":"+F[1]+":thumb150:"+A]=F[2]||null}}}B.done(E)}},"relevant sections":{needs:[["data","sections"]],get:function(B,E){var D,A,C;C=this.getProp("sectionid");A=[];for(D=0;E[D];D++){if(E[D].name!="Featured"&&(Number(E[D].parentid)||0)==(Number(C)||0)){A.push(E[D])}}B.done(A)}},"current section":{needs:[["data","sections"]],think:function(A,B){A.done(this.getCurrentSection(B))}},"featured section":{get:function(A){if(this.featured_section_data){A.done(this.featured_section_data);return }this.difiSave("create_featured",[this.gallery_id,this.typeid,0]);DiFi.timer(10)}},"url names":{think:function(A,G){var C,F,D,E,B;if(!G){G=this.peek("data","sections").status.result;DRE.assert(G,"Something goofy?")}F=[];for(C=0;G[C];C++){F.push({sectionid:G[C].sectionid,url_name:(G[C].name||"untitled").replace(/[^0-9a-zA-Z]+/g,"-")})}F.sort(arguments.callee.ebx.sorter);B=[];for(C=0;F[C];C++){E=F[C].url_name;do{for(j=0;B[j];j++){if(E==B[j]){D=(E.match(/(\d+)$/)||[])[1];if(D){E=E.substr(0,E.length-D.length)+(parseInt(D)+1)}else{E=E+"2"}j=-1;break}}}while(j==-1);F[C].url_name=E;B.push(E)}for(j=0;F[j];j++){for(C=0;G[C];C++){if(G[C].sectionid==F[j].sectionid){G[C].url_name=F[j].url_name;break}}}},sorter:function(B,A){return B.sectionid-A.sectionid}}},"old ui":{clear:{needs:[["old ui","backup"]],get:function(A){if(Tree.hasClass(document.body,"gruze")){A.done();return }var B;this.node.style.minHeight=Ruler.screen.rect().y2+"px";if(Browser.isIE){this.node.style.height=Ruler.screen.rect().y2}B=Tree.get(this.node,"div.deviant");DRE.assert(B.parentNode==this.node);while(B.nextSibling){this.node.removeChild(B.nextSibling)}A.done()}},backup:{get:function(A){var B;B={};B.thumbnails=Tree.get(this.node,"div.stream");this.peek("old ui","restore").reset();A.done(B)}},restore:{needs:[["old ui","backup"]],get:function(A,B){this.peek("old ui","backup").reset();A.done()}}},code:{extras:{get:function(A){var B;if(window.DndDeck){A.done();return }B=document.createElement("script");B.setAttribute("type","text/javascript");B.setAttribute("src","http://s.deviantart.com/css/deck.js");(document.getElementsByTagName("head")[0]||document.documentElement).appendChild(B);arguments.callee.ebx.checkIt.call(this,A)},checkIt:function(A){if(window.DndDeck){setTimeout(Refunction(A,A.done,null),1)}else{setTimeout(Refunction(this,arguments.callee,A),150)}}},deck:{needs:[["code","extras"]],get:function(B){var A;A=new DndDeck();A.error_details=true;A.loadDeck(Page.deckData);B.done(A)}}}},getCurrentSection:function(C){var B,A;A=this.getProp("sectionid");for(B=0;C[B];B++){if(C[B].sectionid==A){break}}return C[B]||null},getQuery:function(){var B,C,A;B=this.getProp("querybase")+":"+this.gallery_deviant;if(Number(this.getProp("sectionid"))){B+="/"+this.getProp("sectionid")}else{C=this._KP_gets(BrowseBubble)[0].getProp("query");if(C!="special:featured"){B=C}else{if(this.featured_section_data){B+="/"+this.featured_section_data.sectionid}}}return B},getTitle:function(){if(Number(this.getProp("sectionid"))){return this._KP_gets(FolderView)[0].uplink.name}if(this.is_group){"#"+this.gallery_deviant+" "+(this.typeid==COMMENT_GALLERIES?"gallery":"favourites")}return this.gallery_deviant+"'s "+(this.typeid==COMMENT_GALLERIES?"gallery":"favourites")},sitBack:function(){popupSitback(this.getTitle(),this.getQuery(),400,300)},showAccess:function(A,B){this.get("ui","access",A,B)},showSubmit:function(){var A;if(window.GroupMemberZone&&(A=GMI.query("GroupMemberZone")[0]||GMI.create("GroupMemberZone",{}))){A.showSubmit(this.typeid)}else{alert("Due to an unexpected error, submission to this group is not currently available.")}}};Gallery.getInstance=function(){return Keeper2.get(document.getElementById("full-module-aggmanager")||Tree.get("div.bubbleview"))};Gallery.makeValidNameString=function(A){A=A.replace(/[^a-zA-Z0-9\-_\ \.\?$'\":,\+]/g," ");A=A.replace(/(?:^\s+|\s+$)/g,"");A=A.replace(/\s{2,}/g," ");A=A.slice(0,44);if(!A.match(/^[a-zA-Z0-9\-_\ \.\?$'\"]{1,44}$/)){return null}return A};MenuTraffic.overrides.gallerylink=function(H){var M,D,J,E,C,I,B,F,L,G,A,K;M=H.split("/");D=[];I=Number(M[1]);B=M[2].split("-");G=B.length>1?String(B.length):"";DRE.assert(B.length>0,"woo hah");F=Gallery.getInstance();A=F.typeid==COMMENT_FAVCOLLECTIONS;F.peek("data","relevant sections").reset();F.get("data","relevant sections");J=[F.getCurrentSection(F.peek("data","sections").status.result),F.featured_section_data].concat(F.peek("data","relevant sections").status.result);K=(J[0]||(F.getProp("url_browse")=="featured"?F.featured_section_data:{})).sectionid;for(E=0;E!=J.length;E++){if(!J[E]){continue}if(B.length>1){if((J[E].name=="Featured"&&!F.getProp("sectionid"))||(Number(J[E].sectionid)==I)){C=-1}else{C=0}}else{if(K==J[E].sectionid){C=-1}else{for(C=0;J[E].ids[C];C++){if(J[E].ids[C][0]+":"+J[E].ids[C][1]==B[0]){C=-1;break}}}}if(C==-1){D.push({title:(J[E].name=="Featured"?(A?(F.is_group?'Remove from "Favourites"':'Hide from "Favourites"'):(F.is_group?'Remove from "Gallery"':'Remove from "Featured"')):"Remove "+G+' from "'+J[E].name+'"')+(F.is_group?"...":""),path:M.concat(["unput",J[E].sectionid]),children:null,flag:Math.min(E,2)})}else{D.push({title:J[E].name=="Featured"?'Show in "'+(A?"Favourites":(F.is_group?"Gallery":"Featured"))+'"':"Show "+G+' in "'+(J[E].name||"Devious Folder")+'"',path:M.concat(["put",J[E].sectionid,K]),children:null,flag:Math.min(E,2)})}}MenuTraffic.got(true,H,{"volatile":true,all:null,title:null,path:M,children:D});return true};Gallery.padArray=function(B,A){if(Browser.isGecko){while(A>B.length){B.push(null)}return B}else{return A<=B.length?B:B.concat(Array(A-B.length))}};if(window.DWait){DWait.run("jms/pages/gallery3.js")}function SectionEditor(){}SectionEditor.showCSS=function(){alert("CSS Available:\n- One-at-a-time descendant and class selectors\n- All standard visual CSS2.1 properties\n- Div &amp; Img tags with class names\n\nUnavailable:\n- Comments\n- Multiple selectors\n- Non-standard properties\n- Imports\n- Character Escaping\n\nHint:\n- Use body, or :root selector to change the entire background!")};SectionEditor.prototype={debug_label:"SectionEditor",template:'<form style="width:480px"><div style="margin:32px 0;padding:0 24px"><div class="modaltabs" style="margin-bottom:16px;border-bottom:1px solid #999;padding:2px;text-align:center;word-spacing:1.3em;"><a class="a" href="" onclick="Keeper2.get(this).activate(this);this.blur();return Events.stop();">Text</a> <a class="a g-only" href="" onclick="Keeper2.get(this).activate(this);this.blur();return Events.stop();">Arrange</a> <a class="a" href="" onclick="Keeper2.get(this).activate(this);this.blur();return Events.stop();">Icon</a> <a class="a" href="" onclick="Keeper2.get(this).activate(this);this.blur();return Events.stop();">Style</a></div><div class="modaltab"><div style="height:316px">Name:<br/><input type="text" class="name" style="font:9pt Verdana;width:400px"/><br/><br/>Text:<br/><textarea class="text" style="font:9pt Verdana;width:400px;height:220px"></textarea><br/>Text Placement: &nbsp;<label><input type="radio" name="attr'+FOLDER_ATTRIBUTE_SWAP_TEXT+'" value="0"/> Left</label> &nbsp; <label><input type="radio" name="attr'+FOLDER_ATTRIBUTE_SWAP_TEXT+'" value="'+FOLDER_ATTRIBUTE_SWAP_TEXT+'"/> Right</label><br/><br/><label class="c-only"><input type="checkbox" name="negattr'+FOLDER_ATTRIBUTE_DISABLE_COMMENTS+'" value="0"/> Allow Comments</label></div><div style="padding:32px 0 0 0;text-align:right"><input type="submit" name="done" value="OK" style="width:12ex"/> &nbsp;&nbsp;&nbsp;<input type="submit" name="cancel" value="Cancel" style="width:12ex"/> </div></div><div class="modaltab" style="display:none"><div style="height:316px"><strong>Quick Rearrange</strong><br/><input type="submit" name="newest" value="Newest to Oldest..."/><br/><input type="submit" name="oldest" value="Oldest to Newest..."/></div><div style="padding:32px 0 0 0;text-align:right"><input type="submit" name="done" value="OK" style="width:12ex"/> &nbsp;&nbsp;&nbsp;<input type="submit" name="cancel" value="Cancel" style="width:12ex"/> </div></div><div class="modaltab" style="display:none"><div style="height:316px"><div class="the-icon"><div class="the-icon-ctrl1"><div class="the-icon-ctrl"><i class="aa">&nbsp;</i></div></div></div><div class="c ppt"><input type="submit" name="icon" value="Change Icon..."/><br/><br/><input type="submit" name="nullicon" value="Reset Icon" style="display:none" class="iconresetbutton"/></div></div><div style="padding:32px 0 0 0;text-align:right"><input type="submit" name="done" value="OK" style="width:12ex"/> &nbsp;&nbsp;&nbsp;<input type="submit" name="cancel" value="Cancel" style="width:12ex"/> </div></div><div class="modaltab" style="display:none"><div style="height:316px"><div class="subbysensei" style="color:#AB2E50"><img src="http://s.deviantart.com/minish/widgets/subby.gif" alt=""/> <span><a target="_blank" href="http://my.deviantart.com/services/#subscription" style="text-decoration:none;color:#AB2E50">Premium Membership</a> Feature</span></div><br/><label><input class="subonly" type="checkbox" name="negattr'+FOLDER_ATTRIBUTE_WITHOUT_HAT+'"/> Show Profile Bar</label><br/><br/><a href="" class="css-link" onclick="if (confirm(\'CSS Styling is recommended for deviants with advanced knowledge of Cascading Style Sheets. Do you want to access the CSS editing area?\'))Keeper2.get(this).setProp(\'css_visible\', true);return Events.stop()">Add CSS...</a><div class="super-secret-css" style="display:none"><strong>CSS</strong><br/><textarea class="css subonly pick-me" style="font:9pt Verdana;width:400px;height:180px"></textarea><br/><a href="#" onclick="SectionEditor.showCSS();return Events.stop()">Limitations</a><br/></div></div><div style="padding:32px 0 0 0;text-align:right"><input type="submit" name="done" value="OK" style="width:12ex"/> &nbsp;&nbsp;&nbsp;<input type="submit" name="cancel" value="Cancel" style="width:12ex"/> </div></div></div></form>',on:function(){var A,B,D,C;DRE.assert(this.owner instanceof FolderView);Modals.push.call({gecko_fix:true},this.node,Refunction.runOnce(this,this.modalResult));this.getNode("name").value=this.owner.uplink.name;this.getNode("text").value=this.owner.uplink.text||"";this.getNode("css").value=this.owner.uplink.css||"";D=this.owner.uplink;A=Tree.gets(this.node,"input");for(C=0;A[C];C++){switch(A[C].type){case"checkbox":if(B=String(A[C].name).match(/^attr(\d+)$/)){if(D.attributes&Number(B[1])){A[C].checked=true}}else{if(B=String(A[C].name).match(/^negattr(\d+)$/)){if(!(D.attributes&Number(B[1]))){A[C].checked=true}}}break;case"radio":if(B=String(A[C].name).match(/^attr(\d+)$/)){if(Number(D.attributes&Number(B[1]))==Number(A[C].value)){A[C].checked=true}}break}}if(this.up(Gallery).typeid==COMMENT_FAVCOLLECTIONS){nodes=Tree.gets(this.node,".g-only");for(C=0;nodes[C];C++){nodes[C].style.display="none"}}else{Tree.get(this.node,"label.c-only").style.display="none"}Tree.get(this.node,"div.the-icon-ctrl").appendChild(this.spawn(GalleryStack,{uplink:this.owner.uplink}).node);if(!this.up(Gallery).getProp("subscription_features")){this.setProp("css_visible",true);Tree.get(this.getNode("subbysensei"),"span").innerHTML=this.up(Gallery).getProp("folder")+' Styling is a new <a target="_blank" href="http://my.deviantart.com/services/#subscription" style="color:#AB2E50">Premium Member-only feature</a>';A=Tree.gets(this.node,".subonly");for(C=0;A[C];C++){A[C].disabled=true}}this.activate(Tree.gets(this.node,"a")[this.mc("tab"+this.owner.uplink.sectionid)||0])},linkIndex:function(B){var A;A=0;while(B=B.previousSibling){if(Tree.tag(B)=="a"){A++}}return A},deactivate:function(){var A,B;B=Tree.get(this.getNode("modaltabs"),"a.active");if(B){Tree.removeClass(B,"active")}Tree.gets(this.node,"div.modaltab")[B?this.linkIndex(B):0].style.display="none"},activate:function(D){var B,D,C,A;this.deactivate();Tree.addClass(D,"active");C=Tree.gets(this.node,"div.modaltab")[this.linkIndex(D)];A=Tree.get(C,".pick-me");setTimeout(Refunction(this,this.delayedFocus,A),1);C.style.display="block";this.mc("tab"+this.owner.uplink.sectionid,this.linkIndex(D))},delayedFocus:function(A){try{A.focus()}catch(B){}},modalResult:function(F,E){var E,C,B,D,A;A=this.up(Gallery);switch(F){case"keeper":return true;case"done":E={};if(this.old_attributes!==undefined){this.broadcast("section",this.owner.uplink.sectionid,"attributes",this.old_attributes);this.old_attributes=undefined}E.name=this.getNode("name").value;E.text=this.getNode("text").value;E.css=this.getNode("css").value;if(E.name==this.owner.uplink.name||!E.name){delete E.name}if(E.text==this.owner.uplink.text){delete E.text}if(E.css==(this.owner.uplink.css||"")){delete E.css}C=0;B=Tree.gets(this.node,"input");for(D=0;B[D];D++){switch(B[D].type){case"checkbox":if(match=String(B[D].name).match(/^attr(\d+)$/)){if(B[D].checked){C|=Number(match[1])}}else{if(match=String(B[D].name).match(/^negattr(\d+)$/)){if(!B[D].checked){C|=Number(match[1])}}}break;case"radio":if(match=String(B[D].name).match(/^attr(\d+)$/)){if(B[D].checked&&Number(B[D].value)){C|=Number(B[D].value)}}break}}if(C!=this.owner.uplink.attributes){E.attributes=C|(this.owner.uplink.attributes&(FOLDER_ATTRIBUTE_CUSTOM_ICON_MASK|FOLDER_ATTRIBUTE_ICON_CACHE_MASK))}if(this.new_image!==undefined){if(E.attributes===undefined){E.attributes=this.owner.uplink.attributes}if(this.new_image==0){E.attributes&=~FOLDER_ATTRIBUTE_CUSTOM_ICON_MASK}else{A.difiSave("put_image",[A.gallery_id,A.moduleid,A.typeid,this.owner.uplink.sectionid,this.new_image.deckId]);E.attributes=(E.attributes&~FOLDER_ATTRIBUTE_CUSTOM_ICON_MASK)|({gif:1,jpg:2,jpeg:2,png:3}[this.new_image.filetype.toLowerCase()]||0);E.attributes=(E.attributes&~FOLDER_ATTRIBUTE_ICON_CACHE_MASK)|(((E.attributes&FOLDER_ATTRIBUTE_ICON_CACHE_MASK)+(1<<BITSHIFT_FOLDER_ATTRIBUTE_ICON_CACHE_MASK))&FOLDER_ATTRIBUTE_ICON_CACHE_MASK);DiFi.timer(1)}}this.broadcast("sectionui",this.owner.uplink.sectionid,"options",E);break;case"oldest":case"newest":if(confirm("Rearrange this "+A.getProp("folder").toLowerCase()+"?")){A.difiSave("sort_folder",[A.gallery_id,A.moduleid,A.typeid,this.owner.uplink.sectionid,F=="newest"?1:0]);DiFi.timer(1)}return false;case"delete":if(confirm("Delete this "+A.getProp("folder").toLowerCase()+"?")){setTimeout(Refunction(this,this.broadcast,"sectionui",this.owner.uplink.sectionid,"delete"),1);break}return false;case"nullicon":if(this.old_attributes===undefined){this.old_attributes=this.owner.uplink.attributes}this._KP_gets(GalleryStack)[0].mc("icon"+this.owner.uplink.sectionid,null);this.broadcast("section",this.owner.uplink.sectionid,"attributes",this.owner.uplink.attributes&~FOLDER_ATTRIBUTE_CUSTOM_ICON_MASK);this.new_image=0;this.invalidateProp("custom_icon");return false;case"icon":console.log("Icon Clicked");Task.station(A.peek("code","deck"),[function(){Task.station.data[0].modalizeDeck("deck_modal_file_layout",{addfile:true,restoreselection:true,ieforms:[]},Task.station.data[0].newPreviewSelectHandler,Refunction.runOnce(this,this.fileDone))},this]);return false}setTimeout(Refunction(this,this.off),1);return true},off:function(){if(this.old_attributes!==undefined){this._KP_gets(GalleryStack)[0].mc("icon"+this.owner.uplink.sectionid,null);this.broadcast("section",this.owner.uplink.sectionid,"attributes",this.old_attributes)}Modals.pop("keeper")},fileDone:function(A){if(!A.is_displayable){alert("The file chosen for your icon is not an image.");return }if(A.filewidth>300||A.fileheight>400){alert("The picture chosen for your icon is too big.");return }if(this.old_attributes===undefined){this.old_attributes=this.owner.uplink.attributes}this._KP_gets(GalleryStack)[0].mc("icon"+this.owner.uplink.sectionid,A.previewUrl);this.broadcast("section",this.owner.uplink.sectionid,"attributes",this.owner.uplink.attributes|FOLDER_ATTRIBUTE_CUSTOM_ICON_MASK);this.new_image=A;this.invalidateProp("custom_icon")},propMap:{custom_icon:{get:function(){return this.owner.uplink.attributes&FOLDER_ATTRIBUTE_CUSTOM_ICON_MASK},change:function(B,A){this.getNode("iconresetbutton").style.display=A?"inline":"none"},render:KEEPER_RENDER_IMMEDIATE},css_visible:{get:function(){return Boolean(this.owner.uplink.css)},change:function(B,A){this.getNode("css-link").style.display=A?"none":"inline";this.getNode("super-secret-css").style.display=A?"block":"none"},render:KEEPER_RENDER_IMMEDIATE}}};if(window.DWait){DWait.run("jms/pages/gallery/section_editor.js")}function GallerySwitch(){}GallerySwitch.prototype={debug_label:"GallerySwitch",template:'<div class="galleryswitch"><div class="hh"><div class="galleryswitchzone"></div></div><a href="" class="gallery-add"></a></div>',on:function(){DRE.assert(this.orientation in {horizontal:0,vertical:0},"Provide real orientation; not "+this.orientation);Events.hook(this.getNode("gallery-add"),"click",Refunction(this.up(Gallery),this.up(Gallery).newSectionClick));this.get("ui","links");this.prop_watcher=this.up(Gallery).watchProp("edit_mode",this.ownerPropChange,this);this.prop_watcherB=this.up(Gallery).watchProp("folder",this.ownerPropChange,this);Events.hook(this.node,"mousedown",Refunction(this,this.mouseDown))},off:function(){this.up(Gallery).unwatchProp("edit_mode",this.prop_watcher);this.up(Gallery).unwatchProp("folder",this.prop_watcherB);Events.unhook(Tree.get(this.node,"a.gallery-add"),"click",Refunction.lastCall(this.up(Gallery),this.up(Gallery).newSectionClick));Events.unhook(this.node,"mousedown",Refunction.lastCall(this,this.mouseDown))},ownerPropChange:function(C,B,D,A){switch(A){case"edit_mode":if(B){this.getNode("gallery-add").style.display=this.up(Gallery).getProp("section behavior").create_folder?"block":"none"}else{this.getNode("gallery-add").style.display="none"}break;case"folder":this.getNode("gallery-add").innerHTML='<img src="http://s.deviantart.com/minish/gallery/add-button-b.gif"/><br/>New '+B;break}},receiver:function(E,A,B,F,D,C){if(!(A instanceof Gallery)||B!="section"){return }switch(D){case"new":if((Number(C.parentid)||0)==(Number(this.up(Gallery).getProp("sectionid"))||0)&&C.name!="Featured"){this.getNode("galleryswitchzone").appendChild(this.spawn(GalleryStack,{uplink:C}).node)}break}},stuff:{ui:{links:{needs:[[Gallery,"data","relevant sections"]],get:function(A,C){var B;for(B=0;C[B];B++){if(C[B].behavior.view){this.getNode("galleryswitchzone").appendChild(this.spawn(GalleryStack,{uplink:C[B]}).node)}}A.done()}}}},gallery_stack:null,mouseDown:function(C){var A,B=C.target||C.srcElement;if(!this.up(Gallery).getProp("edit_mode")){return true}B=Tree.ancestor(B,"div.stackzone");if(B){if(DDD.mouseDown.call(B,C,this)){return false}}return true},ddd:{snap:function(A){this.drag_data={surfer:Surfer.create(A,Tree.get(this.ddd.node,"div.stackctrl")),event_cache:{clientX:A.clientX,clientY:A.clientY,x:A.x,y:A.y},scroll_timer:null,move_targets:{master_rect:Ruler.document.node(this.node),master_node:this.node,nodes:this.up(Gallery).getProp("section behavior").arrange_folders?Tree.gets(this.node,"div.stackzone"):[],hint:null,hover:null,position:-1,position_forward:false}};Tree.addClass(this.drag_data.surfer.node,"stackzone-surfer");this.drag_data.scroll_timer=setInterval(Refunction.runOnce(this,this.ddd.tick),200)},drag:function(F){var D,C,B,E,A;Surfer.update(this.drag_data.surfer,F);this.drag_data.event_cache={clientX:F.clientX,clientY:F.clientY,x:F.x,y:F.y};B=Ruler.document.pointer(F);if(Ruler.hitTest(B,this.drag_data.move_targets.master_rect)!=null){D=0;C=1;if(this.drag_data.move_targets.nodes[0]){mod=this.drag_data.move_targets.master_rect.y-this.drag_data.move_targets.nodes[0].offsetTop;for(D=0;this.drag_data.move_targets.nodes[D];D+=C){if((this.drag_data.move_targets.nodes[D].offsetTop+mod)>B.y){break}}D-=C}E=this.drag_data.move_targets.nodes[Math.max(0,D)];if(E==this.ddd.node){E=null}}else{E=null}if(E!=this.drag_data.move_targets.hover){if(this.drag_data.move_targets.hint&&!E){this.drag_data.move_targets.hint.parentNode.removeChild(this.drag_data.move_targets.hint);this.drag_data.move_targets.hint=null}if(E&&!this.drag_data.move_targets.hover){this.drag_data.move_targets.hint=Tree.create("div.magic-wheelbarrow")}if(E){rect=Ruler.document.node(E);for(D=0;this.drag_data.move_targets.nodes[D];D++){if(this.drag_data.move_targets.nodes[D]==this.ddd.node){A=true}if(this.drag_data.move_targets.nodes[D]==E){break}}DRE.assert(this.drag_data.move_targets.nodes[D],"Weird?");this.drag_data.move_targets.position=D;this.drag_data.move_targets.position_forward=A;if(A){rect.y+=this.ddd.node.offsetHeight}this.drag_data.move_targets.hint.style.left=rect.x+"px";this.drag_data.move_targets.hint.style.top=rect.y+"px";document.body.appendChild(this.drag_data.move_targets.hint)}else{this.drag_data.move_targets.position=-1}this.drag_data.move_targets.hover=E}},drop:function(B){var A;clearInterval(this.drag_data.scroll_timer);A=Keeper2.get(this.ddd.node);if(this.drag_data.move_targets.hint){this.drag_data.move_targets.hint.parentNode.removeChild(this.drag_data.move_targets.hint);this.drag_data.move_targets.hint=null}if(this.drag_data.move_targets.position>=0){Tree.insertBefore(this.ddd.node,this.drag_data.move_targets.nodes[this.drag_data.move_targets.position+(this.drag_data.move_targets.position_forward?1:0)],this.ddd.node.parentNode);this.broadcast("sectionui",A.uplink.sectionid,"position",this.drag_data.move_targets.position)}Surfer.flyHome(this.drag_data.surfer,B);A.last_drag=(new Date()).valueOf()},tick:function(){var A;A=Ruler.screen.pointer(this.drag_data.event_cache);if(A.y<48||A.y>(Ruler.screen.rect().y2-24)){Surfer.update(this.drag_data.surfer,this.drag_data.event_cache);if(A.y<48){if(Browser.isGecko){document.documentElement.scrollTop-=48}else{document.body.scrollTop-=48}}else{if(Browser.isGecko){document.documentElement.scrollTop+=48}else{document.body.scrollTop+=48}}}}}};if(window.DWait){DWait.run("jms/pages/gallery/gallery_switch.js")}function GalleryStack(){}GalleryStack.prototype={debug_label:"GalleryStack",template:'<div class="stackzone"><a href="" class="x"><img src="http://s.deviantart.com/minish/widgets/neutral-x.gif" alt=""/></a><div class="customicon" style="display:none"></div><div class="stackctrl"><div class="stack"><div class="icon icon-i"></div><div class="icon icon-ii"></div><div class="icon icon-iii"></div></div></div><div class="label"></div></div>',on:function(){DRE.assert(this.uplink,"Provide data");Events.hook(this.node,"click",Refunction(this,this.bigClick));Events.hook(this.node,"mouseover",Refunction(this,this.bigHover));Events.hook(this.node,"mouseout",Refunction(this,this.bigHover));this.get("ui","images");this.get("ui","label");this.prop_watcher=this.up(Gallery).watchProp("edit_mode",this.ownerPropChange,this);this.prop_watcherB=this.up(Gallery).watchProp("featured_attributes",this.ownerPropChange,this);Events.hook(this.getNode("label"),"mouseover",Refunction(this,this.labelHover));Events.hook(this.getNode("label"),"mouseout",Refunction(this,this.labelHover));Events.hook(this.getNode("label"),"click",Refunction(this,this.labelClick));Events.hook(Tree.get(this.node,"a.x"),"click",Refunction(this,this.xClick));if(this.uplink.name){this.internal_name=this.uplink.name}else{this.internal_name="Devious "+this.up(Gallery).getProp("folder");setTimeout(bind(this,this.labelClick,null),20)}this.get("ui","collect_rid");Tree.get(this.node,"a.x").style.visibility=this.uplink.behavior["delete"]?"visible":"hidden"},receiver:function(E,A,B,F,D,C){if(B!="section"||F!=this.uplink.sectionid){return }switch(D){case"sectionid":this.get("ui","collect_rid");break;case"delete":setTimeout(Refunction.runOnce(this,this.off),1);break;case"name":this.internal_name=C;this.get("ui","label");break;case"resource":this.setProp("last_resource_change",(new Date()).valueOf());this.get("ui","images");break;case"attributes":this.get("ui","images");break}},bigHover:function(A){if(A.type=="mouseover"){Tree.addClass(this.node,"stackzone-hover")}else{if(A.type=="mouseout"){Tree.removeClass(this.node,"stackzone-hover")}}},bigClick:function(){if(this._KP_gets(GRenamer)[0]||(this.last_drag&&(new Date()).valueOf()-this.last_drag<400)){return false}if(this.uplink.sectionid<0){return }if(Browser.isGecko){this.node.style.cursor="progress"}setTimeout(Refunction(this.up(Gallery),this.up(Gallery).setProp,"sectionid",this.uplink.sectionid,"ui"),75);return false},labelHover:function(A){if(A.type=="mouseover"&&this.uplink.behavior.rename&&this.up(Gallery).getProp("edit_mode")&&!Tree.hasClass(this.node,"stackzone-text")){Tree.addClass(this.getNode("label"),"label-hover")}else{if(A.type=="mouseout"){Tree.removeClass(this.getNode("label"),"label-hover")}}},labelClick:function(B){var A;if(!this.up(Gallery).getProp("edit_mode")||!this.uplink.behavior.rename){return true}if(this._KP_gets(GRenamer)[0]){return true}if(!this.name_task){this.name_task=new Task();this.name_task.listen(this.nameTaskTower,this)}if(Tree.hasClass(this.node,"stackzone-icon")||Tree.hasClass(this.node,"stackzone-text")){if(!B){this.name_task.done()}return true}A=this.getNode("label");while(A.firstChild){A.removeChild(A.firstChild)}A.appendChild(this.spawn(GRenamer,{task:this.name_task,name:this.internal_name}).node);return false},nameTaskTower:function(H,G){var C,F,D,E,B,A;A={featured:""};switch(H){case"possible name":C=arguments[2];F=arguments[3];C=Gallery.makeValidNameString(C);if(!C){F(null)}else{B=this.up(Gallery).peek("data","sections").status.result;Bug.update("Checking "+B.length+" other sectionszs",":D");DRE.assert(B,"Expect section list to have loaded before edit mode/renaming is possible");do{for(D=0;B[D];D++){if(this.uplink.sectionid<=0||B[D].sectionid!=this.uplink.sectionid){if(C==B[D].name||C.toLowerCase() in A){E=(C.match(/(\d+)$/)||[])[1];if(E){C=C.substr(0,C.length-E.length)+(parseInt(E)+1)}else{C=C+" 2"}D=-1;break}}}}while(D==-1);Bug.update("callin that name",C);F(C)}return ;case"complete":if((arguments[2]||this.internal_name)!=this.uplink.name){this.broadcast("sectionui",this.uplink.sectionid,"name",arguments[2]||this.internal_name,this.uplink)}else{this.get("ui","label")}return }},ownerPropChange:function(C,B,D,A){switch(A){case"edit_mode":if(B){Tree.addClass(this.node,"stackzone-edit")}else{Tree.removeClass(this.node,"stackzone-edit")}break;case"featured_attributes":Tree.removeClass(this.getNode("label"),"textonly");Tree.removeClass(this.node,"stackzone-icon");Tree.removeClass(this.node,"stackzone-text");if(B&FEATURED_FOLDER_ATTRIBUTE_SIDEBAR_NO_TEXT){Tree.addClass(this.node,"stackzone-icon")}else{if(B&FEATURED_FOLDER_ATTRIBUTE_SIDEBAR_NO_ICON){Tree.addClass(this.node,"stackzone-text");Tree.addClass(this.getNode("label"),"textonly")}}break;default:DRE.halt("I don't know "+A)}},propMap:{last_resource_change:{get:function(){return(new Date()).valueOf()},change:function(B,A){this.get("ui","images");if(this.uplink.ids.length){Tree.removeClass(Tree.get(this.node,"div.stack"),"stack-empty")}else{Tree.addClass(Tree.get(this.node,"div.stack"),"stack-empty")}}},attributes:{get:function(){},change:function(B,A){this.setProp("attribute_custom_icon",A&FOLDER_ATTRIBUTE_CUSTOM_ICON_MASK);this.setProp("attribute_icon_foreground",A&FOLDER_ATTRIBUTE_ICON_FOREGROUND)}},attribute_custom_icon:{get:function(){},change:function(B,A){}},attribute_icon_foreground:{get:function(){},change:function(B,A){}}},off:function(){if(this.name_task){this.name_task.off();delete this.name_task}this.up(Gallery).unwatchProp("edit_mode",this.prop_watcher);this.up(Gallery).unwatchProp("featured_attributes",this.prop_watcherB);Events.unhook(this.getNode("label"),"mouseover",Refunction(this,this.labelHover));Events.unhook(this.getNode("label"),"mouseout",Refunction(this,this.labelHover));Refunction.lastCall(this,this.labelHover);Events.unhook(this.getNode("label"),"click",Refunction.lastCall(this,this.labelClick));Events.unhook(this.node,"click",Refunction.lastCall(this,this.bigClick));Events.unhook(this.node,"mouseover",Refunction.lastCall(this,this.bigHover));Events.unhook(this.node,"mouseout",Refunction.lastCall(this,this.bigHover));Events.unhook(Tree.get(this.node,"a.x"),"click",Refunction.lastCall(this,this.xClick))},xClick:function(){if(this.uplink.ids.length==0||confirm('Delete "'+this.uplink.name+'"?')){this.broadcast("sectionui",this.uplink.sectionid,"delete")}return false},stuff:{ui:{collect_rid:{think:function(A){this.node.setAttribute("collect_dv",this.up(Gallery).gallery_deviant);if(this.uplink.sectionid>0){this.node.setAttribute("collect_rid",this.uplink.type+":"+this.uplink.sectionid)}A.done()}},"hold it":{think:function(A){A.wait(Task.Delay(1))}},label:{needs:[["ui","hold it"]],think:function(A){if(!Tree.get(this.node,"input")){this.uiPut("label",null,"<span>"+htmlspecialchars(this.internal_name)+"</span>")}A.done()}},images:{needs:[["data","resources"]],think:function(C,D){var G,E,J,I,F,L,H,A,K,B;A=this.getNode("customicon");while(A.firstChild){A.removeChild(A.firstChild)}if(this.uplink.attributes&FOLDER_ATTRIBUTE_CUSTOM_ICON_MASK){A.style.display="block";this.getNode("stackctrl").style.display="none";K="000000000".substr(0,9-String(this.uplink.sectionid).length)+this.uplink.sectionid;B=[null,".gif",".jpg",".png"][this.uplink.attributes&FOLDER_ATTRIBUTE_CUSTOM_ICON_MASK];A.appendChild(Tree.create("img",{src:this.mc("icon"+this.uplink.sectionid)||("http://a.deviantart.com/gallerythumbs/"+K.substr(K.length-1,1)+"/"+K.substr(K.length-2,1)+"/"+K+B+"?"+((this.uplink.attributes&FOLDER_ATTRIBUTE_ICON_CACHE_MASK)>>BITSHIFT_FOLDER_ATTRIBUTE_ICON_CACHE_MASK)+B)}))}else{A.style.display="none";this.getNode("stackctrl").style.display="block";J=Tree.gets(this.node,"div.icon");for(G=0;D[G];G++){if(I=J.pop()){I.innerHTML=D[G]}else{break}}while(I=J.pop()){I.innerHTML=""}}C.done()}},"front rectangle":{parameters:["last_resource_change"],get:function(A){A.done(Ruler.document.node(Tree.get(this.node,".icon-iii")))}}},data:{resources:{parameters:["last_resource_change"],get:function(A,B){A.wait(this.up(App).peek("data","resource views by rid",this.uplink.ids.slice(0,3),"stacktile",{}))}}}}};if(window.DWait){DWait.run("jms/pages/gallery/gallery_stack.js")}function ArtZone(){}ArtZone.prototype={debug_label:"ArtZone",template:'<div class="artzone"></div>',on:function(){var A,B;DRE.assert(this.factory instanceof RIDFactory);DRE.assert(this.up(Gallery).getProp("count_per_page"));this.count_per_page=this.up(Gallery).getProp("count_per_page");this.setProp("visible",!this.start_hidden);this.setProp("show_date",this.show_date||false);if(this.use_size){this.setProp("use_size",this.use_size)}this.get("ui","resources delayed");Events.hook(this.node,"mousedown",Refunction(this,this.mouseDown));Events.hook(this.node,"click",Refunction(this,this.clicked));Events.hook(this.node,"dblclick",Refunction(this,this.clickclicked));if(Browser.isIE){Events.hook(this.node,"selectstart",Refunction(this,this.selectStart))}this.resized=bind(this,this.resized);Events.hook(window,"resize",this.resized);if(Browser.isGecko){this.last_window_size=window.innerWidth}},off:function(){this.gmiOff();this.get("ui","clear");Events.unhook(this.node,"click",Refunction.lastCall(this,this.clicked));Events.unhook(this.node,"dblclick",Refunction.lastCall(this,this.clickclicked));Events.unhook(this.node,"mousedown",Refunction.lastCall(this,this.mouseDown));if(Browser.isIE){Events.unhook(this.node,"selectstart",Refunction.lastCall(this,this.selectStart))}Events.unhook(window,"resize",this.resized);if(Browser.isGecko){}},gmiOn:function(){var A;if(this.gmi_on){this.gmiOff()}this.gmi_on=1;if(window.PreviewStream){A=this.node.getElementsByTagName("div")[0];if(!A){this.gmi_delayed=1;this.gmi_on=0}else{this.gmi_delayed=0}if(!this.gmi_delayed){GMI.apply(A,"PreviewStream",{query:this.getQuery(),offset:this.getProp("page")*Number(this.count_per_page),count_per_page:this.count_per_page,total:this.factory.rids?this.factory.rids.length:null,gallery_owner:this},1)}}},gmiOff:function(){var A;A=this.node.getElementsByTagName("div")[0];if(A&&A.getAttribute("gmindex")){GMI._delete(GMI.getOne(A),1)}this.gmi_on=0;this.gmi_delayed=0},hideAd:function(){if(this.ad&&this.ad.frame){this.ad.frame.className+=" hidoframe";this.ad.frame.style.display="none"}},showAd:function(){if(this.ad&&this.ad.frame){this.ad.frame.className=this.ad.frame.className.replace(/\s*\bhidoframe\b/g,"");this.ad.frame.style.display="block"}setTimeout(this.resized,1)},stuff:{ui:{clear:{think:function(B){var A;if(this.ad){if(!this.mc("ad-m"+Number(this.ad.data.maturecontent))){this.mc("ad-m"+Number(this.ad.data.maturecontent),this.ad);this.ad.frame.style.display="none";if(this.ad.frame.firstChild&&this.ad.frame.firstChild.style){this.ad.frame.firstChild.style.display="none"}}else{if(this.ad.frame==this.mc("ad-m"+Number(this.ad.data.maturecontent)).frame){this.ad.frame.style.display="none";if(this.ad.frame.firstChild&&this.ad.frame.firstChild.style){this.ad.frame.firstChild.style.display="none"}}else{if(Browser.isKHTML){this.ad.frame.style.display="none";if(this.ad.frame.firstChild&&this.ad.frame.firstChild.style){this.ad.frame.firstChild.style.display="none"}}else{this.ad.frame.parentNode.removeChild(this.ad.frame)}}}this.ad=null}this._KP_clear(HTMLPager);this.gmiOff();while(this.node.firstChild){this.node.removeChild(this.node.firstChild)}B.done()}},placeholders:{needs:[["ui","clear"]],think:function(A,D){var I,E,H,C,B,F,G;if((this.factory.rids.length||(0&&this.fancy_waiting))&&(this.owner instanceof BrowseBubble)){I=this.getProp("page");F=true;H=I*Number(this.count_per_page);B=H+Number(this.count_per_page);if(this.factory.rids.length){B=Math.min(B,this.factory.rids.length)}G=[];if(Tree.get("#gallery-admaster")&&this.admaster&&!this.getProp("edit_mode")){G.push('<div style="float:right;position:relative;width:410px;_width:407;text-align:left;_zoom:1" class="gal-tblock"><span style="margin:30px 0 0 56px;display:block;text-align:center;width:308px;_zoom:1;_position:relative"><span class="shadow-holder" style="width:308px !important"><span class="shadow" style="padding:0 !important;width:308px !important;height:258px !important"><img width="300" height="250" src="" alt="" style="visibility:hidden"/></span></span></span></div>')}if(F){for(E=H;E<B;E++){G.push('<div class="tt-a"><span class="tt-w"><span class="shadow"><img src="" width="149" height="92" style="visibility:hidden"/></span></span></div>')}}this.gmiOff();this.node.innerHTML='<div class="stream" style="visibility:hidden">'+(G.join("")||"&nbsp;")+"</div>";this.get("ui","pager");setTimeout(Refunction(Shadows,Shadows.nodes,this.node),1);setTimeout(bind(this,this.resized),1)}else{this.gmiOff();this.node.innerHTML='<div class="stream">&nbsp;</div>'}A.done()}},pager:{think:function(A){this._KP_clear(HTMLPager);if(this.factory.rids.length){this.page_count=Math.ceil(this.factory.rids.length/this.count_per_page)}else{if(this.factory.more_left!==undefined){this.page_count=this.factory.more_left}else{this.page_count=false}}Bug.update("Page count",this.page_count+" (ceiling "+this.factory.rids.length+" / "+this.count_per_page+")");if(this.getProp("page")>0||this.page_count>1||typeof this.page_count=="boolean"&&this.page_count){this.node.appendChild(this.spawn(HTMLPager,{page:this.getProp("page"),pages:this.page_count||false}).node)}A.done()}},"resources delayed":{think:function(A){setTimeout(Refunction(this,this.get,"ui","resources"),10);A.done()}},visibility:{get:function(A){A.done()}},resources:{parameters:["page","edit_mode","last_id_change","show_date","use_size"],needs:[["ui","placeholders"],["data","ad"],["data","branch"],["data","branch done"],["data","rids"],["data","resources"],["ui","ad"],["ui","visibility"],["ui","clear"]],get:function(Q,E,J,G,M,D,C,K,R,B,L,P,S,A){var H,O,N,U,I,F;if(this._KP_dead){return }this.resource_remove_hits=0;U=this.getProp("edit_mode")&&this.up(Gallery).getProp("section behavior").blue_buttons;I=this.up(Gallery).typeid==COMMENT_FAVCOLLECTIONS;H=[];for(O=0;P.length&&O!=P.length;O++){P[O]=P[O].replace(/^\0+/,"")}if(P.length){P=P.join("");if(!S&&!U){F=Boolean(P.indexOf("ismature")>=0||Tree.get("a.ismature"));S=this.mc("ad-m"+Number(F));if(!S){Bug.log("DiFi Lie","Find #gallery-ad-m"+Number(F));S={data:{maturecontent:F},frame:Tree.get("#gallery-ad-m"+Number(F))};if(!S.frame){S=undefined}else{S.frame.style.visibility="hidden"}}if(S){S.frame.style.display="block";if(S.frame.fristChild){S.frame.fristChild.style.display="block"}}}if((Tree.get("#gallery-admaster")&&S&&!U)){this.ad=S;H.push('<div style="float:right;position:relative;width:410px;_width:407;text-align:left" class="gal-tblock"><span style="margin:30px 0 0 56px;display:block;text-align:center;width:308px"><span class="shadow-holder" style="width:308px !important"><span class="shadow" style="padding:0 !important;width:308px !important;height:258px !important"><img class="stream-ad-footprint" width="300" height="250" src="" alt="" style="visibility:hidden"/></span></span>No more ads: <a class="h" href="http://my.deviantart.com/services/#subscription">deviantART Premium Membership</a></span></div>')}if(U){P=P.replace(/<a /g,'<a target="_blank" ');P=P.replace(/ onclick="/g,' disabled_onclick="');P=P.replace(/<!-- \^TTT -->.*?<!-- TTT\$ -->/g,'<!-- ^TTT --><a href="" class="thumbmenu"><img src="http://s.deviantart.com/minish/gallery/menu-button-b.gif" alt="[menu]"/></a><!-- TTT$ -->')}H.push(P);this.gmiOff();this.node.innerHTML='<div class="stream" style="visibility:hidden">'+(H.join("")||"&nbsp;")+"</div>";setTimeout(Refunction.runOnce(this,arguments.callee.ebx.postProduction),1);setTimeout(Refunction.runOnce(this,arguments.callee.ebx.keeps),100)}else{if(E==0&&this.spare_label){this.gmiOff();this.node.innerHTML='<div class="pppp">'+this.spare_label+"</div>"}}if(!this.getProp("edit_mode")){this.gmiOn()}this.get("ui","pager");Q.done()},postProduction:function(){var B,A;B=Tree.get(this.node,"div.stream");Shadows.nodes(this.node);this.resized();if(this.backup_scroll_position){if(Browser.isGecko){document.documentElement.scrollTop=this.backup_scroll_position}else{document.body.scrollTop=this.backup_scroll_position}this.backup_scroll_position=0}},keeps:function(){var targets,i,client;targets=this.node.getElementsByTagName("keeper");for(i=0;targets[i];i++){DRE.assert(targets[i].getAttribute("for"));client=eval(targets[i].getAttribute("for"));DRE.assert(client&&typeof client.on=="function"&&typeof client.off=="function");client.on.call(client,targets[i].parentNode)}}},ad:{parameters:["page"],get:function(A){if(!this.admaster||this.up(Gallery).getProp("edit_mode")){A.done();return }A.wait(this.admaster.peek("ui","ad"));DiFi.timer(100)}}},data:{ad:{think:function(A){this.get("ui","ad");A.done()}},resources:{parameters:["page","edit_mode","last_id_change"],needs:[["data","rids"]],get:function(B,E,D,A,C){if(C.html){B.done(C.html)}else{Bug.log("Resources","Fresh Blood");B.wait(this.up(App).peek("data","resource views by rid",C,"thumb150",this.factory.view_options||{artist:true,title:true}))}}},branch:{think:function(A,B){if(this.getProp("edit_mode")){A.wait(this.up(Gallery).peek("data","featured section"))}else{A.done()}}},"branch done":{think:function(A){A.wait(Task.Delay(1))}},rids:{parameters:["page","edit_mode","last_id_change"],get:function(A,H,I,J){var H,E,G,C,B,D,F;H=this.getProp("page");Bug.log("Resources","Fresh IDs");G=H*Number(this.count_per_page);B=G+Number(this.count_per_page);D=true;if(D){A.wait(this.factory.peek("rids",G,Math.max(B-G,this.count_per_page)))}else{A.done(this.factory.rids.slice(G,B))}}}}},propMap:{page:{get:function(){return this.up(Gallery).getProp("url_page")},change:function(C,B,D,A){if(C.length>1){this.get("ui","resources delayed")}}},visible:{get:function(){return true},change:function(B,A){if(A){this.peek("ui","visibility").done()}}},edit_mode:{get:function(){return false},change:function(B,A){if(B.length>1){this.get("ui","resources delayed")}if(!A){this.gmiOn()}else{this.gmiOff()}}},last_id_change:{get:function(){return(new Date()).valueOf()}},show_date:{get:function(){return false}},use_size:{get:function(){return 150}}},mouseDownResource:function(F){var D,C,A,B,E=F.target||F.srcElement;this.dragged_rid=null;D=Tree.ancestor(E,"a");if(!D){return true}A=D.parentNode;while((A.tagName!="DIV"||!A.getAttribute("collect_rid"))&&(A=A.parentNode)){}if(!A){return true}B=String(A.getAttribute("collect_rid")).split(":");B[0]=Number(B[0]);this.dragged_rid=B;if(DDD.mouseDown.call(A,F,this)){return false}return true},getQuery:function(){var A;A=this.factory.query;if(!A){if(this.up(FolderView)){A=this.up(Gallery).getProp("querybase")+":"+this.up(Gallery).gallery_deviant+"/"+this.up(FolderView).uplink.sectionid}else{Bug.log("cookies","???");return null}}return A},mouseDown:function(F){var D,C,A,B,E=F.target||F.srcElement;if(!this.getProp("edit_mode")){return true}Popup.completeAll();if(!this.mouseDownResource(F)){return false}D=Tree.ancestor(E,"div.stream");if(D){if(DDD.mouseDown.call(D,F,this)){return false}}return true},selectStart:function(A){if(this.drag_data&&this.drag_data.surfer2){return false}},resizedGecko:function(){if(this.last_window_size!=window.innerWidth){this.last_window_size=window.innerWidth;this.resized({type:"resize"})}},resized:function(E){var F,D,A,B,C,G;if(this._KP_dead){return }E=E||{};F=Tree.get(this.node,"div.stream");if(F){if(!F.parentNode.offsetWidth){setTimeout(bind(this,arguments.callee,{type:"resize"}),100);return }if(Browser.isGecko){F.style.visibility="hidden"}F.style.width="auto";void (F.parentNode.offsetWidth);D=F.parentNode.offsetWidth-(parseInt(Station.read(F.parentNode,"paddingLeft"))+parseInt(Station.read(F.parentNode,"paddingRight")));F.style.width=(D-(D%205))+"px";F.style.visibility="visible"}if(!Tree.get("#output")){dre_warning("Unexpected document structure");return }if(this.ad){A=Tree.get(this.node,"img.stream-ad-footprint");if(A){A=A.parentNode;while(!A.offsetWidth){A=A.parentNode;if(!A){return }}A=Ruler.document.node(A);B=0;C=this.ad.frame;C.style.position="absolute";C.style.zIndex=21;C.style.width="300px";C.style.height="250px";C.style.left="auto";C.style.right=(Tree.get("#output").offsetWidth-(A.x2-4))+"px";C.style.top=(A.y+3)+"px";Tree.removeClass(C,"hidoframe");C.style.visibility="visible";if(C.firstChild&&C.firstChild.style){C.firstChild.style.visibility="visible"}}}if(E.type=="resize"){setTimeout(bind(this,arguments.callee,{roundTwo:true}),1)}},clickclicked:function(C){var A,B=C.target||C.srcElement;if(!this.getProp("edit_mode")){return true}A=B;while((A.tagName!="DIV"||!A.getAttribute("collect_rid"))&&(A=A.parentNode)){}if(A&&(A=Tree.get(A,"a.thumbmenu"))){this.optionsClicked(A)}},clicked:function(E){var C,B,F,A,H,I,G,D=E.target||E.srcElement;if(!this.getProp("edit_mode")){return true}C=D.parentNode;while((C.tagName!="DIV"||!C.getAttribute("collect_rid"))&&(C=C.parentNode)){}if(C){G=Tree.ancestor(D,"a.thumbmenu")}if(G&&Tree.hasClass(C,"selected")){this.optionsClicked(G);G.blur();return false}if(Browser.isIE&&this.drag_data&&this.drag_data.ie_cancel_next_click){this.drag_data.ie_cancel_next_click=false;return false}F=Tree.get(this.node,"div.stream").childNodes;H=DDD.eventKeys(E);if(H.range||!H.multiple){for(A=0;F[A];A++){if(!(F[A].nodeType==1&&F[A].getAttribute("collect_rid"))){continue}if(H.range&&this.last_range_clicker&&(F[A]==C||F[A]==this.last_range_clicker)){if(this.last_range_clicker==C){continue}if(I){Tree.addClass(F[A],"selected");I=false;C=null;continue}else{I=true}}else{if(F[A]==C){continue}}if(I){Tree.addClass(F[A],"selected")}else{if(Tree.hasClass(F[A],"selected")){Tree.removeClass(F[A],"selected")}}}}if(!H.range){this.last_range_clicker=null}if(C){if(H.multiple||H.range||Tree.ancestor(D,"a")){if(H.multiple&&Tree.hasClass(C,"selected")){Tree.removeClass(C,"selected")}else{this.last_range_clicker=C;Tree.addClass(C,"selected")}}else{Tree.removeClass(C,"selected")}}if(G){this.optionsClicked(G);G.blur()}return false},optionsClicked:function(B){var A,H,C,I,D,G,F,E;D=[];F=Tree.gets(Tree.get(this.node,"div.stream"),"div.selected");if(!F.length){E=B;while((E.tagName!="DIV"||!E.getAttribute("collect_rid"))&&(E=E.parentNode)){}if(!E){return }F.push(E)}for(i=0;F[i];i++){D.push(F[i].getAttribute("collect_rid"));this.check150Cache(F[i])}H="gallerylink/"+(this.sectionid||0)+"/"+D.join("-");I=H.split("/");C=Pager.create({rootri:H,href_base:"",theme:"light",callback:this.galleryMenuBack,callback_object:this});Pager.loadPage(C,H);A=Popup.create({className:"gallerylink"});A.node.appendChild(C.node);G=Ruler.screen.node(B);Popup.show(A,G)},galleryMenuBack:function(F,A){var C,B,H,D,G,I,K,E,J;if(F!=""){Pager.select(A,"");C=F.split("/");DRE.assert(C.shift()=="gallerylink","bottom bottom");G=Number(C.shift());B=C.shift().split("-");Popup.complete(A.node);switch(C[0]){case"feature":this.up(Gallery).featured_warning_done=true;for(D=0;D!=B.length;D++){this.broadcast("sectionui",this.up(Gallery).featured_section_data.sectionid,"resource",B[D].split(":"),0,this.sectionid)}break;case"unfeature":if(!this.up(Gallery).featured_warning_done||this.up(Gallery).is_group){this.up(Gallery).featured_warning_done=true;if(this.up(Gallery).is_group){if(!confirm("Are you sure you want to remove the selected art?")){return }}else{if(this.up(Gallery).typeid==COMMENT_FAVCOLLECTIONS){if(!confirm('After this item has been hidden from your Favourites, you can bring it back any time by finding it in the "Browse" section.')){return }}else{if(!confirm('After this item has been removed from "Featured", you can bring it back any time by finding it in the "Browse" section.')){return }}}}for(D=0;D!=B.length;D++){this.broadcast("sectionui",this.sectionid,"resource",B[D].split(":"),-1)}break;case"put":J=Number(C.pop())||0;for(D=0;D!=B.length;D++){this.broadcast("sectionui",C[1],"resource",B[D].split(":"),0,J)}break;case"unput":if(this.up(Gallery).is_group){if(!confirm("Are you sure you want to remove the selected art?")){return }}for(D=0;D!=B.length;D++){this.broadcast("sectionui",C[1],"resource",B[D].split(":"),-1)}break;default:alert("Unknown command. Please try again later.")}}return false},ddd:{snap:function(I){var A,H,F,K,O,N,C,M,D,J,G,B,L,P,E;DRE.assert(this.ddd.node);N=Tree.get(this.node,"div.stream");if(N==this.ddd.node||N.parentNode==this.ddd.node){L={};J=Tree.gets(Tree.get(this.node,"div.stream"),"div.selected");P=DDD.eventKeys(I);for(H=0;J[H];H++){if(P.multiple||P.range){L[J[H].getAttribute("collect_rid")]=true}else{Tree.removeClass(J[H],"selected")}}C=[];K=N.childNodes;for(H=0;K[H];H++){if(K[H].nodeType==1&&K[H].getAttribute("collect_rid")){C.push(K[H])}}this.drag_data={surfer2:Surfer2.create(I,Ruler.document.pointer(I)),event_cache:{clientX:I.clientX,clientY:I.clientY,x:I.x,y:I.y},scroll_timer:null,select_targets:{master_node:N,selection_map:L,nodes:C,columns:this.thumbsPerRow(N,C)}};this.drag_data.surfer2.node.style.display="block"}else{P=DDD.eventKeys(I);if(P.multiple||P.range){Tree.addClass(this.ddd.node,"selected")}J=Tree.gets(N,"div.selected");B=[];H=0;for(H=0;J[H];H++){if(J[H]==this.ddd.node){break}}if(J.length==1||!J[H]){for(H=0;J[H];H++){Tree.removeClass(J[H],"selected")}J=[this.ddd.node]}for(H=0;J[H];H++){this.check150Cache(J[H]);switch(parseInt(J[H].getAttribute("collect_rid"))){case COMMENT_DEVIATION:B.push(Surfer.create(I,Tree.get(J[H],"img")));break;case COMMENT_GALLERIES:case COMMENT_FAVCOLLECTIONS:E=Surfer.create(I,Tree.get(J[H],"div.tv150"),1,undefined,true);Tree.addClass(E.node,"surfer-tv150 tv150");Tree.addClass(Tree.get(E.node,"div.a-stream"),"stream");O=Tree.gets(E.node,"a");for(F=0;O[F];F++){O[F].removeAttribute("href")}B.push(E);break;default:DRE.breakpoint()}}if(J.length>1||!this.up(Gallery).getProp("section behavior").arrange_resources){C=[]}else{C=[];K=Tree.get(this.node,"div.stream").childNodes;for(H=0;K[H];H++){if(K[H].nodeType==1&&K[H].getAttribute("collect_rid")){C.push(K[H])}}}this.drag_data={surfers:B,event_cache:{clientX:I.clientX,clientY:I.clientY,x:I.x,y:I.y},scroll_timer:null,drop_targets:{rects:[],nodes:Tree.gets(this.up(Gallery).node,"div.stackzone"),hover:null},move_targets:{master_rect:Ruler.document.node(N),master_node:N,nodes:C,columns:this.thumbsPerRow(N,C),hint:null,hover:null,position:-1,position_forward:false}};if(this.sectionid&&(D=this._KP_gets(HTMLPager)[0])){this.drag_data.page_targets={master_rect:Ruler.document.node(D.node),master_node:D.node,nodes:Tree.gets(D.node,"a"),rects:[],hover:null}}for(H=0;this.drag_data.drop_targets.nodes[H];H++){this.drag_data.drop_targets.rects.push(Ruler.document.node(this.drag_data.drop_targets.nodes[H]))}if(this.drag_data.page_targets){for(H=0;this.drag_data.page_targets.nodes[H];H++){this.drag_data.page_targets.rects.push(Ruler.document.node(this.drag_data.page_targets.nodes[H]))}}}this.drag_data.scroll_timer=setInterval(Refunction.runOnce(this,this.ddd.tick),200)},drag:function(J){var K,I,O,Q,B,E,L,D,C,G,O,H,N,P,F,M,A;DRE.assert(this.drag_data.surfers||this.drag_data.surfer2);this.drag_data.event_cache={clientX:J.clientX,clientY:J.clientY,x:J.x,y:J.y};if(this.drag_data.surfer2){M=this.drag_data.select_targets.nodes;A={};O=Surfer2.update(this.drag_data.surfer2,J);N=Ruler.document.node(this.drag_data.select_targets.master_node);if(M[0]){P=M[0].offsetWidth;F=Math.max(M[0].offsetHeight,(M[0].firstChild.nextSibling?M[0].firstChild.nextSibling:M[0].firstChild).offsetHeight)}for(D=0;M[D];D++){H={x:N.x+((D%this.drag_data.select_targets.columns)*P),y:N.y+Math.floor(D/this.drag_data.select_targets.columns)*F,x2:P,y2:F};H.x2+=H.x;H.y2+=H.y;B=((O.x<H.x2&&H.x<O.x2)&&(O.y<H.y2&&H.y<O.y2));if(B^this.drag_data.select_targets.selection_map[M[D].getAttribute("collect_rid")]){Tree.addClass(M[D],"selected")}else{if(Tree.hasClass(M[D],"selected")){Tree.removeClass(M[D],"selected")}}}return }for(D=0;this.drag_data.surfers[D];D++){Surfer.update(this.drag_data.surfers[D],J)}K=Ruler.document.pointer(J);if(Ruler.hitTest(K,this.drag_data.move_targets.master_rect)!=null){if(this.sectionid&&(Q=this.thumbFromPoint(this.drag_data.move_targets.master_node,K,this.drag_data.move_targets.nodes,this.drag_data.move_targets.columns))){if(Q!=this.ddd.node){L=Q}}}else{if((I=Ruler.hitTest(K,this.drag_data.drop_targets.rects))!=null){E=this.drag_data.drop_targets.nodes[I]}}if(L!=this.drag_data.move_targets.hover){if(this.drag_data.move_targets.hint&&!L){this.drag_data.move_targets.hint.parentNode.removeChild(this.drag_data.move_targets.hint);this.drag_data.move_targets.hint=null}if(L&&!this.drag_data.move_targets.hover){this.drag_data.move_targets.hint=Tree.create("div.magic-arrow")}if(L){O=Ruler.document.node(L);for(D=0;this.drag_data.move_targets.nodes[D];D++){if(this.drag_data.move_targets.nodes[D]==this.ddd.node){G=true}if(this.drag_data.move_targets.nodes[D]==L){break}}DRE.assert(this.drag_data.move_targets.nodes[D],"Weird?");this.drag_data.move_targets.position=D;this.drag_data.move_targets.position_forward=G;Bug.update("Changing to",D+" ("+G+" / "+this.drag_data.move_targets.columns+")");if(G){O.x+=this.ddd.node.offsetWidth}this.drag_data.move_targets.hint.style.left=O.x+"px";if(Browser.isGecko&&!Browser.isFirefox3){O.y-=201}this.drag_data.move_targets.hint.style.top=O.y+"px";document.body.appendChild(this.drag_data.move_targets.hint)}else{this.drag_data.move_targets.position=-1}this.drag_data.move_targets.hover=L}if(E!=this.drag_data.drop_targets.hover){if(this.drag_data.drop_targets.hover){Tree.removeClass(this.drag_data.drop_targets.hover,"maybedrop")}if(E){Tree.addClass(E,"maybedrop");this.drag_data.drop_targets.hover=E}this.drag_data.drop_targets.hover=E}if(this.drag_data.page_targets&&this.drag_data.page_targets.hover){Tree.removeClass(this.drag_data.page_targets.hover,"maybedrop")}if(this.drag_data.page_targets){if(Ruler.hitTest(K,this.drag_data.page_targets.master_rect)!=null){for(D=0;this.drag_data.surfers[D];D++){Station.apply(this.drag_data.surfers[D].node,"opacity",0.4);this.drag_data.surfers[D].node_opacity=0.4}if((I=Ruler.hitTest(K,this.drag_data.page_targets.rects))!=null){this.drag_data.page_targets.hover=this.drag_data.page_targets.nodes[I];Tree.addClass(this.drag_data.page_targets.hover,"maybedrop")}else{this.drag_data.page_targets.hover=null}}else{for(D=0;this.drag_data.surfers[D];D++){Station.apply(this.drag_data.surfers[D].node,"opacity",1);this.drag_data.surfers[D].node_opacity=0.14}this.drag_data.page_targets.hover=null}}},drop:function(D){var E,B,H,C,I,G,A,F;clearInterval(this.drag_data.scroll_timer);if(this.drag_data.surfer2){Surfer2.clear(this.drag_data.surfer2);this.drag_data.surfer2={};this.drag_data.ie_cancel_next_click=true;return }A=[];F=Tree.gets(Tree.get(this.node,"div.stream"),"div.selected");for(B=0;F[B];B++){A.push(F[B].getAttribute("collect_rid").split(":"))}if(!A.length){A.push(this.ddd.node.getAttribute("collect_rid").split(":"))}if(this.drag_data.move_targets.hint){this.drag_data.move_targets.hint.parentNode.removeChild(this.drag_data.move_targets.hint);this.drag_data.move_targets.hint=null}if(this.drag_data.move_targets.position>=0){Tree.insertBefore(this.ddd.node,this.drag_data.move_targets.nodes[this.drag_data.move_targets.position+(this.drag_data.move_targets.position_forward?1:0)],this.ddd.node.parentNode);for(B=0;this.drag_data.surfers[B];B++){Surfer.flyHome(this.drag_data.surfers[B],D)}G=this.drag_data.move_targets.position;G+=this.getProp("page")*this.count_per_page;for(B=0;B!=A.length;B++){this.broadcast("sectionui",this.sectionid,"resource",A[B],G)}}else{if(this.drag_data.drop_targets.hover){Tree.removeClass(this.drag_data.drop_targets.hover,"maybedrop");H=Keeper2.get(this.drag_data.drop_targets.hover);for(B=0;B!=A.length;B++){this.broadcast("sectionui",H.uplink.sectionid,"resource",A[B],0,this.sectionid)}for(B=0;this.drag_data.surfers[B];B++){if(E){Surfer.sinkInto(this.drag_data.surfers[B],D,E)}else{Surfer.dissolve(this.drag_data.surfers[B],D)}}}else{if(this.drag_data.page_targets&&this.drag_data.page_targets.hover){Tree.removeClass(this.drag_data.page_targets.hover,"maybedrop");for(B=0;this.drag_data.surfers[B];B++){Surfer.dissolve(this.drag_data.surfers[B],D)}G=Number(this.drag_data.page_targets.hover.getAttribute("htmlpage"))||0;G*=this.count_per_page;for(B=0;B!=A.length;B++){this.broadcast("sectionui",this.sectionid,"resource",A[B],G)}}else{for(B=0;this.drag_data.surfers[B];B++){Surfer.flyHome(this.drag_data.surfers[B],D)}}}}this.drag_data.surfers={}},tick:function(){var B,A;B=Ruler.screen.pointer(this.drag_data.event_cache);if(B.y<48||B.y>(Ruler.screen.rect().y2-24)){if(this.drag_data.surfers){for(A=0;this.drag_data.surfers[A];A++){Surfer.update(this.drag_data.surfers[A],this.drag_data.event_cache)}}else{Surfer2.update(this.drag_data.surfer2,this.drag_data.event_cache)}if(B.y<48){if(Browser.isGecko){document.documentElement.scrollTop-=48}else{document.body.scrollTop-=48}}else{if(Browser.isGecko){document.documentElement.scrollTop+=48}else{document.body.scrollTop+=48}}}}},thumbsPerRow:function(D,C){var B,A,F,E=10;if(!C[0]){return 0}A=C[0].offsetTop;for(B=1;C[B];B++){if(C[B].offsetTop-A>E){break}if(Browser.isIE){if(F!==undefined&&C[B].offsetLeft<=F){break}F=C[B].offsetLeft}}return B},thumbFromPoint:function(I,J,A,B){var B,A,D,F,H,G,C,E;H=Ruler.document.node(I);D=0;if(A[0]){C=H.y;E=Math.max(A[0].offsetHeight,(A[0].firstChild.nextSibling?A[0].firstChild.nextSibling:A[0].firstChild).offsetHeight);for(D=0;A[D];D+=B){if(C>J.y){break}C+=E}D-=B;D+=Math.floor((J.x-H.x)/A[0].offsetWidth)}return A[Math.max(0,D)]},check150Cache:function(B){var H,F,D,G,E,C,I,A;H=(B.getAttribute("collect_rid")||"").split(":");H[0]=Number(H[0]);if(App.cacheResourceView(H[0],H[1],"stacktile","")){return }A=Tree.get(B,"a");switch(H[0]){case COMMENT_DEVIATION:if(0&&Tree.hasClass(A,"film")){D=Tree.gets(A,"img")[1];if(!D){F="";break}G=150;E=D.height||D.offsetHeight}else{D=Tree.get(A,"img");if(!D){F="";break}G=D.width||D.offsetWidth;E=D.height||D.offsetHeight}C=Math.max(G,E);if(C>75){G*=75/C;E*=75/C}F=thumbHTML({id:H[1],url:A.getAttribute("href"),tooltip:"",thumb75:Tree.get(A,"q")?{width:75,height:63,src:"http://th09.deviantart.com/images/150/shared/poetry.jpg"}:{width:G,height:E,src:D.src},size:75});break;case COMMENT_GALLERIES:case COMMENT_FAVCOLLECTIONS:if(!Tree.ancestor(A,"div.tt-tv150")){I=[""].concat(Tree.gets(A,"div.icon")).pop();if(I){I=Tree.get(I,"div.tt-aa")||"";if(I){I=I.parentNode.innerHTML;I=I.replace(/\btt-a\b/g,"tt-aa");I=I.replace(/ (?:width|height)\=/g," hack_the_planet=")}}}else{I=Tree.get(A,"div.tt-a");I=I?I.innerHTML:""}F=('<div class="tt-aa tt-tv70"><div class="tt-ww"><div class="tv70"><div class="tv70-tag">'+(H[0]==COMMENT_FAVCOLLECTIONS?"Collection":"Gallery")+'</div><a href="/" class="tv70-cover"></a><div class="a-stream"><div class="tt-a">'+I+"</div></div></div></div></div>");break;default:F=""}if(F){App.cacheResourceView(H[0],H[1],"stacktile","",(F||"").replace(/ collect_rid=/g," nop_rid="))}}};if(window.DWait){DWait.run("jms/pages/gallery/artzone.js")}function RIDFactory(){}RIDFactory.prototype={debug_label:"IDFactory",on:function(){DRE.assert(this.owner);DRE.assert(this.factory_method);DRE.assert(this.rids instanceof Array)},off:function(){},stuff:{rids:{think:function(A,E,C){var D,B;Bug.log("RIDFactory","Fetching RIDs by "+this.factory_method+"(bug "+this.rids.guid+")");switch(this.factory_method){case"loaded":D=this.rids.slice(E,E+C);for(B=0;B!=D.length;B++){if(!D[B]){break}}if(B==D.length){return A.done(D)}case"query":this.up(App).peek("data","resource views by query",this.query,E,C,"thumb150",this.view_options||{title:true,artist:true}).reset();Task.station(this.up(App).peek("data","resource views by query",this.query,E,C,"thumb150",this.view_options||{title:true,artist:true}),[arguments.callee.ebx.gotResources,this,A,C]);break;default:DRE.halt("uhh.. "+this.factory_method+"?");break}},gotResources:function(A,D){var C,B;B=Browser.isGecko?[]:Array(Number(Task.station.data[0].total)||24);B.html=Task.station.data[0].resources;this.more_left=Boolean(Task.station.data[0].more);if(Number(Task.station.data[0].total)){for(C=0;C!=this.rids.length;C++){if(this.rids[C]){break}}if(!this.rids[C]){this.rids.length=Number(Task.station.data[0].total)}}if(Browser.isGecko){while(B.length<(Number(Task.station.data[0].total)||24)){B.push(null)}}A.done(B)}}},receiver:function(F,B,C,A,E,D){if(C=="section"&&A==this.sectionid&&E=="sectionid"){this.sectionid=D;return }}};if(window.DWait){DWait.run("jms/pages/gallery/ridfactory.js")}function BrowseBubble(){}BrowseBubble.prototype={debug_label:"BrowseBubble",template:'<div class="browsebubble"><div class="browsemorechoices"></div></div>',template_bar:('<span class="bb bb-with-sep"><span class="gmpanel gallery-links"><a href="" class="h featuredlink" browse_choice_mode="featured" onclick="with (Gallery.getInstance()) { setProp(\'url_page\', 0, \'navigate\'); setProp(\'url_browse\', \'featured\'); } this.blur(); return Events.stop();">Featured</a> <a href="" class="h browselink" browse_choice_mode="browse"     onclick="with (Gallery.getInstance()) { setProp(\'url_page\', 0, \'navigate\'); setProp(\'url_browse\', \'browse\'); }   this.blur(); return Events.stop();">Browse</a> <a href="" class="h scrapbooklink" browse_choice_mode="scrapbook" onclick="with (Gallery.getInstance()) { setProp(\'url_page\', 0, \'navigate\'); setProp(\'url_browse\', \'browse/scraps\'); } this.blur(); return Events.stop();">Scrapbook</a> </span></span><span class="bb bb-with-sep"><span class="gmpanel"><span class="gallerysearch"><form action=""><input class="itext" type="text" onkeypress="if (Browser.isIE && window.event.keyCode == 13) { Keeper2.get(Tree.get(\'div.browsebubble\')).searchSubmit();return Events.stop(); }"/> <input class="ibutton" type="submit" value="Search Gallery" onclick="if (Browser.isIE) { Keeper2.get(Tree.get(\'div.browsebubble\')).searchSubmit();return Events.stop(); }"/></form></span></span></span>'),template_editmode:('<a class="gmbutton2 gmhyper" onclick="return DWait.readyLink(\'jms/pages/gallery3.js\', this, \'Gallery.getInstance().editClick()\')" href="">Done<b></b></a><a class="gmbutton2 gmhyper" onclick="return DWait.readyLink(\'jms/pages/gallery3.js\', this, function () { Keeper2.get(Tree.get(\'div.browsebubble\')).get(\'ask\', \'options\') })" href="">Options<b></b></a><a style="display:none" class="gmbutton2 gmhyper gmcruise" onclick="Gallery.getInstance().publishClick();return GMI.evCancel()" href="">Publish...<b></b></a><a class="gmbutton2 gmhyper" onclick="return DWait.readyLink(\'jms/pages/gallery3.js\', this, function () { Keeper2.get(Tree.get(\'div.browsebubble\')).get(\'ask\', \'hints\') })" href="">Hints<b></b></a>'),on:function(){this.is_group=this.up(Gallery).is_group;DRE.assert(this.username,"Provide username");this.getNode("bar");if(!this.is_group){if(this.up(Gallery).typeid!=COMMENT_GALLERIES){this.getNode("gallerysearch").parentNode.parentNode.style.display="none";this.getNode("featuredlink").innerHTML="Favourites"}Events.hook(Tree.get(this.getNode("gallerysearch"),"form"),"submit",Refunction(this,this.searchSubmit))}this.prop_watcher=this.up(Gallery).watchProp("url_browse",this.urlChange,this);this.prop_watcher_b=this.up(Gallery).watchProp("edit_mode",this.editModeChange,this)},off:function(){if(this.getNode("bar").parentNode){this.getNode("bar").parentNode.removeChild(this.getNode("bar"))}if(!this.is_group){Events.unhook(Tree.get(this.getNode("gallerysearch"),"form"),"submit",Refunction.lastCall(this,this.searchSubmit))}if(this.prop_watcher!==undefined){this.up(Gallery).unwatchProp("url_browse",this.prop_watcher)}this.up(Gallery).unwatchProp("edit_mode",this.prop_watcher_b)},stuff:{ask:{options:{think:function(A){this.spawn(GalleryEditor);A.done()}},hints:{think:function(A){this.spawn(GalleryHints);A.done()}}}},nodeMap:{bar:{get:function(){return document.createElement("div")},renderCall:function(A,B){var C;if(this.is_group){B.innerHTML=""}else{B.innerHTML=this.template_bar}C=GMI.query("GPage")[0].findBluesBar();C.insertBefore(B,C.firstChild);GMI.query("GPage")[0].findBluesBarButtons().style.visibility="visible"},render:KEEPER_RENDER_IMMEDIATE},featuredlink:T={get:function(A,B){return Tree.get(this.getNode("bar"),"."+A)}},browselink:T,scrapbooklink:T,gallerysearch:T,itext:T},editModeChange:function(C,B,D,A){GMI.query("GPage")[0].setBluesBarButtons(B?this.template_editmode:null);this.up(Gallery).invalidateProp("editbutton_visibility");if(B&&vms_feature("cruisers")&&(eax=Tree.get("a.gmcruise"))){eax.style.display="block"}},urlChange:function(E,F,A,B){var G,H,J,C,D,I;DRE.assert(B=="url_browse");if(this.is_group){this.setProp("query","special:featured");return }G=F.split("/");D=G[0];if(D=="newest"||D=="popular"){D="browse"}if(F=="browse/scraps"){D="scrapbook"}Tree.removeClass(Tree.get(this.getNode("bar"),"a.active")||this.node,"active");J=Tree.gets(this.getNode("bar"),"a");for(C=0;J[C];C++){if(J[C].getAttribute("browse_choice_mode")==D){Tree.addClass(J[C],"active");break}}switch(G[0]){case"everything":case"everything-newest":case"everything-popular":case"newest":case"popular":case"browse":I=G[0].indexOf("popular")>=0;if(window.LOTCC){LOTCC.bcpw("act","browse artist gallery")}this.setProp("query",this.up(Gallery).getProp("querybase")+":"+this.username+" "+(I?"boost:popular":"sort:time")+(G[1]&&this.up(Gallery).typeid!=COMMENT_FAVCOLLECTIONS?" in:"+G.slice(1).join("/").replace(/\/$/,""):""));if(!this._KP_gets(BrowseOptions)[0]&&this.up(Gallery).typeid!=COMMENT_FAVCOLLECTIONS){this.getNode("browsemorechoices").appendChild(this.spawn(BrowseOptions,{show_sort:this.up(Gallery).typeid!=COMMENT_FAVCOLLECTIONS,cat_root:(this.up(Gallery).typeid!=COMMENT_GALLERIES)?"art":"gallery/"+this.up(Gallery).gallery_id,show_count:true}).node)}return ;case"scrapbook":this.setProp("query",this.up(Gallery).getProp("querybase")+":"+this.username+" in:scraps");break;case"search":this.getNode("itext").value=G.slice(1).join(" ");this.setProp("query","by:"+this.username+" "+this.getNode("itext").value);break;case"featured":default:this.setProp("query","special:featured");break}if(this._KP_clear(BrowseOptions)){}},searchSubmit:function(B){var A;A=this.getNode("itext").value;if(A.match(/^\s*$/)){this.getNode("itext").focus();return false}this.up(Gallery).setProp("url_browse","search/"+A);this.setProp("query","by:"+this.username+" "+A);return false},receiver:function(F,D,G,I,B,H){var C,E,A;if((D instanceof Gallery)&&G=="section"&&I==GALLERY_FEATURED_ID&&B=="new"&&H&&H.name=="Featured"&&this.getProp("query")=="special:featured"){C=this._KP_gets(ArtZone)[0];A=this.up(Gallery).featured_section_data;if(!C||!A){Bug.log("WHUT",C+" + "+A);return }C.factory.off();C.factory=this.spawn(RIDFactory,{factory_method:"loaded",rids:A.ids,query:this.up(Gallery).getProp("querybase")+":"+this.up(Gallery).gallery_deviant,view_options:this.up(Gallery).typeid==COMMENT_FAVCOLLECTIONS?{}:{artist:false}});C.sectionid=A.sectionid;C.setProp("last_id_change",C.getProp("last_id_change")+1)}else{if((D instanceof Gallery)&&G=="section"&&(I==GALLERY_FEATURED_ID||I==this.up(Gallery).featured_section_data.sectionid)){switch(B){case"attributes":this.setProp("scrapbook_link",H&FEATURED_FOLDER_ATTRIBUTE_NO_SCRAPS_LINK);break;case"rids":if(this.getProp("query")=="special:featured"){this.setProp("query","");this.setProp("query","special:featured")}break}}}},propMap:{query:{get:function(){return""},change:function(D,C){var B,A;if(!C){return }this._KP_clear(ArtZone);this._KP_clear(RIDFactory);this._KP_clear("div.seealso");B=this.up(Gallery).mutations.thumbnail_editing.ArtZone;if(C=="special:featured"){if(A=this.up(Gallery).featured_section_data){C=this.up(Gallery).getProp("querybase")+":"+this.username+"/"+A.sectionid;B.factory=this.spawn(RIDFactory,{factory_method:this.up(Gallery).getProp("gallery_owner")||this.up(Gallery).is_group?"loaded":"query",rids:A.ids,query:C,view_options:this.up(Gallery).typeid==COMMENT_FAVCOLLECTIONS?{}:{artist:false}});B.sectionid=A.sectionid}else{C=this.up(Gallery).getProp("querybase")+":"+this.username;B.factory=this.spawn(RIDFactory,{factory_method:"query",query:C,rids:[],view_options:this.up(Gallery).typeid==COMMENT_FAVCOLLECTIONS?{}:{artist:false}});B.sectionid=GALLERY_FEATURED_ID}}else{B.sectionid=null;B.factory=this.spawn(RIDFactory,{factory_method:"query",query:C,rids:[],view_options:this.up(Gallery).typeid==COMMENT_FAVCOLLECTIONS?{}:{artist:false}})}B.thumb_keeper={query:C,label:""};B.start_hidden=false;B.spare_label='<div class="artnull">No deviations</div>';B.count_per_page=this.up(Gallery).getProp("count_per_page");B.admaster=this.up(Gallery);this.node.appendChild(this.spawn(ArtZone,B).node);if((this.up(Gallery).getProp("daily_deviations")>0||(0))&&(Tree.get(this.getNode("bar"),"a.active")||this.node).getAttribute("browse_choice_mode")=="browse"){this.node.appendChild(Tree.createFragment('<div class=" seealso c pppp">See Also: &nbsp;&nbsp; <a class="h" href="http://'+this.username+'.deviantart.com/dds/">'+this.username+"'s daily deviations</a> &nbsp;&nbsp; </div>"))}}},scrapbook_link:{get:function(){return this.up(Gallery).getProp("featured_attributes")&FEATURED_FOLDER_ATTRIBUTE_NO_SCRAPS_LINK},change:function(B,A){if(!this.is_group){this.getNode("scrapbooklink").style.display=(A||this.up(Gallery).getProp("scraps")==0)?"none":"inline"}},render:KEEPER_RENDER_IMMEDIATE}}};if(window.DWait){DWait.run("jms/pages/gallery/browse_bubble.js")}function GalleryEditor(){}GalleryEditor.prototype={debug_label:"GalleryEditor",template:'<form style="width:320px"><div style="margin:32px 0;padding:0 24px"><div class="modaltabs" style="margin-bottom:16px;border-bottom:1px solid #999;padding:2px;text-align:center;word-spacing:1.3em;"><a class="a" href="" onclick="Keeper2.get(this).activate(this);return Events.stop();">Style</a> <a class="a featuredtab" href="" onclick="Keeper2.get(this).activate(this);this.blur();return Events.stop();">Featured</a></div><div class="modaltab"><div style="height:160px"><span class="g-only o-only"><label><input type="checkbox" class="scrapcheck" name="negattr'+FEATURED_FOLDER_ATTRIBUTE_NO_SCRAPS_LINK+'"/> Scrapbook link</label><br/><br/></span><span class="terminology">Folder</span> bar:<br/><label><input type="radio" name="attr'+FEATURED_FOLDER_ATTRIBUTE_SIDEBAR_ICON_MASK+'" value="0"/> Icons &amp; Text</label><br/><label><input type="radio" name="attr'+FEATURED_FOLDER_ATTRIBUTE_SIDEBAR_ICON_MASK+'" value="'+FEATURED_FOLDER_ATTRIBUTE_SIDEBAR_NO_TEXT+'"/> Icons Only</label><br/><label><input type="radio" name="attr'+FEATURED_FOLDER_ATTRIBUTE_SIDEBAR_ICON_MASK+'" value="'+FEATURED_FOLDER_ATTRIBUTE_SIDEBAR_NO_ICON+'"/> Text Only</label><br/><br/><span class="terminology">Folder</span> bar placement:<br/><label><input type="radio" name="attr'+FEATURED_FOLDER_ATTRIBUTE_SWAP_SIDEBAR+'" value="0"/> Left</label> &nbsp;&nbsp; <label><input type="radio" name="attr'+FEATURED_FOLDER_ATTRIBUTE_SWAP_SIDEBAR+'" value="'+FEATURED_FOLDER_ATTRIBUTE_SWAP_SIDEBAR+'"/> Right</label><br/><br/><span class="leet-only o-only"><br/><label><input type="checkbox" name="attr'+FEATURED_FOLDER_ATTRIBUTE_COLLECTIONS_SPECIAL+'"/> I am deviously oldschool</label><br/><br/></span></div><div style="padding:32px 0 0 0;text-align:right"><input type="submit" name="done" value="OK" style="width:12ex"/> &nbsp;&nbsp;&nbsp;<input type="submit" name="cancel" value="Cancel" style="width:12ex"/> </div></div><div class="modaltab" style="display:none"><div style="height:160px"><div class="o-only"><strong>Quick Reset</strong><br/><input class="feature-all" type="submit" name="reset" value="Feature All Deviations..."/><br/><input class="unfeature-all" type="submit" name="clear" value="Unfeature All Deviations..."/><br/><br/></div><span class="g-only"><strong>Quick Rearrange</strong><br/><input type="submit" name="newest" value="Newest to Oldest..."/><br/><input type="submit" name="oldest" value="Oldest to Newest..."/></span></div><div style="padding:32px 0 0 0;text-align:right"><input type="submit" name="done" value="OK" style="width:12ex"/> &nbsp;&nbsp;&nbsp;<input type="submit" name="cancel" value="Cancel" style="width:12ex"/> </div></div></div></form>',linkIndex:function(B){var A;A=0;while(B=B.previousSibling){if(Tree.tag(B)=="a"){A++}}return A},deactivate:function(){var A,B;B=Tree.get(this.getNode("modaltabs"),"a.active");if(!B){return }Tree.removeClass(B,"active");Tree.gets(this.node,"div.modaltab")[this.linkIndex(B)].style.display="none"},activate:function(B){var A,B;this.deactivate();Tree.addClass(B,"active");Tree.gets(this.node,"div.modaltab")[this.linkIndex(B)].style.display="block"},on:function(){var A,C,E,B,D,F,G;DRE.assert(this.owner instanceof BrowseBubble);Modals.push(this.node,Refunction.runOnce(this,this.modalResult));E=this.up(Gallery).featured_section_data;B=Tree.gets(this.node,"span.terminology");F=this.up(Gallery).getProp("folder");for(D=0;B[D];D++){B[D].firstChild.nodeValue=F}if(this.up(Gallery).is_group){if(this.up(Gallery).typeid==COMMENT_FAVCOLLECTIONS){this.getNode("modaltabs").style.display="none"}B=Tree.gets(this.node,".o-only");for(D=0;B[D];D++){B[D].parentNode.removeChild(B[D])}}else{if(this.up(Gallery).typeid==COMMENT_FAVCOLLECTIONS){this.getNode("featuredtab").innerHTML="Reset";B=Tree.gets(this.node,".g-only");for(D=0;B[D];D++){B[D].parentNode.removeChild(B[D])}this.getNode("feature-all").value="Unhide All Favourites...";this.getNode("unfeature-all").style.display="none";this.getNode("unfeature-all").parentNode.insertBefore(this.getNode("unfeature-all"),this.getNode("feature-all"))}else{Tree.get(this.node,"input.scrapcheck").disabled=!this.up(Gallery).getProp("scraps")}}A=Tree.gets(this.node,"input");for(D=0;A[D];D++){switch(A[D].type){case"checkbox":if(C=String(A[D].name).match(/^attr(\d+)$/)){if(E.attributes&Number(C[1])){A[D].checked=true}}else{if(C=String(A[D].name).match(/^negattr(\d+)$/)){if(!(E.attributes&Number(C[1]))){A[D].checked=true}}}break;case"radio":if(C=String(A[D].name).match(/^attr(\d+)$/)){if(Number(E.attributes&Number(C[1]))==Number(A[D].value)){A[D].checked=true}}break}}if(this.up(Gallery).typeid!=COMMENT_FAVCOLLECTIONS||!this.up(Gallery).pre3){G=Tree.get(this.node,"span.leet-only");if(G){G.parentNode.removeChild(G)}}if(Tree.get(this.node,"div.modaltabs")){this.activate(Tree.get(this.node,"a"))}},modalResult:function(F,E){var E,C,B,D,A;A=this.up(Gallery);switch(F){case"keeper":return true;case"done":E={};C=0;B=Tree.gets(this.node,"input");for(D=0;B[D];D++){switch(B[D].type){case"checkbox":if(match=String(B[D].name).match(/^attr(\d+)$/)){if(B[D].checked){C|=Number(match[1])}}else{if(match=String(B[D].name).match(/^negattr(\d+)$/)){if(!B[D].checked){C|=Number(match[1])}}}break;case"radio":if(match=String(B[D].name).match(/^attr(\d+)$/)){if(B[D].checked&&Number(B[D].value)){C|=Number(B[D].value)}}break}}if(C!=this.up(Gallery).featured_section_data.attributes){E.attributes=C}this.broadcast("sectionui",this.up(Gallery).featured_section_data.sectionid,"options",E);break;case"clear":if(confirm(this.up(Gallery).typeid==COMMENT_FAVCOLLECTIONS?"Hide All Favourites?":"Unfeature all deviations?")){this.up(Gallery).difiSave("reset_featured",[A.gallery_id,A.moduleid,A.typeid,0]);DiFi.timer(1)}return false;case"reset":if(confirm(this.up(Gallery).typeid==COMMENT_FAVCOLLECTIONS?'Put all deviations back into "Favourites"?':"Feature all deviations?")){this.up(Gallery).difiSave("reset_featured",[A.gallery_id,A.moduleid,A.typeid,1]);DiFi.timer(1)}return false;case"oldest":case"newest":if(confirm("Rearrange all Featured items?")){this.up(Gallery).difiSave("sort_folder",[A.gallery_id,A.moduleid,A.typeid,A.featured_section_data.sectionid,F=="newest"?1:0]);DiFi.timer(1)}return false}setTimeout(Refunction.runOnce(this,this.off),1);return true},off:function(){Modals.pop("keeper")}};if(window.DWait){DWait.run("jms/pages/gallery/gallery_editor.js")}function GalleryHints(){}GalleryHints.prototype={debug_label:"GalleryHints",template:'<form style="width:440px"><div style="margin:32px 0;padding:0 24px;line-height:1.7em"><strong class="headerhint">Gallery</strong><br/><img src="http://e.deviantart.com/emoticons/b/bulletgreen.gif"/> <span class="folderhint">Create folders for your <span class="grouphint">group\'s</span> deviations</span><br/><span class="grouphint upsidedown"><img src="http://e.deviantart.com/emoticons/b/bulletgreen.gif"/> Change what\'s in your Featured set, whenever you like<br/></span><img src="http://e.deviantart.com/emoticons/b/bulletgreen.gif"/> <span class="draghint">Drag &amp; Drop to arrange your <span class="grouphint">group\'s</span> deviations</span><br/><img src="http://e.deviantart.com/emoticons/b/bulletgreen.gif"/> Use the <img width="19" height="17" src="http://s.deviantart.com/minish/gallery/menu-button-b.gif" alt="[menu]"/> buttons for quick organization<br/><img src="http://e.deviantart.com/emoticons/b/bulletgreen.gif"/> <span style="color:#E20">New!</span> <span class="ctrlhint">Press Ctrl + Click to select many deviations</span><br/><img src="http://e.deviantart.com/emoticons/b/bulletgreen.gif"/> Or, use your mouse to draw selection rectangles</span><br/><br/><div class="c"><input type="submit" name="cancel" value="Cool!" style="width:12ex"/></div></div></form>',on:function(){var B,A,C;C=this.up(Gallery).is_group;if(Browser.isMac){this.getNode("ctrlhint").innerHTML="Press &#8984; + Click to select many deviations"}if(this.up(Gallery).typeid==COMMENT_FAVCOLLECTIONS){this.getNode("headerhint").innerHTML="Favourites";if(this.up(Gallery).getProp("folder")=="devPack"){this.getNode("folderhint").innerHTML='Make devPacks of your <span class="grouphint">group\'s</span> favourite deviations'}else{this.getNode("folderhint").innerHTML='Make collections of your <span class="grouphint">group\'s</span> favourite deviations'}this.getNode("draghint").innerHTML='Drag &amp; Drop to arrange your <span class="grouphint">group\'s</span> favourites'}B=Tree.gets(this.node,"span.grouphint");for(A=0;A!=B.length;A++){B[A].style.display=(Number(C)^Number(B[A].className.indexOf("upsidedown")>=0))?"inline":"none"}DRE.assert(this.owner instanceof BrowseBubble);Modals.push(this.node,Refunction.runOnce(this,this.modalResult))},modalResult:function(B,A){switch(B){case"keeper":return true}setTimeout(Refunction.runOnce(this,this.off),1);return false},off:function(){Modals.pop("keeper")}};if(window.DWait){DWait.run("jms/pages/gallery/gallery_hints.js")}function GRenamer(){}GRenamer.prototype={debug_label:"GRenamer",template:'<input type="text" style="width:100%"/>',on:function(){DRE.assert(this.task);DRE.assert(this.name);Events.hook(this.node,"blur",Refunction(this,this.blurred));Events.hook(this.node,"keypress",Refunction(this,this.keyd));this.node.value=this.name;this.get("ui","focus")},off:function(){Events.unhook(this.node,"blur",Refunction(this,this.blurred));Events.unhook(this.node,"keypress",Refunction(this,this.keyd));if(this.task){this.task.off()}},stuff:{ui:{wait:{think:function(A){A.wait(Task.Delay(20))}},focus:{needs:[["ui","wait"]],get:function(B,A){this.node.focus();this.node.select();B.done()}}}},blurred:function(A){if(this._KP_dead){return }this.done()},done:function(){this.name=this.node.value;DRE.assert(task.listeners.length>0);this.task.milestone("possible name",this.name,Refunction.runOnce(this,this.nameResult))},nameResult:function(A){Bug.update("Settled",$j.makeArray(arguments)+" it is");this.name=A;this.task.done(this.name);this.task=null;this.off()},keyd:function(A){if(this._KP_dead){return }if(A.keyCode==13){this.done()}else{if(A.keyCode==27){this.node.value=this.name;this.done()}}}};if(window.DWait){DWait.run("jms/pages/gallery/grenamer.js")}function FolderView(){}FolderView.prototype={on:function(){DRE.assert(this.uplink,"Let's get to business in Barbados AND Kyoto!");Events.hook(window,"resize",Refunction(this,this.resized));setTimeout(Refunction(this,this.resized),1);this.getNode("bar");Tree.addClass(this.getNode("folderview-control"),"folderview-control-gallery-"+this.uplink.sectionid);this.setProp("attributes",this.uplink.attributes);this.prop_watcher=this.up(Gallery).watchProp("edit_mode",this.ownerPropChange,this);this.prop_watcher_b=this.up(Gallery).watchProp("section behavior",this.ownerPropChange,this);this.get("ui","all");this.get("ui","extra bubble");this.get("ui","comments")},off:function(){this.get("ui","no extra bubble");Events.unhook(window,"resize",Refunction.lastCall(this,this.resized));this.up(Gallery).unwatchProp("edit_mode",this.prop_watcher);this.up(Gallery).unwatchProp("section behavior",this.prop_watcher_b);if(this.getProp("without_hat")){Tree.removeClass(this.up(Gallery).node,"without-hat");Tree.removeClass(document.body,"without-hat")}if(this.getNode("bar").parentNode){this.getNode("bar").parentNode.removeChild(this.getNode("bar"))}if(this.uplink.safe_css){CSSVault.apply("gallery"," ")}},debug_label:"FolderView",template:'<div class="folderview ch"><i class="c tc tl"><b></b></i><i class="c tc tr"><b></b></i><div style="overflow:hidden !important;position:relative !important"><div class="folderview-control"><div class="folderview-top"></div><div class="folderview-art"></div><div class="folderview-bottom"></div></div></div></div>',template_editmode:('<a class="gmbutton2 gmhyper" onclick="return DWait.readyLink(\'jms/pages/gallery3.js\', this, \'Gallery.getInstance().editClick()\')" href="">Done<b></b></a><a class="gmbutton2 gmhyper optionbutton" style="display:none" onclick="return DWait.readyLink(\'jms/pages/gallery3.js\', this, function () { Keeper2.get(Tree.get(\'div.folderview\')).get(\'ask\', \'options\') })" href="">Options<b></b></a><a style="display:none" class="gmbutton2 gmhyper gmcruise" onclick="Gallery.getInstance().publishClick();return GMI.evCancel()" href="">Publish...<b></b></a><a class="gmbutton2 gmhyper deletebutton" style="display:none;margin-left:24px !important" onclick="return DWait.readyLink(\'jms/pages/gallery3.js\', this, function () { Keeper2.get(Tree.get(\'div.folderview\')).get(\'ask\', \'delete\') })" href="">Delete<b></b></a>'),template_folder:('<a id="togglable-gallery-edit-button" style="display:none" class="gmbutton2 gmhyper" onclick="return DWait.readyLink(\'jms/pages/gallery3.js\', this, \'Gallery.getInstance().editClick()\')" href="">Edit<b></b></a><a class="gmbutton2 galleryaccessbtn" style="display:none" href="" onclick="return DWait.readyLink(\'jms/pages/gallery3.js\', this, \'Gallery.getInstance().showAccess(this, &quot;manage&quot)\')"><i class="icon i21"></i> Access<b></b></a><a class="gmbutton2" href="" onclick="return DWait.readyLink(\'jms/pages/gallery3.js\', this, \'Gallery.getInstance().sitBack()\')"><i class="icon i20"></i>SitBack<b></b></a>'),stuff:{ui:{stats:{needs:[["ui","extra bubble"],["data","all"]],think:function(B,A){var D,C;D=0;if(this.uplink.comment_data&&!(this.uplink.comment_data instanceof Array)){for(C in this.uplink.comment_data){D++}}Tree.get(A[0],"span.statcounter-comments").innerHTML=D;Tree.get(A[0],"span.statcounter-faves").innerHTML=this.uplink.fave_count+(this.uplink.fave_count?' [<a class="a" href="http://www.deviantart.com/gallection/'+this.up(Gallery).getProp("sectionid")+'/favourites" onclick="return popup(this.href, \'favs\', 460, 600)">who?</a>]':"");Tree.get(A[0],"input.statshare-link").value="http://"+this.up(Gallery).gallery_deviant.toLowerCase()+".deviantart.com/"+(this.up(Gallery).typeid==COMMENT_FAVCOLLECTIONS?"favourites":"gallery")+"/#"+this.uplink.url_name;Tree.get(A[0],"strong.stathead").innerHTML=this.uplink.name+" by "+this.up(Gallery).gallery_symbol+this.up(Gallery).gallery_deviant;Tree.get(A[0],"div.statbutton-collect").style.display=(window.deviantART&&(!deviantART.deviant||!deviantART.deviant.username||deviantART.deviant.id==this.up(Gallery).gallery_id))?"none":"block";Tree.get(A[0],"div.statbutton-fave").style.display=(window.deviantART&&(!deviantART.deviant||!deviantART.deviant.username||deviantART.deviant.id==this.up(Gallery).gallery_id))?"none":"block";Tree.get(A[0],"span.optional-header").style.display=(window.deviantART&&(!deviantART.deviant||!deviantART.deviant.username||deviantART.deviant.id==this.up(Gallery).gallery_id))?"none":"inline";B.done()}},"extra bubble":{get:function(B){var C,A;A=[];C=Tree.create("div.bubbleview bubbletwo ch",{},Tree.createFragment('<i class="c tc tl"><b></b></i><i class="c tc tr"><b></b></i><i class="c tc bl tbl"><b></b></i><i class="c tc br tbr"><b></b></i><table align="center" class="f"><tr><td class="f comment-city-1" style="width:320px"></td><td class="f comment-city-2" style="width:480px"><div class="pppp comment-city" style="width:480px;margin:auto"></div></td><td class="f comment-city-3" style="width:320px;padding-top:64px"><div class="collect-bubble" style="display:none" class="collect-bubble"><div style="padding:10px 24px 0 20px;text-align:center;"><div style="line-height:1.3em;height:2.6em;overflow:hidden" class="collect-bubble-name">&nbsp;</div><div style="white-space:nowrap;text-align:center;_background:#FFFCD9"><div class="collect-bubble-view stream" style="text-align:center;height:180px;overflow:hidden;margin-top:-30px"></div><div class="drag-notice" style="_zoom:1">Drag and Drop to Collect</div></div></div></div><div class="ch altview ppp" style="white-space:nowrap;font-size:8.25pt"><i class="c tl"><b></b></i><i class="c tr"><b></b></i><i class="c bl"><b></b></i><i class="c br"><b></b></i><strong class="stathead"></strong><br/><div class="icons vicons" style="margin-top:2px;width:180px"><div class="statbutton-collect"><img style="position:absolute;margin-left:0;margin-top:1px;" src="http://i.deviantart.com/icons/deviation/mousefav.gif"> <a href="" onclick="Keeper2.get(Tree.get(\'div.folderview\')).collectamundo();(window.event || {}).cancelBubble = true;return false">Collect</a></div><div class="statbutton-fave"><img style="position:absolute;margin-left:0;margin-top:1px;" src="http://i.deviantart.com/icons/deviation/addfav.gif"> <a href="" onclick="Keeper2.get(Tree.get(\'div.folderview\')).faverave();(window.event || {}).cancelBubble = true;return false">Add to Favourites</a></div></div><span class="optional-header"><br/><strong>Details</strong><br/></span>Comments: <span class="statcounter-comments"></span><br/>Favourites &amp; Collections: <span class="statcounter-faves"></span><br/><br/><br/><label><strong>Copy Link</strong> &nbsp;&nbsp; For Chat, Instant Messaging, Email<br/><input type="text" class="itext statshare-link" onclick="this.select()" value="" style="width:300px;opacity:.6;filter:alpha(opacity=60)"/></label><br/><span style="display:none" class="grouphax"><br/><br/><label><strong>Copy Thumbs</strong><br/><input type="text" class="itext thumbshare-codes" onclick="this.select()" value="" style="width:300px;opacity:.6;filter:alpha(opacity=60)"/></label><br/></span></div></td></tr></table>'));Tree.get("div.bubbleview").className+=" ch";Tree.get("div.bubbleview").parentNode.insertBefore(C,Tree.get("div.bubbleview").nextSibling);A.push(C);B.done(A);if(deviantART.deviant&&deviantART.deviant.id){DiFi.pushPublicGet("Gallections","is_favorite",[deviantART.deviant.id,this.up(Gallery).typeid,this.uplink.sectionid],function(G,F){var E,D;if(G){E=F.response.content;if(E){D=Tree.get("div.statbutton-fave");Tree.get(D,"img").setAttribute("src","http://i.deviantart.com/icons/deviation/minusfav.gif");Tree.setText(Tree.get(D,"a"),"Remove from Favorites")}}})}DiFi.send()}},"no extra bubble":{needs:[["ui","extra bubble"]],get:function(B,A){var C;this._KP_clear(TalkTower);while(C=A.pop()){C.parentNode.removeChild(C)}Tree.get("div.bubbleview").className=Tree.get("div.bubbleview").className.replace(/\bch\b/g,"")}},comments:{parameters:["attributes"],needs:[["data","all"],["ui","extra bubble"]],get:function(D,C,G){var B,F,E,A;A=this.peek("ui","extra bubble").status.result;E=this.uplink.comment_data;F=Tree.get(A[0],"div.comment-city");this._KP_clear(TalkTower);if(C&FOLDER_ATTRIBUTE_DISABLE_COMMENTS){Tree.addClass(Tree.ancestor(F,"table"),"no-comments")}else{Tree.removeClass(Tree.ancestor(F,"table"),"no-comments");B={};B.comments=E;B.typeid=this.up(Gallery).typeid==COMMENT_FAVCOLLECTIONS?COMMENT_FAVCOLLECTIONS:COMMENT_GALLERIES;B.itemid=this.uplink.sectionid;B.storage_handle={total:0};B.STRING_header_a="Devious Comments";B.STRING_empty="";B.STRING_header_b="Write a Comment";B.owner_control=this.up(Gallery).getProp("gallery_owner");F.appendChild(this.spawn(TalkTower,B).node)}D.done()}},sidebar:{needs:[[Gallery,"data","relevant sections"],["ui","some"]],get:function(B,E){var C,A,D;this._KP_clear(GallerySwitch);this.getNode("subfolders").appendChild(this.spawn(GallerySwitch,{orientation:this.up(Gallery).option_bar_horizontal?"horizontal":"vertical"}).node);B.done();this.invalidateProp("sidebar_visibility")}},some:{get:function(B){var A,G,D,C,F,E;GMI.query("GPage")[0].setBluesBarButtons(" ");D=(this.up(Gallery).is_group?"#"+this.up(Gallery).gallery_deviant+" ":this.up(Gallery).gallery_deviant+"'s ")+(this.up(Gallery).typeid==COMMENT_GALLERIES?"gallery":"favourites");C="return DWait.readyLink('jms/pages/gallery3.js', this, function () {this.style.cursor='wait';setTimeout(bind(Gallery.getInstance(), Gallery.getInstance().setProp, 'sectionid', 0), 10);})";this.getNode("bar").innerHTML=('<div class="nav2 bb-with-sep"><a class="l" href="/gallery/" onclick="'+C+'">'+D+"</a></div>");if(deviantART.pageData&&deviantART.pageData.navigation_context&&Number((deviantART.pageData.navigation_context.hash_match||"").substr(1))==this.uplink.sectionid){G=Tree.createFragment(this.navigationHTML(),true);if(this.up(Gallery).getProp("gallery_owner")){Tree.addClass(G,"resource-nav-h-getouttheway")}}header_html=this.uplink.name;if(this.uplink.parentid){F=this.up(Gallery).peek("data","sections").status.result;for(E=0;E!=F.length;E++){if(Number(F[E].sectionid)==Number(this.uplink.parentid)){header_html='<a class="h" href="#'+F[E].url_name+'">'+F[E].name.replace(/</g,"&lt;")+"</a> > "+header_html}}}G=document.createElement("h2");G.innerHTML=header_html;this.getNode("folderview-top").appendChild(G);this.getNode("folderview-top").appendChild(Tree.create("div.description",{},""));this.getNode("folderview-top").appendChild(Tree.create("div.subfolders",{},""));A=this.up(Gallery).mutations.thumbnail_editing.ArtZone;A.factory=this.spawn(RIDFactory,{factory_method:this.up(Gallery).getProp("gallery_owner")||this.up(Gallery).is_group?"loaded":"query",rids:this.uplink.ids,query:this.up(Gallery).getProp("querybase")+":"+this.up(Gallery).gallery_deviant+"/"+this.uplink.sectionid,view_options:this.up(Gallery).typeid==COMMENT_FAVCOLLECTIONS?{}:{artist:false}});A.sectionid=this.uplink.sectionid;A.thumb_keeper={query:this.up(Gallery).getProp("querybase")+":"+this.up(Gallery).gallery_deviant+"/"+this.uplink.sectionid,label:this.uplink.name};A.spare_label=(this.up(Gallery).getProp("edit_mode")?('<img src="http://e.deviantart.com/emoticons/f/fella.gif" alt="Fella says:" title="Fella says"/> This is your '+(this.up(Gallery).is_group?"group's ":"")+"new "+(this.up(Gallery).typeid==COMMENT_GALLERIES?"Gallery Folder":this.up(Gallery).getProp("folder"))+'!<br/><br/>Use the <img src="http://s.deviantart.com/minish/gallery/menu-button.gif"/> buttons in your '+(this.up(Gallery).is_group?"group's ":"")+'<a href="" class="h" onclick="Keeper2.get(this).up(Gallery).setProp(\'sectionid\', 0);return Events.stop();">'+(this.up(Gallery).typeid==COMMENT_GALLERIES?"Gallery":"Favourites")+"</a> to start adding deviations."):"");A.count_per_page=this.up(Gallery).getProp("count_per_page");A.start_hidden=true;A.admaster=this.up(Gallery);G=this.spawn(ArtZone,A);G.get("ui","resources");B.done()}},all:{needs:[["ui","some"],["data","all"],["ui","stats"],["ui","css"],["ui","comments"]],get:function(A){this.getNode("folderview-art").appendChild(this._KP_gets(ArtZone)[0].node);this._KP_gets(ArtZone)[0].setProp("visible",true);this.invalidateProp("display_text");setTimeout(Refunction(this,this.resized),5);this.get("ui","sidebar");A.done();if(this.up(Gallery).is_group){setTimeout(function(){var B;B=String(Gallery.getInstance()._KP_gets(FolderView)[0]._KP_gets(ArtZone)[0].peek("data","resources").status.result).match(/collect_rid="1:(.*?)"/g).join(": :thumb").replace(/(collect_rid="1:|")/g,"");Tree.get("input.thumbshare-codes").value=B?(":thumb"+B+":"):"";Tree.get("span.grouphax").style.display="inline"},1)}}},css:{needs:[["data","all"]],think:function(A){if(this.up(Gallery).getProp("subscription_features")){CSSVault.apply("gallery",this.uplink.safe_css||"")}A.done()}},"reset art":{needs:[["ui","all"]],think:function(){this._KP_clear(ArtZone);mutation=this.up(Gallery).mutations.thumbnail_editing.ArtZone;mutation.factory=this.spawn(RIDFactory,{factory_method:"loaded",rids:this.uplink.ids,view_options:this.up(Gallery).typeid==COMMENT_FAVCOLLECTIONS?{}:{artist:false}});mutation.sectionid=this.uplink.sectionid;mutation.thumb_keeper={query:this.up(Gallery).getProp("querybase")+":"+this.up(Gallery).gallery_deviant+"/"+this.uplink.sectionid,label:this.uplink.name};mutation.spare_label="";mutation.start_hidden=false;mutation.admaster=this.up(Gallery);this.getNode("folderview-art").appendChild(this.spawn(ArtZone,mutation).node)}}},data:{all:{get:function(A){var D,B,C;if(this.uplink.text!==undefined&&this.uplink.display_text!==undefined&&this.uplink.comment_data!==undefined){A.done()}D=[this.up(App).peek("data","moods"),Task.DiFi(DiFi.pushPublicGet,this,"Resources","summaryAndHTMLFromRID",[this.uplink.type,this.uplink.sectionid,this.uplink.galleryid,"thumb150","artist:0,title:0"]),Task.DiFi(DiFi.pushPublicGet,this,"Comments","getThread",[this.up(Gallery).typeid==COMMENT_FAVCOLLECTIONS?COMMENT_FAVCOLLECTIONS:COMMENT_GALLERIES,this.uplink.sectionid,50]),Task.DiFi(DiFi.pushPublicGet,this,"Aggregations","get_text",[this.uplink.galleryid,this.up(Gallery).moduleid,this.up(Gallery).typeid,this.uplink.sectionid]),Task.DiFi(DiFi.pushPublicGet,this,"Aggregations","get_css",[this.uplink.galleryid,this.up(Gallery).moduleid,this.up(Gallery).typeid,this.uplink.sectionid])];for(B=0;D[B];B++){D[B].run()}D.push([arguments.callee.ebx.difiCrowd,this,A]);A.wait.apply(A,D)},difiCrowd:function(A){var C,B,D;App.cacheResourceView(this.uplink.type,this.uplink.sectionid,"thumb150",{artist:0,title:0},(Task.station.data[3]||{}).html);this.uplink.text=(Task.station.data[1]||{}).original;this.uplink.display_text=(Task.station.data[1]||{}).formatted;this.uplink.css=(Task.station.data[0]||{}).original;this.uplink.safe_css=(Task.station.data[0]||{}).formatted;this.uplink.fave_count=((Task.station.data[3]||{}).summary||{}).favecount;DRE.assert(this.uplink.attributes!==undefined,"Provide attributes");DRE.assert(this.uplink.name!==undefined,"Provide name");if(Task.station.data[2].bodies&&!(Task.station.data[2].bodies instanceof Array)){if(!window.Page){Page=deviantART.pageData||{}}if(!Page.comment_bodies){Page.comment_bodies={}}Page.comment_bodies.repaired=true;for(B in Task.station.data[2].bodies){Page.comment_bodies[B]={text:Task.station.data[2].bodies[B].text,signature:Task.station.data[2].bodies[B].signature}}}C=Task.station.data[2].thread;D={};if(!(C instanceof Array)){for(B in C){D[B]=C[B]}}this.uplink.comment_data=D;A.done(this.uplink)}}},css:{clear:{think:function(A){A.abort("Unimplemented: CSS 1")}},apply:{think:function(){task.abort("Unimplemented: CSS 2")}}},ask:{options:{think:function(A){this.spawn(SectionEditor);A.done()}},"delete":{think:function(A){var B;B=this.up(Gallery).getProp("folder");B=B.substr(0,1).toLowerCase()+B.substr(1);if(confirm("Are you sure you want to delete this "+B+"?\n\nHint: To remove individual deviations, use the blue arrow links instead.\n\nDelete this "+B+"?")){setTimeout(Refunction(this,this.broadcast,"sectionui",this.uplink.sectionid,"delete"),1)}A.done()}}}},receiver:function(E,A,B,G,D,C){var F;if(B=="section"&&G==this.uplink.sectionid){switch(D){case"delete":this.getNode("folderview-top").style.display="none";F=document.createElement("div");F.innerHTML='<h2 style="padding:12px">Deleted</h2>';this.node.insertBefore(F,this.node.firstChild);this.setProp("display_text",C);this.setProp("without_hat",false);this.uplink.safe_css="";this.getNode("optionbutton").style.display="none";this.getNode("deletebutton").style.display="none";this._KP_clear(ArtZone);this.get("ui","css");break;case"rids":this.get("ui","reset art");break;case"name":Tree.setText(Tree.get(this.getNode("folderview-top"),"h2"),C);break;case"text":this.setProp("display_text",C?"...":"");break;case"formattext":this.setProp("display_text",C);break;case"safecss":this.get("ui","css");break;case"attributes":this.setProp("attributes",C);this.get("ui","comments");break}}else{if(B=="sectionmessage"&&G==this.uplink.sectionid){switch(D){case"badcss":alert("Unable to use this CSS: "+C[0]+".\n\nHint: token "+C[1]);this.uplink.safe_css="";this.get("ui","css");break}}}},nodeMap:{bar:{get:function(){return document.createElement("div")},renderCall:function(A,B){var C;B.innerHTML=this.template_bar;C=GMI.query("GPage")[0].findBluesBar();C.insertBefore(B,C.firstChild);GMI.query("GPage")[0].findBluesBarButtons().style.visibility="visible"},render:KEEPER_RENDER_IMMEDIATE},deletebutton:T={get:function(A,B){return Tree.get(GMI.query("GPage")[0].findBluesBar(),"."+A)},invalidate:KEEPER_INVALIDATE_ALWAYS},optionbutton:T},propMap:{attributes:{get:function(){return this.uplink.attributes}},has_css:{get:function(){},change:function(B,A){}},display_text:{get:function(){return this.uplink.display_text||""},change:function(C,B){var A;if(A=Tree.get(this.getNode("folderview-top"),"div.description")){A.innerHTML=B;this.invalidateProp("text_align")}},render:KEEPER_RENDER_IMMEDIATE},text_align:{get:function(){var A;A=this.getProp("attributes")&FOLDER_ATTRIBUTE_SWAP_TEXT;Tree.removeClass(this.node,"folderview-ll");Tree.removeClass(this.node,"folderview-rr");if(this.getProp("display_text")||this.getProp("sidebar_visibility")||A){Tree.addClass(this.node,A?"folderview-rr":"folderview-ll")}return A},change:function(B,A){},watches_props:{attributes:function(B,A){this.invalidateProp("text_align")},sidebar_visibility:function(B,A){this.invalidateProp("text_align")}},render:KEEPER_RENDER_IMMEDIATE},without_hat:{get:function(){return this.getProp("attributes")&FOLDER_ATTRIBUTE_WITHOUT_HAT},change:function(B,A){if(A){Tree.addClass(document.body,"without-hat");Tree.addClass(this.up(Gallery).node,"without-hat")}else{Tree.removeClass(document.body,"without-hat");Tree.removeClass(this.up(Gallery).node,"without-hat")}},watches_props:{attributes:function(B,A){this.invalidateProp("without_hat")}},render:KEEPER_RENDER_IMMEDIATE},sidebar_visibility:{get:function(){var A,B;A=this.up(Gallery);B=A.peek("data","relevant sections");B.reset();A.peek("data","relevant sections").run();return A.getProp("edit_mode")||(B.status.result||[false])[0]},change:function(B,A){this.getNode("subfolders").style.display=A&&(this.up(Gallery).is_group||vms_feature("pachunkajunk"))?"block":"none"}}},ownerPropChange:function(C,B,D,A){switch(A){case"edit_mode":Task.station(this.peek("ui","all"),[function(E){GMI.query("GPage")[0].setBluesBarButtons(E?this.template_editmode:(this.up(Gallery).is_group?this.template_folder:null));if(vms_feature("cruisers")&&(eax=Tree.get("a.gmcruise"))){eax.style.display="block"}if(this.up(Gallery).is_group){if(Tree.get("a.galleryaccessbtn")){Tree.get("a.galleryaccessbtn").style.display=this.up(Gallery).gallery_access?"block":"none"}}this.up(Gallery).invalidateProp("editbutton_visibility");this.invalidateProp("sidebar_visibility");this.adjustBehavior()},this,B]);this.adjustBehavior();break;case"section behavior":this.adjustBehavior();break}},adjustBehavior:function(){Task.station(this.peek("ui","all"),[function(A){if(this.getNode("optionbutton")){this.getNode("optionbutton").style.display=this.up(Gallery).getProp("edit_mode")&&A.options_button?"block":"none";this.getNode("deletebutton").style.display=this.up(Gallery).getProp("edit_mode")&&A["delete"]?"block":"none"}},this,this.up(Gallery).getProp("section behavior")])},resized:function(){var A;if(Browser.isIE){this.getNode("folderview-control").style.height=Ruler.screen.rect().y2+"px"}else{this.getNode("folderview-control").style.minHeight=Ruler.screen.rect().y2+"px"}A=this._KP_gets(ArtZone)[0];if(A){A.resized({type:"resize"})}},collectamundo:function(){var B,C;function A(E){var D=E.target||E.srcElement;if(!Tree.ancestor(D,"div.collect-bubble")){(Tree.get("div.collect-bubble")||{style:{}}).style.display="none";Events.unhook(document.documentElement,"mousedown",arguments.callee)}}B=Tree.get("div.collect-bubble");if(B.style.display!="block"){Tree.get(B,"div.collect-bubble-name").innerHTML=(Tree.get(Tree.ancestor(B,"div.bubbletwo"),"strong.stathead").innerHTML||"").replace(/^(.*)( by ?[^\s]+)$/,"<strong>$1</strong>$2");Tree.get(B,"div.collect-bubble-view").innerHTML=App.cacheResourceView(this.uplink.type,this.uplink.sectionid,"thumb150",{artist:0,title:0}).replace(/<a /g,"<a onclick=\"Station.push(Tree.get(Tree.ancestor(this, 'div.collect-bubble'), '.drag-notice'), 'opacity', {from: 1, to: 0, f: Interpolators.sineCurve, time:300}, {from: 0, to: 1, f: Interpolators.sineCurve, time:300});(window.event || {}).cancelBubble = true;return false\" ");B.style.display="block";Events.hook(document.documentElement,"mousedown",A)}return false},faverave:function(A){var B;B=Tree.get(Tree.get(Tree.get("div.bubbletwo"),".statbutton-fave"),"a");switch(B.innerHTML.substr(0,6)){case"Add to":B.innerHTML="Thanks!";DiFi.pushPost("Gallections","create_featured",[deviantART.deviant.id,COMMENT_FAVCOLLECTIONS],function(D,C){if(!D){B.innerHTML="Add to Favourites (retry)";return }DiFi.pushPost("Aggregations","add_resource",[deviantART.deviant.id,0,COMMENT_FAVCOLLECTIONS,C.response.content.galleryid,this.up(Gallery).typeid,this.uplink.sectionid,0],function(F,E){if(!F){B.innerHTML="Add to Favourites (retry)";return }this.uplink.fave_count++;this.get("ui","stats");Tree.get(B.parentNode,"img").src="http://s.deviantart.com/icons/deviation/minusfav.gif";B.innerHTML="Remove from Favourites"},this);DiFi.timer(1)},this);DiFi.send();break;case"Remove":B.innerHTML="...";DiFi.pushPost("Gallections","create_featured",[deviantART.deviant.id,COMMENT_FAVCOLLECTIONS],function(D,C){if(!D){B.innerHTML="Remove from Favourites (try again)";return }DiFi.pushPost("Aggregations","remove_resource",[deviantART.deviant.id,0,COMMENT_FAVCOLLECTIONS,C.response.content.galleryid,this.up(Gallery).typeid,this.uplink.sectionid],function(F,E){if(!F){B.innerHTML="Remove from Favourites (try again)";return }this.uplink.fave_count=Math.max(0,this.uplink.fave_count-1);this.get("ui","stats");Tree.get(B.parentNode,"img").src="http://s.deviantart.com/icons/deviation/addfav.gif";B.innerHTML="Add to Favourites"},this);DiFi.timer(1)},this);DiFi.send();break}return false},navigationHTML:function(){var C,B,A;C=deviantART.pageData.navigation_context;B=Number(C.qx);if(B!=0&&B!=1&&B!=-1){B=null}A=[];A.push('<div class="resource-nav-h"><table align="center" class="f"><tr><td class="f"><div class="h resource-nav ringview"><i class="tl c"><i></i><b></b></i><i class="tr c"><i></i><b></b></i><i class="bl c"><i></i><b></b></i><i class="br c"><i></i><b></b></i><div class="ringview-ctrl resource-nav-ctrl">');if(B==null||B<0){A.push('<a onclick="this.blur()" class="a" href="/global/resourcenav?offset='+C.offset+"&q="+C.q+"&go=-1&label="+htmlspecialchars(C.label)+"&link="+htmlspecialchars(C.link.replace(/\#/,"%23"))+"&rid="+(this.up(Gallery).typeid==COMMENT_FAVCOLLECTIONS?COMMENT_FAVCOLLECTIONS:COMMENT_GALLERIES)+":"+this.uplink.sectionid+'"><img src="http://e.deviantart.com/emoticons/p/pointl.gif" alt="&lt;-"/> Back</a>')}else{A.push('<span style="visibility:hidden"><img src="http://e.deviantart.com/emoticons/p/pointl.gif" alt="&lt;-"/> Back</span> ')}A.push(' &nbsp;&nbsp;&nbsp; <a href="'+htmlspecialchars(C.link)+'">'+htmlspecialchars(C.label)+"</a> &nbsp;&nbsp;&nbsp; ");if(B==null||B>0){A.push('<a onclick="this.blur()" style="letter-spacing:-1px" class="a" href="/global/resourcenav?offset='+C.offset+"&q="+C.q+"&go=1&label="+htmlspecialchars(C.label)+"&link="+htmlspecialchars(C.link.replace(/\#/,"%23"))+"&rid="+(this.up(Gallery).typeid==COMMENT_FAVCOLLECTIONS?COMMENT_FAVCOLLECTIONS:COMMENT_GALLERIES)+":"+this.uplink.sectionid+'">Forward &nbsp;<img src="http://e.deviantart.com/emoticons/p/pointr.gif" alt="-&gt;"/></a>')}else{A.push('<span style="visibility:hidden">Forward &nbsp;<img src="http://e.deviantart.com/emoticons/p/pointr.gif" alt="-&gt;"/></span>')}A.push("</div></div></td></tr></table></div>");return A.join("")}};if(window.DWait){DWait.run("jms/pages/gallery/folder_view.js")}BrowseOptions=function(){};BrowseOptions.prototype={on:function(){this.setProp("show_sort",this.show_sort);this.setProp("cat_root",this.cat_root);this.setProp("show_count",this.show_count);this.getNode("browse-more").setAttribute("menuri",this.getProp("cat_root"));Events.hook(this.node,"click",Refunction(this,this.clicked));Events.hook(window,"resize",Refunction(this,this.sized));this.get("ui","bar")},off:function(){Events.unhook(this.node,"click",Refunction.lastCall(this,this.clicked));Events.unhook(window,"resize",Refunction.lastCall(this,this.sized));if(this.prop_watcher){this.up(Gallery).unwatchProp("url_browse",this.prop_watcher)}},sized:function(A){this.get("ui","more link")},ownerPropChange:function(G,F,H,B){var E,C,A,D;DRE.assert(B=="url_browse");E=F.split("/");if(!(E[0] in {browse:0,popular:0,newest:0})){return }Tree.removeClass(Tree.get(this.getNode("browse-sort"),"a.active")||this.node,"active");if(E[0]=="browse"){E[0]="newest"}A=Tree.gets(this.getNode("browse-sort"),"a");for(C=0;A[C];C++){if(E[0]==A[C].getAttribute("menusort")){Tree.addClass(A[C],"active")}}E=E.slice(1);Tree.removeClass(Tree.get(this.getNode("browse-cat"),"a.active")||this.node,"active");if(!E[0]){if(Tree.get(this.getNode("browse-cat"),"a")){Tree.addClass(Tree.get(this.getNode("browse-cat"),"a"),"active")}}else{D=this.getProp("cat_root").split("/").length;A=Tree.gets(this.getNode("browse-cat"),"a");for(C=0;A[C];C++){if(E[0]==(A[C].getAttribute("menuri")||"").split("/")[D]){Tree.addClass(A[C],"active")}}}},template:'<div class="browse-options"><div class="browse-sort">&nbsp;</div><a href="" style="display:none" class="browse-more">more <img src="http://s.deviantart.com/minish/gallery/down.gif" alt=""/></a><div class="browse-cat">&nbsp;</div><div class="browse-count">&nbsp;</div></div>',debug_label:"",stuff:{ui:{bar:{think:function(A){setTimeout(Refunction(this,this.get,"ui","bar invoke"),1);A.done()}},"bar invoke":{parameters:["show_sort","cat_root","show_count"],needs:[["data","categories"],["ui","clear"]],get:function(D,G,C,H,B,A){var F,E;E=[];if(G){E.push("<a href=\"\" onclick=\"Keeper2.get(this).up(Gallery).setProp('url_browse', ('newest/' + Keeper2.get(this).up(Gallery).getProp('url_browse').split('/').slice(1).join('/')).replace(/\\/$/, ''));this.blur();return Events.stop();\" menusort=\"newest\">Newest</a>");E.push(" &nbsp; ");E.push("<a href=\"\" onclick=\"Keeper2.get(this).up(Gallery).setProp('url_browse', ('popular/' + Keeper2.get(this).up(Gallery).getProp('url_browse').split('/').slice(1).join('/')).replace(/\\/$/, ''));this.blur();return Events.stop();\" menusort=\"popular\">Popular</a>")}this.getNode("browse-sort").innerHTML=E.join("");E=[];if(B&&B[0]){E.push("<a href=\"\" onclick=\"Keeper2.get(this).up(Gallery).setProp('url_browse', Keeper2.get(this).up(Gallery).getProp('url_browse').split('/')[0]);this.blur();return Events.stop();\"><span>All</span></a> ");for(F=0;B[F];F++){E.push(' &nbsp; <a href="" menuri="'+B[F].path.join("/")+'"><span>'+B[F].title+"</span>");if(B[F].children){E.push(' <img src="http://s.deviantart.com/minish/gallery/down.gif" alt=""/>')}E.push("</a>&nbsp; ")}}this.getNode("browse-cat").innerHTML=E.join("");if(this.prop_watcher){this.up(Gallery).unwatchProp("url_browse",this.prop_watcher)}this.prop_watcher=this.up(Gallery).watchProp("url_browse",Refunction.runOnce(this,this.ownerPropChange));setTimeout(Refunction(this,this.get,"ui","more link"),1);D.done()}},"more link":{think:function(){var B,C,A;B=Tree.gets(this.getNode("browse-cat"),"a");A=false;for(C=1;B[C];C++){if(B[C].offsetLeft<=B[C-1].offsetLeft){A=true;break}}this.getNode("browse-more").style.display=A?"block":"none"}},clear:{think:function(A){var B;for(B=0;this.node.childNodes[B];B++){if(Tree.tag(this.node.childNodes[B])=="div"){while(this.node.childNodes[B].firstChild){this.node.childNodes[B].removeChild(this.node.childNodes[B].firstChild)}}}A.done()}},selected:{parameters:["show_sort","cat_root","show_count","selected_sort","selected_cat","selected_count"],needs:[["ui","bar invoke"]],get:function(C,E,B,G,D,A,F){}}},data:{categories:{parameters:["cat_root"],get:function(B,A){if(!A){B.done([])}else{this.peek("connections","menutraffic").run();MenuTraffic.get(A);DiFi.timer(1)}}}},connections:{menutraffic:{get:function(A){MenuTraffic.register(arguments.callee.ebx.traffictalk,this);A.done()},traffictalk:function(A,B){if(A==this.getProp("cat_root")&&!("result" in this.peek("data","categories").status)){this.peek("data","categories").done(B?B.children:[])}}}}},propMap:{show_sort:{get:function(){},change:tmp=function(B,A){this.get("ui","bar")}},cat_root:{get:function(){},change:tmp},show_count:{get:function(){},change:tmp},selected_sort:{get:function(){},change:tmp=function(){if(method=="ui"){this.get("ui","selected")}}},selected_cat:{get:function(){},change:tmp},selected_count:{get:function(){},change:tmp}},clicked:function(F){var D,B,E,A,G,C;D=Tree.ancestor(F.target||F.srcElement,"a");if(D&&(B=D.getAttribute("menuri"))){E=B.split("/");A=Pager.create({rootri:B,href_base:"",theme:"dark",callback:this.menuDone,callback_object:this,master_links:true});Pager.loadPage(A,B);popup=Popup.create({className:"deviantcategories"});popup.node.appendChild(A.node);Popup.show(popup,Ruler.screen.node(D));return false}return true},menuDone:function(C,B,E){var A,D;A=C.split("/");A=A.slice(A[0]=="art"?1:2).join("/");D=MenuTraffic.getTitles(C).pop();if(B){Popup.complete(B.node)}if(E!="navigate"){this.up(Gallery).setProp("url_page",0,"navigate");this.up(Gallery).setProp("url_browse",this.up(Gallery).getProp("url_browse").split("/")[0]+(A?"/"+A:""),"ui")}return false}};if(window.DWait){DWait.run("jms/pages/gallery/browse_options.js")}DWait.count();