var poGridInstance=null;var PioenPartners_JS_Grid={_lnSorted:0,initGrid:function(lcGrid){var loGrid=document.getElementById(lcGrid);var loBody=document.getElementById(lcGrid+"Body");var loHeader=document.getElementById(lcGrid+"Header");this._disableSelect(loBody);this._disableSelect(loHeader);try{if(loGrid.style.width.indexOf("%")==-1){loBody.style.height=(parseInt(loGrid.style.height)-21)+"px";loBody.style.width=(parseInt(loGrid.style.width))+"px";}else{}}catch(e){}
poGridInstance=this;this._cleanNodes(loGrid)
var loRow=loHeader.getElementsByTagName("div")[0];var lnColumns=loRow.getElementsByTagName("div").length;for(var lnI=0;lnI<lnColumns;lnI++){var loColumn=loRow.getElementsByTagName("div")[lnI];loColumn.onclick=new Function("document.getElementById('"+lcGrid+"Wait').style.visibility = 'visible'; setTimeout(\"PioenPartners_JS_Grid.doSort('"+lcGrid+"', "+lnI+");\", 100);");loColumn.className='OrderNone';}
this._showLines(loBody);},chromeFix:function(lcGrid){var loGrid=document.getElementById(lcGrid);var loBody=document.getElementById(lcGrid+"Body");var laRows=new Array();var lnRows=loBody.getElementsByTagName("div").length;for(var lnI=0;lnI<lnRows;lnI++){if(loBody.getElementsByTagName("div")[lnI].className!="PPGridColumn"){laRows.push(loBody.getElementsByTagName("div")[lnI]);}}
var lnRows=laRows.length;for(var lnI=0;lnI<lnRows;lnI++){loBody.appendChild(laRows[lnI]);}},doSort:function(lcGrid,lnIndex){var loBody=document.getElementById(lcGrid+"Body");var loHeader=document.getElementById(lcGrid+"Header");document.getElementById(lcGrid+"Wait").style.visibility="visible";this._lnSorted=lnIndex;var loRow=loHeader.getElementsByTagName("div")[0];var loColumn=loRow.getElementsByTagName("div")[lnIndex];var lcOrder='ASC';switch(loColumn.className){case'OrderASC':loColumn.className='OrderDESC';lcOrder='DESC'
break;case'OrderDESC':loColumn.className='OrderASC';break;case'OrderNone':loColumn.className='OrderASC';break;}
var lnColumns=loRow.getElementsByTagName("div").length;for(lnI=0;lnI<lnColumns;lnI++){if(lnI!=lnIndex){loRow.getElementsByTagName("div")[lnI].className='OrderNone';}}
var laRows=new Array();var lnRows=loBody.getElementsByTagName("div").length;for(var lnI=0;lnI<lnRows;lnI++){if(loBody.getElementsByTagName("div")[lnI].className!="PPGridColumn"){laRows.push(loBody.getElementsByTagName("div")[lnI]);}}
var lcType="String";var lnRows=laRows.length;for(var lnI=0;lnI<lnRows;lnI++){var luValue=this._getColumnValue(laRows[lnI].childNodes[lnIndex]);if(luValue.length!=0){if(luValue.match(/[0-9]{2}-[0-9]{2}-[0-9]{4} [0-9]{2}:[0-9]{2}/)){lcType="DateTime";}else if(luValue.match(/[0-9]{2}-[0-9]{2}-[0-9]{4} - [0-9]{2}:[0-9]{2}/)){lcType="DateTime";}else if(luValue.match(/[0-9]{2}-[0-9]{2}-[0-9]{4}/)){lcType="Date";}else if(!isNaN(luValue)){lcType="Numeric";}else{lcType="String";}
lnI=laRows.length;}}
if(lcType=="DateTime"){laRows.sort(this._doSortDateTime);}else if(lcType=="Date"){laRows.sort(this._doSortDate);}else if(lcType=="Numeric"){laRows.sort(this._doSortNumeric);}else{laRows.sort(this._doSortString);}
if(lcOrder=='DESC'){laRows.reverse();}
for(var lnI=0;lnI<lnRows;lnI++){loBody.appendChild(laRows[lnI]);}
document.getElementById(lcGrid+"Wait").style.visibility="hidden";this._showLines(loBody);},doFilter:function(lcGrid,lcFilterText){var loBody=document.getElementById(lcGrid+"Body");var lcFilterText=lcFilterText.toUpperCase();var lnRows=loBody.getElementsByTagName("div").length;for(var lnI=0;lnI<lnRows;lnI++){var loRow=loBody.getElementsByTagName("div")[lnI];if(loRow.className!="PPGridColumn"){var llFound=false;if(lcFilterText==""){llFound=true;}else{llFound=loRow.innerHTML.toUpperCase().indexOf(lcFilterText)!=-1;}
if(llFound==false){loRow.style.display="none";}else{loRow.style.display="block";}}}
this._showLines(loBody);},_doSortDateTime:function(loRowA,loRowB){var lcValueA=poGridInstance._getColumnValue(loRowA.childNodes[poGridInstance._lnSorted]).toLowerCase();var lcValueB=poGridInstance._getColumnValue(loRowB.childNodes[poGridInstance._lnSorted]).toLowerCase();lcValueA=lcValueA.replace(" - "," ");lcValueB=lcValueB.replace(" - "," ");var lnValueA=lcValueA.substr(6,4)+lcValueA.substr(3,2)+lcValueA.substr(0,2)+lcValueA.substr(11,2)+lcValueA.substr(14,2);var lnValueB=lcValueB.substr(6,4)+lcValueB.substr(3,2)+lcValueB.substr(0,2)+lcValueB.substr(11,2)+lcValueB.substr(14,2);if(lnValueA==lnValueB){return 0;}
if(lnValueA<lnValueB){return-1;}
return 1;},_doSortDate:function(loRowA,loRowB){var lcValueA=poGridInstance._getColumnValue(loRowA.childNodes[poGridInstance._lnSorted]).toLowerCase();var lcValueB=poGridInstance._getColumnValue(loRowB.childNodes[poGridInstance._lnSorted]).toLowerCase();var lnValueA=lcValueA.substr(6,4)+"-"+lcValueA.substr(3,2)+"-"+lcValueA.substr(0,2);var lnValueB=lcValueB.substr(6,4)+"-"+lcValueB.substr(3,2)+"-"+lcValueB.substr(0,2);if(lnValueA==lnValueB){return 0;}
if(lnValueA<lnValueB){return-1;}
return 1;},_doSortNumeric:function(loRowA,loRowB){var lnValueA=parseFloat(poGridInstance._getColumnValue(loRowA.childNodes[poGridInstance._lnSorted]));var lnValueB=parseFloat(poGridInstance._getColumnValue(loRowB.childNodes[poGridInstance._lnSorted]));if(lnValueA==lnValueB){return 0;}
if(lnValueA<lnValueB){return-1;}
return 1;},_doSortString:function(loRowA,loRowB){var lcValueA=poGridInstance._getColumnValue(loRowA.childNodes[poGridInstance._lnSorted]).toLowerCase();var lcValueB=poGridInstance._getColumnValue(loRowB.childNodes[poGridInstance._lnSorted]).toLowerCase();if(lcValueA==lcValueB){return 0;}
if(lcValueA<lcValueB){return-1;}
return 1;},_getColumnValue:function(loColumn){var luValue="";var laChildren=loColumn.childNodes;try{var lnChildren=laChildren.length;for(var lnI=0;lnI<lnChildren;lnI++){if(laChildren[lnI].tagName!="DIV"){if(laChildren[lnI].nodeValue.length!=0){luValue=laChildren[lnI].nodeValue;break;}}else{luValue=this._getColumnValue(laChildren[lnI].childNodes);}}}catch(e){}
return luValue;},_cleanNodes:function(loNode){var loExpr=/\S/;var lnNodes=loNode.childNodes.length;for(var lnI=0;lnI<lnNodes;lnI++){try{var loChildNode=loNode.childNodes[lnI];if(loChildNode.nodeType==3&&!loExpr.test(loChildNode.nodeValue)){loNode.removeChild(loNode.childNodes[lnI]);lnI--;}
if(loChildNode.nodeType==1){this._cleanNodes(loChildNode);}}catch(e){}}},_showLines:function(loBody){var lnShownRows=0;var lnRows=loBody.getElementsByTagName("div").length;for(var lnI=0;lnI<lnRows;lnI++){var loRow=loBody.getElementsByTagName("div")[lnI];if(loRow.className!="PPGridColumn"){if(loRow.style.display!="none"){if((lnShownRows%2)==0){loRow.className='Even';}else{loRow.className='Odd';}
lnShownRows++;}
loRow.onmouseover=function(){this.className='Hover';}
loRow.classOld=loRow.className;loRow.onmouseout=function(e){this.className=this.classOld;}}}},_disableSelect:function(loElement){loElement.onselectstart=function(){return false;};loElement.unselectable="on";loElement.style.MozUserSelect="none";loElement.style.cursor="default";}};
