jQuery(document).ready(function(d){var c,f,b,a,e=false;f=function(){c=d("#media-items").sortable({items:".media-item",placeholder:"sorthelper",axis:"y",distance:2,update:b})};b=function(j,h){var i=h.element.sortable("toArray"),g=i.length;d.each(i,function(l,m){var k=e?(g-l):(1+l);d("#"+m+" .menu_order input").val(k)})};sortIt=function(){var h=d(".menu_order_input"),g=h.length;h.each(function(k){var j=e?(g-k):(1+k);d(this).val(j)})};clearAll=function(g){g=g||0;d(".menu_order_input").each(function(){if(this.value=="0"||g){this.value=""}})};d("#asc").click(function(){e=false;sortIt();return false});d("#desc").click(function(){e=true;sortIt();return false});d("#clear").click(function(){clearAll(1);return false});f();clearAll();if(d("#media-items>*").length>1){a=wpgallery.getWin();d("#save-all, #gallery-settings").show();if(typeof a.tinyMCE!="undefined"&&a.tinyMCE.activeEditor&&!a.tinyMCE.activeEditor.isHidden()){wpgallery.mcemode=true;wpgallery.init()}else{d("#insert-gallery").show()}}});jQuery(window).unload(function(){tinymce=tinyMCE=wpgallery=null});var tinymce=null,tinyMCE,wpgallery;wpgallery={mcemode:false,editor:{},dom:{},is_update:false,el:{},I:function(a){return document.getElementById(a)},init:function(){var d=this,a,f,c,e,b=d.getWin();if(!d.mcemode){return}a=(""+document.location.search).replace(/^\?/,"").split("&");f={};for(c=0;c