(function(d){d.extend({tablesorter:new (function(){function b(a,c){n(a+","+((new Date).getTime()-c.getTime())+"ms")}function n(a){typeof console!="undefined"&&typeof console.debug!="undefined"?console.log(a):alert(a)}function r(a,c){if(a.config.debug)var f="";var h=a.tBodies[0].rows;if(a.tBodies[0].rows[0]){var e=[];h=h[0].cells;for(var m=h.length,g=0;g<m;g++){var j=false;if(d.metadata&&d(c[g]).metadata()&&d(c[g]).metadata().sorter)j=p(d(c[g]).metadata().sorter);else if(a.config.headers[g]&&a.config.headers[g].sorter)j=
p(a.config.headers[g].sorter);if(!j)a:{j=a;for(var k=h[g],l=s.length,t=1;t<l;t++)if(s[t].is(d.trim(z(j.config,k)),j,k)){j=s[t];break a}j=s[0]}if(a.config.debug)f+="column:"+g+" parser:"+j.id+"\n";e.push(j)}}a.config.debug&&n(f);return e}function p(a){for(var c=s.length,f=0;f<c;f++)if(s[f].id.toLowerCase()==a.toLowerCase())return s[f];return false}function q(a){if(a.config.debug)var c=new Date;for(var f=a.tBodies[0]&&a.tBodies[0].rows.length||0,h=a.tBodies[0].rows[0]&&a.tBodies[0].rows[0].cells.length||
0,e=a.config.parsers,m={row:[],normalized:[]},g=0;g<f;++g){var j=a.tBodies[0].rows[g],k=[];m.row.push(d(j));for(var l=0;l<h;++l)k.push(e[l].format(z(a.config,j.cells[l]),a,j.cells[l]));k.push(g);m.normalized.push(k)}a.config.debug&&b("Building cache for "+f+" rows:",c);return m}function z(a,c){if(!c)return"";var f="";return f=a.textExtraction=="simple"?c.childNodes[0]&&c.childNodes[0].hasChildNodes()?c.childNodes[0].innerHTML:c.innerHTML:typeof a.textExtraction=="function"?a.textExtraction(c):d(c).text()}
function x(a,c){if(a.config.debug)var f=new Date;for(var h=c.row,e=c.normalized,m=e.length,g=e[0].length-1,j=d(a.tBodies[0]),k=[],l=0;l<m;l++){k.push(h[e[l][g]]);if(!a.config.appender)for(var t=h[e[l][g]],v=t.length,u=0;u<v;u++)j[0].appendChild(t[u])}a.config.appender&&a.config.appender(a,k);k=null;a.config.debug&&b("Rebuilt table:",f);y(a);setTimeout(function(){d(a).trigger("sortEnd")},0)}function E(a){if(a.config.debug)var c=new Date;for(var f=[],h=0;h<a.tHead.rows.length;h++)f[h]=0;$tableHeaders=
d("thead th",a);$tableHeaders.each(function(e){this.count=0;this.column=e;var m=a.config.sortInitialOrder;this.order=i=typeof m!="Number"?m.toLowerCase()=="desc"?1:0:m==1?m:0;if(!(m=d.metadata&&d(this).metadata().sorter===false?true:false))m=a.config.headers[e]&&a.config.headers[e].sorter===false?true:false;if(m)this.sortDisabled=true;this.sortDisabled||d(this).addClass(a.config.cssHeader);a.config.headerList[e]=this});if(a.config.debug){b("Built headers:",c);n($tableHeaders)}return $tableHeaders}
function y(a){for(var c=a.config.widgets,f=c.length,h=0;h<f;h++)A(c[h]).format(a)}function A(a){for(var c=w.length,f=0;f<c;f++)if(w[f].id.toLowerCase()==a.toLowerCase())return w[f]}function F(a,c){for(var f=c.length,h=0;h<f;h++)if(c[h][0]==a)return true;return false}function B(a,c,f,h){c.removeClass(h[0]).removeClass(h[1]);var e=[];c.each(function(){this.sortDisabled||(e[this.column]=d(this))});a=f.length;for(c=0;c<a;c++)e[f[c][0]].addClass(h[f[c][1]])}function G(a){if(a.config.widthFixed){var c=
d("<colgroup>");d("tr:first td",a.tBodies[0]).each(function(){c.append(d("<col>").css("width",d(this).width()))});d(a).prepend(c)}}function C(a,c,f){if(a.config.debug)var h=new Date;for(var e="var sortWrapper = function(a,b) {",m=c.length,g=0;g<m;g++){var j=c[g][0],k=c[g][1],l="e"+g;e+="var "+l+" = "+(a.config.parsers[j].type=="text"?k==0?"sortText":"sortTextDesc":k==0?"sortNumeric":"sortNumericDesc")+"(a["+j+"],b["+j+"]); ";e+="if("+l+") { return "+l+"; } ";e+="else { "}g=f.normalized[0].length-
1;e+="return a["+g+"]-b["+g+"];";for(g=0;g<m;g++)e+="}; ";e+="return 0; ";e+="}; ";eval(e);f.normalized.sort(sortWrapper);a.config.debug&&b("Sorting on "+c.toString()+" and dir "+k+" time:",h);return f}var s=[],w=[];this.defaults={cssHeader:"header",cssAsc:"headerSortUp",cssDesc:"headerSortDown",sortInitialOrder:"asc",sortMultiSortKey:"shiftKey",sortForce:null,sortAppend:null,textExtraction:"simple",parsers:{},widgets:[],widgetZebra:{css:["even","odd"]},headers:{},widthFixed:false,cancelSelection:true,
sortList:[],headerList:[],dateFormat:"us",decimal:".",debug:false};this.benchmark=b;this.construct=function(a){return this.each(function(){if(this.tHead&&this.tBodies){var c,f,h,e;this.config={};e=d.extend(this.config,d.tablesorter.defaults,a);c=d(this);f=E(this);this.config.parsers=r(this,f);h=q(this);var m=[e.cssDesc,e.cssAsc];G(this);f.click(function(g){c.trigger("sortStart");var j=c[0].tBodies[0]&&c[0].tBodies[0].rows.length||0;if(!this.sortDisabled&&j>0){d(this);j=this.column;this.order=this.count++%
2;if(g[e.sortMultiSortKey])if(F(j,e.sortList))for(g=0;g<e.sortList.length;g++){var k=e.sortList[g],l=e.headerList[k[0]];if(k[0]==j){l.count=k[1];l.count++;k[1]=l.count%2}}else e.sortList.push([j,this.order]);else{e.sortList=[];if(e.sortForce!=null){k=e.sortForce;for(g=0;g<k.length;g++)k[g][0]!=j&&e.sortList.push(k[g])}e.sortList.push([j,this.order])}setTimeout(function(){B(c[0],f,e.sortList,m);x(c[0],C(c[0],e.sortList,h))},1);return false}}).mousedown(function(){if(e.cancelSelection){this.onselectstart=
function(){return false};return false}});c.bind("update",function(){this.config.parsers=r(this,f);h=q(this)}).bind("sorton",function(g,j){d(this).trigger("sortStart");e.sortList=j;for(var k=e.sortList,l=this.config,t=k.length,v=0;v<t;v++){var u=k[v],D=l.headerList[u[0]];D.count=u[1];D.count++}B(this,f,k,m);x(this,C(this,k,h))}).bind("appendCache",function(){x(this,h)}).bind("applyWidgetId",function(g,j){A(j).format(this)}).bind("applyWidgets",function(){y(this)});if(d.metadata&&d(this).metadata()&&
d(this).metadata().sortlist)e.sortList=d(this).metadata().sortlist;e.sortList.length>0&&c.trigger("sorton",[e.sortList]);y(this)}})};this.addParser=function(a){for(var c=s.length,f=true,h=0;h<c;h++)if(s[h].id.toLowerCase()==a.id.toLowerCase())f=false;f&&s.push(a)};this.addWidget=function(a){w.push(a)};this.formatFloat=function(a){a=parseFloat(a);return isNaN(a)?0:a};this.formatInt=function(a){a=parseInt(a);return isNaN(a)?0:a};this.isDigit=function(a,c){var f="\\"+c.decimal;return RegExp("/(^[+]?0("+
f+"0+)?$)|(^([-+]?[1-9][0-9]*)$)|(^([-+]?((0?|[1-9][0-9]*)"+f+"(0*[1-9][0-9]*)))$)|(^[-+]?[1-9]+[0-9]*"+f+"0+$)/").test(d.trim(a))};this.clearTableBody=function(a){if(d.browser.msie)(function(){for(;this.firstChild;)this.removeChild(this.firstChild)}).apply(a.tBodies[0]);else a.tBodies[0].innerHTML=""}})});d.fn.extend({tablesorter:d.tablesorter.construct});var o=d.tablesorter;o.addParser({id:"text",is:function(){return true},format:function(b){return d.trim(b.toLowerCase())},type:"text"});o.addParser({id:"digit",
is:function(b,n){return d.tablesorter.isDigit(b,n.config)},format:function(b){return d.tablesorter.formatFloat(b)},type:"numeric"});o.addParser({id:"currency",is:function(b){return/^[\u00a3$\u20ac?.]/.test(b)},format:function(b){return d.tablesorter.formatFloat(b.replace(RegExp(/[^0-9.]/g),""))},type:"numeric"});o.addParser({id:"ipAddress",is:function(b){return/^\d{2,3}[\.]\d{2,3}[\.]\d{2,3}[\.]\d{2,3}$/.test(b)},format:function(b){b=b.split(".");for(var n="",r=b.length,p=0;p<r;p++){var q=b[p];n+=
q.length==2?"0"+q:q}return d.tablesorter.formatFloat(n)},type:"numeric"});o.addParser({id:"url",is:function(b){return/^(https?|ftp|file):\/\/$/.test(b)},format:function(b){return jQuery.trim(b.replace(RegExp(/(https?|ftp|file):\/\//),""))},type:"text"});o.addParser({id:"isoDate",is:function(b){return/^\d{4}[\/-]\d{1,2}[\/-]\d{1,2}$/.test(b)},format:function(b){return d.tablesorter.formatFloat(b!=""?(new Date(b.replace(RegExp(/-/g),"/"))).getTime():"0")},type:"numeric"});o.addParser({id:"percent",
is:function(b){return/\%$/.test(d.trim(b))},format:function(b){return d.tablesorter.formatFloat(b.replace(RegExp(/%/g),""))},type:"numeric"});o.addParser({id:"usLongDate",is:function(b){return b.match(RegExp(/^[A-Za-z]{3,10}\.? [0-9]{1,2}, ([0-9]{4}|'?[0-9]{2}) (([0-2]?[0-9]:[0-5][0-9])|([0-1]?[0-9]:[0-5][0-9]\s(AM|PM)))$/))},format:function(b){return d.tablesorter.formatFloat((new Date(b)).getTime())},type:"numeric"});o.addParser({id:"shortDate",is:function(b){return/\d{1,2}[\/\-]\d{1,2}[\/\-]\d{2,4}/.test(b)},
format:function(b,n){var r=n.config;b=b.replace(/\-/g,"/");if(r.dateFormat=="us")b=b.replace(/(\d{1,2})[\/\-](\d{1,2})[\/\-](\d{4})/,"$3/$1/$2");else if(r.dateFormat=="uk")b=b.replace(/(\d{1,2})[\/\-](\d{1,2})[\/\-](\d{4})/,"$3/$2/$1");else if(r.dateFormat=="dd/mm/yy"||r.dateFormat=="dd-mm-yy")b=b.replace(/(\d{1,2})[\/\-](\d{1,2})[\/\-](\d{2})/,"$1/$2/$3");return d.tablesorter.formatFloat((new Date(b)).getTime())},type:"numeric"});o.addParser({id:"time",is:function(b){return/^(([0-2]?[0-9]:[0-5][0-9])|([0-1]?[0-9]:[0-5][0-9]\s(am|pm)))$/.test(b)},
format:function(b){return d.tablesorter.formatFloat((new Date("2000/01/01 "+b)).getTime())},type:"numeric"});o.addParser({id:"metadata",is:function(){return false},format:function(b,n,r){b=n.config;b=!b.parserMetadataName?"sortValue":b.parserMetadataName;return d(r).metadata()[b]},type:"numeric"});o.addWidget({id:"zebra",format:function(b){if(b.config.debug)var n=new Date;d("tr:visible",b.tBodies[0]).filter(":even").removeClass(b.config.widgetZebra.css[1]).addClass(b.config.widgetZebra.css[0]).end().filter(":odd").removeClass(b.config.widgetZebra.css[0]).addClass(b.config.widgetZebra.css[1]);
b.config.debug&&d.tablesorter.benchmark("Applying Zebra widget",n)}})})(jQuery);(function(d){function o(p){p.length?d("#message").text(p).css("color","red").show("fast"):d("#message").text("").hide("slow")}function b(p){var q=d("#search").val();q=q.toLowerCase();o("");if(q.match(/^\*+[^\*]*\*+$/)){o("Only use * and the beginning or end of your search, not both");p.stopPropagation();return false}if(q.match(/^\**[a-z]+\**$/)){q=escape(q);document.location.href=base_url+"word/portion/search/"+q}else o("Please search for just letters (a-z)");p.stopPropagation();return false}function n(){d("#searchForm").bind("submit",
b);d("#search").focus();d("table.tablesorter").tablesorter({textExtraction:r})}function r(p){return d(p).text()}d(window).load(function(){setTimeout(n,50)})})(jQuery);
