(function(a){a.extend({ajaxsorter:new function(){this.construct=function(h){return this.each(function(){var b=a(this).metadata();function g(d){a(d,a('#'+b.reload_id)).addClass('loading')}a('thead th',this).each(function(){var c=a(this).metadata();function f(d,e){b.post.order_by=d;b.post.direction=e;g('small.result');a('#'+b.reload_id).load(b.url,b.post)}if(c.sql){if(c.sql==b.post.order_by){if(b.post.direction=='down'){a(this).addClass('header headerSortUp');a(this).click(function(){f(c.sql,'up');return false})}else{a(this).addClass('header headerSortDown');a(this).click(function(){f(c.sql,'down');return false})}}else{a(this).addClass('header');a(this).click(function(){f(c.sql,'up');return false})}}});a('.navlink',a('#'+b.reload_id)).click(function(){g('div.navPage');a('#'+b.reload_id).load(a(this).attr('href'),b.post);return false});a('div.navForm',a('#'+b.reload_id)).each(function(){var c=this;a('a',c).unbind('click').click(function(){var d=a(':input',c).val();if(d){g('div.navPage');if(a(c).is('.pge'))d=parseInt(a(this).attr('rel'))*(parseInt(d)-1);var e=a(this).attr('href').match(/([^#]*)(.*)/);a('#'+b.reload_id).load(e[1]+d+e[2],b.post)}return false})})})}}});a.fn.extend({ajaxsorter:a.ajaxsorter.construct})})(jQuery);