/*
 *  © 2000-2010 deviantART, Inc. All rights reserved.
 */
if(!window.AutoExec){AutoExec=[]}window.GPage=GMIBase.extend({init:function(){this.ownerid=this.gmiUp("Gruser").gmi_args.id;this.id=this.gmi_args.id;this.name=this.gmi_args.name},findBluesBar:function(A){var C,B;A=A||"blues-bar-ctrl";C=this.gmiUp("Gruser").gmi_node.getElementsByTagName("div");for(B=0;B!=C.length;B++){if((" "+C[B].className+" ").indexOf(" "+A+" ")>-1){return C[B]}}},findBluesBarButtons:function(){return this.findBluesBar("gmbutton2town")},setBluesBarButtons:function(A){var B;B=this.findBluesBarButtons();if(!this.blues_buttons_backup){this.blues_buttons_backup=B.innerHTML}B.innerHTML=A||this.blues_buttons_backup},findCoreOutput:function(){var A=document.getElementById("gruze-main");if(A){return A}var B,C=this.gmi_node.getElementsByTagName("td");for(B=0;B!=C.length;B++){if(C[B].className.indexOf("gruze-main")>=0){return C[B]}}}});if(window.DWait){DWait.run("jms/pages/gruzecontrol/gpage.js")}window.GZone=GMIBase.extend({});if(window.DWait){DWait.run("jms/pages/gruzecontrol/gzone.js")}DWait.ready(["jms/lib/gwebpage.js","jms/lib/gmi.js","jms/pages/gruzecontrol/gpage.js","jms/pages/gruzecontrol/gruserutils_textdown.js","jms/lib/jquery/plugins/jquery.select.pager.js"],function(){CANCEL_CLICK=";if (window.event)event.cancelBubble=true;try{this.blur()}catch(e){}return false;";window.GMFrame_Gruser=GMIBase.extend({gmiConstructor:function(){delete this.gmi_args.privileges;if((GMI.query("Gruser")[0]||this).gmi_args.group||vms_feature("pachunkajunk")){this.templates=this.templates_cruise;this.cruise_control=true}this.match_load_view_id=100;this.current_view=this.expected_view=this.gmi_args.view;this.api=this.gmi_args.api||"GrusersModules";this.position=this.gmi_args.position;this.version=this.gmi_args.version;this.setBehavior(this.gmi_args.behavior||{});this.gruser_id=this.gmi_args.gruser_id;this.probably_not_changed=true;if(!this.gmi_node.firstChild){this.gmi_node.appendChild(document.createTextNode(" "))}if(this.canBehave("difi_query_hook")){this.refreshControlHTML()}},gmiDestructor:function(){if(this.has_css){CSSVault.apply("gmf"+this.gmi_args.id," ")}},extractNode:function(){if(this.backup_node){throw new Error("this.backup_node already exists")}this.backup_node=this.gmi_node;this.gmi_node=this.gmi_node.cloneNode(true)},returnNode:function(){var A;if(!this.backup_node){throw new Error("There is no this.backup_node to restore")}this.backup_node.parentNode.replaceChild(this.gmi_node,this.backup_node);delete this.backup_node},templates:{configButtonHTML:'<span class="gmb-edit"                    ><a href="#" onclick="GMI.gmiUp(this).configClick(this)'+CANCEL_CLICK+'"                >Edit</a></span>',submitButtonHTML:'<span class="gmb-submit"                  ><a href="#" onclick="GMI.gmiUp(this).loadView(\'submit\')'+CANCEL_CLICK+'"         >New</a></span>',menuButtonHTML:'<span class="gmb-menu" title="Menu"       ><a href="#" onclick="GMI.gmiUp(this).menu()'+CANCEL_CLICK+'"                       >Menu</a></span>'},templates_cruise:{configButtonHTML:'<b class="gm-chaos gm-chaos-edit gmbuttons"><a href="#" class="gmbutton2 gmbutton2chaos" onclick="GMI.gmiUp(this).configClick(this);return GMI.evCancel()">Edit</a></b>',submitButtonHTML:'<b class="gm-chaos gm-chaos-new gmbuttons"><a href="#" class="gmbutton2 gmbutton2chaos" onclick="GMI.gmiUp(this).loadView(\'submit\');return GMI.evCancel()'+CANCEL_CLICK+'">New</a></b>',menuButtonHTML:'<span class="gmb-menu" title="Menu"       ><a href="#" onclick="GMI.gmiUp(this).menu()'+CANCEL_CLICK+'"                       >Menu</a></span>'},refreshControlHTML:function(){var C,A;if(this.canBehave("no_frame_buttons")){return }A=this.getMainNode();if(((this.gmi_node.firstChild||{}).className||"").indexOf("gm-controls")>=0){this.gmi_node.firstChild.className="gm-controls"+(this.isConfigView(this.current_view)?" gm-controls-config":"");C=[];if(this.canBehave("button_editing")||this.canBehave("edit")||(this.canBehave("faux_edit")&&this.cruise_control)||((this.gmi_args.privileges&&!this.view_context)&&this.current_view==this.gmi_args.view)){C.push(this.templates.configButtonHTML);if(this.canBehave("button_editing")){if(this.cruise_control){C[C.length-1]=C[C.length-1].replace(/class="/,'class="gm-chaos-current ')}else{C[C.length-1]=C[C.length-1].replace(/<a /,'<a class="current" ')}}}if(this.canBehave("submit")){C.push(this.templates.submitButtonHTML);if(this.current_view=="new"){if(this.cruise_control){C[C.length-1]=C[C.length-1].replace(/class="/,'class="gm-chaos-current ')}else{C[C.length-1]=C[C.length-1].replace(/<a /,'<a class="current" ')}}var B;if(B=this.canBehave("submit_url")){C[C.length-1]=C[C.length-1].replace(/\bhref="[^"]*?"\b/,'href="'+B+'"').replace(/\bonclick=".*?"\b/,"")}}this.gmi_node.firstChild.innerHTML=C.join(" ")}this.linkHook(Boolean(this.canBehave("difi_query_hook")));if(this.view_callback){this.view_callback()}},setBehavior:function(A){delete A.log;this.current_behavior=A},canBehave:function(A){return this.current_behavior[A]},toast:function(B){var A;if(this.toasting){return true}A=this.gmi_node.getElementsByTagName("h2");if(A&&A.length){A='"'+(A[0].textContent||A[0].innerText).replace(/^\s+/,"").replace(/\s+$/,"")+'"'}else{A="this widget"}if(!B&&!confirm("Are you sure you want to remove "+A+" from this page?"+(this.gmiUp("Gruser").gmi_args.group?"":'\n\nHint: To bring back widgets, or add more, click "Edit Page" at the top of the page.')+(this.canBehave("confirm_remove")?"\n\n"+this.canBehave("confirm_remove"):""))){return false}this.toasting=true;Station.run(this.gmi_node,"opacity",{from:1,to:0,time:300,f:Interpolators.sineCurve},"marginBottom",{from:0,to:-(this.gmi_node.offsetHeight+(Browser.isIE?0:(!this.edit_mode?6:16))),time:175,f:Station.f.inversion(Interpolators.pulse)},bind(this,function(){this.gmi_node.parentNode.removeChild(this.gmi_node);if(window.da_minish_widgetbar&&da_minish_widgetbar.open){da_minish_widgetbar.refreshModules(true)}else{eax=GMI.query("ModuleCatalog")[0];if(eax){eax.draw()}}setTimeout(bind(GMI,GMI._delete,this),1)}));DiFi.pushPost(this.api,"removeModule",[this.getGruserID(),this.gmiUp("GPage").gmi_args.id,this.gmi_args.id],this.genericError);DiFi.timer(1600);return true},genericError:function(B,A){if(!B&&!(ModuleArranger||this).errors_done){(ModuleArranger||this).errors_done=true;alert("There was an error saving your changes.\n\nPlease try again shortly.")}},linkHook:function(A){if(A==Boolean(this.link_hook_state)){return }console.log("It's on");if(A){if(!window.URLQueryString){throw new Error("jms/lib/urlmanager.js required to use auto-link feature")}this.urlm=new BrowseAwareURLQueryString(this.canBehave("difi_query_hook"),{ignore_blanks:true});this.urlm.addListener(bind(this,this.linkHookNav),false);this.gmi_node.onclick=bind(this,this.linkHookClicked)}else{this.gmi_node.onclick=null;this.urlm.destructor();delete this.urlm}this.link_hook_state=A},linkHookNav:function(A,C){var B;B=this.getLinkHookTarget();B.heavy_loading=true;B.loadView("generic",A)},getLinkHookTarget:function(){var A=this.canBehave("difi_query_gmi_target");if(A){return GMI.query(A[0],A[1])[0]}return this},linkHookClicked:function(F){var G,I,A,B,H,E;F=(F||window.event);G=F.target||F.srcElement;if(G.tagName=="A"){E=G.getAttribute("href").split("?");B=E[1]||"";A=this.urlm.locationStringToState(B||"");if(I=this.canBehave("difi_query_special")){for(H in I){switch(I[H]){case"last_id_before_query_string":var D,C;D=E[0].split("/");while(D.length&&!(C=D.pop())){}if(Number(C)){A[H]=C}break;default:throw new Error("Unsupported url mod: "+I[H])}}}H=false;for(H in A){break}if(H){if(!this.getLinkHookTarget()){throw new Error("Di-Fi link target not found. Falling back on regular pageload.")}this.urlm.set(A);if(F.cancelable){F.preventDefault()}else{F.cancelBubble=true}return false}}return true},pretendView:function(A){this.gmi_node.className="modframe-"+this.gmi_args.id+(A?" gr-loading":"");if(this.heavy_loading){if(A){Station.apply(this.gmi_node,"opacity",0.5)}else{Station.apply(this.gmi_node,"opacity",1);this.heavy_loading=false}}return true},loadView:function(A,C,B){if((this.expected_view==A&&!C)||this.animating_view){return }if(A=="submit"&&(this.uncommitted||this.uncommitted===0)){alert('Sorry!\n\nThis widget must be added to the page before the "new" button can be used.');return }if(B){this.heavy_loading=true}this.expected_view=A;if(!C&&this.displayCachedBody(A)){this.pretendView(null)}else{this.pretendView(A);switch(A){case"[fake_config]":this.createPrivEditor(bind(this,this.loadFakeViewDone,A));break;default:this.fetchBody(A,C)}}this.refreshControlHTML()},loadFakeViewDone:function(A){var B;if(this.expected_view==A){B=this.getMainNode().cloneNode(true);B.className="gr-configbox gr-box";this.displayCachedBody(A,B,{button_save_cancel:true,button_editing:true});this.pretendView(null);this.configViewTab(this.last_config_tab.getElementsByTagName("span")[0],"privileges")}},maybeSave:function(){if(this.quit_now){this.loadView("generic");this.quit_now=false}else{this.saveAndChangeView()}},disableTransitions:function(){this.disable_transitions=true},saveAndChangeView:function(K,J,C){var B,H,E,F,G,A,I,D;if(this.expected_view=="[whatever_save_sends]"){return }D=this.expected_view=="[fake_config]";if(this.priv_editor&&!this.priv_editor.saveReady()){return }if(D){if(this.priv_editor){this.priv_editor.save()}this.loadView("generic");return }I=GMI.query(K||this.gmi_node,"GruserUtils_TextDown");for(F=0;F!=I.length;F++){I[F].save()}this.expected_view="[whatever_save_sends]";this.pretendView("generic");H=this.findInputs(K);this.beforeSave(K);if(C){E=C(H)}else{if(this.custom_serializer){E=this.custom_serializer(H)}else{E=this.buildFormData(H)}}DiFi.pushPost(this.api,"save",[this.getGruserID(),this.gmi_args.id,J||this.current_view,E],bind(this,this.saved,H));DiFi.timer(1);if(this.priv_editor){this.priv_editor.save()}if(this.save_view_hax){this.expected_view=this.save_view_hax}},beforeSave:function(A){jQuery(A||this.gmi_node).find("form.observer").triggerHandler("submit")},justSave:function(F,B,C,A,D){this.beforeSave(B);var E=jQuery.extend(this.buildFormData(this.findInputs(B),true),C);this.pretendView(true);DiFi.pushPost(this.api,"save",[this.getGruserID(),this.gmi_args.id,A||this.current_view,E],F);DiFi.timer(1)},justLoadView:function(C,A,B){DiFi.pushPost(this.api,"displayModule",[this.gmiUp("Gruser").gmi_args.id,this.gmi_args.id,A||this.current_view,B],C);DiFi.timer(1)},moduleCall:function(B,A,C){if(!C){C=function(E,D){console.log("moduleCall response:"+E,D)}}DiFi.pushPost(this.api,"moduleCallback",[this.gmiUp("Gruser").gmi_args.id,this.gmiUp("GPage").gmi_args.id,this.gmi_args.id,B,A],C);DiFi.timer(1)},findInputs:function(A){return jQuery(A||this.gmi_node).find("textarea, input, select").filter(":not(:disabled)[name]").get()},buildFormData:function(B,D){var E={},L={},F,G;for(F=0;F!=B.length;F++){if(!D){B[F].disabled=true}if((B[F].type in {checkbox:0,radio:0})&&!B[F].checked){continue}var H=/\[([^\]]*)\]/g;if(G=B[F].name.match(H)){var A=B[F].name.replace(H,"");if(!E[A]){E[A]={};L[E[A]]=0}var I=E[A];for(var C=0;C<G.length;C++){var J=G[C].replace(/[\[\]]/g,"");var K=false;if(J==""){while(I[L[I]]){L[I]++}J=L[I];K=true}if(C==G.length-1){if(K&&B[F].type=="select-multiple"){jQuery("option:selected",B[F]).each(function(){J=L[I]++;I[J]=this.value})}else{I[J]=B[F].value}}else{if(!I[J]){I[J]={};L[I[J]]=0}I=I[J]}}}else{E[B[F].name]=B[F].value}}if(this.canBehave("save_extras")){E.save_extras=this.canBehave("save_extras")}return E},saved:function(A,F,D){var B,C,E;for(B=0;B!=A.length;B++){A[B].disabled=false}if(!F||!D.response.content.html){if(this.expected_view in {"[whatever_save_sends]":1,"[self_only]":1}){this.expected_view=this.current_view;this.quit_now=true;this.pretendView(null)}if(F){E='Cannot redirect to "'+D.response.content.view+'"\n\nServer returned blank view.'}else{if((D.response.content.error||{code:""}).code=="VERSION_MISMATCH"){E="Your settings were not saved because newer settings were found on the server."}else{E=((D.response.content||{}).error||{}).human||(this.save_hook_hax?null:"Some of your settings were not saved, due to a "+(D.request?"server":"connection")+" error.")}}if(this.save_hook_hax){this.save_hook_hax(false,{response:{content:{error:E}}})}else{alert(E)}return }if(this.expected_view=="[self_only]"&&!D.response.content.has_errors&&D.response.content.view!=this.current_view){this.expected_view=this.current_view;this.pretendView(null);if(this.save_hook_hax){this.save_hook_hax(true,{response:{content:{}}})}}if(!(this.expected_view in {"[whatever_save_sends]":1,"[self_only]":1})){this.cached_nodes={};this.cached_behavior={};return }if(this.save_hook_hax){this.save_hook_hax(false,{response:{content:{error:"The server returned an unexpected view: "+D.response.content.view}}})}this.displayCachedBody(D.response.content.view,D.response.content.html||'<img src="about:blank" alt="[x]"/>',D.response.content.frame_behavior||{});this.pretendView(null);this.refreshControlHTML();this.importGWebPage(D.response.content)},displayCachedBody:function(A,G,F){var D,C,H,B,E;if(A==this.current_view&&!G){return true}if(!this.cached_nodes){this.cached_nodes={}}if(!this.cached_behavior){this.cached_behavior={}}if(!G){G=this.cached_nodes[A];F=this.cached_behavior[A]}if(G){E=this.getMainNode();if(this.current_view==this.gmi_args.view){this.cached_nodes[this.current_view]=E;this.cached_behavior[this.current_view]=this.current_behavior}if((typeof G)=="string"){H=document.createElement("div");H.innerHTML=G;G=H.getElementsByTagName("*")[0]||H.firstChild||document.createTextNode("[?]")}this.previous_view=this.current_view;this.expected_view=A;this.current_view=A;this.setBehavior(F);this.refreshControlHTML();this.playTransition(G,E);this.probably_not_changed=true;GMI.query("GruserUtils_TextDown");return true}},getMainNode:function(A){var B=(A||this.gmi_node).getElementsByTagName("div");if(B[0].className.indexOf("gm-controls")>=0){if(!B[1]){B[1]=document.createElement("div");this.gmi_node.appendChild(B[1])}return B[1]}return B[0]},getTitle:function(){var A;if(A=this.canBehave("arranger_title")){return A}A=(this.gmi_node.getElementsByTagName("h2")||[])[0];if(A){return A.textContent||A.innerText}return"Unknown Widget"},accessClick:function(){this.pretendView("access");GMAccess.show(this.getGruserID(),"module",this.gmi_args.id,this.gmi_args.access=="view",this.getTitle(),bind(this,this.accessDone))},accessDone:function(A){this.pretendView(false);if(A&&this.isConfigView(this.current_view)&&!(this.gmi_node.getElementsByTagName("textarea")||[])[0]){this.loadView(this.current_view,true)}},configClick:function(E,G){function B(){var H;H=Popup.create({className:"cruiser",bias:"right",no_shadow:true});H.node.setAttribute("gmi-redirect",this.gmi_node.getAttribute("gmindex"));return H}Popup.completeAll();if(this.canBehave("button_editing")){if(this.cruise_control&&E){var C;if(!(C=this.cached_save_popup)){C=this.cached_save_popup=B.call(this)}C.node.innerHTML=('<div class="blockmenu"><a href="" class="f edit_link" onclick="Popup.completeAll();GMI.up(this).saveAndChangeView();return GMI.evCancel()" style="font-weight:bold">Save and Exit</a><a href="" class="f edit_link" onclick="Popup.completeAll();GMI.up(this).popView();return GMI.evCancel()">Exit Without Saving</a></div>');if(typeof (G)=="function"){G(C.node)}E.className+=" active";C.options.callback=bind(this,this.configPopupDone,E);Popup.show(C,Ruler.screen.node(E.parentNode,true));return }else{this.maybeSave()}}else{if(this.canBehave("edit")||this.canBehave("delete")||G){if(this.cruise_control&&E&&!this.canBehave("no_menus")){var C;if(!(C=this.cached_edit_popup)){C=this.cached_edit_popup=B.call(this)}var F=typeof (G)=="string"?G:"";var D=F?"normal":"bold";C.node.innerHTML=('<div class="blockmenu">'+((F+(this.canBehave("edit")?'<a href="" class="f edit_link" onclick="GMI.up(this).configClick();return GMI.evCancel()" style="font-weight:'+D+'">'+(typeof this.canBehave("edit")=="string"?this.canBehave("edit"):"Edit this Widget")+"</a>":"")+(this.canBehave("delete")&&this.gmiUp("GZone")&&(!window.Modals||!Modals.stack.length)?'<a href="" class="f del_link" onclick="Popup.completeAll();GMI.up(this).toast();return GMI.evCancel()">Remove this Widget</a>':""))||'<div class="blockdisabled">This Widget Has No Options</div>')+"</div>");if(typeof (G)=="function"){G(C.node)}else{if(this.canBehave("custom_config_menu")=="append"){jQuery(this.gmi_node).find(".custom_config_menu>a").clone().appendTo(C.node.firstChild)}}E.className+=" active";C.options.callback=bind(this,this.configPopupDone,E);Popup.show(C,Ruler.screen.node(E.parentNode,true));return }var A=this.canBehave("edit_arguments");this.loadView(this.canBehave("edit_view"),A)}else{if(this.gmi_args.privileges&&!this.view_context){this.loadView("[fake_config]")}else{throw new Error("Can't edit")}}}},configPopupDone:function(A){A.className=A.className.replace(/\bactive\b/,"")},addButtons:function(C,B){var A;A=this.isConfigView(this.current_view)&&(this.gmi_args.privileges&&!this.view_context);if(this.canBehave("button_save_cancel")||A){if(this.view_context){this.view_context.setControls(this)}else{var D;D=document.createElement("div");D.className="gr-hijack c pp";D.innerHTML=((B||!this.canBehave("delete")||!this.isConfigView(this.current_view)?"":('<div style="position:absolute;right:8px;bottom:8px;font-size:8.25pt;text-align:left;text-decoration:underline;line-height:1.5em">'+(this.canBehave("delete")?'<a href="#" onclick="GMI.up(this).toast()'+CANCEL_CLICK+'">Remove...</a><br/>':"")+(((this.gmiUp("GPage")||{}).gmi_args||{}).layoutable&&!((this.gmiUp("Gruser")||{}).gmi_args||{}).group?'<a href="#" onclick="GruserEditMode.getInstance().set(true)'+CANCEL_CLICK+'">Rearrange...</a>':"")+"</div>"))+'<table class="f" align="center"><tr>'+(A=="manage"||this.canBehave("button_save_cancel")?('<td style="padding:0 8px"><a href="#" class="gmbutton2 gmbutton2s" onclick="GMI.up(this).saveAndChangeView()'+CANCEL_CLICK+'">Save<b></b></a></td><td style="padding:0 8px"><a href="#" class="gmbutton2 gmbutton2c" onclick="GMI.up(this).cancelView()'+CANCEL_CLICK+'">Cancel<b></b></a></td>'):(A=="view"?('<td style="padding:0 8px"><a href="#" class="gmbutton2 gmbutton2c" onclick="GMI.up(this).popView()'+CANCEL_CLICK+'">Done<b></b></a></td>'):""))+"</tr></table>");C.appendChild(D)}}else{if(this.view_context){this.view_context.setControls(null)}}},createPrivEditor:function(A){this.priv_editor=GMI.create("GMPrivs",{owner:this,callback:A,read_only:this.gmi_args.privileges=="view",model:"actions"});this.priv_editor.gmi_node.style.display="none";this.priv_editor.gmi_node.className="ppp";this.priv_editor.load()},configViewTab:function(D,F,C){var B,A,G,E;A=D.parentNode.parentNode.parentNode;switch(F){case"privileges":if(!this.priv_editor){this.createPrivEditor(bind(this,arguments.callee,D,F))}A.insertBefore(this.priv_editor.gmi_node,D.parentNode.parentNode.nextSibling);if(!this.priv_editor.isReady()){this.pretendView("config");return }this.pretendView(null);E=this.priv_editor.gmi_node;break;case"history":if(!this.history_node){this.history_node=document.createElement("div");this.history_node.style.display="none";A.insertBefore(this.history_node,D.parentNode.parentNode.nextSibling);this.pretendView("config");DiFi.pushPrivateGet(this.api,"displayModule",[this.getGruserID(),this.gmi_args.id,"view_log",{}],bind(this,function(H,J,I){var K;if(!J){this.history_node.innerHTML='<div class="pppp"><img src="about:blank" alt="[?]"/></div>'}else{K=document.createElement("div");K.innerHTML=I.response.content.html||'<div class="pppp"><img src="about:blank" alt="[??]"/></div>';this.history_node.appendChild((this.gbb(K)||K).getElementsByTagName("div")[0]||K)}H()},bind(this,arguments.callee,D,F)));DiFi.timer(1);return }this.pretendView(null);E=this.history_node;break}for(B=0;B!=D.parentNode.childNodes.length;B++){D.parentNode.childNodes[B].className=(D.parentNode.childNodes[B]==D?"selected":"")}for(B=0;G=A.childNodes[B];B++){if(G.tagName=="DIV"&&(" "+G.className+" ").indexOf(" gr-hijack ")<0){if(G==this.history_node||G==(this.priv_editor||{}).gmi_node){G.style.display=(G==E?"block":"none")}else{G.style.display=E?"none":"block"}}}},gbb:function(D){var B,A,C;B=(D.getElementsByTagName&&D.getElementsByTagName("div"))||[];for(A=-1;A!=B.length;A++){C=(A==-1?D:B[A]);if((" "+C.className+" ").indexOf(" gr-body ")>=0){return(C.getElementsByTagName("div")||[])[0]}}},playTransition:function(C,J){var L,H,A,G,D,B,K,E;B=300;K=Interpolators.pulse;H=this.gbb(C);A=this.gbb(J);if(H&&A&&!this.disable_transitions){this.addButtons(H);C.style.position="absolute";C.style.width=J.offsetWidth+"px";C.style.zIndex=40;J.style.position="relative";J.style.zIndex=50;J.parentNode.insertBefore(C,J);if(this.current_view!="generic"&&window.$j){try{$j("select",C).selectpager()}catch(I){}}G=H.offsetHeight;D=A.offsetHeight;if(Math.abs((C.offsetHeight-G)-(J.offsetHeight-D))<4){L=[[H],[A]];if(G>D){H.parentNode.style.overflow="hidden";L[0].push("marginTop");L[1].push("paddingBottom");L[0].push({from:(D-G),to:0,time:B,f:K});L[1].push({from:0,to:(G-D),time:B,f:K})}else{A.parentNode.style.overflow="hidden";L[0].push("paddingBottom");L[1].push("marginTop");L[0].push({from:(D-G),to:0,time:B,f:K});L[1].push({from:0,to:(G-D),time:B,f:K})}L.push([J,"opacity",{from:1,to:0,time:B,f:K},bind(this,this.aniNodeDone,C,J,A)]);for(E=0;E!=L.length;E++){this.animating_view=true;Station.run.apply(Station,L[E])}}else{this.aniNodeDone(C,J,A)}}else{this.addButtons(C);J.parentNode.insertBefore(C,J);this.aniNodeDone(C,J,A)}},aniNodeDone:function(B,A,C){this.animating_view=false;if(B.style){B.style.position="relative";B.style.width="auto"}if(A.parentNode){A.parentNode.removeChild(A);this.previousViewCleanup();Station.apply(A,"opacity",1);if(C){Station.apply(C,"marginTop",0);Station.apply(C,"paddingBottom",0)}}if(window.Modals){Modals.refreshShadow()}},isConfigView:function(A){return this.is_inplace_editing||A in {config:1,"[fake_config]":1}},previousViewCleanup:function(){if(!this.isConfigView(this.current_view)&&this.priv_editor){GMI._delete(this.priv_editor);delete this.priv_editor}},popView:function(){this.is_inplace_editing=false;this.loadView(this.previous_view||this.gmi_args.view);this.previous_view=null},cancelView:function(){this.popView()},fetchBody:function(A,B){if(typeof B!="object"){B={}}DiFi.pushPrivateGet(this.api,"displayModule",[this.getGruserID(),this.gmi_args.id,A,B],bind(this,function(F,D,C){var E;if(!D){if(!C.request||C.request.args[2]==this.expected_view){alert((C.request?'"'+C.request.args[2]+'"':"Edit mode")+" is currently unavailable.\n\nPlease try again soon.");if(C.request&&C.request.args[2]=="config"&&(this.gmi_args.privileges&&!this.view_context)){this.loadView("[fake_config]")}else{this.loadView(this.gmi_args.view)}}return }if(F==this.match_load_view_id){this.displayCachedBody(C.request.args[2],C.response.content.html||'<img src="about:blank" alt="[x]"/>',C.response.content.frame_behavior||"");this.pretendView(null);this.importGWebPage(C.response.content)}},++this.match_load_view_id));DiFi.timer(1)},getGruserID:function(){return this.gruser_id||this.gmiUp("Gruser").gmi_args.id},importGWebPage:function(A){gWebPage.update(A,null,this.gmi_node);if(A.css&&window.CSSVault){this.has_css=true;CSSVault.apply("gmf"+this.gmi_args.id,A.css)}},editInPlace:function(B){this.is_inplace_editing=true;var C=jQuery(this.gmi_node);var D=C.find("a").attr("disabled","disabled");D.click(function(F){var E=jQuery(this);if(E.attr("disabled")){if(E.parents(".gr-configbox").length>0){F.preventDefault();return false}return true}return true});var A=GMI.query(this.getMainNode(),"GInPlace");jQuery.each(A,function(E){this.edit();if(B&&E==0){this.$input.focus()}});if(!B){jQuery(this.gmi_node).find("a.toast").show()}else{jQuery(this.gmi_node).find("a.toast").hide()}},gmAction:function(B,C){var D={type:"gm-action",context:B};if(B){var A=$j(B);D.action=C||A.attr("gmi-action");D.callback=A.attr("gmi-callback")||""}$j(this.gmi_node).trigger(D);if(window.event){event.cancelBubble=true}return false}});window.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/pages/gruzecontrol/gmframe_gruser.js")}});DWait.ready(["jms/legacy/modals.js","jms/lib/gwebpage.js","jms/pages/gruzecontrol/gmframe_gruser.js"],function(){window.WidgetUtils={modal:function(F,A,H,C,E,G,J){var D,I,B;difi=function(L,K){if(!L){DiFi.stdErr("Sorry, an error has occurred!",K.response.content);Modals.pop();return }D.innerHTML=K.response.content.html||"<span>[x]</span>";Station.run((D.getElementsByTagName("*")||[])[0]||D,"opacity",{from:0.01,to:1,time:700,f:Interpolators.sineCurve});if(K.request.method=="displayModule"){GMI.apply(D,"GMFrame_Gruser",{id:K.request.args[1],view:K.request.args[2]})}if(window.Shadows){setTimeout(Shadows.nodes,1)}if(window.Keeper){setTimeout(Keeper.master_on,1)}gWebPage.update(K.response.content,null,D);if(K.request.method!="displayModule"){GMI.query(D,"GMFrame_Gruser")}};if(!J){J={w:430,h:196}}D=document.createElement("div");D.className="chn";D.style.width=J.w+"px";D.style.height=J.h+"px";D.style.background="#D8E0DC";D.innerHTML='<h3 style="text-align:center;padding-top:50px;color:#A0AFA9">Loading...</h3>';if(H){DiFi.pushPrivateGet(F,"findAndDisplayModule",[A,H,C,E||"generic",G||{}],difi)}else{DiFi.pushPrivateGet(F,"displayModule",[A,C,E||"generic",G||{}],difi)}DiFi.send();Modals.lightfade=true;I=Modals.push(D);if(B=GMI.query("Gruser")[0]){I.setAttribute("gmi-redirect",B.gmi_node.getAttribute("gmindex"))}}};if(window.DWait){DWait.run("jms/pages/gruzecontrol/widgets/utils.js")}});DWait.ready(["jms/pages/gruzecontrol/gmframe_gruser.js","jms/pages/gruzecontrol/bluesbar.js","jms/lib/station.js","jms/lib/difi.js"],function(){window.GMFrame_BluesBar=GMFrame_Gruser.extend({gmiConstructor:function(){this.base();this.refreshControlHTML();if((this.gmiUp("Gruser")||this).gmi_args.group){delete this.EDITABLE_CLASSES.stats}},configClick:function(){if(this.current_view=="config_bar"){this.maybeSave()}else{this.loadView("config_bar")}},currentPopupIs:function(A){this.current_popup=A;this.refreshControlHTML()},showEditHint:function(D){var A,C,B;B=this.gmi_node.getElementsByTagName("a")[0];BluesBar.hiddenMenu(B,true);A=this.hint_popup||Popup.create({className:"gruserhint"});this.hint_popup=A;A.node.innerHTML='<img src="http://e.deviantart.com/emoticons/p/pointl.gif" alt="<-"/> Hint: To change '+D+", click edit.";C=Ruler.screen.node(B);C.x=300;C.y2+=8;Popup.show(A,C)},EDITABLE_CLASSES:{why:1,activity:1,stats:1},saveAndChangeView:function(){this.base(this.current_popup.node)},loadView:function(A){if(this.hint_popup){Popup.complete(this.hint_popup)}this.base(A)},refreshControlHTML:function(){var A,D,C,B;if(!this.current_popup){return }for(A in this.EDITABLE_CLASSES){if((" "+this.current_popup.node.className+" ").indexOf("-"+A+" ")<0){continue}D=this.current_popup.node.firstChild;D.setAttribute("gmi-redirect",this.gmi_node.getAttribute("gmindex"));if((" "+D.firstChild.className+" ").indexOf(" gm-controls ")<0){C=document.createElement("div");D.insertBefore(C,D.firstChild)}if(this.current_view!="config_bar"){D.firstChild.className="gm-controls";D.firstChild.innerHTML=(this.canBehave("edit")?this.templates.configButtonHTML:"")}else{D.firstChild.className="gm-controls gm-controls-config gm-fakeout";if(this.cruise_control){D.firstChild.innerHTML=this.templates.configButtonHTML.replace(/class="/,'class="gm-chaos-current ')}else{D.firstChild.innerHTML=this.templates.configButtonHTML.replace(/<a /,'<a class="current" ')}}B=(this.current_view=="config_bar"||this.expected_view=="config_bar");if((this.current_popup.invincible||false)!=B){this.current_popup.invincible=B;this.setLockedMode(B)}}},setLockedMode:function(A){var C,B;this.gmi_node.className=A?"bluesbar-locked":"";B=GMI.query("GPage")[0].findBluesBarButtons().getElementsByTagName("a");for(C=0;C!=B.length;C++){if(A){B[C].className+=" disabledbutton"}else{B[C].className=B[C].className.replace(/\bdisabledbutton\b/g,"")}}},pretendView:function(A){if(this.current_popup){if(A){this.current_popup.node.className+=" gr-loading"}else{this.current_popup.node.className=this.current_popup.node.className.replace(/\bgr.loading\b/,"")}}return true},getMainNode:function(){var B,A;if(this.current_popup){B=this.current_popup.node.firstChild;A=B.getElementsByTagName("div");if((" "+A[0].className+" ").indexOf(" gm-controls ")>=0){return A[1]}return A[0]}return this.gmi_node},animatePopup:function(A,C){var D,B;B=175;if(this.current_popup&&(A||C)){this.current_popup.node.style.overflow="hidden";Popup.removeShadow(this.current_popup);D=bind(Popup,Popup.addShadow,this.current_popup);if(C){Station.push(this.current_popup.node,"height",{from:parseInt(Station.read(this.current_popup.node,"height")),to:C,time:B,f:Interpolators.pulse},"overflow",{to:"visible"},D)}if(A){Station.push(this.current_popup.node,"width",{from:parseInt(Station.read(this.current_popup.node,"width")),to:A,time:B,f:Interpolators.pulse})}}},playTransition:function(C,I){switch(BluesBar.menu_on.href.split("-").pop()){case"why":if(this.current_view=="config_bar"){Popup.removeShadow(this.current_popup);this.current_popup.node.style.height="500px";Popup.addShadow(this.current_popup)}else{Popup.removeShadow(this.current_popup);this.current_popup.node.style.height="auto";setTimeout(bind(Popup,Popup.addShadow,this.current_popup),1)}break;case"stats":if(this.current_view!="config_bar"&&this.current_popup){BluesBar.verify("stats",C)}break;case"activity":if(this.current_view!="config_bar"&&this.current_popup){BluesBar.verify("activity",C)}break}function J(N){var M,F;M=N.getElementsByTagName("div");for(F=-1;F!=M.length;F++){d=(F==-1?N:M[F]);if((" "+d.className+" ").indexOf(" gr-body ")>=0){return(d.getElementsByTagName("div")||[])[0]}}}var L,H,A,G,D,B,K,E;B=400;K=Interpolators.pulse;H=J(C);A=J(I);if(H&&A){this.addButtons(H,true);C.style.position="absolute";C.style.width=I.offsetWidth+"px";C.style.zIndex=40;I.style.position="relative";I.style.zIndex=50;I.parentNode.insertBefore(C,I);G=H.offsetHeight;D=A.offsetHeight;this.aniNodeDone(C,I,A)}else{I.parentNode.insertBefore(C,I);this.aniNodeDone(C,I,A)}},aniNodeDone:function(B,A,C){B.style.position="static";B.style.width="auto";if(A.parentNode){A.parentNode.removeChild(A)}},displayCachedBody:function(F,D,B){var E,C,J,K,H,G,A,I;if(F==this.current_view&&!D){return true}if(!this.cached_nodes){this.cached_nodes={}}if(!this.cached_behavior){this.cached_behavior={}}if(!D){D=this.cached_nodes[F];B=this.cached_behavior[F]}if(D){G=this.getMainNode();if(this.current_view==this.gmi_args.view){this.cached_nodes[this.current_view]=G;this.cached_behavior[this.current_view]=this.current_behavior}if(F!="config_bar"&&(typeof D)=="string"){A=BluesBar.menu_on.href.split("#").pop();while(this.gmi_node.firstChild){this.gmi_node.removeChild(this.gmi_node.firstChild)}if((typeof D)=="string"){this.gmi_node.innerHTML=D}else{this.gmi_node.appendChild(D)}J=this.gmi_node.getElementsByTagName("a");for(C=0;C!=J.length;C++){if(J[C].href.split("#").pop()==A){BluesBar.menu_on=J[C];BluesBar.menu_on.className+=" active";BluesBar.ieFix(J[C])}}if(!Browser.isIE&&this.current_popup.node.previousSibling){document.body.appendChild(this.current_popup.node.previousSibling)}document.body.appendChild(this.current_popup.node);D=document.getElementById(A).getElementsByTagName("*")[0].cloneNode(true);if(A.split("-").pop()=="why"){setTimeout(bind(this,this.updateTagLine),10)}}else{if((typeof D)=="string"){K=document.createElement("div");K.innerHTML=D;D=K.getElementsByTagName("*")[0]}if(F=="config_bar"){A=BluesBar.menu_on.href.split("-").pop();E=D.getElementsByTagName("div");I=[];for(C=0;C!=E.length;C++){if(E[C].className.indexOf("bluesbar-config-")==0){if(E[C].className!="bluesbar-config-"+A){I.push(E[C])}}}for(C=0;C!=I.length;C++){I[C].parentNode.removeChild(I[C])}}}this.previous_view=F=="config"?null:this.current_view;this.expected_view=F;this.current_view=F;this.setBehavior(B);this.refreshControlHTML();this.playTransition(D,G);GMI.query("GruserUtils_TextDown");return true}},updateTagLine:function(){document.getElementById("gruser-tagline").innerHTML=document.getElementById("super-secret-tagline").innerHTML}});if(window.DWait){DWait.run("jms/pages/gruzecontrol/gmframe_bluesbar.js")}});GruserUtils_TextDown=GMIBase.extend({gmiConstructor:function(){var A;this.focus=bind(this,this.focus);this.select=this.gmi_node.getElementsByTagName("select")[0];this.hidden=this.gmi_node.getElementsByTagName("input")[0];this.neutral=this.gmi_args.neutral;this.default_input=this.gmi_args.default_input||"To be deviant";this.show_cancel=this.gmi_args.show_cancel;this.select.onchange=bind(this,this.changeCheck);A=document.createElement("input");A.type="text";A.value=this.hidden.value;A.onkeypress=bind(this,this.keyPress);A.style.width="100px";this.text=A;A=document.createElement("button");A.innerHTML="Done";A.onclick=bind(this,this.save);this.button=A;if(this.show_cancel){A=document.createElement("button");A.innerHTML="Cancel";A.onclick=bind(this,this.cancel);this.cancelbutton=A}if(!Number(this.select.value)&&this.hidden.value){this.textToSelect();this.mode("select")}else{this.mode("select")}this.gmi_node.appendChild(this.text);this.gmi_node.appendChild(document.createTextNode(" "));this.gmi_node.appendChild(this.button);if(this.show_cancel){this.gmi_node.appendChild(this.cancelbutton)}},changeCheck:function(A){if(!Number(this.select.value)&&this.select.selectedIndex==this.select.getElementsByTagName("option").length-1){setTimeout(bind(this,this.mode,"text"))}else{this.text.value=this.hidden.value=""}},mode:function(A){if(A!=this.current_mode){if(A=="text"){if(!this.text.value){this.text.value=this.default_input}this.select.style.display="none";this.text.style.display="inline";this.button.style.display="inline";if(this.show_cancel){this.cancelbutton.style.display="inline"}setTimeout(this.focus,1)}else{this.text.style.display="none";this.button.style.display="none";this.select.style.display="inline";if(this.show_cancel){this.cancelbutton.style.display="none"}}this.current_mode=A}},focus:function(){try{this.text.focus();this.text.select()}catch(A){}},save:function(){if(this.current_mode=="text"){if(!this.neutral){this.text.value=this.grammarize(this.text.value)}this.hidden.value=this.text.value;this.textToSelect();this.mode("select")}},cancel:function(){this.select.selectedIndex=0;jQuery(this.select).change();this.mode("select")},grammarize:function(A){if(A.split(" ")[0] in {to:1,"for":1,To:1,For:1}){return A}return"To "+A},textToSelect:function(){var B,A;if(!this.text.value){if(this.custom_option){this.custom_option.parentNode.removeChild(this.custom_option);this.custom_option=null}this.select.selectedIndex=0;jQuery(this.select).change();return }B=this.custom_option;if(!B){B=document.createElement("option");B.value="0"}B.innerText=B.text=this.text.value;if(!this.custom_option){this.custom_option=B;A=this.select.getElementsByTagName("option");this.select.insertBefore(B,A[A.length-1])}this.select.selectedIndex=this.select.getElementsByTagName("option").length-2},keyPress:function(A){if((A||window.event).keyCode in {13:0,27:0}){this.save()}}});if(window.DWait){DWait.run("jms/pages/gruzecontrol/gruserutils_textdown.js")}CANCEL_CLICK=";if (window.event)event.cancelBubble=true;try{this.blur()}catch(e){}return false;";ModuleArranger=GMIBase.extend({gmiConstructor:function(){this.adding=0;this.api=this.gmi_args.api||"GrusersModules";this.link=this.gmi_args.page;this.link.init();if(this.gmi_args.layout_changer){this.arrange_map_node=document.createElement("div");this.arrange_map_node.innerHTML='<h2 style="text-align:center;padding:40px;color:#708077">Loading...</h2>'}else{var A=document.getElementById("module-arrange-map");if(A){this.arrange_map_node=A.cloneNode(true);this.arrange_map_node.style.display="block"}else{this.arrange_map_node=document.createTextNode('No zone-map available for "'+this.link.gmi_args.name+'"')}}this.render();if(this.gmi_args.layout_changer&&typeof this.gmi_args.layout_changer=="object"){this.gmi_args.layout_changer.setArranger(this)}},gmiDestructor:function(){GMI._delete(this.gmiQuery("MAMiniZone"))},setListener:function(A){this.listener=A;if(this.module_repository!=undefined){A.populated(this.module_repository)}},enable:function(){this.disabled=false},disable:function(){this.disabled=true},syncLayout:function(A){this.arrange_map_node.innerHTML=ModuleArranger.generateMapFromLayout(this.link,A,this.gmi_args.page_title);this.construct()},render:function(){var B,A;if(!this.gmi_args.no_tabs){this.label_node=document.createElement("div");this.label_node.className="arranger-label";this.label_node.innerHTML='<div style="padding:14px 24px 0 24px;height:32px;_height:46;overflow:hidden;cursor:default;font:12pt Trebuchet MS"><strong>Loading...</strong></div>';this.gmi_node.appendChild(this.label_node)}this.zone_node=document.createElement("div");this.zone_node.className="zone-holder";if(this.gmi_args.height){A=this.gmi_args.height-(46+45);Station.apply(this.zone_node,"height",A)}this.gmi_node.appendChild(this.zone_node);if(!this.gmi_args.no_buttons){B=document.createElement("div");B.className="bottom-bit";B.innerHTML=('<table class="f" align="center"><tr><td class="f"><a href="" class="gmbutton2 gmbutton2s" onclick="Modals.pop()'+CANCEL_CLICK+'" style="width:50px">Done<b></b></a></td>'+(document.getElementById("module-hints")?('<td class="f"><a href="" class="gmbutton2 gmbutton2c" onclick="GMI.up(this).popupHints()'+CANCEL_CLICK+'">Hints...<b></b></a></td>'):"")+'<td class="f"><a href="" class="gmbutton2 gmbutton2c" onclick="if (GMI.up(this).confirmReset()) this.nextSibling.submit()'+CANCEL_CLICK+'">Restore...<b></b></a><form action="/profile/reset" method="post" style="display:none"><input type="hidden" name="pagename" value="'+this.link.gmi_args.name+'"></form></td></tr></table>');this.gmi_node.appendChild(B)}if(!this.populate()){this.loading_node=document.createElement("div");this.gmi_node.appendChild(this.loading_node);if(!this.gmi_args.inline||!this.gmi_args.layout_changer){if(Browser.isIE){this.zone_node.style.visibility="hidden"}else{Station.apply(this.zone_node,"opacity",0.1)}}}if(this.label_node){this.label_node.firstChild.innerHTML="<strong>Drag and drop</strong> widgets to rearrange the page"}this.construct();this.draw()},popupHints:function(){var A;A=document.createElement("div");A.className="light";A.style.padding="20px 32px";A.style.width="540px";A.appendChild(document.getElementById("module-hints").cloneNode(true));Station.apply(A.firstChild,"display","block");Modals.push(A)},confirmReset:function(){return confirm("Restoring will:\n- Undo all rearrangements you have performed.\n- Restore any Default Widgets that you have deleted.\n\nDo you want to restore?")},construct:function(){var D,E,A,B,F,C;while(this.zone_node.firstChild){this.zone_node.removeChild(this.zone_node.firstChild)}this.zone_node.appendChild(this.arrange_map_node);if(!this.gmi_args.inline){this.zone_node.appendChild(document.createElement("br"))}E=this.zone_node.getElementsByTagName("div");if(this.gmi_args.inline){if(F=(this.zone_node.getElementsByTagName("mainmarker")||[])[0]){F.parentNode.innerHTML=('<div class="ch ch-indi" style="margin:8px 8px 0 8px"><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="ch-ctrl indifade" style="padding:12px"><a id="megaclick-done" style="float:right;margin-right:8px" class="gmbutton2 gmbutton2r" href="" onclick="GroupMutant.inline();return GMI.evCancel()">Done<b></b></a><h3>Customize '+(this.gmi_args.page_title?'your <span style="color:#FBD467">'+this.gmi_args.page_title+"</span>":"this page")+" with Widgets</h3>The grey bars show how your "+(this.gmi_args.page_title||"")+" widgets are currently arranged.<br><strong>Drag and Drop</strong> these widgets to rearrange them, or add brand new widgets from the list below.<br></div></div>")}C=document.getElementById("pagemenu");F=(this.zone_node.getElementsByTagName("td")||[])[0];if(C&&F&&F.className.indexOf("gruze-sidebar")>=0){F.insertBefore(C.cloneNode(true),F.firstChild);F.style.paddingBottom="50px"}}B=this.getZones();for(D=0;D!=B.length;D++){for(A=0;A!=E.length;A++){if(E[A].getAttribute("contains-zone")==B[D].gmi_args.name){break}}if(!E[A]){continue}E[A].appendChild(GMI.create("MAMiniZone",{link:B[D],arranger:this,sticky:B[D].gmi_args.name in (this.link.gmi_args.sticky_zones||{}),linked:B[D].gmi_args.name in (this.link.gmi_args.linked_zones||{})||B[D].gmi_args.locked,no_move:B[D].gmi_args.name=="bottom_right"&&(this.link.gmi_args.name in {frontroom:0,userpage:0})}).gmi_node)}},getZones:function(){return this.gmi_args.zones},draw:function(){var B,A;A=this.gmiQuery("MAMiniZone");for(B=0;B!=A.length;B++){A[B].draw()}},zoneNotice:function(){if(this.label_node){this.label_node.firstChild.innerHTML="Some widgets can only be put in certain zones"}},populate:function(){if(!this.module_repository&&!this.gmi_args.in_group_ops){this.module_repository=ModuleArranger.last_module_repository}if(this.module_repository){if(this.listener){this.listener.populated(this.module_repository)}return true}DiFi.pushPrivateGet(this.api,"fetchModuleList",[this.link.ownerid,this.link.gmi_args.id],bind(this,this.difiDone));DiFi.timer(1)},difiDone:function(B,A){if(B){this.module_repository=ModuleArranger.last_module_repository=A.response.content;this.gmi_node.removeChild(this.loading_node);if(Browser.isIE){this.zone_node.style.visibility="visible"}else{Station.push(this.zone_node,"opacity",{from:0.1,to:1,f:Interpolators.sineCurve,time:250})}if(this.listener){this.listener.populated(this.module_repository)}if(this.gmi_args.additional_div_hook){this.gmi_args.additional_div_hook.style.display="block"}}else{if(this.listener){this.listener.populated(null)}if(Modals.stack.length){DiFi.stdErr("Unable to load widget list.",A.response.content);if(!this.gmi_args.in_group_ops){Modals.pop()}}}},ddd:{snap:function(G){var D,E,C,A,B,F,H;this.scroll_node=this.gmi_args.in_group_ops?GMI.up(this.gmi_node).gmi_node.parentNode:this.zone_node;this.scroll_top_offset=this.getScrollOffset();this.scroll_left_offset=0;if(!this.dragged_mod){DDD.p_down.y+=this.scroll_left_offset||0}else{DDD.p_down.y+=this.scroll_top_offset}this.surfer=Surfer.create(G,this.ddd.node,1,1,true);if(this.gmi_args.inline){if(!this.surfer_mod){H=document.createElement("div");H.className="modsurfer-notice modsurfer-yes";this.surfer_mod=H}this.surfer.node.appendChild(this.surfer_mod);if(!this.surfer_notice_switch){this.surfer_notice_switch=new LiquidSwitch(bind(this,this.surferNotice),"off")}}this.surfer.node.style.display="block";this.surfer.node.className+=" gm-minimized gm-mini-drag";document.body.appendChild(this.surfer.node);this.ddd.node.style.visibility="hidden";this.surfer.node.style.width=this.ddd.node.offsetWidth+"px";if(this.dragged_mod){this.drag_image_node=this.ddd.node}else{this.drag_image_node=this.ddd.node.cloneNode(true);this.drag_image_node.className="gm-placeholder gm-minimized"}this.drag_info=this.getDropInfo(this.drag_subject,this.dragged_mod&&this.dragged_mod.gmiUp("MAMiniZone"));this.drag_info.orig_ref=[this.drag_image_node.parentNode,this.drag_image_node,this.drag_image_node.nextSibling];this.drag_index=null;for(D=0;D!=this.drag_info.leftovers.length;D++){if(!this.recommendation_filter_active){Station.stopAnimation(this.drag_info.leftovers[D]);Station.push(this.drag_info.leftovers[D],"opacity",{from:Number(Station.read(this.drag_info.leftovers[D],"opacity"))||1,to:0.15,f:Interpolators.sineCurve,time:250})}}if(D&&(this.link.gmi_args.name in {userpage:1})){setTimeout(bind(this,this.zoneNotice),1500)}if(this.gmi_args.inline){this.drag_data={};DDDUtils.mix(this);this.dddTickStart(G)}else{this.tiki_rect=Ruler.document.node(this.scroll_node||this.zone_node.parentNode);this.tikitimer=setInterval(bind(this,this.ddd.tick),100)}},drag:function(D){var C,A,B;this.drag_event_cache={clientX:D.clientX,clientY:D.clientY,x:D.x,y:D.y};if(this.dddTickUpdate){this.dddTickUpdate(D)}Surfer.update(this.surfer,D);A=Ruler.hitTest(Ruler.document.pointer(D,{x:0,y:this.scroll_top_offset}),this.drag_info.rects);if(A!=null){if(this.drag_info.modules[A].gmi_node==this.ddd.node||(A>0&&this.drag_info.modules[A-1].gmi_node==this.ddd.node)){B=true;A=null}}if(this.drag_index!=A){this.drag_index=A;if(A==null){this.insertBefore.apply(this,this.drag_info.orig_ref)}else{if(this.surfer_notice_switch){this.surfer_notice_switch.change("yes:Drop here!",100,300)}this.insertBefore(this.drag_info.zones[A].zone_node,this.drag_image_node,(this.drag_info.modules[A] instanceof MAMiniModule)?this.drag_info.modules[A].gmi_node:null)}}if(A==null){A=Ruler.hitTest(Ruler.document.pointer(D,{x:0,y:this.scroll_top_offset}),this.drag_info.restrictions);if(!B&&A!=null){if(this.surfer_notice_switch){this.surfer_notice_switch.change("no:"+this.drag_info.restrictions[A].restriction,100,300)}}else{if(this.surfer_notice_switch){this.surfer_notice_switch.change("off",100,300)}}}},tick:function(){var B,A;B=this.drag_event_cache;c=Ruler.document.pointer(B);A=Browser.isGecko?document.documentElement:document.body;if(Ruler.hitTest(c,[this.tiki_rect])===0){if(c.y<(this.tiki_rect.y+80)){this.scroll_node.scrollTop-=32}else{if(c.y>(this.tiki_rect.y2-80)){this.scroll_node.scrollTop+=32}}}DDD.p_down.y-=this.scroll_top_offset;this.scroll_top_offset=this.getScrollOffset();DDD.p_down.y+=this.scroll_top_offset},drop:function(B){var E,D,C,A;if(this.dddTickEnd){this.dddTickEnd(B)}clearInterval(this.tikitimer);if(this.surfer_notice_switch){this.surfer_notice_switch.change("off",0,300)}for(i=0;i!=this.drag_info.leftovers.length;i++){if(!this.recommendation_filter_active){Station.push(this.drag_info.leftovers[i],"opacity",{from:0.15,to:0.15,time:250},{from:0.15,to:1,f:Interpolators.sineCurve,time:250})}}A=this.drag_index;if(A!=null){if((this.drag_info.modules[this.drag_index] instanceof MAMiniModule)&&this.dragged_mod&&this.drag_info.zones[this.drag_index]==this.dragged_mod.gmiUp("MAMiniZone")&&Number(this.drag_info.modules[this.drag_index].link.position)>Number(this.dragged_mod.link.position)){C=Number(this.drag_info.modules[this.drag_index].link.position)-1}else{if(this.drag_info.modules[this.drag_index-1]&&this.drag_info.zones[this.drag_index-1]==this.drag_info.zones[this.drag_index]){C=Number(this.drag_info.modules[this.drag_index-1].link.position)+1}else{C=1}}C=Math.max(C,1);if(this.dragged_mod){Surfer.flyHome(this.surfer,B,bind(this,this.doneAni,this.ddd.node));if(this.gmi_args.live_preview){this.insertBefore(this.drag_info.zones[A].link.gmi_node,this.dragged_mod.link.gmi_node,(this.drag_info.modules[A] instanceof MAMiniModule)?this.drag_info.modules[A].link.gmi_node:null)}if(window.megaDebug){if(MAMiniModule.last_changed&&MAMiniModule.last_changed.changed=="blue"){MAMiniModule.last_changed.changed=null}MAMiniModule.last_changed=this.dragged_mod;this.dragged_mod.link.changed="blue"}this.dragged_mod.link.position=C;DiFi.pushPost(this.api,"positionModule",[this.link.ownerid,this.drag_info.zones[A].link.gmi_args.page_id||this.link.gmi_args.id,this.dragged_mod.link.gmi_args.id,this.drag_info.zones[A].link.gmi_args.foreign_name||this.drag_info.zones[A].link.gmi_args.name,C,this.dragged_mod.link.version++],bind(this,this.positionDone,this.dragged_mod.link.gmi_args.id));if((this.dragged_mod.link.gmi_args.behavior||{}).volatile_render){this.enterVolatileMode()}DiFi.timer(1)}else{this.surfer.ddd_node_opacity=1;this.surfer.node.parentNode.removeChild(this.surfer.node);delete this.surfer;if(this.listener){this.listener.draw(this.drag_subject.typeid)}eax=this.drag_image_node.getElementsByTagName("h2")[0];eax.innerHTML=('<i class="icon i'+(Number(this.drag_subject.typeid)+1)+'"></i> <span style="zoom:1;position:relative">Adding...</span>');this.drag_image_node.className="gm-minimized";this.drag_image_node.style.visibility="visible";Station.push(eax.getElementsByTagName("span")[0],"visibility",{to:"visible",time:400},{to:"hidden",time:400},{to:"visible",time:400},{to:"hidden",time:400},{to:"visible",time:400},{to:"hidden",time:400},{to:"visible",time:400},{to:"hidden",time:400},{to:"visible",time:400},{to:"hidden",time:400});this.adding++;DiFi.pushPost(this.api,"addModule",[this.link.ownerid,this.link.gmi_args.id,this.drag_subject.name,this.drag_info.zones[A].link.gmi_args.name,C],bind(this,this.addDone,this.drag_image_node));DiFi.timer(1)}}else{rect=Ruler.document.node(this.ddd.node);if(!this.dragged_mod){rect.y-=this.scroll_left_offset}else{rect.y-=this.scroll_top_offset}Surfer.flyHome(this.surfer,B,bind(this,this.doneAni,this.ddd.node),rect)}}},getScrollOffset:function(){return this.gmi_args.inline?0:this.scroll_node.scrollTop+(document.body.scrollTop||document.documentElement.scrollTop)},surferNotice:function(B,A){B=B.split(":");switch(B[0]){case"yes":case"no":if(A=="off"){Station.run(this.surfer_mod,"height",{from:1,to:20,time:300,f:Interpolators.pulse});Station.run(this.surfer_mod,"top",{from:-10,to:-30,time:300,f:Interpolators.pulse})}this.surfer_mod.className="modsurfer-notice modsurfer-"+B[0];this.surfer_mod.innerHTML="<div>"+B[1]+"</div>";Station.apply(this.surfer_mod,"display","block");break;case"off":Station.push(this.surfer_mod,"height",{from:20,to:1,time:300,f:Interpolators.pulse},"display",{to:"none"});Station.run(this.surfer_mod,"top",{from:-30,to:-10,time:300,f:Interpolators.pulse})}},filterOn:function(B){var A;if(this.recommendation_filter_active){this.recommendation_filter_active=null;this.filterOn([])}A=this.getDropInfo({permitted:true,allowed_zones:B}).leftovers;for(i=0;i!=A.length;i++){Station.stopAnimation(A[i]);Station.push(A[i],"opacity",{from:Number(Station.read(A[i],"opacity"))||1,to:B.length?0.15:1,f:Interpolators.sineCurve,time:250})}this.recommendation_filter_active=Boolean(B.length)},enterVolatileMode:function(){var A;if(A=document.getElementById("megaclick-done")){A.onclick=function(){return true}}},doneAni:function(A){A.style.visibility="visible";if(Browser.isIE){A.style.display="none";A.style.display="block"}},offerDelay:function(A){if(this.adding>0){}},addDone:function(E,D,B){var A,C;Station.stopAnimation(E);if(!D){if(E.parentNode){E.parentNode.removeChild(E)}if(this.listener){this.listener.draw()}DiFi.stdErr("Unable to edit widgets at this time.",B.response.content)}else{A=this.drawNewModule(B.response.content.html,B.request.args[3],B.request.args[4]);A.importGWebPage(B.response.content);A.uncommitted=true;C=GMI.create("MAMiniModule",{link:A,highlight:"new",arranger:this,zones:this.getZones(),page:this.link});E.parentNode.replaceChild(C.gmi_node,E);if(this.gmi_args.in_group_ops||this.gmi_args.inline){A.uncommitted=false;DiFi.pushPost("GrusersModules","addModuleCommit",[this.link.ownerid,this.link.gmi_args.id,A.gmi_args.id],window.DiFiHolder?DiFiHolder.getStdCallback():DiFi.stdErrCallback);DiFi.timer(1)}if((A.gmi_args.behavior||{}).volatile_render){this.enterVolatileMode()}}this.adding--},drawNewModule:function(F,G,H){var J,A,D,I,E,B,C;if(F instanceof GMFrame_Gruser){J=F;B=J.gmi_node}else{J=document.createElement("div");J.innerHTML=F||'<img src="about:blank" alt="[x]"/>';J=J.getElementsByTagName("*")[0];B=J}A=this.getZones();for(D=0;D!=A.length;D++){if(A[D].gmi_args.name==G){I=A[D].gmiQuery("GMFrame_Gruser");E=I[Number(H)-1];if(E){E.gmi_node.parentNode.insertBefore(B,E.gmi_node)}else{A[D].gmi_node.appendChild(B)}C=true;break}}if(!C){(A[0]||GMI.query("GPage")[0]).gmi_node.appendChild(B)}if(!(F instanceof GMFrame_Gruser)){J=GMIBase.getOne(J)}J.highlight=true;if(window.Shadows){Shadows.nodes(J.gmi_node)}if(window.Keeper){Keeper.master_on()}return J},positionDone:function(E,H,G){var C,B,F,A,D;if(H){D=this.link.gmiQuery("GMFrame_Gruser");for(C in G.response.content.layout){B=G.response.content.layout[C];for(F=0;F!=B.length;F++){for(A=0;A!=D.length;A++){if(D[A].gmi_args.id==B[F].moduleid){if(window.megaDebug){if(Number(D[A].position)!=Number(B[F].position)){D[A].changed="red"}else{if(D[A].gmi_args.id==E){D[A].changed="blue";MAMiniModule.last_changed=D[A]}else{D[A].changed=null}}}D[A].position=B[F].position;D[A].version=B[F].version;break}}}}}else{DiFi.stdErr("",G.response.content)}},insertBefore:function(A,C,B){if(!A){if(C.parentNode){C.parentNode.removeChild(C)}}else{if(B){A.insertBefore(C,B)}else{A.appendChild(C)}}},getModuleFromTypeID:function(A){return(this.module_repository||{})[A]},getDropInfo:function(J,I){var H,L,E,A,B,C,F,I,K;if(GMI.query("Gruser")[0].gmi_args.group){F=Ruler.document.node(this.gmi_node)}B=this.gmiQuery("MAMiniZone");H={rects:[],modules:[],zones:[],leftovers:[],restrictions:[]};K=J.allowed_zones;if(I&&I.link.gmi_args.page_id){K=K.concat([I.link.gmi_args.name])}for(E=0;E!=B.length;E++){C=B[E].gmi_node;while(C&&(" "+C.className+" ").indexOf(" sealed-zone ")<0){C=C.parentNode}if(!C){C=B[E].gmi_node}if(I&&Boolean(I.gmi_args.sticky)!=Boolean(B[E].gmi_args.sticky)){if(this.gmi_args.inline){M=B[E].getDropInfo(B[E].gmi_node,F)[0];if(M){M.restriction="Widgets cannot be moved to or from the Sticky Zone after they have been installed";H.restrictions.push(M)}}}else{for(A=0;A!=K.length;A++){if((J.permitted!==false&&B[E].link.gmi_args.name==K[A])){L=B[E].getDropInfo(C,F);for(x=0;x!=L.rects.length;x++){H.rects.push(L.rects[x]);H.modules.push(L.modules[x]);H.zones.push(B[E])}break}}}if(A==K.length){if(this.gmi_args.layout_changer){while(C&&(" "+C.className+" ").indexOf(" gruze-sidebar ")<0){C=C.parentNode}if(!C){C=B[E].gmi_node}H.leftovers.push(C||B[E].gmi_node)}else{H.leftovers.push(C||B[E].gmi_node)}if(this.gmi_args.inline){var M;M=B[E].getDropInfo(C,F).rects[0];if(M){M.restriction=J.permitted===false?"Upgrade to a Super Group to get this great widget":"This widget cannot be placed in this zone";H.restrictions.push(M)}}}}var D,L,G;if(this.gmi_args.inline){G=GMI.query("Gruser")[0].gmi_args["super"]?"This sidebar does not allow widgets":"Upgrade to a Super Group to add widgets to your sidebar";D=this.gmi_node.getElementsByTagName("td");for(E=0;L=D[E];E++){if(L.className.indexOf("gruze-sidebar")>=0){if(!GMI.query(L,"MAMiniZone").length){M=Ruler.document.node(L);M.restriction=G;H.restrictions.push(M)}}}}return H},findModuleByTypeId:function(A){var B,C;A=Number(A);C=this.gmiQuery("MAMiniModule");for(B=0;B!=C.length;B++){if(Number(C[B].link.gmi_args.typeid)==A){return C[B].link}}}});if(window.DWait){DWait.run("jms/pages/gruzecontrol/widgets/arranger.js")}CANCEL_CLICK=";if (window.event)event.cancelBubble=true;try{this.blur()}catch(e){}return false;";window.ModuleCatalog=GMIBase.extend({gmiConstructor:function(){var A;if(this.gmi_args.category_placeholder){this.category_chooser=GMI.create("ModuleCatalog_Categories",{catalog:this,editor_proxy:this.gmi_args.editor_proxy,page:this.gmi_args.page});this.gmi_args.category_placeholder.appendChild(this.category_chooser.gmi_node)}this.inline_mode=this.gmi_args.inline;this.offset=0;this.gmi_node.onselectstart=this.cancel;if(!ModuleCatalog.sort_setting){for(A in this.SORT_OPTIONS){break}ModuleCatalog.sort_setting=A}this.gmi_node.className="clog";this.gmi_node.innerHTML=("");if(this.gmi_args.height&&Browser.isIE){Station.apply(this.gmi_node,"height",this.gmi_args.height)}this.label_node=document.createElement("div");this.label_node.className="clog-label";this.label("loading");this.gmi_node.appendChild(this.label_node);this.clogs_node=document.createElement("div");this.clogs_node.className="clogs"+(this.gmi_args.groups_mode?" pzone":"");this.gmi_node.appendChild(this.clogs_node);this.clogs_node.innerHTML='<div catalog_welcome="1"></div>';if(this.gmi_args.arranger){this.arranger=this.gmi_args.arranger}else{this.arranger=GMI.create("ModuleArranger",{})}if(!this.module_repository){this.delayed_output=true;if(Browser.isIE){this.clogs_node.style.visibility="hidden"}else{Station.apply(this.clogs_node,"opacity",0.01)}}if(this.gmi_args.groups_mode&&!this.gmi_args.inline){this.resized=bind(this,this.resized);Events.hook(window,"resize",this.resized);window.CatalogSelection=DivOnlySelection.extend(this.catalog_selection_prototype);this.selector=new CatalogSelection(this.clogs_node,bind(this,this.selChange));this.selector.hook({sticky_selection:true})}},gmiDestructor:function(){if(this.gmi_args.groups_mode){Events.unhook(window,"resize",this.resized);this.selector.unhook();delete this.selector;(this.gmi_args.ops_proxy||this.gmiUp("GroupManager")).hide4thColumn()}GMI._delete(this.gmiQuery("MAMiniModule"))},selChange:function(A){var B;if(this.preview_node){this.preview_node.parentNode.removeChild(this.preview_node);delete this.preview_node}if(!A[0]){if(this.drawing_bias){this.filterOn(null)}(this.gmi_args.ops_proxy||GMI.up(this.gmi_node)).hide4thColumn();setTimeout(bind(this,this.label,""),200)}else{if(A[0].getAttribute("catalog_welcome")){this.preview_node=document.createElement("div");this.preview_node.innerHTML=('<div style="margin:80px;width:333px;color:#506056"><h3 style="color:#506056"><img src="http://e.deviantart.net/emoticons/p/pointl.gif" alt="<-"/> Recommended Widgets for the '+({main:"Main Column",sidebar:"Sidebar"}[this.drawing_bias]||"")+'</h3><br><br><span style="font-size:10pt">To preview or install any widget, simply click its name in the catalog on the left!</span><br><br><br><span style="color:#607066;font-size:8.25pt">Click <a href="" style="text-decoration:underline" onclick="GMI.query(\'ModuleCatalog\')[0].selector.setSelection(null);return GMI.evCancel()">Cancel</a> to return to the layout editor.</span></div>');(this.gmi_args.ops_proxy||this.gmiUp("GroupManager")).slide4thColumn(bind(this.selector,this.selector.setSelection,null)).appendChild(this.preview_node)}setTimeout(bind(this,this.label,"back"),175)}},catalog_selection_prototype:{select:function(A){A.className+=" clog-selected";if(!A.getAttribute("name")){return }GMI.getOne(A).clogSelect()},deselect:function(A){A.className=A.className.replace(/\bclog.selected\b/g,"");if(!A.getAttribute("name")){return }GMI.getOne(A).clogDeselect()},isSelected:function(A){return(" "+A.className+" ").indexOf(" clog-selected ")>=0}},clearSelection:function(){if(this.selector){this.selector.setSelection(null);return true}},resized:function(){if(this.selector&&this.selector.getSelection().length){return }if(this.resize_timeout){clearTimeout(this.resize_timeout)}this.resize_timeout=setTimeout(bind(this,this.draw),100)},cancel:function(){return false},link:function(){this.arranger.setListener(this)},populated:function(A){this.module_repository=A;if(A){this.ready();if(this.category_chooser){this.category_chooser.setData(A)}}},label:function(A){if(A=="back"&&this.gmi_args.editor_proxy){A=""}switch(A){case"back":A='&nbsp;<div class="nav2 bb-with-sep"><a class="l" href="" onclick="GMI.up(this).selector.setSelection(null);return GMI.evCancel()">Back to Layout View</a></div>';break;case"loading":A="&nbsp;";break;default:if(this.gmi_args.groups_mode){switch(this.drawing_bias){case"main":case"sidebar":A='<span style="color:#5B9FC0;white-space:nowrap;cursor:pointer" onclick="GMI.up(this).filterOff()">Displaying '+(this.drawing_bias=="main"?"Large":"Sidebar")+' Widgets <img src="http://s.deviantart.net/styles/minimal/minish/close-filter.gif"></span>';break;default:A="Widgets You Can Add:"}}else{A=this.getSortHTML()}}this.label_node.innerHTML=A},SORT_OPTIONS:{"Featured Widgets":null,Alphabetical:function(B,A){if((B.title||"").toLowerCase()>(A.title||"").toLowerCase()){return 1}return -1},Main:function(C,B){var D,A,E=-1,F=-1;for(D=0;D!=(C.allowed_zones||[]).length;D++){if(!C.allowed_zones[D].indexOf("sidebar")){E=1;break}}for(A=0;A!=(B.allowed_zones||[]).length;A++){if(!B.allowed_zones[A].indexOf("sidebar")){F=1;break}}if(E!=F){return E}if((C.title||"").toLowerCase()>(B.title||"").toLowerCase()){return 1}return -1}},getSortHTML:function(){var B,C,A;A=[];for(B in this.SORT_OPTIONS){if(B=="Main"){break}C=this.SORT_OPTIONS[B];if(B==ModuleCatalog.sort_setting){A.push("<strong>"+B+"</strong>")}else{A.push('<a href="" onclick="return GMI.up(this).sortClick(\''+B+"')\">"+B+"</a>")}}return A.join(" | ")},sortModules:function(){var C,A,B;B=[];for(A in this.module_repository){B.push(this.module_repository[A])}C=this.SORT_OPTIONS[this.sort_bias||ModuleCatalog.sort_setting];if(C){B.sort(C)}this.sorted_modules=B},sortClick:function(A){ModuleCatalog.sort_setting=A;this.label();this.sortModules();this.changePage(0);if(window.event){event.cancelBubble=true}return false},ready:function(){this.draw();if(this.delayed_output){if(Browser.isIE){this.clogs_node.style.visibility="visible"}else{Station.push(this.clogs_node,"opacity",{from:0.01,to:1,time:400,f:Interpolators.sineCurve})}}this.label("add")},clear:function(){GMI._delete(this.gmiQuery("MAMiniModule"));if(this.pager_node&&this.pager_node.parentNode){this.pager_node.parentNode.removeChild(this.pager_node)}},draw:function(F){var H,K,E,D,I,J,C,A,B,J,G;this.clear();this.refreshInstanceCounts(F);D=0;E=0;H=0;K=this.inline_mode?0:this.gmi_args.override_height?Ruler.screen.rect().y2-430:(this.gmi_node.parentNode.offsetHeight-205);if(!this.sorted_modules){this.sortModules()}for(B=0;J=this.sorted_modules[B];B++){if(((this.gmi_args.groups_mode&&J.removable)||(this.instance_counts[J.typeid]||0)<Number(J.limit))&&(J.allowed_zones||[])[0]!="top_secret"){if(this.drawing_bias=="sidebar"){for(G=0;G!=J.allowed_zones.length;G++){if(!J.allowed_zones[G].indexOf("sidebar")){G=-1;break}}if(G>=0){continue}}if(this.drawing_bias_category&&this.drawing_bias_category!=(J.owner_name||"profile")&&!((this.drawing_bias_category in ModuleCatalog_CATMAP.custom_hack)&&Number(J.typeid)==25)){continue}if(!this.modal_active&&!this.gmi_args.no_pager&&(D++<this.offset||(E&&E>=K))){continue}if(J.permitted_reason=="APP_NOT_INSTALLED"){continue}H++;C=GMI.create("MAMiniModule",{spec:J,catalog:this,arranger:this.arranger,zones:this.gmi_args.zones,page:this.gmi_args.page,groups_mode:this.gmi_args.groups_mode,inline:this.gmi_args.inline,installs_total:Number(J.limit),installs_left:Number(J.limit)-(this.instance_counts[J.typeid]||0),selection_proxy:false,ops_proxy:this.gmi_args.ops_proxy});C.gmi_node.className+=this.gmi_args.groups_mode?" gm-clog2":" gm-clog";this.clogs_node.appendChild(C.gmi_node);E+=93}}if(E>=K||!this.on_display){this.on_display=H}if(this.inline_mode){if(!this.more_button_node){eax=document.createElement("div");eax.innerHTML='<a class="gmbutton2 catalog-more-button" onclick="GMI.up(this).modal();return GMI.evCancel()" href="">Show All...<b></b></a>';this.more_button_node=eax}this.gmi_node.appendChild(this.more_button_node)}else{if(!this.modal_active&&!this.gmi_args.no_pager){this.clogs_node.appendChild(this.pager_node=new HTMLPager(this,{page:this.offset/this.on_display,pages:this.gmi_args.groups_mode?this.offset/this.on_display<Math.floor(D/this.on_display):Math.ceil(D/this.on_display),prev_label:"&nbsp;",next_label:"&nbsp;"},bind(this,this.changePage)).node);this.pager_node.style.top=(this.gmi_node.parentNode.offsetHeight-(this.gmi_args.groups_mode?10:75))+"px"}}},modal:function(){var B,A;if(this.gmi_args.inline){this.gmi_node.parentNode.className+=" widget-catalog-expanded";if(Browser.isIE){this.gmi_node.style.display="none";setTimeout(bind(this,function(){this.gmi_node.style.display="block"}),1)}return }A=this.gmi_node.parentNode;B=document.createElement("div");B.className="phone-modal scroll-catalog gm-nomove";B.style.width="890px";B.appendChild(this.gmi_node);eax=document.createElement("div");eax.className="bottom-bit";eax.innerHTML='<table align="center"><td style="padding-top:8px" class=f><a href="" class="gmbutton2" style="width:80px" onclick="Modals.pop();return GMI.evCancel()">Cancel<b></b></table>';B.appendChild(eax);this.inline_mode=false;this.modal_active=true;Modals.push(B,bind(this,this.modalDone,A));this.draw()},modalDone:function(A){this.modal_active=false;this.inline_mode=true;A.appendChild(this.gmi_node);this.draw()},itemAdded:function(){if(this.modal_active){setTimeout("Modals.pop()",1)}},changePage:function(A){this.offset=A*this.on_display;this.draw()},mouseHover:function(B,A){B.className="entry"+(A?" entry-hover":"")},refreshInstanceCounts:function(A){var E,D,C,B;D={};if(this.arranger){E=GMI.query("GMFrame_Gruser");for(C=0;C!=E.length;C++){B=E[C].gmi_args.typeid;if(!D[B]){D[B]=0}D[B]++}if(A){if(!D[A]){D[A]=0}D[A]++}}this.instance_counts=D},enable:function(){this.arranger.enable();this.disabled=false;Station.run(this.gmi_node,"opacity",{from:0.2,to:1,f:Interpolators.sineCurve,time:400})},disable:function(){this.arranger.disable();this.disabled=true;Station.run(this.gmi_node,"opacity",{from:1,to:0.2,f:Interpolators.sineCurve,time:400})},FILTER_ZONES:{sidebar:["sidebar1","sidebar2"],main:["top_left","mid_left","bottom_left","top_right","mid_right","bottom_right"]},filterOn:function(B,C){var A;if(this.category_chooser){return this.category_chooser.resetSelection()}this.offset=0;this.drawing_bias=B?(!B.indexOf("sidebar")?"sidebar":"main"):null;this.sort_bias=this.drawing_bias=="main"?"Main":null;Station.run(this.clogs_node,"opacity",{from:0.01,to:1,time:500,f:Interpolators.sineCurve});this.sortModules();this.draw();if(B){A=this.selector.getAllSelectable();this.selector.setSelection(A[0])}if(!B){this.label()}},filterOff:function(){this.filterOn(null)},categoryOn:function(A){if(!this.drawing_bias_category&&!A){return }this.drawing_bias_category=A;this.draw()}});ModuleCatalog.getLatestID=function(){return ModuleCatalog.latest_id};ModuleCatalog.clearLatestID=function(){ModuleCatalog.latest_id=null};ModuleCatalog_CATMAP={names:{Messages:"Stats",Profile:"Misc"},custom_hack:{gallery:1,faves:1,blog:1,members:1}};window.ModuleCatalog_Categories=GMIBase.extend({gmiConstructor:function(){if(!this.gmi_args.catalog){throw new Error("No catalog interface passed")}this.selector=new LinkOnlySelection(this.gmi_node,bind(this,this.selected));this.selector.hook({sticky_selection:1,fast_clicks:1});this.setData(this.gmi_args.data)},gmiDestructor:function(){this.selector.unhook();delete this.selector},setData:function(A){this.data=A;this.construct()},construct:function(){var C,E,A,B,D;if(!this.data){return }A={Gallery:0,Faves:0,Blog:0,Members:0,Messages:0,Notes:0};for(C in this.data){if((E=(this.data[C].owner_name||"profile"))&&this.data[C].permitted_reason!="APP_NOT_INSTALLED"){E=E.substr(0,1).toUpperCase()+E.substr(1);if(!(E in A)){A[E]=0}A[E]++}}D=0;for(C in A){D++;if((!ModuleCatalog_CATMAP[C])&&C.toLowerCase()==this.gmi_args.page.gmi_args.name){this.recommended_selection_index=D}}B=[];B.push('<a href="" style="position:relative;left:-8px" class=f mattercat="">All Types</a>');for(C in A){if(!A[C]){continue}B.push('<a href="" class=f mattercat="'+C+'">'+(ModuleCatalog_CATMAP.names[C]||C)+" ("+(A[C]+((C.toLowerCase()) in ModuleCatalog_CATMAP.custom_hack?1:0))+")</a>")}this.gmi_node.className="guideblock guidemenu";this.gmi_node.innerHTML=B.join("");this.resetSelection()},selected:function(A){if(A[0]&&A[0].getAttribute("matterlayout")){}else{this.gmi_args.catalog.categoryOn((A[0].getAttribute("mattercat")||"").toLowerCase());if(A[0].getAttribute("mattercat")){this.gmi_args.catalog.modal()}}},resetSelection:function(B){var A=this.selector.getAllSelectable();this.selector.setSelection(typeof B=="number"?A[B]:A[this.recommended_selection_index]||A[0])}});if(window.DWait){DWait.run("jms/pages/gruzecontrol/modulecatalog.js")}ModuleTheatre=GMIBase.extend({gmiConstructor:function(){this.want=0;this.preview_records={};if(this.gmi_args.label){eax=document.createElement("div");eax.innerHTML='<div style="padding:0 0 8px 0;text-align:center;font-weight:bold;cursor:default">'+this.gmi_args.label+"</div>";this.gmi_node.appendChild(eax)}this.gmi_node.appendChild(this.core_node=document.createElement("div"));this.core_node.className="bubbleview";this.gmi_node.appendChild(document.createElement("br"));this.gmi_node.onclick=bind(this,this.click)},gmiDestructor:function(){this.cleanupPreviews();this.cleanView()},click:function(B){var A;B=B||window.event;A=B.target||B.srcElement;while(1){if(A.tagName=="A"){B.cancelBubble=true;return false}if(A=A.parentNode){continue}return true}},extractModule:function(){if(this.latest_coolness){this.preview_records[this.latest_coolness.gmi_args.id]=null;return this.latest_coolness}},fetch:function(A){if(A instanceof GMFrame_Gruser){this.fetchView(A)}else{this.fetchPreview(A)}},cleanView:function(){if(this.locked_to_mod){this.locked_to_mod.view_context=null;if(this.locked_to_mod.current_view!="generic"){this.locked_to_mod.loadView("generic")}this.locked_to_mod.returnNode();this.locked_to_mod=false}},fetchView:function(A){if(this.locked_to_mod){throw new Error("Busy")}this.locked_to_mod=A;A.extractNode();this.displayMod(A)},fetchPreview:function(A){this.loading=true;this.core_node.innerHTML='<h3 style="text-align:center;color:#708078;margin:80px;cursor:wait">Generating Preview...</h3>';this.gmi_args.view_context.setControls(null);this.cleanupPreviews();DiFi.pushPost("GrusersModules","addPreviewModule",[this.gmi_args.page.ownerid,this.gmi_args.page.gmi_args.id,A.name],bind(this,this.gotPreview,++this.want));DiFi.timer(1)},gotPreview:function(B,C,A){if(!C){this.core_node.innerHTML='<h3 style="text-align:center;color:#708078;margin:80px">This Widget Cannot be Displayed</h3>';this.gmi_args.view_context.setControls(null);return }this.loading=false;nm=document.createElement("div");nm.innerHTML=A.response.content.html||'<img src="about:blank" alt="[x]"/>';nm=nm.firstChild;Station.run(nm,"opacity",{from:0.01,to:1,time:400,f:Interpolators.sineCurve});nm=GMIBase.getOne(nm);nm.uncommitted=0;this.preview_records[nm.gmi_args.id]=nm;if(this.want==B){this.latest_coolness=nm;while(this.core_node.firstChild){this.core_node.removeChild(this.core_node.firstChild)}this.displayMod(nm)}nm.importGWebPage(A.response.content)},displayMod:function(A){this.core_node.appendChild(A.gmi_node);if(window.Shadows){Shadows.nodes(A.gmi_node)}if(window.Keeper){Keeper.master_on()}this.gmi_args.view_context.setControls(null);A.view_context=this.gmi_args.view_context},cleanupPreviews:function(){for(i in this.preview_records){if(this.preview_records[i]){if(this.preview_records[i].gmi_args.destroyable){DiFi.pushPost("GrusersModules","destroyModule",[this.gmi_args.page.ownerid,this.gmi_args.page.gmi_args.id,this.preview_records[i].gmi_args.id])}else{DiFi.pushPost("GrusersModules","removeModule",[this.gmi_args.page.ownerid,this.gmi_args.page.gmi_args.id,this.preview_records[i].gmi_args.id])}GMI._delete(this.preview_records[i])}}this.preview_records={};DiFi.timer(1)}});if(window.DWait){DWait.run("jms/pages/gruzecontrol/moduletheatre.js")}MAMiniZone=GMIBase.extend({gmiConstructor:function(){this.link=this.gmi_args.link;this.arranger=this.gmi_args.arranger;if(!(this.link instanceof GZone)){throw new Error("Need GZone link")}this.render()},gmiDestructor:function(){GMI._delete(this.gmiQuery("MAMiniModule"))},render:function(){var A;this.zone_node=document.createElement("div");this.zone_node.className="pzone";this.gmi_node.appendChild(this.zone_node);this.draw()},draw:function(){var A,D,C,B,E;D=this.gmiQuery("MAMiniModule");for(A=0;A!=D.length;A++){GMI._delete(D[A])}B=this.link.gmiQuery("GMFrame_Gruser");C=ModuleCatalog.getLatestID();for(A=0;A!=B.length;A++){if(B[A].canBehave("no_midget")){}else{if(B[A].canBehave("arranger_replacement")){E=document.createElement("div");E.className="warr-widget-filler";E.style.height="3.3em";E.innerHTML=B[A].canBehave("arranger_replacement");this.zone_node.appendChild(E)}else{mm=GMI.create("MAMiniModule",{link:B[A],highlight:B[A].gmi_args.id==C||B[A].highlight,arranger:this.arranger,no_move:this.gmi_args.linked||this.gmi_args.no_move});this.zone_node.appendChild(mm.gmi_node)}}}},getDropInfo:function(F,A){var B,C,E,D;B={rects:[],modules:this.gmiQuery("MAMiniModule")};for(C=0;C!=B.modules.length;C++){E=Ruler.document.node(B.modules[C].gmi_node);E.y-=4;E.y2+=4;E.x-=12;E.x2+=12;B.rects.push(E)}E=Ruler.document.node(this.gmi_node);if(Browser.isIE&&this.gmi_node.childNodes.length==0){E.y2=E.y+50}else{E.y=E.y2-50;E.y2+=35}if(A){if(B.rects[0]){B.rects[0].y=Math.min(B.rects[0].y,A.y+20)}if(this.gmi_args.sticky){E.y2=Math.min(E.y2,E.y+100)}else{E.y2=Math.max(E.y2,A.y2+50)}}D=Ruler.document.node(F);E.y2=Math.max(E.y2,D.y2);B.modules.push(this);B.rects.push(E);return B}});if(window.DWait){DWait.run("jms/pages/gruzecontrol/ma_minizone.js")}CANCEL_CLICK=";if (window.event)event.cancelBubble=true;try{this.blur()}catch(e){}return false;";MAMiniModule=GMIBase.extend({gmiConstructor:function(){this.link=this.gmi_args.link;this.spec=this.gmi_args.spec;this.arranger=this.gmi_args.arranger;this.catalog=this.gmi_args.catalog;this.listener=this.gmi_args.listener;this.gmi_node.onmousedown=bind(this,this.mouseDown);this.render();if(this.gmi_args.highlight=="new"||(this.link&&this.link.highlight=="new")){if(this.link){this.link.highlight=true}this.addedParty()}if(this.gmi_args.inline){this.gmi_node.onclick=bind(this,this.popup)}},gmiDestructor:function(){if(this.theatre){GMI._delete(this.theatre)}if(this.viewing_node){this.viewing_node.innerHTML="";if(this.viewing_node.parentNode){this.viewing_node.parentNode.removeChild(this.viewing_node)}delete this.viewing_node}},addedParty:function(){var A;A=this.gmi_node.getElementsByTagName("b")[0];A.innerHTML='<span style="color:#46983B">Added!</span>';Station.push(A,"visibility",{to:"hidden",time:250},{to:"visible",time:250},{to:"hidden",time:250},{to:Browser.isIE?"visible":"inherit",time:1200},"innerHTML",{to:this.getTitle()})},menu:function(){var B,D;D=this.gmi_node.getElementsByTagName("a")[0];D.className+=" active";if(!this.cached_popup){B=Popup.create({className:"gruser popup2-gruser-app",callback:bind(this,this.menuDone,D)});B.node.innerHTML=('<div style="padding:8px 0"><div class="pager2 pager-light"><div class="page2">'+(!this.link.canBehave("no_modal")?('<a class="f" href="#" onclick="GMI.up(this).menuClick(\'view\')'+CANCEL_CLICK+'">View Widget</a>'):"")+(this.link.canBehave("edit")||this.link.gmi_args.privileges?('<a class="f" href="#" onclick="GMI.up(this).menuClick(\'edit\')'+CANCEL_CLICK+'">Edit Widget</a>'):"")+(this.link.canBehave("log")&&document.getElementById("group")?('<a class="f" href="#" onclick="GMI.up(this).menuClick(\'log\')'+CANCEL_CLICK+'">View Widget Log</a>'):"")+(this.link.canBehave("delete")?('<div class="hr" style="margin:8px 0"></div><a class="f" href="#" onclick="GMI.up(this).menuClick(\'delete\')'+CANCEL_CLICK+'">Remove Widget</a>'):"")+"</div></div></div>");var C=B.node.getElementsByTagName("a");if(C){var A=(C.length*20)+30;B.node.style.height=A+"px"}else{B.node.style.height="90px"}B.node.style.width="180px";B.node.setAttribute("gmi-redirect",this.gmi_node.getAttribute("gmindex"));this.cached_popup=B}Popup.show(this.cached_popup,Ruler.screen.node(D,true))},menuClick:function(A){switch(A){case"view":this.popup();this.link.loadView("generic",true);break;case"edit":this.popup();this.link.loadView("config");break;case"log":this.popup();this.link.loadView("view_log");break;case"delete":this.toast(true);break;default:throw new Error(A+" --whut?")}Popup.completeAll()},menuDone:function(A){A.className=A.className.replace(/\bactive\b/g,"")},toast:function(B){var A;if(this.link&&this.link.canBehave("confirm_remove")){B=false}if(this.link&&(A=this.link.toast(B))){this.gmi_node.parentNode.removeChild(this.gmi_node);if(this.catalog){this.catalog.draw()}}return A},getTitle:function(){var A;if(this.spec){return this.spec.title||"It's a Mystery"}return this.link.getTitle()},render:function(){var C,B,A;C=this.getTitle();B=Number(this.spec?this.spec.icon:this.link.gmi_args.icon);this.gmi_node.style.position="relative";this.gmi_node.className+=" gm-minimized";if(this.gmi_args.highlight){this.gmi_node.className+=" gm-highlight"}if(this.gmi_args.no_move){this.gmi_node.className+=" gm-nomove"}if(this.spec){if(this.gmi_args.groups_mode){if(this.spec.permitted===false){A=' class="gmbutton2" style="background-image:url(http://st.deviantart.com/minish/gruzecontrol/widgets/wpreview.gif);width:123px" '}else{if(this.gmi_args.installs_left===0){A=' class="gmbutton2" style="background-image:url(http://st.deviantart.com/minish/gruzecontrol/widgets/wdone.gif);width:123px" '}else{if(this.gmi_args.installs_left==this.gmi_args.installs_total){A=' class="gmbutton2" style="background-image:url(http://st.deviantart.com/minish/gruzecontrol/widgets/wadd.gif);width:123px" '}else{A=' class="gmbutton2" style="background-image:url(http://st.deviantart.com/minish/gruzecontrol/widgets/wadd.gif);width:123px" '}}}}else{A=' title="Click to Preview" class="gmbutton2 '+(this.spec.permitted===false?"viewbutton":"addbutton")+'" '}}this.gmi_node.innerHTML=('<div class="gm-controls">'+(!this.spec&&!this.link.canBehave("no_modal_edit")&&(this.link.canBehave("delete")||this.link.canBehave("edit")||this.link.gmi_args.privileges)?this.link.templates.menuButtonHTML:"")+'</div><div class="gr-box"><i class="gr1"><i></i></i><i class="gr2"><i></i></i><i class="gr3"><i></i></i><div class="gr-top"><i class="tri"></i><div class="gr"><i class="move" title="Drag me!"></i><h2><i class="icon i'+B+'"></i> '+(this.spec?'<i title="Drag me!" class="bigicon i'+B+'" style="background-position:-'+((B-1)*(120/3)*2)+'px 0"></i> ':"")+"<b>"+C+"</b>"+(window.megaDebug?'<tt style="color:#888"></tt>':"")+"</h2>"+((this.spec&&this.spec.permitted!=undefined)?'<div class="drag-only">'+this.premoLabel()+"</div>":"")+(this.spec?'<div class="clog-only">'+(this.spec.description||"&nbsp;")+'<a href=""'+A+' onclick="if (arguments[0]) arguments[0].stopPropagation();return GMI.up(this).popup()"></a></div>':"")+'</div></div><i class="gr3 gb"></i><i class="gr2 gb"></i><i class="gr1 gb gb1"></i></div>');if(window.megaDebug){this.X=setInterval(bind(this,this.bonk),100)}},premoLabel:function(){return this.isGroup()?"<em>Super&nbsp;Group&nbsp;W...</em>":"This is a Premium Widget"},premoLabel2:function(){return this.isGroup()?"Super Group":"Premium Membership"},isGroup:function(){return !!document.getElementById("group")},bonk:function(){if(!window.megaDebug){return }var A;A=this.gmi_node.getElementsByTagName("tt")[0];if(!this.gmi_node.parentNode){clearInterval(this.X);A.innerHTML=" -";return }A.innerHTML=" @ <span "+(this.link&&this.link.changed?' style="color:'+this.link.changed+'"':"")+">"+(this.link?this.link.position:"[?]")+"</span>"},mouseDown:function(C){var A,B;Popup.completeAll();if(!(GMI.query("Gruser")[0]||this).gmi_args.group){document.documentElement.scrollTop=document.body.scrollTop=0}C=C||window.event;if(this.link&&(C.target||C.srcElement).tagName=="A"){return }B=this.spec?8:4;if((!this.spec||this.gmi_args.installs_left)&&!this.gmi_args.no_move){this.scroll_left_offset=0;this.arranger.drag_subject=(this.spec?this.spec:this.arranger.getModuleFromTypeID(this.link.gmi_args.typeid))||{allowed_zones:[]};if(this.arranger.drag_subject&&!this.arranger.disabled&&!(this.catalog||{}).modal_active){this.arranger.dragged_mod=this.spec?null:this;DDD.mouseDown.call(this.gmi_node,C,this.arranger,B);if(DDD.mod_down.y<-30){DDD.p_down.y+=(DDD.mod_down.y+20)}}}C.cancelBubble=true;return false},previewModalDone:function(A){switch(A){case"done":break;default:this.theatre.cleanupPreviews();this.theatre.cleanView();return true}},setControls:function(D){var B,E,C,A;E=[];C="";A=GMI.query("Gruser")[0].gmi_args.group?"http://www.deviantart.com/supergroup/?forgroupid="+(GMI.query("Gruser")[0].gmi_args.id):"https://www.deviantart.com/checkout/?mx=gruser2&amp;utm_source=grusers&amp;utm_medium=modulead&amp;utm_campaign="+(this.sped?this.spec.name:"unknown");this.module_saver=D;if(this.spec&&this.spec.permitted!=undefined){if(this.spec.permitted){E.push('<div class="zone-party-welcome">Your <a href="'+A+'" target="_blank">'+this.premoLabel2()+"</a> lets you add this great widget</div>")}else{E.push('<div class="zone-party-talktothehand">Upgrade to a <a href="'+A+'" target="_blank">'+this.premoLabel2()+"</a> to add this great widget</div>")}}if(this.link&&this.link.canBehave("delete")&&D){C=('<td style="padding:0 8px"><a href="" class="gmbutton2 gmbutton2c" onclick="GMI.up(this).theatreClick(\'delete\')'+CANCEL_CLICK+'">'+(this.gmi_args.groups_mode?"Uninstall...":"Remove...")+"<b></b></a></td>")}if(this.link&&!D){E.push('<div style="text-align:center"><a href="" style="margin:auto;width:125px" class="gmbutton2 gmbutton2c" onclick="GMI.up(this).theatreClick(\'cancel\')'+CANCEL_CLICK+'">'+(this.gmi_args.groups_mode?"Go Back":"Close")+"<b></b></a></div>")}else{if(this.theatre.loading||(!this.link&&this.spec.permitted===false)){B='<a href="#" class="gmbutton2 gmbutton2g disabledbutton" onclick="'+CANCEL_CLICK+'">Install Now<b></b></a>'}else{B='<a href="#" class="gmbutton2 gmbutton2g" onclick="GMI.up(this).theatreClick(\'add\')'+CANCEL_CLICK+'">Install Now<b></b></a>'}E.push(!D?('<table class="f" align="center"><tr><td style="padding:0 8px">'+B+'</td><td style="padding:0 8px"><a href="" class="gmbutton2 gmbutton2c" onclick="GMI.up(this).theatreClick(\'cancel\')'+CANCEL_CLICK+'">Cancel<b></b></a></td>'+C+"</tr></table>"):('<table class="f" align="center"><tr><td style="padding:0 8px"><a href="" class="gmbutton2 gmbutton2s" onclick="GMI.up(this).theatreClick(\'saver\')'+CANCEL_CLICK+'">Save'+(this.link?"":" &amp; Preview")+'<b></b></a></td><td style="padding:0 8px"><a href="" class="gmbutton2 gmbutton2c" onclick="GMI.up(this).theatreClick(\'nosaver\')'+CANCEL_CLICK+'">Cancel<b></b></a></td>'+C+"</tr></table>"))}this.control_node.innerHTML=E.join("")},theatreClick:function(B){var D,A,C;C=(this.gmi_args.groups_mode&&!this.gmi_args.inline)&&this.spec;switch(B){case"cancel":if(C){this.gmi_args.selection_proxy.setSelection(null)}else{Modals.pop("cancel")}break;case"saver":this.module_saver.saveAndChangeView();break;case"nosaver":this.module_saver.loadView("generic");break;case"add":D=this.getTargetForModule();if(A=this.theatre.extractModule()){this.arranger.drawNewModule(A,D.zone,D.pos);A.highlight="new";A.view_context=null;A.uncommitted=true;this.arranger.draw();DiFi.pushPost("GrusersModules","positionModule",[this.arranger.link.ownerid,this.arranger.link.gmi_args.id,A.gmi_args.id,D.zone,D.pos,A.version++],bind(this.arranger,this.arranger.positionDone,A.gmi_args.id));DiFi.timer(1);if(this.arranger.gmi_args.inline){nm.uncommitted=false;DiFi.pushPost("GrusersModules","addModuleCommit",[this.arranger.link.ownerid,this.arranger.link.gmi_args.id,A.gmi_args.id],window.DiFiHolder?DiFiHolder.getStdCallback():DiFi.stdErrCallback);DiFi.timer(1)}if(this.catalog){this.catalog.itemAdded();this.catalog.draw(this.spec.typeid)}if(this.listener){this.listener("add",A)}}else{}this.theatre.cleanView();if(C){this.gmi_args.selection_proxy.setSelection(null)}else{Modals.pop("done")}return ;case"delete":if(confirm("Remove this widget from the page?")){this.theatre.cleanView();this.toast(true);if(C){this.gmi_args.selection_proxy.setSelection(null)}else{Modals.pop("done")}}break}},getTargetForModule:function(){var E,B,A,F,D,C;E=this.gmi_args.page;A=this.gmi_args.zones;C={};for(D=0;D!=A.length;D++){C[A[D].gmi_args.name]=A[D].gmiQuery("GMFrame_Gruser").length}B=this.spec.allowed_zones[0];for(D=0;D!=this.spec.allowed_zones.length;D++){if(C[this.spec.allowed_zones[D]]<C[B]&&!GMI.query("Gruser")[0].gmi_args.group){B=this.spec.allowed_zones[D]}}F=1;if(E.gmi_args.name=="userpage"){if(B=="top_right"){F=2}}return{zone:B,pos:F}},clogSelect:function(){if(this.gmi_args.installs_left==0){this.link=this.arranger.findModuleByTypeId(this.spec.typeid)}this.popup(true)},clogDeselect:function(){if(this.theatre){this.theatre.cleanupPreviews();this.theatre.cleanView();this.theatre.gmi_node.parentNode.removeChild(this.theatre.gmi_node)}if(this.viewing_node){this.viewing_node.innerHTML="";if(this.viewing_node.parentNode){this.viewing_node.parentNode.removeChild(this.viewing_node)}delete this.viewing_node}this.link=null},popup:function(bypass){var divs,i,zone,mod,r,super_height,n,eax;if(this.gmi_args.installs_left==0){return false}if(this.gmi_args.selection_proxy&&bypass!==true){return false}if(!this.arranger||!this.arranger.disabled){if(!this.theatre){this.theatre=GMI.create("ModuleTheatre",{view_context:this,label:this.gmi_args.groups_mode?"":(this.link?"Viewing Widget:":"Widget Preview:"),page:this.gmi_args.page})}mod=50;if(!this.link){if(Number(this.spec.typeid)==4){this.spec.permitted=undefined}}if(!this.link&&this.spec.permitted!=undefined){mod+=20}if(this.gmi_args.groups_mode&&!this.gmi_args.inline&&this.spec){n=this.viewing_node=document.createElement("div");n.setAttribute("gmi-redirect",this.gmi_node.getAttribute("gmindex"));eax=this.gmi_node.getElementsByTagName("h2")[0].cloneNode(true);eax.className="modhead";n.appendChild(eax);this.control_node=document.createElement("div");this.control_node.style.margin="-30px 0 40px 0";n.appendChild(this.control_node);this.theatre.fetch(this.link||this.spec);n.insertBefore(this.theatre.gmi_node,this.control_node);(this.gmi_args.ops_proxy||this.gmiUp("GroupManager")).slide4thColumn(bind(this.gmi_args.selection_proxy,this.gmi_args.selection_proxy.setSelection,null)).appendChild(n);if(this.gmi_args.catalog){setTimeout(bind(this.gmi_args.catalog,this.gmi_args.catalog.label,"back"),175)}}else{r=Ruler.screen.rect();super_height=Math.max((Math.min(r.y2-130,350+mod)),Math.min(r.y2-100,350+mod));eax=document.createElement("div");eax.className="light zone-modal c";eax.style.width="550px";eax.setAttribute("gmi-redirect",this.gmi_node.getAttribute("gmindex"));eax.innerHTML=('<div style="padding:16px 50px 16px '+(mod)+"px;margin-bottom:"+(mod+2)+"px;height:"+super_height+"px;_height:"+(super_height+22)+';overflow:auto;text-align:left"></div><div style="position:absolute;left:0;bottom:0;width:100%;padding:12px 0 0 0;height:'+(mod-11)+"px;_height:"+(mod+2)+';overflow:hidden;background:#CCD9C8;border-top:1px solid #9CA998"></div>');this.control_node=eax.getElementsByTagName("div")[1];eax.getElementsByTagName("div")[0].appendChild(this.theatre.gmi_node);this.theatre.fetch(this.link||this.spec);if((GMI.query("Gruser")[0]||this).gmi_args.group){Modals.lightfade=true}with(Modals.push(eax,bind(this,this.previewModalDone))){getElementsByTagName("a")[0].style.right="26px"}}}if(window.event){event.cancelBubble=true}return false}});if(window.DWait){DWait.run("jms/pages/gruzecontrol/ma_minimodule.js")}(function(B){var C,A,E;B.fn.selectpager=function(F){F=B.extend({},B.fn.selectpager.defaults,F);return this.each(function(){if(!this.tagName=="SELECT"||this.getAttribute("no_custom_select")){return }var I=B(this);var J=I.data("select_pager");if(J){J.remove()}if(I.children().length>F.maxLength){return }I.hide();var H=B("<div>").addClass(F.className);if(F.setID){var G;if(G=I.attr("id")||I.attr("name")){H.attr("id",G+"-pager")}}if(I.attr("disabled")){H.addClass("select_pager_disabled")}I.data("select_pager",H);var K;H.data("options",F).append('<span class="text">Nothing selected...</span>').append('<div class="button">').insertAfter(I).bind("mouseover",function(){H.addClass("hover")}).bind("mouseleave",function(){H.removeClass("hover")}).click(function(P){P.preventDefault();P.stopPropagation();if(I.attr("disabled")){return }if(!K){K=A(H,I,F);H.data("menu",K)}H.addClass("active");var N=B(K.node);var O=B(document.body).hasClass("modal-active");var R=true;if(O&&!Browser.isIE){R=false}if(O&&!R){N.css("position","relative")}var Q=Ruler.screen.node(this,R);Popup.show(K,Q,true);var M=B(K.node).find("div.option");var L=Math.min(M.size()*(M.height()+7),Math.max(200,B(window).height()-150));N.height(Math.min(L,F.maxHeight));Popup.show(K,Q,true);if(O&&!R){N.css("position","fixed")}});D(I.find("option:selected"),H.find(".text"),F);if(B.browser.mozilla&&parseFloat(B.browser.version)<1.9){H.css("float","left").nextAll("br").css("clear","both")}})};B.fn.selectpager.defaults={className:"select_pager",filter:function(F){return F&&F.replace(/ \*$/,"")||""},maxLength:60,maxHeight:800,setID:false};function A(I,H,G){var K=I.text()||"Browse";var L=B('<div class="pager-holder pager-select"><div class="jsid-pager pager2"><div class="page2"></div></div></div>');var J=L.find(".page2");H.find("option").each(function(){var N=B(this);var M=B("<div>"+G.filter(N.html())+"</div>").data("option",N).data("base",I).addClass("option");if(N.attr("disabled")){M.addClass("disabled")}if(N.attr("selected")){M.addClass("selected")}if(N.attr("class")){M.addClass(N.attr("class"))}J.append(M)});J.find("div.option").bind("mouseover",function(){B(this).addClass("hover")}).bind("mouseleave",function(){B(this).removeClass("hover")}).click(E);var F=Popup.create({className:G.className,callback:function(M){I.removeClass("active")},allow_resize:true});F.node.appendChild(L.get(0));if(B.browser.mozilla||B.browser.safari){B.each(["bottomleft","bottomright"],function(){B(F.node).css("-moz-border-radius-"+this,"5px").css("-webkit-border-radius-"+this,"5px")})}return F}function E(I){I.preventDefault();I.stopPropagation();var F=B(this);var H=F.data("option");var G=F.data("base");if(H.attr("disabled")){return }F.siblings(".selected").removeClass("selected");F.addClass("selected");H.parent().val(H.val()).change();D(H,G.find(".text"),G.data("options"));Popup.complete(G.data("menu"))}function D(H,G,F){G.attr("class","text").addClass(H.attr("class")).html(F.filter(H.html()))}})(jQuery);if(window.DWait){DWait.run("jms/lib/jquery/plugins/jquery.select.pager.js")}GruserEditMode=Base.extend({toggle:function(){this.set(!this.local_ma)},set:function(A){if(Boolean(A)==Boolean(this.local_ma)){return }if(A){this.showMasterModal()}else{Modals.pop()}},getPage:function(){return GMI.query("GPage")[0]},showMasterModal:function(){var div,div2,eax,r,h,container,canvas,page,api,gruser,zones;gruser=GMI.query("Gruser")[0];api=this.api=(gruser.gmi_args||{}).api;canvas=Browser.isGecko?document.documentElement:document.body;canvas.scrollTop=0;ModuleCatalog.clearLatestID();div=document.createElement("div");div.className="light zone-modal phone-modal";div.style.width="550px";r=Ruler.screen.rect();h=Math.max((Math.min(r.y2-45,400)),Math.min(r.y2-60,550));page=this.getPage();zones=GMI.query("GZone");this.local_ma=GMI.create("ModuleArranger",{api:api,height:h,layout_changer:gruser.gmi_args.group?GMI.create("RoomLayoutChanger",{gruser_id:gruser.gmi_args.id,gruser_proxy:gruser}):null,live_preview:true,page:page,zones:zones});div.appendChild(this.local_ma.gmi_node);container=document.createElement("div");container.style.height=(h-33)+"px";container.className="gruser-drawer";container.innerHTML='<i class="bbb"></i>';this.local_mc=GMI.create("ModuleCatalog",{api:api,arranger:this.local_ma,zones:zones,page:page});container.appendChild(this.local_mc.gmi_node);div.appendChild(container);with(Modals.push(div,bind(this,this.masterModalDone))){style.left="65%";style.overflow="visible";if(previousSibling){previousSibling.style.left="65%"}with(getElementsByTagName("a")[0]){style.top="15px";style.right="26px"}}this.local_mc.link()},masterModalDone:function(A){var D,C,B,F,E;if(A!="all_done"){E=new CBC(bind(Modals,Modals.pop,"all_done"));this.local_ma.offerDelay(E);E.start();return false}GMI._delete(this.local_ma);GMI._delete(this.local_mc);this.local_ma=null;this.local_mc=null;D=this.getPage();C=D.gmiQuery("GMFrame_Gruser");for(B=0;B!=C.length;B++){if(C[B].uncommitted){C[B].uncommitted=false;DiFi.pushPost(this.api||"GrusersModules","addModuleCommit",[D.ownerid,D.gmi_args.id,C[B].gmi_args.id],bind(this,this.moduleBust,C[B]))}}DiFi.send();if(window.GMessaging&&(F=GMI.query("GMessaging")[0])){F.reload()}},moduleBust:function(A,C,B){if(!C&&!this.bust_reported){A.uncommitted=true;this.bust_reported=true;alert("Some of the widgets you added were not saved.\n\nPlease try again soon.");this.set(true)}}});GruserEditMode.getInstance=function(){return GruserEditMode.instance||(GruserEditMode.instance=new GruserEditMode)};if(window.DWait){DWait.run("jms/pages/gruzecontrol/grusereditmode.js")}DWait.count();