/* Copyright (c) 2007 Paul Bakaus (paul.bakaus@googlemail.com) and Brandon Aaron (brandon.aaron@gmail.com || http://brandonaaron.net)
 * Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php)
 * and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses.
 *
 * $LastChangedDate: 2007-12-20 08:43:48 -0600 (Thu, 20 Dec 2007) $
 * $Rev: 4257 $
 *
 * Version: 1.2
 *
 * Requires: jQuery 1.2+
 */
eval(function(p,a,c,k,e,r){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('(5($){$.19={P:\'1.2\'};$.u([\'j\',\'w\'],5(i,d){$.q[\'O\'+d]=5(){p(!3[0])6;g a=d==\'j\'?\'s\':\'m\',e=d==\'j\'?\'D\':\'C\';6 3.B(\':y\')?3[0][\'L\'+d]:4(3,d.x())+4(3,\'n\'+a)+4(3,\'n\'+e)};$.q[\'I\'+d]=5(b){p(!3[0])6;g c=d==\'j\'?\'s\':\'m\',e=d==\'j\'?\'D\':\'C\';b=$.F({t:Z},b||{});g a=3.B(\':y\')?3[0][\'8\'+d]:4(3,d.x())+4(3,\'E\'+c+\'w\')+4(3,\'E\'+e+\'w\')+4(3,\'n\'+c)+4(3,\'n\'+e);6 a+(b.t?(4(3,\'t\'+c)+4(3,\'t\'+e)):0)}});$.u([\'m\',\'s\'],5(i,b){$.q[\'l\'+b]=5(a){p(!3[0])6;6 a!=W?3.u(5(){3==h||3==r?h.V(b==\'m\'?a:$(h)[\'U\'](),b==\'s\'?a:$(h)[\'T\']()):3[\'l\'+b]=a}):3[0]==h||3[0]==r?S[(b==\'m\'?\'R\':\'Q\')]||$.N&&r.M[\'l\'+b]||r.A[\'l\'+b]:3[0][\'l\'+b]}});$.q.F({z:5(){g a=0,f=0,o=3[0],8,9,7,v;p(o){7=3.7();8=3.8();9=7.8();8.f-=4(o,\'K\');8.k-=4(o,\'J\');9.f+=4(7,\'H\');9.k+=4(7,\'Y\');v={f:8.f-9.f,k:8.k-9.k}}6 v},7:5(){g a=3[0].7;G(a&&(!/^A|10$/i.16(a.15)&&$.14(a,\'z\')==\'13\'))a=a.7;6 $(a)}});5 4(a,b){6 12($.11(a.17?a[0]:a,b,18))||0}})(X);',62,72,'|||this|num|function|return|offsetParent|offset|parentOffset|||||borr|top|var|window||Height|left|scroll|Left|padding|elem|if|fn|document|Top|margin|each|results|Width|toLowerCase|visible|position|body|is|Right|Bottom|border|extend|while|borderTopWidth|outer|marginLeft|marginTop|client|documentElement|boxModel|inner|version|pageYOffset|pageXOffset|self|scrollTop|scrollLeft|scrollTo|undefined|jQuery|borderLeftWidth|false|html|curCSS|parseInt|static|css|tagName|test|jquery|true|dimensions'.split('|'),0,{}));
eval(function(p,a,c,k,e,r){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('(9($){2 q=9(a){2 b=a.w;2 d=b.8;2 e=[];6(2 i=0;i<d;i++){2 f=b[i].Z;2 g=f.8;6(2 j=0;j<g;j++){2 c=f[j];2 h=c.12||1;2 n=c.10||1;2 o=-1;3(!e[i]){e[i]=[]}2 m=e[i];z(m[++o]){}c.E=o;6(2 k=i;k<i+h;k++){3(!e[k]){e[k]=[]}2 p=e[k];6(2 l=o;l<o+n;l++){p[l]=1}}}}};2 u=9(a){2 v=0,i,k,r=(a.Y)?a.Y.w:0;3(r){6(i=0;i<r.8;i++){r[i].T=v++}}6(k=0;k<a.H.8;k++){r=a.H[k].w;3(r){6(i=0;i<r.8;i++){r[i].T=v++}}}r=(a.W)?a.W.w:0;3(r){6(i=0;i<r.8;i++){r[i].T=v++}}};$.U.1D=9(m){2 n=$.1A({1o:5,1n:5,1r:5,1i:B,1g:5,1f:B,1e:5,1d:B,1c:5,1b:B,1a:5,19:[],17:B,16:5,15:B,K:\'1s\',J:\'\',I:\'\',G:\'\'},m);1q V.1E(9(){2 d=[],A=[],4=V,r,13=0,L=[-1,-1];3(!4.H||!4.H.8){1q}2 f=9(a,b){2 c,X,S,N,7,s;6(S=0;S<a.8;S++,13++){X=a[S];6(N=0;N<X.Z.8;N++){c=X.Z[N];3((b==\'R\'&&n.1g)||(b==\'Q\'&&n.1f)||(b==\'P\'&&n.1i)){s=c.12;z(--s>=0){A[13+s].1p(c)}}3((b==\'R\'&&n.1c)||(b==\'P\'&&n.1d)||(b==\'Q\'&&n.1b)){s=c.10;z(--s>=0){7=c.E+s;3($.1C(7+1,n.19)>-1){1B}3(!d[7]){d[7]=[]}d[7].1p(c)}}3((b==\'R\'&&n.1n)||(b==\'P\'&&n.1o)||(b==\'Q\'&&n.1r)){c.C=5}}}};2 g=9(e){2 p=e.11;z(p!=V&&p.C!==5){p=p.D}3(p.C===5){l(p,5)}};2 j=9(e){2 p=e.11;z(p!=V&&p.C!==5){p=p.D}3(p.C===5){l(p,B)}};2 k=9(e){2 t=e.11;z(t&&t!=4&&!t.C)t=t.D;3(t.C&&n.G!=\'\'){2 x=t.E,y=t.D.T,s=\'\';$(\'1m.\'+n.G+\', 1l.\'+n.G,4).1k(n.G);3(x!=L[0]||y!=L[1]){3(n.K!=\'\'){s+=\',.\'+n.K}3(n.J!=\'\'){s+=\',.\'+n.J}3(n.I!=\'\'){s+=\',.\'+n.I}3(s!=\'\'){$(\'1m, 1l\',4).1z(s.1y(1)).18(n.G)}L=[x,y]}1h{L=[-1,-1]}}};2 l=9(a,b){3(b){$.U.M=$.U.18}1h{$.U.M=$.U.1k}2 h=d[a.E]||[],F=[],i=0,7,O;3(n.J!=\'\'){z(n.1a&&++i<a.10&&d[a.E+i]){h=h.14(d[a.E+i])}$(h).M(n.J)}3(n.K!=\'\'){7=a.D.T;3(A[7]){F=F.14(A[7])}i=0;z(n.1e&&++i<a.12){3(A[7+i]){F=F.14(A[7+i])}}$(F).M(n.K)}3(n.I!=\'\'){O=a.D.D.1x.1w();3((O==\'R\'&&n.16)||(O==\'P\'&&n.17)||(O==\'Q\'&&n.15)){$(a).M(n.I)}}};q(4);u(4);6(r=0;r<4.w.8;r++){A[r]=[]}3(4.Y){f(4.Y.w,\'P\')}6(r=0;r<4.H.8;r++){f(4.H[r].w,\'R\')}3(4.W){f(4.W.w,\'Q\')}$(V).1j(\'1v\',g).1j(\'1u\',j).1t(k)})}})(1F);',62,104,'||var|if|tbl|true|for|rI|length|function|||||||||||||||||||||||rows|||while|rowIndex|false|thover|parentNode|realIndex|rH|clickClass|tBodies|cellClass|colClass|rowClass|lastClick|tableHoverHover|cI|nn|THEAD|TFOOT|TBODY|rowI|realRIndex|fn|this|tFoot|row|tHead|cells|colSpan|target|rowSpan|rCnt|concat|footCells|bodyCells|headCells|addClass|ignoreCols|spanCols|footCols|bodyCols|headCols|spanRows|footRows|bodyRows|else|headRows|bind|removeClass|th|td|allowBody|allowHead|push|return|allowFoot|hover|click|mouseout|mouseover|toUpperCase|nodeName|substring|filter|extend|break|inArray|tableHover|each|jQuery'.split('|'),0,{}));
(function($){$.extend({tablesorter:new function(){var parsers=[],widgets=[];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};function benchmark(s,d){log(s+","+(new Date().getTime()-d.getTime())+"ms");}this.benchmark=benchmark;function log(s){if(typeof console!="undefined"&&typeof console.debug!="undefined"){console.log(s);}else{alert(s);}}function buildParserCache(table,$headers){if(table.config.debug){var parsersDebug="";}var rows=table.tBodies[0].rows;if(table.tBodies[0].rows[0]){var list=[],cells=rows[0].cells,l=cells.length;for(var i=0;i<l;i++){var p=false;if($.metadata&&($($headers[i]).metadata()&&$($headers[i]).metadata().sorter)){p=getParserById($($headers[i]).metadata().sorter);}else if((table.config.headers[i]&&table.config.headers[i].sorter)){p=getParserById(table.config.headers[i].sorter);}if(!p){p=detectParserForColumn(table,cells[i]);}if(table.config.debug){parsersDebug+="column:"+i+" parser:"+p.id+"\n";}list.push(p);}}if(table.config.debug){log(parsersDebug);}return list;};function detectParserForColumn(table,node){var l=parsers.length;for(var i=1;i<l;i++){if(parsers[i].is($.trim(getElementText(table.config,node)),table,node)){return parsers[i];}}return parsers[0];}function getParserById(name){var l=parsers.length;for(var i=0;i<l;i++){if(parsers[i].id.toLowerCase()==name.toLowerCase()){return parsers[i];}}return false;}function buildCache(table){if(table.config.debug){var cacheTime=new Date();}var totalRows=(table.tBodies[0]&&table.tBodies[0].rows.length)||0,totalCells=(table.tBodies[0].rows[0]&&table.tBodies[0].rows[0].cells.length)||0,parsers=table.config.parsers,cache={row:[],normalized:[]};for(var i=0;i<totalRows;++i){var c=table.tBodies[0].rows[i],cols=[];cache.row.push($(c));for(var j=0;j<totalCells;++j){cols.push(parsers[j].format(getElementText(table.config,c.cells[j]),table,c.cells[j]));}cols.push(i);cache.normalized.push(cols);cols=null;};if(table.config.debug){benchmark("Building cache for "+totalRows+" rows:",cacheTime);}return cache;};function getElementText(config,node){if(!node)return"";var t="";if(config.textExtraction=="simple"){if(node.childNodes[0]&&node.childNodes[0].hasChildNodes()){t=node.childNodes[0].innerHTML;}else{t=node.innerHTML;}}else{if(typeof(config.textExtraction)=="function"){t=config.textExtraction(node);}else{t=$(node).text();}}return t;}function appendToTable(table,cache){if(table.config.debug){var appendTime=new Date()}var c=cache,r=c.row,n=c.normalized,totalRows=n.length,checkCell=(n[0].length-1),tableBody=$(table.tBodies[0]),rows=[];for(var i=0;i<totalRows;i++){rows.push(r[n[i][checkCell]]);if(!table.config.appender){var o=r[n[i][checkCell]];var l=o.length;for(var j=0;j<l;j++){tableBody[0].appendChild(o[j]);}}}if(table.config.appender){table.config.appender(table,rows);}rows=null;if(table.config.debug){benchmark("Rebuilt table:",appendTime);}applyWidget(table);setTimeout(function(){$(table).trigger("sortEnd");},0);};function buildHeaders(table){if(table.config.debug){var time=new Date();}var meta=($.metadata)?true:false,tableHeadersRows=[];for(var i=0;i<table.tHead.rows.length;i++){tableHeadersRows[i]=0;};$tableHeaders=$("thead th",table);$tableHeaders.each(function(index){this.count=0;this.column=index;this.order=formatSortingOrder(table.config.sortInitialOrder);if(checkHeaderMetadata(this)||checkHeaderOptions(table,index))this.sortDisabled=true;if(!this.sortDisabled){$(this).addClass(table.config.cssHeader);}table.config.headerList[index]=this;});if(table.config.debug){benchmark("Built headers:",time);log($tableHeaders);}return $tableHeaders;};function checkCellColSpan(table,rows,row){var arr=[],r=table.tHead.rows,c=r[row].cells;for(var i=0;i<c.length;i++){var cell=c[i];if(cell.colSpan>1){arr=arr.concat(checkCellColSpan(table,headerArr,row++));}else{if(table.tHead.length==1||(cell.rowSpan>1||!r[row+1])){arr.push(cell);}}}return arr;};function checkHeaderMetadata(cell){if(($.metadata)&&($(cell).metadata().sorter===false)){return true;};return false;}function checkHeaderOptions(table,i){if((table.config.headers[i])&&(table.config.headers[i].sorter===false)){return true;};return false;}function applyWidget(table){var c=table.config.widgets;var l=c.length;for(var i=0;i<l;i++){getWidgetById(c[i]).format(table);}}function getWidgetById(name){var l=widgets.length;for(var i=0;i<l;i++){if(widgets[i].id.toLowerCase()==name.toLowerCase()){return widgets[i];}}};function formatSortingOrder(v){if(typeof(v)!="Number"){i=(v.toLowerCase()=="desc")?1:0;}else{i=(v==(0||1))?v:0;}return i;}function isValueInArray(v,a){var l=a.length;for(var i=0;i<l;i++){if(a[i][0]==v){return true;}}return false;}function setHeadersCss(table,$headers,list,css){$headers.removeClass(css[0]).removeClass(css[1]);var h=[];$headers.each(function(offset){if(!this.sortDisabled){h[this.column]=$(this);}});var l=list.length;for(var i=0;i<l;i++){h[list[i][0]].addClass(css[list[i][1]]);}}function fixColumnWidth(table,$headers){var c=table.config;if(c.widthFixed){var colgroup=$('<colgroup>');$("tr:first td",table.tBodies[0]).each(function(){colgroup.append($('<col>').css('width',$(this).width()));});$(table).prepend(colgroup);};}function updateHeaderSortCount(table,sortList){var c=table.config,l=sortList.length;for(var i=0;i<l;i++){var s=sortList[i],o=c.headerList[s[0]];o.count=s[1];o.count++;}}function multisort(table,sortList,cache){if(table.config.debug){var sortTime=new Date();}var dynamicExp="var sortWrapper = function(a,b) {",l=sortList.length;for(var i=0;i<l;i++){var c=sortList[i][0];var order=sortList[i][1];var s=(getCachedSortType(table.config.parsers,c)=="text")?((order==0)?"sortText":"sortTextDesc"):((order==0)?"sortNumeric":"sortNumericDesc");var e="e"+i;dynamicExp+="var "+e+" = "+s+"(a["+c+"],b["+c+"]); ";dynamicExp+="if("+e+") { return "+e+"; } ";dynamicExp+="else { ";}var orgOrderCol=cache.normalized[0].length-1;dynamicExp+="return a["+orgOrderCol+"]-b["+orgOrderCol+"];";for(var i=0;i<l;i++){dynamicExp+="}; ";}dynamicExp+="return 0; ";dynamicExp+="}; ";eval(dynamicExp);cache.normalized.sort(sortWrapper);if(table.config.debug){benchmark("Sorting on "+sortList.toString()+" and dir "+order+" time:",sortTime);}return cache;};function sortText(a,b){return((a<b)?-1:((a>b)?1:0));};function sortTextDesc(a,b){return((b<a)?-1:((b>a)?1:0));};function sortNumeric(a,b){return a-b;};function sortNumericDesc(a,b){return b-a;};function getCachedSortType(parsers,i){return parsers[i].type;};this.construct=function(settings){return this.each(function(){if(!this.tHead||!this.tBodies)return;var $this,$document,$headers,cache,config,shiftDown=0,sortOrder;this.config={};config=$.extend(this.config,$.tablesorter.defaults,settings);$this=$(this);$headers=buildHeaders(this);this.config.parsers=buildParserCache(this,$headers);cache=buildCache(this);var sortCSS=[config.cssDesc,config.cssAsc];fixColumnWidth(this);$headers.click(function(e){$this.trigger("sortStart");var totalRows=($this[0].tBodies[0]&&$this[0].tBodies[0].rows.length)||0;if(!this.sortDisabled&&totalRows>0){var $cell=$(this);var i=this.column;this.order=this.count++%2;if(!e[config.sortMultiSortKey]){config.sortList=[];if(config.sortForce!=null){var a=config.sortForce;for(var j=0;j<a.length;j++){if(a[j][0]!=i){config.sortList.push(a[j]);}}}config.sortList.push([i,this.order]);}else{if(isValueInArray(i,config.sortList)){for(var j=0;j<config.sortList.length;j++){var s=config.sortList[j],o=config.headerList[s[0]];if(s[0]==i){o.count=s[1];o.count++;s[1]=o.count%2;}}}else{config.sortList.push([i,this.order]);}};setTimeout(function(){setHeadersCss($this[0],$headers,config.sortList,sortCSS);appendToTable($this[0],multisort($this[0],config.sortList,cache));},1);return false;}}).mousedown(function(){if(config.cancelSelection){this.onselectstart=function(){return false};return false;}});$this.bind("update",function(){this.config.parsers=buildParserCache(this,$headers);cache=buildCache(this);}).bind("sorton",function(e,list){$(this).trigger("sortStart");config.sortList=list;var sortList=config.sortList;updateHeaderSortCount(this,sortList);setHeadersCss(this,$headers,sortList,sortCSS);appendToTable(this,multisort(this,sortList,cache));}).bind("appendCache",function(){appendToTable(this,cache);}).bind("applyWidgetId",function(e,id){getWidgetById(id).format(this);}).bind("applyWidgets",function(){applyWidget(this);});if($.metadata&&($(this).metadata()&&$(this).metadata().sortlist)){config.sortList=$(this).metadata().sortlist;}if(config.sortList.length>0){$this.trigger("sorton",[config.sortList]);}applyWidget(this);});};this.addParser=function(parser){var l=parsers.length,a=true;for(var i=0;i<l;i++){if(parsers[i].id.toLowerCase()==parser.id.toLowerCase()){a=false;}}if(a){parsers.push(parser);};};this.addWidget=function(widget){widgets.push(widget);};this.formatFloat=function(s){var i=parseFloat(s);return(isNaN(i))?0:i;};this.formatInt=function(s){var i=parseInt(s);return(isNaN(i))?0:i;};this.isDigit=function(s,config){var DECIMAL='\\'+config.decimal;var exp='/(^[+]?0('+DECIMAL+'0+)?$)|(^([-+]?[1-9][0-9]*)$)|(^([-+]?((0?|[1-9][0-9]*)'+DECIMAL+'(0*[1-9][0-9]*)))$)|(^[-+]?[1-9]+[0-9]*'+DECIMAL+'0+$)/';return RegExp(exp).test($.trim(s));};this.clearTableBody=function(table){if($.browser.msie){function empty(){while(this.firstChild)this.removeChild(this.firstChild);}empty.apply(table.tBodies[0]);}else{table.tBodies[0].innerHTML="";}};}});$.fn.extend({tablesorter:$.tablesorter.construct});var ts=$.tablesorter;ts.addParser({id:"text",is:function(s){return true;},format:function(s){return $.trim(s.toLowerCase());},type:"text"});ts.addParser({id:"digit",is:function(s,table){var c=table.config;return $.tablesorter.isDigit(s,c);},format:function(s){return $.tablesorter.formatFloat(s);},type:"numeric"});ts.addParser({id:"currency",is:function(s){return/^[£$€?.]/.test(s);},format:function(s){return $.tablesorter.formatFloat(s.replace(new RegExp(/[^0-9.]/g),""));},type:"numeric"});ts.addParser({id:"ipAddress",is:function(s){return/^\d{2,3}[\.]\d{2,3}[\.]\d{2,3}[\.]\d{2,3}$/.test(s);},format:function(s){var a=s.split("."),r="",l=a.length;for(var i=0;i<l;i++){var item=a[i];if(item.length==2){r+="0"+item;}else{r+=item;}}return $.tablesorter.formatFloat(r);},type:"numeric"});ts.addParser({id:"url",is:function(s){return/^(https?|ftp|file):\/\/$/.test(s);},format:function(s){return jQuery.trim(s.replace(new RegExp(/(https?|ftp|file):\/\//),''));},type:"text"});ts.addParser({id:"isoDate",is:function(s){return/^\d{4}[\/-]\d{1,2}[\/-]\d{1,2}$/.test(s);},format:function(s){return $.tablesorter.formatFloat((s!="")?new Date(s.replace(new RegExp(/-/g),"/")).getTime():"0");},type:"numeric"});ts.addParser({id:"percent",is:function(s){return/\%$/.test($.trim(s));},format:function(s){return $.tablesorter.formatFloat(s.replace(new RegExp(/%/g),""));},type:"numeric"});ts.addParser({id:"usLongDate",is:function(s){return s.match(new 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(s){return $.tablesorter.formatFloat(new Date(s).getTime());},type:"numeric"});ts.addParser({id:"shortDate",is:function(s){return/\d{1,2}[\/\-]\d{1,2}[\/\-]\d{2,4}/.test(s);},format:function(s,table){var c=table.config;s=s.replace(/\-/g,"/");if(c.dateFormat=="us"){s=s.replace(/(\d{1,2})[\/\-](\d{1,2})[\/\-](\d{4})/,"$3/$1/$2");}else if(c.dateFormat=="uk"){s=s.replace(/(\d{1,2})[\/\-](\d{1,2})[\/\-](\d{4})/,"$3/$2/$1");}else if(c.dateFormat=="dd/mm/yy"||c.dateFormat=="dd-mm-yy"){s=s.replace(/(\d{1,2})[\/\-](\d{1,2})[\/\-](\d{2})/,"$1/$2/$3");}return $.tablesorter.formatFloat(new Date(s).getTime());},type:"numeric"});ts.addParser({id:"time",is:function(s){return/^(([0-2]?[0-9]:[0-5][0-9])|([0-1]?[0-9]:[0-5][0-9]\s(am|pm)))$/.test(s);},format:function(s){return $.tablesorter.formatFloat(new Date("2000/01/01 "+s).getTime());},type:"numeric"});ts.addParser({id:"metadata",is:function(s){return false;},format:function(s,table,cell){var c=table.config,p=(!c.parserMetadataName)?'sortValue':c.parserMetadataName;return $(cell).metadata()[p];},type:"numeric"});ts.addWidget({id:"zebra",format:function(table){if(table.config.debug){var time=new Date();}$("tr:visible",table.tBodies[0]).filter(':even').removeClass(table.config.widgetZebra.css[1]).addClass(table.config.widgetZebra.css[0]).end().filter(':odd').removeClass(table.config.widgetZebra.css[0]).addClass(table.config.widgetZebra.css[1]);if(table.config.debug){$.tablesorter.benchmark("Applying Zebra widget",time);}}});})(jQuery);
(function($) {
	$.extend({
		tablesorterPager: new function() {
			
			function updatePageDisplay(c) {
				var s = $(c.cssPageDisplay,c.container).val((c.page+1) + c.seperator + c.totalPages);	
			}
			
			function setPageSize(table,size) {
				var c = table.config;
				c.size = size;
				c.totalPages = Math.ceil(c.totalRows / c.size);
				c.pagerPositionSet = false;
				moveToPage(table);
				fixPosition(table);
			}
			
			function fixPosition(table) {
				var c = table.config;
				if(!c.pagerPositionSet && c.positionFixed) {
					var c = table.config, o = $(table);
					if(o.offset) {
						c.container.css({
							top: o.offset().top + o.height() + 'px',
							position: 'absolute'
						});
					}
					c.pagerPositionSet = true;
				}
			}
			
			function moveToFirstPage(table) {
				var c = table.config;
				c.page = 0;
				moveToPage(table);
			}
			
			function moveToLastPage(table) {
				var c = table.config;
				c.page = (c.totalPages-1);
				moveToPage(table);
			}
			
			function moveToNextPage(table) {
				var c = table.config;
				c.page++;
				if(c.page >= (c.totalPages-1)) {
					c.page = (c.totalPages-1);
				}
				moveToPage(table);
			}
			
			function moveToPrevPage(table) {
				var c = table.config;
				c.page--;
				if(c.page <= 0) {
					c.page = 0;
				}
				moveToPage(table);
			}
						
			
			function moveToPage(table) {
				var c = table.config;
				if(c.page < 0 || c.page > (c.totalPages-1)) {
					c.page = 0;
				}
				
				renderTable(table,c.rowsCopy);
			}
			
			function renderTable(table,rows) {
				
				var c = table.config;
				var l = rows.length;
				var s = (c.page * c.size);
				var e = (s + c.size);
				if(e > rows.length ) {
					e = rows.length;
				}
				
				
				var tableBody = $(table.tBodies[0]);
				
				// clear the table body
				
				$.tablesorter.clearTableBody(table);
				
				for(var i = s; i < e; i++) {
					
					//tableBody.append(rows[i]);
					
					var o = rows[i];
					var l = o.length;
					for(var j=0; j < l; j++) {
						
						tableBody[0].appendChild(o[j]);

					}
				}
				
				fixPosition(table,tableBody);
				
				$(table).trigger("applyWidgets");
				
				if( c.page >= c.totalPages ) {
        			moveToLastPage(table);
				}
				
				updatePageDisplay(c);
			}
			
			this.appender = function(table,rows) {
				
				var c = table.config;
				
				c.rowsCopy = rows;
				c.totalRows = rows.length;
				c.totalPages = Math.ceil(c.totalRows / c.size);
				
				renderTable(table,rows);
			};
			
			this.defaults = {
				size: 10,
				offset: 0,
				page: 0,
				totalRows: 0,
				totalPages: 0,
				container: null,
				cssNext: '.next',
				cssPrev: '.prev',
				cssFirst: '.first',
				cssLast: '.last',
				cssPageDisplay: '.pagedisplay',
				cssPageSize: '.pagesize',
				seperator: "/",
				positionFixed: true,
				appender: this.appender
			};
			
			this.construct = function(settings) {
				
				return this.each(function() {	
					
					config = $.extend(this.config, $.tablesorterPager.defaults, settings);
					
					var table = this, pager = config.container;
				
					$(this).trigger("appendCache");
					
					config.size = parseInt($(".pagesize",pager).val());
					
					$(config.cssFirst,pager).click(function() {
						moveToFirstPage(table);
						return false;
					});
					$(config.cssNext,pager).click(function() {
						moveToNextPage(table);
						return false;
					});
					$(config.cssPrev,pager).click(function() {
						moveToPrevPage(table);
						return false;
					});
					$(config.cssLast,pager).click(function() {
						moveToLastPage(table);
						return false;
					});
					$(config.cssPageSize,pager).change(function() {
						setPageSize(table,parseInt($(this).val()));
						return false;
					});
				});
			};
			
		}
	});
	// extend plugin scope
	$.fn.extend({
        tablesorterPager: $.tablesorterPager.construct
	});
	
})(jQuery);
// <reference path="jQuery.js" />
function wwEditable(column, callback, options) {
    var _I = this;
    var _Ctl = column;            
    if (typeof(column)=="string")
        _Ctl = jQuery("#" + column)[0];    
             	    
    // options
    this.callback = callback;
    this.extraData = null;   
    this.textMode = "text";  
    this.updatedColor = null;
    
    // operationals
    this.origHtml = null;    
    this.origText = null;
    this.enteredText = null;            
    this.jcol = jQuery(_Ctl);     
    this.jedit = null;
    _Ctl.wwEditable = true;        

    if (options)
        jQuery.extend(this,options);
                   
    this.edit = function()
    {        
        if (callback)
          _I.callback = callback;
                   
          
        // *** Check if we're already editing and exit
        var jctl = jQuery("#__editColumn");
        if (jctl.length > 0)
            return;
                                
        _I.origHtml = _I.jcol.html();
        _I.origText = _I.jcol.text();
        if (_I.textMode == "text")       
            _I.jcol.html("<" +"form action='javascript:void(0);'><input id='__editColumn' value='" + _I.jcol.text() + "' style='width:" + _I.jcol.css("width") + "' /></form>");
        else
            _I.jcol.html("<" + "form action='javascript:void(0);'><textarea id='__editColumn' style='width:" + _I.jcol.css("width") + "'>" +  _I.jcol.text() + "</textarea></form>");
        
        // *** Select and focus the new input control
        var jctl = jQuery("#__editColumn");
        _I.jedit = jctl;        
        setTimeout( function() { jctl[0].focus() },50);

        jctl.keydown(_I._keyDownHandler);
        _I._bindBlur();
    }
    this.update = function() {           
        if (_I.jedit == null)
          return; 
        
        _I.jedit.remove();    
        _I.jedit = null;          
              
        if (_I.origHtml.toLowerCase().substr(0,2) == "<a") {
            _I.jcol.html(_I.origHtml);            
            var c = _I.jcol.find("a");
            _I.jcol.find("a").text(_I.enteredText);
        }
        else
            _I.jcol.text(_I.enteredText);        
                
        if (_I.updatedColor)
           _I.jcol.prepend("<div style='float: right;background:" + _I.updatedColor + ";height: 5px; width: 5px;'></div>");
                        
        _I.origHtml = _I.jcol.html();
    }
    this.abort = function()
    {    
        _I.jedit.remove();        
        _I.jedit == null;
        _I.jcol.html(_I.origHtml);                    
    }
    this.nextColumn = function(jcols)
    {
          if (!jcols)
            jcols = _I.jcol.find("~td");
            
          if (jcols.length>0)
          {
              for(var x=0;x<jcols.length;x++) {
                var jitem = jQuery(jcols[x]);
                if (jitem[0].wwEditable) {
                    jitem.trigger("click");
                    break;
                }
              }
          }
          else{                 
            var row = _I.jcol.parent().find("+tr");                    
            if (row.length > 0)
               _I.nextColumn(row.find(">td"));  
         }
    }
    this._updateHandler=function(event)
    {                                    
        _I.enteredText = _I.jedit.val();     
        _I._bindBlur(true);
        var res = null;        
        if (_I.callback) {                               
           res = _I.callback(_I.enteredText,_I)
           if (res==false) _I.abort(); 
           if (res) _I.update();           
        }                 
        _I._bindBlur();                          
    }
    this._bindBlur = function(unbind)
    {
        if (unbind)
            _I.jedit.unbind("blur",_I._updateHandler);
        else
          // MF - protection against err
           {if (_I.jedit != null)
            _I.jedit.bind("blur",_I._updateHandler);}
    }
    this._keyDownHandler = function(event)
    {                                     
        if (event.keyCode == 27)
            {_I.abort(); return;}
        if (event.keyCode == 13){ 
            if (_I.textMode!="multiline"){
                _I._updateHandler();
                _I.nextColumn();
                return false;
            } 
        }                      
        if (event.keyCode == 9 && event.shiftKey) {
            _I._updateHandler();                 
             var prev = _I.jcol[0].previousSibling;
             if (prev)
                   jQuery(prev).trigger("click");              
             return false;             
        }
        if (event.keyCode == 9) {            
            _I._updateHandler();
            _I.nextColumn()
            return false;                                                                                                       
        }    
    }
}

// Hook up as jQuery plug-in
// static object
jQuery.editable = 
{
    makeEditable:  function(selector, callback, options)
    {            
        var s = jQuery(selector);
        if (s.length < 1)
           return;
        
        s.each( function(index) {          
            var jitem = jQuery(this);        
            this.wwEditable = true;
            jitem.click(function(event) {new wwEditable(this,callback,options).edit(); return true; } );                    
        } );    
        return s;
    },
    makeTableEditable: function(selector,callback,options)
    {
        var s = jQuery(selector);
        if (s.length < 1)
           return;    
        this.makeEditable(s.find("td"),callback,options);    
        return s;
    }
}

// jQuery selector function extensions
jQuery.fn.makeEditable = function(callback,options)
{
    return jQuery.editable.makeEditable(this,callback,options);
}
jQuery.fn.makeTableEditable = function(callback,options)
{
   return jQuery.editable.makeTableEditable(this,callback,options);
};
eval(function(p,a,c,k,e,r){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('(5($){$.K.w=5(b,c){2(3.7==0)6;2(14 b==\'15\'){c=(14 c==\'15\')?c:b;6 3.L(5(){2(3.M){3.N();3.M(b,c)}v 2(3.17){4 a=3.17();a.1x(O);a.1y(\'P\',c);a.18(\'P\',b);a.1z()}})}v{2(3[0].M){b=3[0].1A;c=3[0].1B}v 2(Q.R&&Q.R.19){4 d=Q.R.19();b=0-d.1C().18(\'P\',-1D);c=b+d.1E.7}6{t:b,S:c}}};4 q={\'9\':"[0-9]",\'a\':"[A-T-z]",\'*\':"[A-T-1a-9]"};$.1b={1F:5(c,r){q[c]=r}};$.K.U=5(){6 3.1G("U")};$.K.1b=5(m,n){n=$.1H({C:"1I",V:B},n);4 o=D W("^"+$.1J(m.1c(""),5(c,i){6 q[c]||((/[A-T-1a-9]/.1d(c)?"":"\\\\")+c)}).1e(\'\')+"$");6 3.L(5(){4 d=$(3);4 f=D 1f(m.7);4 g=D 1f(m.7);4 h=u;4 j=u;4 l=B;$.L(m.1c(""),5(i,c){g[i]=(q[c]==B);f[i]=g[i]?c:n.C;2(!g[i]&&l==B)l=i});5 X(){x();y();1g(5(){$(d[0]).w(h?m.7:l)},0)};5 Y(e){4 a=$(3).w();4 k=e.Z;j=(k<16||(k>16&&k<10)||(k>10&&k<1h));2((a.t-a.S)!=0&&(!j||k==8||k==1i)){E(a.t,a.S)}2(k==8){11(a.t-->=0){2(!g[a.t]){f[a.t]=n.C;2($.F.1K){s=y();d.G(s.1j(0,a.t)+" "+s.1j(a.t));$(3).w(a.t+1)}v{y();$(3).w(1k.1l(l,a.t))}6 u}}}v 2(k==1i){E(a.t,a.t+1);y();$(3).w(1k.1l(l,a.t));6 u}v 2(k==1L){E(0,m.7);y();$(3).w(l);6 u}};5 12(e){2(j){j=u;6(e.Z==8)?u:B}e=e||1M.1N;4 k=e.1O||e.Z||e.1P;4 a=$(3).w();2(e.1Q||e.1R){6 O}v 2((k>=1h&&k<=1S)||k==10||k>1T){4 p=13(a.t-1);2(p<m.7){2(D W(q[m.H(p)]).1d(1m.1n(k))){f[p]=1m.1n(k);y();4 b=13(p);$(3).w(b);2(n.V&&b==m.7)n.V.1U(d)}}}6 u};5 E(a,b){1o(4 i=a;i<b&&i<m.7;i++){2(!g[i])f[i]=n.C}};5 y(){6 d.G(f.1e(\'\')).G()};5 x(){4 a=d.G();4 b=0;1o(4 i=0;i<m.7;i++){2(!g[i]){f[i]=n.C;11(b++<a.7){4 c=D W(q[m.H(i)]);2(a.H(b-1).1p(c)){f[i]=a.H(b-1);1V}}}}4 s=y();2(!s.1p(o)){d.G("");E(0,m.7);h=u}v h=O};5 13(a){11(++a<m.7){2(!g[a])6 a}6 m.7};d.1W("U",5(){d.I("N",X);d.I("1q",x);d.I("1r",Y);d.I("1s",12);2($.F.1t)3.1u=B;v 2($.F.1v)3.1X(\'1w\',x,u)});d.J("N",X);d.J("1q",x);d.J("1r",Y);d.J("1s",12);2($.F.1t)3.1u=5(){1g(x,0)};v 2($.F.1v)3.1Y(\'1w\',x,u);x()})}})(1Z);',62,124,'||if|this|var|function|return|length||||||||||||||||||||||begin|false|else|caret|checkVal|writeBuffer|||null|placeholder|new|clearBuffer|browser|val|charAt|unbind|bind|fn|each|setSelectionRange|focus|true|character|document|selection|end|Za|unmask|completed|RegExp|focusEvent|keydownEvent|keyCode|32|while|keypressEvent|seekNext|typeof|number||createTextRange|moveStart|createRange|z0|mask|split|test|join|Array|setTimeout|41|46|substring|Math|max|String|fromCharCode|for|match|blur|keydown|keypress|msie|onpaste|mozilla|input|collapse|moveEnd|select|selectionStart|selectionEnd|duplicate|100000|text|addPlaceholder|trigger|extend|_|map|opera|27|window|event|charCode|which|ctrlKey|altKey|122|186|call|break|one|removeEventListener|addEventListener|jQuery'.split('|'),0,{}));
eval(function(p,a,c,k,e,d){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--){d[e(c)]=k[c]||e(c)}k=[function(e){return d[e]}];e=function(){return'\\w+'};c=1};while(c--){if(k[c]){p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c])}}return p}('t=(8($){8 t(1q,m){f(1w(m)!="2s")m={};$.2t(5,t.1r,m);5.g=$(1q);5.1Q("N","F","O","C","Z","12");5.1t();5.C();5.F()};t.1r={1d:["2r","2q","2m","2n","1s","2o","2p","2v","2w","2D","2E","2F"],1e:["2C","2B","2x","2l","1s","2z","2A","2G","2d","28","27","2a"],18:["2k","2c","2j","2h","2g","2f","2i"],A:1};t.2e={1t:8(){5.1c=$(\'<1I u="H"></1I>\');b 1v=$(\'<p u="29"></p>\').I($(\'<a 1f="#" u="2b">&26;</a>\').G(5.Z)," ",5.1c," ",$(\'<a 1f="#" u="2y">&2O;</a>\').G(5.12));b V="<1C><1H><U>";$(5.24(5.18)).22(8(){V+="<1u>"+5+"</1u>"});V+="</U></1H><o></o></1C>";5.q=5.z=$(\'<1B u="34"></1B>\').I(1v,V).2H(1i.10);f($.1x.31&&$.1x.30<7){5.M=$(\'<1y u="36" 35="0" 3b="#"></1y>\').39(5.q);5.z=5.z.38(5.M)};5.o=$("o",5.q);5.g.1F(5.J(8(){5.C()}))},Q:8(6){5.1l=k h(6.l(),6.e(),1);b v=5.v(6),Y=5.Y(6);b 1A=5.1R(v,Y);b w="";X(b i=0;i<=1A;i++){b n=k h(v.l(),v.e(),v.r()+i);f(5.21(n))w+="<U>";f(n.e()==6.e()){w+=\'<x 6="\'+5.E(n)+\'"><a 1f="#">\'+n.r()+\'</a></x>\'}1b{w+=\'<x u="2Y" 6="\'+5.E(n)+\'">\'+n.r()+\'</x>\'};f(5.20(n))w+="</U>"};5.1c.1z().I(5.1W(6)+" "+6.l());5.o.1z().I(w);$("a",5.o).G(5.J(8(j){5.C(5.1g($(j.1p).2M().2L("6")));5.F();9 16}));$("x[6="+5.E(k h())+"]",5.o).1G("2I")},C:8(6){f(1w(6)=="2K"){6=5.1g(5.g.1a())};f(6){5.2P=6;5.Q(6);b S=5.E(6);$(\'x[6=\'+S+\']\',5.o).1G("2Q");f(5.g.1a()!=S){5.g.1a(S).1F()}}1b{5.Q(k h())}},N:8(){5.z.P("1D","2V");5.1Z();5.g.1n("1o",5.N);$([1E,1i.10]).G(5.O)},F:8(){5.z.P("1D","2W");$([1E,1i.10]).1n("G",5.O);5.g.1o(5.N)},O:8(j){f(j.1p!=5.g[0]&&!5.1O(j)){5.F()}},1g:8(1J){b D;f(D=1J.32(/^(\\d{1,2}) ([^\\s]+) (\\d{4,4})$/)){9 k h(D[3],5.1T(D[2]),D[1])}1b{9 2S}},E:8(6){9 6.r()+" "+5.1e[6.e()]+" "+6.l()},1Z:8(){b c=5.g.c();5.z.P({L:c.L+5.g.14(),T:c.T});f(5.M){5.M.P({2R:5.q.1N(),2T:5.q.14()})}},1k:8(25){5.Q(k h(5.1l.2U(5.1l.e()+25)))},Z:8(){5.1k(-1);9 16},12:8(){5.1k(1);9 16},1W:8(6){9 5.1d[6.e()]},1O:8(j){b c=5.q.c();c.1K=c.T+5.q.1N();c.1X=c.L+5.q.14();9 j.1M<c.1X&&j.1M>c.L&&j.1L<c.1K&&j.1L>c.T},J:8(1m){b 1P=5;9 8(){9 1m.2J(1P,K)}},1Q:8(){X(b i=0;i<K.15;i++){5[K[i]]=5.J(5[K[i]])}},R:8(1h,1V){X(b i=0;i<1h.15;i++){f(1V==1h[i])9 i}},2N:8(H){9 5.R(5.1d,H)},1T:8(H){9 5.R(5.1e,H)},2X:8(1S){9 5.R(5.18,1S)},1R:8(B,y){B=h.1U(B.l(),B.e(),B.r());y=h.1U(y.l(),y.e(),y.r());9(y-B)/37},19:8(23,6,1j){b 1Y=1j*(3a.2Z(6.11()-23-(1j*7))%7);9 k h(6.l(),6.e(),6.r()+1Y)},v:8(6){9 5.19(5.A,k h(6.l(),6.e()),-1)},Y:8(6){9 5.19((5.A-1)%7,k h(6.l(),6.e()+1,0),1)},21:8(6){9 6.11()==5.A},20:8(6){9 6.11()==(5.A-1)%7},24:8(17){b 13=[];X(b i=0;i<17.15;i++){13[i]=17[(i+5.A)%7]};9 13}};$.1m.W=8(m){9 5.22(8(){k t(5,m)})};$.W={2u:8(m){$("g.W").W(m)}};9 t})(33);',62,198,'|||||this|date||function|return||var|offset||getMonth|if|input|Date||event|new|getFullYear|opts|currentDay|tbody||dateSelector|getDate||DateInput|class|rangeStart|dayCells|td|end|rootLayers|start_of_week|start|selectDate|matches|dateToString|hide|click|month_name|append|bindToObj|arguments|top|ieframe|show|hideIfClickOutside|css|selectMonth|indexFor|stringDate|left|tr|tableShell|date_input|for|rangeEnd|prevMonth|body|getDay|nextMonth|newDays|outerHeight|length|false|days|short_day_names|changeDayTo|val|else|monthNameSpan|month_names|short_month_names|href|stringToDate|array|document|direction|moveMonthBy|currentMonth|fn|unbind|focus|target|el|DEFAULT_OPTS|May|build|th|monthNav|typeof|browser|iframe|empty|numDays|div|table|display|window|change|addClass|thead|span|string|right|pageX|pageY|outerWidth|insideSelector|self|bindMethodsToObj|daysBetween|day_name|shortMonthNum|UTC|value|monthName|bottom|difference|setPosition|isLastDayOfWeek|isFirstDayOfWeek|each|to|adjustDays|amount|laquo|Nov|Oct|month_nav|Dec|prev|Mon|Sep|prototype|Fri|Thu|Wed|Sat|Tue|Sun|Apr|March|April|June|July|February|January|object|extend|initialize|August|September|Mar|next|Jun|Jul|Feb|Jan|October|November|December|Aug|appendTo|today|apply|undefined|attr|parent|monthNum|raquo|selectedDate|selected|width|null|height|setMonth|block|none|shortDayNum|unselected_month|abs|version|msie|match|jQuery|date_selector|frameborder|date_selector_ieframe|86400000|add|insertBefore|Math|src'.split('|'),0,{}));
/*
	 *	jquery.suggest 1.1 - 2007-08-06
	 *	
	 *	Uses code and techniques from following libraries:
	 *	1. http://www.dyve.net/jquery/?autocomplete
	 *	2. http://dev.jquery.com/browser/trunk/plugins/interface/iautocompleter.js	
	 *
	 *	All the new stuff written by Peter Vulgaris (www.vulgarisoip.com)	
	 *	Feel free to do whatever you want with this file
	 *
	 *  Script modified by M.Fitzgibbon, PRBO Conservation Science (see comments with "MF")
	 */

    // MF - suggestController will determine whether suggest should show or not
    var suggestController = 
    {
        suppress:true  
    };

	(function($) {

		$.suggest = function(input, options) {
	
			var $input = $(input).attr("autocomplete", "off");
			var $results = $(document.createElement("ul"));

			var timeout = false;		// hold timeout ID for suggestion results to appear	
			var prevLength = 0;			// last recorded length of $input.val()
			var cache = [];				// cache MRU list
			var cacheSize = 0;			// size of cache in chars (bytes?)
            
            var lastkey = 0;  // MF added
			
			$results.addClass(options.resultsClass).appendTo('body');
				

			resetPosition();
			$(window)
				.load(resetPosition)		// just in case user is changing size of page while loading
				.resize(resetPosition);

			$input.blur(function() {
				setTimeout(function() { $results.hide() }, 200);
			});
			
			
			// help IE users if possible
			try {
				$results.bgiframe();
			} catch(e) { }


			// I really hate browser detection, but I don't see any other way
			if ($.browser.mozilla)
				$input.keypress(processKey);	// onkeypress repeats arrow keys in Mozilla/Opera
			else
				$input.keydown(processKey);		// onkeydown repeats arrow keys in IE/Safari
			



			function resetPosition() {
				// requires jquery.dimension plugin
				var offset = $input.offset();
				$results.css({
					top: (offset.top + input.offsetHeight) + 'px',
					left: offset.left + 'px'
				});
			}
			
			
			function processKey(e) {
            
                lastkey = e.keyCode;
				
				// handling up/down/escape requires results to be visible
				// handling enter/tab requires that AND a result to be selected
				if ((/27$|38$|40$/.test(e.keyCode) && $results.is(':visible')) ||
					(/^13$|^9$/.test(e.keyCode) && getCurrentResult())) {
		            
		            if (e.preventDefault)
		                e.preventDefault();
					if (e.stopPropagation)
		                e.stopPropagation();

					e.cancelBubble = true;
					e.returnValue = false;
				
					switch(e.keyCode) {
	
						case 38: // up
							prevResult();
							break;
				
						case 40: // down
							nextResult();
							break;
	
						case 9:  // tab
						case 13: // return
							selectCurrentResult();
                            $results.hide();  // MF: added
							break;
							
						case 27: //	escape
							$results.hide();
							break;
	
					}
					
				} else if ($input.val().length != prevLength) {

					if (timeout) 
						clearTimeout(timeout);
					timeout = setTimeout(suggest, options.delay);
					prevLength = $input.val().length;
					
				}			
					
				
			}
			
			
			function suggest() {
			
				var q = $.trim($input.val());

				if (q.length >= options.minchars) {
					
					cached = checkCache(q);
					
					if (cached) {
					
						displayItems(cached['items']);
						
					} else {
					
						$.get(options.source, {q: q}, function(txt) {

							$results.hide();
							
							var items = parseTxt(txt, q);
							
							displayItems(items);
							addToCache(q, items, txt.length);
							
						});
						
					}
					
				} else {
				
					$results.hide();
					
				}
					
			}
			
			
			function checkCache(q) {

				for (var i = 0; i < cache.length; i++)
					if (cache[i]['q'] == q) {
						cache.unshift(cache.splice(i, 1)[0]);
						return cache[0];
					}
				
				return false;
			
			}
			
			function addToCache(q, items, size) {

				while (cache.length && (cacheSize + size > options.maxCacheSize)) {
					var cached = cache.pop();
					cacheSize -= cached['size'];
				}
				
				cache.push({
					q: q,
					size: size,
					items: items
					});
					
				cacheSize += size;
			
			}
			
			function displayItems(items) {
				
				if (!items)
					return;
					
				if (!items.length) {
					$results.hide();
					return;
				}
                
                // MF added
                if (lastkey == 9 || lastkey == 13)  {
                  return;
                }
                
				var html = '';
				for (var i = 0; i < items.length; i++)
					html += '<li>' + items[i] + '</li>';

				// MF - make results use suggestController object
				$results.html(html);
				if (suggestController.suppress === true)
				{
					$results.hide();
				}
				else
				{
					resetPosition();   // MF - added resetPosition call to deal with dynamically resized screen
				    $results.show();
					$results
						.children('li')
						.mouseover(function() {
							$results.children('li').removeClass(options.selectClass);
							$(this).addClass(options.selectClass);
						})
						.click(function(e) {
							e.preventDefault(); 
							e.stopPropagation();
							selectCurrentResult();
						});
				}					
							
			}
			
			function parseTxt(txt, q) {
				
				var items = [];
				var tokens = txt.split(options.delimiter);
				
				// parse returned data for non-empty items
				for (var i = 0; i < tokens.length; i++) {
					var token = $.trim(tokens[i]);
					if (token) {
						token = token.replace(
							new RegExp(q, 'ig'), 
							function(q) { return '<span class="' + options.matchClass + '">' + q + '</span>' }
							);
						items[items.length] = token;
					}
				}
				
				return items;
			}
			
			function getCurrentResult() {
			
				if (!$results.is(':visible'))
					return false;
			
				var $currentResult = $results.children('li.' + options.selectClass);
				
				if (!$currentResult.length)
					$currentResult = false;
					
				return $currentResult;

			}
			
			function selectCurrentResult() {
			
				$currentResult = getCurrentResult();
			
				if ($currentResult) {
					$input.val($currentResult.text());
					$results.hide();
					
					if (options.onSelect)
						options.onSelect.apply($input[0]);
						
				}
			
			}
			
			function nextResult() {
			
				$currentResult = getCurrentResult();
			
				if ($currentResult)
					$currentResult
						.removeClass(options.selectClass)
						.next()
							.addClass(options.selectClass);
				else
					$results.children('li:first-child').addClass(options.selectClass);
			
			}
			
			function prevResult() {
			
				$currentResult = getCurrentResult();
			
				if ($currentResult)
					$currentResult
						.removeClass(options.selectClass)
						.prev()
							.addClass(options.selectClass);
				else
					$results.children('li:last-child').addClass(options.selectClass);
			
			}
	
		}
		
		$.fn.suggest = function(source, options) {
		
			if (!source)
				return;
		
			options = options || {};
			options.source = source;
			options.delay = options.delay || 100;
			options.resultsClass = options.resultsClass || 'ac_results';
			options.selectClass = options.selectClass || 'ac_over';
			options.matchClass = options.matchClass || 'ac_match';
			options.minchars = options.minchars || 2;
			options.delimiter = options.delimiter || '\n';
			options.onSelect = options.onSelect || false;
			options.maxCacheSize = options.maxCacheSize || 65536;
	
			this.each(function() {
				new $.suggest(this, options);
			});
	
			return this;
			
		};
		
	})(jQuery);

