var admin={textarea:g.d.getElementById("admin_editor"),browser:{},sorter:{},load:function(){if(admin.textarea)admin.editor=CKEDITOR.replace(admin.textarea.id,{customConfig:"/js/cks/?v=20150715152628"});var y=1;while(g.d.getElementById("admin_browser"+y)){g.d.getElementById("admin_browser"+y).addEventListener("click",function(){admin.openbrowser(this);},0);y++;}if(g.d.getElementById("sorting"))admin.sorting();if(g.d.getElementById("manager"))admin.ckf();},ckf:function(){admin.browser.inline=new CKFinder();admin.browser.inline.basePath="/cks/ckf/";admin.browser.inline.defaultDisplayFilename=1;admin.browser.inline.height=500;admin.browser.inline.selectMultiple=1;admin.browser.inline.appendTo("manager");},openbrowser:function(fld){if(!site.overlay)site.createoverlay();site.overlay.className="browser dn oz pf";site.overlay.innerHTML="<div class=\"ma oh pr\" id=\"browser\"><h1 class=\"fwb pa\">Browse Server</h1></div>";admin.browser.modal=new CKFinder();admin.browser.modal.basePath="/cks/ckf/";admin.browser.modal.height=500;admin.browser.modal.selectActionFunction=function(uri){fld.previousSibling.value=uri;site.hideoverlay();fld.previousSibling.focus();};site.showoverlay();admin.browser.modal.appendTo(g.d.getElementById("browser"));site.overlay.style.opacity=1;return false;},order:function(item){var add,max,min,temp,neworder=parseInt(admin.sorter.selects[item].value),oldorder=parseInt(g.d.getElementById("corder"+item).value);if(oldorder!=neworder){if(oldorder>neworder){max=oldorder;min=neworder-1;add=1;}else{max=neworder;min=oldorder;add=-1;}g.d.getElementById("corder"+item).value=neworder;for(var x=admin.sorter.count;x--;){if(x!=item&&g.d.getElementById("corder"+x)){temp=parseInt(g.d.getElementById("corder"+x).value);if(temp>min&&temp<=max){g.d.getElementById("norder"+x).selectedIndex=temp+add-1;g.d.getElementById("corder"+x).value=temp+add;}}}}},sorting:function(){admin.sorter.selects=g.d.getElementById("sorting").getElementsByTagName("select");admin.sorter.count=admin.sorter.selects.length;for(var x=admin.sorter.count;x--;){admin.sorter.selects[x].addEventListener("change",function(){admin.order(site.childindex(this.parentNode.parentNode));},0);}}};