var SORT_COLUMN_INDEX;function table_stripe(b){var a=["rowEven","rowOdd"];b.select("tbody tr").each(function(d){d.removeClassName(a[1]);d.addClassName(a[0]);a.reverse(true)})}function table_makeSortable(b){var a=0;b.down("tr").childElements().each(function(c){if(c.hasClassName("nosort")){++a;return}c.setAttribute("columnIndex",a++);c.setStyle({cursor:"pointer"});c.observe("click",function(f){var g=f.findElement("th");f.stop();var d=g.down("a");if(d&&!d.hasClassName("sortlink")){return true}table_resortTable(g);return false})})}function table_getSortValue(a){var b="";if(Object.isString(a)||Object.isUndefined(a)){return a}a=$(a);if(a.readAttribute("sortval")){return a.readAttribute("sortval")}if(a.innerText){return a.innerText}$A(a.childNodes).each(function(c){switch(c.nodeType){case 1:b+=table_getSortValue(c);break;case 3:b+=c.nodeValue;break}});return b}function table_resortTable(d){var c=d.up("table"),e=d.up().childElements(),b,a=0;e.each(function(g){if(d==g){if(g.hasClassName("sortup")){g.removeClassName("sortup");g.addClassName("sortdown")}else{if(g.hasClassName("sortdown")){g.removeClassName("sortdown");g.addClassName("sortup");a=1}else{g.addClassName("sortdown")}}}else{g.removeClassName("sortup");g.removeClassName("sortdown")}});if(e.size()<=1){return}SORT_COLUMN_INDEX=d.readAttribute("columnIndex");var f=table_getSortValue(c.down("tbody > tr").cells[SORT_COLUMN_INDEX]);if(f.match(/^\d\d[\/-]\d\d[\/-]\d\d\d\d$/)||f.match(/^\d\d[\/-]\d\d[\/-]\d\d$/)){b=table_sort_date}else{if(f.match(/^[�$]/)){b=table_sort_currency}else{if(f.match(/^[\d\.]+$/)){b=table_sort_numeric}else{b=table_sort_caseinsensitive}}}$A(c.getElementsByTagName("tbody")).each(function(h){var g=[],i=$A(h.getElementsByTagName("tr"));i.sort(b);if(a){i.reverse()}i.each(function(j){if(j.hasClassName("sortbottom")){g.push(j)}else{h.appendChild(j)}});g.each(function(j){h.appendChild(j)})});if(c.hasClassName("striped")){table_stripe(c)}if(typeof table_sortCallback!="undefined"&&Object.isFunction(table_sortCallback)){table_sortCallback(c.id,d.id,a)}}function table_sort_date(e,c){var h=table_getSortValue(e.cells[SORT_COLUMN_INDEX]),i=table_getSortValue(c.cells[SORT_COLUMN_INDEX]),f,d,g;if(h.length==10){f=h.substr(6,4)+h.substr(3,2)+h.substr(0,2)}else{g=h.substr(6,2);if(parseInt(g)<50){g="20"+g}else{g="19"+g}f=g+h.substr(3,2)+h.substr(0,2)}if(i.length==10){d=i.substr(6,4)+i.substr(3,2)+i.substr(0,2)}else{g=i.substr(6,2);if(parseInt(g)<50){g="20"+g}else{g="19"+g}d=g+i.substr(3,2)+i.substr(0,2)}if(f==d){return 0}else{if(f<d){return-1}}return 1}function table_sort_currency(d,c){var e=table_getSortValue(d.cells[SORT_COLUMN_INDEX]).replace(/[^0-9.]/g,""),f=table_getSortValue(c.cells[SORT_COLUMN_INDEX]).replace(/[^0-9.]/g,"");return parseFloat(e)-parseFloat(f)}function table_sort_numeric(d,c){var e=parseFloat(table_getSortValue(d.cells[SORT_COLUMN_INDEX]));if(isNaN(e)){e=0}var f=parseFloat(table_getSortValue(c.cells[SORT_COLUMN_INDEX]));if(isNaN(f)){f=0}return e-f}function table_sort_caseinsensitive(d,c){var e=table_getSortValue(d.cells[SORT_COLUMN_INDEX]).toLowerCase(),f=table_getSortValue(c.cells[SORT_COLUMN_INDEX]).toLowerCase();if(e==f){return 0}else{if(e<f){return-1}}return 1}function table_sort_default(d,c){var e=table_getSortValue(d.cells[SORT_COLUMN_INDEX]),f=table_getSortValue(c.cells[SORT_COLUMN_INDEX]);if(e==f){return 0}else{if(e<f){return-1}}return 1}document.observe("dom:loaded",function(){$$("table.striped").each(table_stripe);$$("table.sortable").each(table_makeSortable)});