var SORT_COLUMN_INDEX;function table_stripe(B){var A=["rowEven","rowOdd"];B.select("tbody tr").each(function(C){C.removeClassName(A[1]);C.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(E){var F=E.findElement("th");E.stop();var D=F.down("a");if(D&&!D.hasClassName("sortlink")){return true}table_resortTable(F);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(C,A){var F=table_getSortValue(C.cells[SORT_COLUMN_INDEX]),G=table_getSortValue(A.cells[SORT_COLUMN_INDEX]),D,B,E;if(F.length==10){D=F.substr(6,4)+F.substr(3,2)+F.substr(0,2)}else{E=F.substr(6,2);if(parseInt(E)<50){E="20"+E}else{E="19"+E}D=E+F.substr(3,2)+F.substr(0,2)}if(G.length==10){B=G.substr(6,4)+G.substr(3,2)+G.substr(0,2)}else{E=G.substr(6,2);if(parseInt(E)<50){E="20"+E}else{E="19"+E}B=E+G.substr(3,2)+G.substr(0,2)}if(D==B){return 0}else{if(D<B){return -1}}return 1}function table_sort_currency(B,A){var C=table_getSortValue(B.cells[SORT_COLUMN_INDEX]).replace(/[^0-9.]/g,""),D=table_getSortValue(A.cells[SORT_COLUMN_INDEX]).replace(/[^0-9.]/g,"");return parseFloat(C)-parseFloat(D)}function table_sort_numeric(B,A){var C=parseFloat(table_getSortValue(B.cells[SORT_COLUMN_INDEX]));if(isNaN(C)){C=0}var D=parseFloat(table_getSortValue(A.cells[SORT_COLUMN_INDEX]));if(isNaN(D)){D=0}return C-D}function table_sort_caseinsensitive(B,A){var C=table_getSortValue(B.cells[SORT_COLUMN_INDEX]).toLowerCase(),D=table_getSortValue(A.cells[SORT_COLUMN_INDEX]).toLowerCase();if(C==D){return 0}else{if(C<D){return -1}}return 1}function table_sort_default(B,A){var C=table_getSortValue(B.cells[SORT_COLUMN_INDEX]),D=table_getSortValue(A.cells[SORT_COLUMN_INDEX]);if(C==D){return 0}else{if(C<D){return -1}}return 1}document.observe("dom:loaded",function(){$$("table.striped").each(table_stripe);$$("table.sortable").each(table_makeSortable)});