addEvent(window,"load",sortables_init);var SORT_COLUMN_INDEX;function sortables_init(){if(!document.getElementsByTagName){return}tbls=document.getElementsByTagName("table");for(ti=0;ti<tbls.length;ti++){thisTbl=tbls[ti];if(((" "+thisTbl.className+" ").indexOf("datagrid")!=-1)&&(thisTbl.id)){ts_makeSortable(thisTbl)}}}function ts_makeSortable(a){if(a.rows&&a.rows.length>0){var b=a.rows[0]}if(!b){return}}function ts_getInnerText(d){if(typeof d=="string"){return d}if(typeof d=="undefined"){return d}if(d.innerText){return d.innerText}var e="";var c=d.childNodes;var a=c.length;for(var b=0;b<a;b++){switch(c[b].nodeType){case 1:e+=ts_getInnerText(c[b]);break;case 3:e+=c[b].nodeValue;break}}return e}function ts_resortTable(h,l){var n;for(var p=0;p<h.childNodes.length;p++){if(h.childNodes[p].tagName&&h.childNodes[p].tagName.toLowerCase()=="span"){n=h.childNodes[p]}}n=h;var a=ts_getInnerText(n);var c=h.parentNode;var d=l||c.cellIndex;var o=getParent(c,"TABLE");if(o.rows.length<=1){return}var k=ts_getInnerText(o.rows[1].cells[d]);sortfn=ts_sort_caseinsensitive;if(k.match(/^\d\d[\/-]\d\d[\/-]\d\d\d\d$/)){sortfn=ts_sort_date}if(k.match(/^\d\d[\/-]\d\d[\/-]\d\d$/)){sortfn=ts_sort_date}if(k.match(/^[�$]/)){sortfn=ts_sort_currency}if(k.match(/^[\d\.]+$/)){sortfn=ts_sort_numeric}SORT_COLUMN_INDEX=d;var e=new Array();var g=new Array();for(i=0;i<o.rows[0].length;i++){e[i]=o.rows[0][i]}for(j=1;j<o.rows.length;j++){g[j-1]=o.rows[j]}g.sort(sortfn);var f="&nbsp;&uarr;";var b="&nbsp;&darr;";if(n.getAttribute("origText")==null){n.setAttribute("origText",a)}if(n.getAttribute("sortdir")=="down"){ARROW=f;g.reverse();n.setAttribute("sortdir","up")}else{ARROW=b;n.setAttribute("sortdir","down")}for(i=0;i<g.length;i++){if(!g[i].className||(g[i].className&&(g[i].className.indexOf("sortbottom")==-1))){o.tBodies[0].appendChild(g[i])}}for(i=0;i<g.length;i++){if(g[i].className&&(g[i].className.indexOf("sortbottom")!=-1)){o.tBodies[0].appendChild(g[i])}}var m=document.getElementsByTagName("span");for(var p=0;p<m.length;p++){if(m[p].className=="sortarrow"){if(getParent(m[p],"table")==getParent(h,"table")){m[p].innerHTML="&nbsp;&nbsp;&nbsp;"}}}n.innerHTML=n.getAttribute("origText")+ARROW}function getParent(b,a){if(b==null){return null}else{if(b.nodeType==1&&b.tagName.toLowerCase()==a.toLowerCase()){return b}else{return getParent(b.parentNode,a)}}}function ts_sort_date(d,c){aa=ts_getInnerText(d.cells[SORT_COLUMN_INDEX]);bb=ts_getInnerText(c.cells[SORT_COLUMN_INDEX]);if(aa.length==10){dt1=aa.substr(6,4)+aa.substr(3,2)+aa.substr(0,2)}else{yr=aa.substr(6,2);if(parseInt(yr)<50){yr="20"+yr}else{yr="19"+yr}dt1=yr+aa.substr(3,2)+aa.substr(0,2)}if(bb.length==10){dt2=bb.substr(6,4)+bb.substr(3,2)+bb.substr(0,2)}else{yr=bb.substr(6,2);if(parseInt(yr)<50){yr="20"+yr}else{yr="19"+yr}dt2=yr+bb.substr(3,2)+bb.substr(0,2)}if(dt1==dt2){return 0}if(dt1<dt2){return -1}return 1}function ts_sort_currency(d,c){aa=ts_getInnerText(d.cells[SORT_COLUMN_INDEX]).replace(/[^0-9.]/g,"");bb=ts_getInnerText(c.cells[SORT_COLUMN_INDEX]).replace(/[^0-9.]/g,"");return parseFloat(aa)-parseFloat(bb)}function ts_sort_numeric(d,c){aa=parseFloat(ts_getInnerText(d.cells[SORT_COLUMN_INDEX]));if(isNaN(aa)){aa=0}bb=parseFloat(ts_getInnerText(c.cells[SORT_COLUMN_INDEX]));if(isNaN(bb)){bb=0}return aa-bb}function ts_sort_caseinsensitive(d,c){aa=ts_getInnerText(d.cells[SORT_COLUMN_INDEX]).toLowerCase();bb=ts_getInnerText(c.cells[SORT_COLUMN_INDEX]).toLowerCase();if(aa==bb){return 0}if(aa<bb){return -1}return 1}function ts_sort_default(d,c){aa=ts_getInnerText(d.cells[SORT_COLUMN_INDEX]);bb=ts_getInnerText(c.cells[SORT_COLUMN_INDEX]);if(aa==bb){return 0}if(aa<bb){return -1}return 1}function addEvent(e,d,b,a){if(e.addEventListener){e.addEventListener(d,b,a);return true}else{if(e.attachEvent){var c=e.attachEvent("on"+d,b);return c}else{alert("Handler could not be removed")}}};