/*
 * Ext JS Library 1.1.1
 * Copyright(c) 2006-2007, Ext JS, LLC.
 * licensing@extjs.com
 * 
 * http://www.extjs.com/license
 */

Ext.grid.Grid=function(A,B){this.container=Ext.get(A);this.container.update("");this.container.setStyle("overflow","hidden");this.container.addClass("x-grid-container");this.id=this.container.id;Ext.apply(this,B);if(this.ds){this.dataSource=this.ds;delete this.ds}if(this.cm){this.colModel=this.cm;delete this.cm}if(this.sm){this.selModel=this.sm;delete this.sm}if(this.width){this.container.setWidth(this.width)}if(this.height){this.container.setHeight(this.height)}this.addEvents({"click":true,"dblclick":true,"contextmenu":true,"mousedown":true,"mouseup":true,"mouseover":true,"mouseout":true,"keypress":true,"keydown":true,"cellclick":true,"celldblclick":true,"rowclick":true,"rowdblclick":true,"headerclick":true,"headerdblclick":true,"rowcontextmenu":true,"cellcontextmenu":true,"headercontextmenu":true,"bodyscroll":true,"columnresize":true,"columnmove":true,"startdrag":true,"enddrag":true,"dragdrop":true,"dragover":true,"dragenter":true,"dragout":true,render:true});Ext.grid.Grid.superclass.constructor.call(this)};Ext.extend(Ext.grid.Grid,Ext.util.Observable,{minColumnWidth:25,autoSizeColumns:false,autoSizeHeaders:true,monitorWindowResize:true,maxRowsToMeasure:0,trackMouseOver:true,enableDragDrop:false,enableColumnMove:true,enableColumnHide:true,enableRowHeightSync:false,stripeRows:true,autoHeight:false,autoExpandColumn:false,autoExpandMin:50,autoExpandMax:1000,view:null,loadMask:false,rendered:false,render:function(){var B=this.container;if((!B.dom.offsetHeight||B.dom.offsetHeight<20)||B.getStyle("height")=="auto"){this.autoHeight=true}var A=this.getView();A.init(this);B.on("click",this.onClick,this);B.on("dblclick",this.onDblClick,this);B.on("contextmenu",this.onContextMenu,this);B.on("keydown",this.onKeyDown,this);this.relayEvents(B,["mousedown","mouseup","mouseover","mouseout","keypress"]);this.getSelectionModel().init(this);A.render();if(this.loadMask){this.loadMask=new Ext.LoadMask(this.container,Ext.apply({store:this.dataSource},this.loadMask))}this.rendered=true;this.fireEvent("render",this);return this},reconfigure:function(B,A){if(this.loadMask){this.loadMask.destroy();this.loadMask=new Ext.LoadMask(this.container,Ext.apply({store:B},this.loadMask))}this.view.bind(B,A);this.dataSource=B;this.colModel=A;this.view.refresh(true)},onKeyDown:function(A){this.fireEvent("keydown",A)},destroy:function(A,B){if(this.loadMask){this.loadMask.destroy()}var C=this.container;C.removeAllListeners();this.view.destroy();this.colModel.purgeListeners();if(!B){this.purgeListeners()}C.update("");if(A===true){C.remove()}},processEvent:function(C,E){this.fireEvent(C,E);var D=E.getTarget();var B=this.view;var G=B.findHeaderIndex(D);if(G!==false){this.fireEvent("header"+C,this,G,E)}else{var F=B.findRowIndex(D);var A=B.findCellIndex(D);if(F!==false){this.fireEvent("row"+C,this,F,E);if(A!==false){this.fireEvent("cell"+C,this,F,A,E)}}}},onClick:function(A){this.processEvent("click",A)},onContextMenu:function(B,A){this.processEvent("contextmenu",B)},onDblClick:function(A){this.processEvent("dblclick",A)},walkCells:function(J,C,B,E,I){var H=this.colModel,F=H.getColumnCount();var A=this.dataSource,G=A.getCount(),D=true;if(B<0){if(C<0){J--;D=false}while(J>=0){if(!D){C=F-1}D=false;while(C>=0){if(E.call(I||this,J,C,H)===true){return[J,C]}C--}J--}}else{if(C>=F){J++;D=false}while(J<G){if(!D){C=0}D=false;while(C<F){if(E.call(I||this,J,C,H)===true){return[J,C]}C++}J++}}return null},getSelections:function(){return this.selModel.getSelections()},autoSize:function(){if(this.rendered){this.view.layout();if(this.view.adjustForScroll){this.view.adjustForScroll()}}},getGridEl:function(){return this.container},stopEditing:function(){},getSelectionModel:function(){if(!this.selModel){this.selModel=new Ext.grid.RowSelectionModel()}return this.selModel},getDataSource:function(){return this.dataSource},getColumnModel:function(){return this.colModel},getView:function(){if(!this.view){this.view=new Ext.grid.GridView(this.viewConfig)}return this.view},getDragDropText:function(){var A=this.selModel.getCount();return String.format(this.ddText,A,A==1?"":"s")}});Ext.grid.Grid.prototype.ddText="{0} selected row{1}";
Ext.grid.AbstractGridView=function(){this.grid=null;this.events={"beforerowremoved":true,"beforerowsinserted":true,"beforerefresh":true,"rowremoved":true,"rowsinserted":true,"rowupdated":true,"refresh":true};Ext.grid.AbstractGridView.superclass.constructor.call(this)};Ext.extend(Ext.grid.AbstractGridView,Ext.util.Observable,{rowClass:"x-grid-row",cellClass:"x-grid-cell",tdClass:"x-grid-td",hdClass:"x-grid-hd",splitClass:"x-grid-hd-split",init:function(A){this.grid=A;var B=this.grid.getGridEl().id;this.colSelector="#"+B+" ."+this.cellClass+"-";this.tdSelector="#"+B+" ."+this.tdClass+"-";this.hdSelector="#"+B+" ."+this.hdClass+"-";this.splitSelector="#"+B+" ."+this.splitClass+"-"},getColumnRenderers:function(){var B=[];var A=this.grid.colModel;var D=A.getColumnCount();for(var C=0;C<D;C++){B[C]=A.getRenderer(C)}return B},getColumnIds:function(){var C=[];var A=this.grid.colModel;var D=A.getColumnCount();for(var B=0;B<D;B++){C[B]=A.getColumnId(B)}return C},getDataIndexes:function(){if(!this.indexMap){this.indexMap=this.buildIndexMap()}return this.indexMap.colToData},getColumnIndexByDataIndex:function(A){if(!this.indexMap){this.indexMap=this.buildIndexMap()}return this.indexMap.dataToCol[A]},setCSSStyle:function(C,B,D){var A="#"+this.grid.id+" .x-grid-col-"+C;Ext.util.CSS.updateRule(A,B,D)},generateRules:function(B){var C=[],E=this.grid.id+"-cssrules";Ext.util.CSS.removeStyleSheet(E);for(var D=0,A=B.getColumnCount();D<A;D++){var F=B.getColumnId(D);C.push(this.colSelector,F," {\n",B.config[D].css,"}\n",this.tdSelector,F," {\n}\n",this.hdSelector,F," {\n}\n",this.splitSelector,F," {\n}\n")}return Ext.util.CSS.createStyleSheet(C.join(""),E)}});
Ext.grid.GridView=function(A){Ext.grid.GridView.superclass.constructor.call(this);this.el=null;Ext.apply(this,A)};Ext.extend(Ext.grid.GridView,Ext.grid.AbstractGridView,{rowClass:"x-grid-row",cellClass:"x-grid-col",tdClass:"x-grid-td",hdClass:"x-grid-hd",splitClass:"x-grid-split",sortClasses:["sort-asc","sort-desc"],enableMoveAnim:false,hlColor:"C3DAF9",dh:Ext.DomHelper,fly:Ext.Element.fly,css:Ext.util.CSS,borderWidth:1,splitOffset:3,scrollIncrement:22,cellRE:/(?:.*?)x-grid-(?:hd|cell|csplit)-(?:[\d]+)-([\d]+)(?:.*?)/,findRE:/\s?(?:x-grid-hd|x-grid-col|x-grid-csplit)\s/,bind:function(B,A){if(this.ds){this.ds.un("load",this.onLoad,this);this.ds.un("datachanged",this.onDataChange,this);this.ds.un("add",this.onAdd,this);this.ds.un("remove",this.onRemove,this);this.ds.un("update",this.onUpdate,this);this.ds.un("clear",this.onClear,this)}if(B){B.on("load",this.onLoad,this);B.on("datachanged",this.onDataChange,this);B.on("add",this.onAdd,this);B.on("remove",this.onRemove,this);B.on("update",this.onUpdate,this);B.on("clear",this.onClear,this)}this.ds=B;if(this.cm){this.cm.un("widthchange",this.onColWidthChange,this);this.cm.un("headerchange",this.onHeaderChange,this);this.cm.un("hiddenchange",this.onHiddenChange,this);this.cm.un("columnmoved",this.onColumnMove,this);this.cm.un("columnlockchange",this.onColumnLock,this)}if(A){this.generateRules(A);A.on("widthchange",this.onColWidthChange,this);A.on("headerchange",this.onHeaderChange,this);A.on("hiddenchange",this.onHiddenChange,this);A.on("columnmoved",this.onColumnMove,this);A.on("columnlockchange",this.onColumnLock,this)}this.cm=A},init:function(A){Ext.grid.GridView.superclass.init.call(this,A);this.bind(A.dataSource,A.colModel);A.on("headerclick",this.handleHeaderClick,this);if(A.trackMouseOver){A.on("mouseover",this.onRowOver,this);A.on("mouseout",this.onRowOut,this)}A.cancelTextSelection=function(){};this.gridId=A.id;var B=this.templates||{};if(!B.master){B.master=new Ext.Template("<div class=\"x-grid\" hidefocus=\"true\">","<div class=\"x-grid-topbar\"></div>","<div class=\"x-grid-scroller\"><div></div></div>","<div class=\"x-grid-locked\">","<div class=\"x-grid-header\">{lockedHeader}</div>","<div class=\"x-grid-body\">{lockedBody}</div>","</div>","<div class=\"x-grid-viewport\">","<div class=\"x-grid-header\">{header}</div>","<div class=\"x-grid-body\">{body}</div>","</div>","<div class=\"x-grid-bottombar\"></div>","<a href=\"#\" class=\"x-grid-focus\" tabIndex=\"-1\"></a>","<div class=\"x-grid-resize-proxy\">&#160;</div>","</div>");B.master.disableformats=true}if(!B.header){B.header=new Ext.Template("<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\">","<tbody><tr class=\"x-grid-hd-row\">{cells}</tr></tbody>","</table>{splits}");B.header.disableformats=true}B.header.compile();if(!B.hcell){B.hcell=new Ext.Template("<td class=\"x-grid-hd x-grid-td-{id} {cellId}\"><div title=\"{title}\" class=\"x-grid-hd-inner x-grid-hd-{id}\">","<div class=\"x-grid-hd-text\" unselectable=\"on\">{value}<img class=\"x-grid-sort-icon\" src=\"",Ext.BLANK_IMAGE_URL,"\" /></div>","</div></td>");B.hcell.disableFormats=true}B.hcell.compile();if(!B.hsplit){B.hsplit=new Ext.Template("<div class=\"x-grid-split {splitId} x-grid-split-{id}\" style=\"{style}\" unselectable=\"on\">&#160;</div>");B.hsplit.disableFormats=true}B.hsplit.compile();if(!B.body){B.body=new Ext.Template("<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\">","<tbody>{rows}</tbody>","</table>");B.body.disableFormats=true}B.body.compile();if(!B.row){B.row=new Ext.Template("<tr class=\"x-grid-row {alt}\">{cells}</tr>");B.row.disableFormats=true}B.row.compile();if(!B.cell){B.cell=new Ext.Template("<td class=\"x-grid-col x-grid-td-{id} {cellId} {css}\" tabIndex=\"0\">","<div class=\"x-grid-col-{id} x-grid-cell-inner\"><div class=\"x-grid-cell-text\" unselectable=\"on\" {attr}>{value}</div></div>","</td>");B.cell.disableFormats=true}B.cell.compile();this.templates=B},onColWidthChange:function(){this.updateColumns.apply(this,arguments)},onHeaderChange:function(){this.updateHeaders.apply(this,arguments)},onHiddenChange:function(){this.handleHiddenChange.apply(this,arguments)},onColumnMove:function(){this.handleColumnMove.apply(this,arguments)},onColumnLock:function(){this.handleLockChange.apply(this,arguments)},onDataChange:function(){this.refresh();this.updateHeaderSortState()},onClear:function(){this.refresh()},onUpdate:function(B,A){this.refreshRow(A)},refreshRow:function(A){var C=this.ds,B;if(typeof A=="number"){B=A;A=C.getAt(B)}else{B=C.indexOf(A)}this.insertRows(C,B,B,true);this.onRemove(C,A,B+1,true);this.syncRowHeights(B,B);this.layout();this.fireEvent("rowupdated",this,B,A)},onAdd:function(C,A,B){this.insertRows(C,B,B+(A.length-1))},onRemove:function(F,B,D,E){if(E!==true){this.fireEvent("beforerowremoved",this,D,B)}var C=this.getBodyTable(),A=this.getLockedTable();if(C.rows[D]){C.firstChild.removeChild(C.rows[D])}if(A.rows[D]){A.firstChild.removeChild(A.rows[D])}if(E!==true){this.stripeRows(D);this.syncRowHeights(D,D);this.layout();this.fireEvent("rowremoved",this,D,B)}},onLoad:function(){this.scrollToTop()},scrollToTop:function(){if(this.scroller){this.scroller.dom.scrollTop=0;this.syncScroll()}},getHeaderPanel:function(A){if(A){this.headerPanel.show()}return this.headerPanel},getFooterPanel:function(A){if(A){this.footerPanel.show()}return this.footerPanel},initElements:function(){var C=Ext.Element;var B=this.grid.getGridEl().dom.firstChild;var A=B.childNodes;this.el=new C(B);this.headerPanel=new C(B.firstChild);this.headerPanel.enableDisplayMode("block");this.scroller=new C(A[1]);this.scrollSizer=new C(this.scroller.dom.firstChild);this.lockedWrap=new C(A[2]);this.lockedHd=new C(this.lockedWrap.dom.firstChild);this.lockedBody=new C(this.lockedWrap.dom.childNodes[1]);this.mainWrap=new C(A[3]);this.mainHd=new C(this.mainWrap.dom.firstChild);this.mainBody=new C(this.mainWrap.dom.childNodes[1]);this.footerPanel=new C(A[4]);this.footerPanel.enableDisplayMode("block");this.focusEl=new C(A[5]);this.focusEl.swallowEvent("click",true);this.resizeProxy=new C(A[6]);this.headerSelector=String.format("#{0} td.x-grid-hd, #{1} td.x-grid-hd",this.lockedHd.id,this.mainHd.id);this.splitterSelector=String.format("#{0} div.x-grid-split, #{1} div.x-grid-split",this.lockedHd.id,this.mainHd.id)},getHeaderCell:function(A){return Ext.DomQuery.select(this.headerSelector)[A]},getHeaderCellMeasure:function(A){return this.getHeaderCell(A).firstChild},getHeaderCellText:function(A){return this.getHeaderCell(A).firstChild.firstChild},getLockedTable:function(){return this.lockedBody.dom.firstChild},getBodyTable:function(){return this.mainBody.dom.firstChild},getLockedRow:function(A){return this.getLockedTable().rows[A]},getRow:function(A){return this.getBodyTable().rows[A]},getRowComposite:function(B){if(!this.rowEl){this.rowEl=new Ext.CompositeElementLite()}var D=[],C,A;if(C=this.getLockedRow(B)){D.push(C)}if(A=this.getRow(B)){D.push(A)}this.rowEl.elements=D;return this.rowEl},getCell:function(D,B){var A=this.cm.getLockedCount();var C;if(B<A){C=this.lockedBody.dom.firstChild}else{C=this.mainBody.dom.firstChild;B-=A}return C.rows[D].childNodes[B]},getCellText:function(B,A){return this.getCell(B,A).firstChild.firstChild},getCellBox:function(B){var A=this.fly(B).getBox();if(Ext.isOpera){A.y=B.offsetTop+this.mainBody.getY()}return A},getCellIndex:function(A){var B=String(A.className).match(this.cellRE);if(B){return parseInt(B[1],10)}return 0},findHeaderIndex:function(B){var A=Ext.fly(B).findParent("td."+this.hdClass,6);return A?this.getCellIndex(A):false},findHeaderCell:function(B){var A=Ext.fly(B).findParent("td."+this.hdClass,6);return A?A:false},findRowIndex:function(B){if(!B){return false}var A=Ext.fly(B).findParent("tr."+this.rowClass,6);return A?A.rowIndex:false},findCellIndex:function(B){var A=this.el.dom;while(B&&B!=A){if(this.findRE.test(B.className)){return this.getCellIndex(B)}B=B.parentNode}return false},getColumnId:function(A){return this.cm.getColumnId(A)},getSplitters:function(){if(this.splitterSelector){return Ext.DomQuery.select(this.splitterSelector)}else{return null}},getSplitter:function(A){return this.getSplitters()[A]},onRowOver:function(B,A){var C;if((C=this.findRowIndex(A))!==false){this.getRowComposite(C).addClass("x-grid-row-over")}},onRowOut:function(B,A){var C;if((C=this.findRowIndex(A))!==false&&C!==this.findRowIndex(B.getRelatedTarget())){this.getRowComposite(C).removeClass("x-grid-row-over")}},renderHeaders:function(){var J=this.cm;var F=this.templates.hcell,I=this.templates.header,K=this.templates.hsplit;var D=[],B=[],H=[],C=[],A={};for(var E=0,G=J.getColumnCount();E<G;E++){A.cellId="x-grid-hd-0-"+E;A.splitId="x-grid-csplit-0-"+E;A.id=J.getColumnId(E);A.title=J.getColumnTooltip(E)||"";A.value=J.getColumnHeader(E)||"";A.style=(this.grid.enableColumnResize===false||!J.isResizable(E)||J.isFixed(E))?"cursor:default":"";if(!J.isLocked(E)){D[D.length]=F.apply(A);H[H.length]=K.apply(A)}else{B[B.length]=F.apply(A);C[C.length]=K.apply(A)}}return[I.apply({cells:B.join(""),splits:C.join("")}),I.apply({cells:D.join(""),splits:H.join("")})]},updateHeaders:function(){var A=this.renderHeaders();this.lockedHd.update(A[0]);this.mainHd.update(A[1])},focusRow:function(B){var A=this.scroller.dom.scrollLeft;this.focusCell(B,0,false);this.scroller.dom.scrollLeft=A},focusCell:function(D,A,C){var B=this.ensureVisible(D,A,C);this.focusEl.alignTo(B,"tl-tl");if(Ext.isGecko){this.focusEl.focus()}else{this.focusEl.focus.defer(1,this.focusEl)}},ensureVisible:function(O,E,D){if(typeof O!="number"){O=O.rowIndex}if(O<0&&O>=this.ds.getCount()){return }E=(E!==undefined?E:0);var M=this.grid.colModel;while(M.isHidden(E)){E++}var C=this.getCell(O,E);if(!C){return }var J=this.scroller.dom;var N=parseInt(C.offsetTop,10);var I=parseInt(C.offsetLeft,10);var L=N+C.offsetHeight;var G=I+C.offsetWidth;var A=J.clientHeight-this.mainHd.dom.offsetHeight;var K=parseInt(J.scrollTop,10);var F=parseInt(J.scrollLeft,10);var H=K+A;var B=F+J.clientWidth;if(N<K){J.scrollTop=N}else{if(L>H){J.scrollTop=L-A}}if(D!==false){if(I<F){J.scrollLeft=I}else{if(G>B){J.scrollLeft=G-J.clientWidth}}}return C},updateColumns:function(){this.grid.stopEditing();var B=this.grid.colModel,E=this.getColumnIds();var F=0;for(var D=0,A=B.getColumnCount();D<A;D++){var C=B.getColumnWidth(D);this.css.updateRule(this.colSelector+E[D],"width",(C-this.borderWidth)+"px");this.css.updateRule(this.hdSelector+E[D],"width",(C-this.borderWidth)+"px")}this.updateSplitters()},generateRules:function(I){var B=[],C=this.grid.id+"-cssrules";Ext.util.CSS.removeStyleSheet(C);for(var D=0,F=I.getColumnCount();D<F;D++){var H=I.getColumnId(D);var G="";if(I.config[D].align){G="text-align:"+I.config[D].align+";"}var E="";if(I.isHidden(D)){E="display:none;"}var A="width:"+(I.getColumnWidth(D)-this.borderWidth)+"px;";B.push(this.colSelector,H," {\n",I.config[D].css,G,A,"\n}\n",this.hdSelector,H," {\n",G,A,"}\n",this.tdSelector,H," {\n",E,"\n}\n",this.splitSelector,H," {\n",E,"\n}\n")}return Ext.util.CSS.createStyleSheet(B.join(""),C)},updateSplitters:function(){var B=this.cm,F=this.getSplitters();if(F){var G=0,D=true;for(var E=0,A=B.getColumnCount();E<A;E++){if(B.isHidden(E)){continue}var C=B.getColumnWidth(E);if(!B.isLocked(E)&&D){G=0;D=false}G+=C;F[E].style.left=(G-this.splitOffset)+"px"}}},handleHiddenChange:function(B,A,C){if(C){this.hideColumn(A)}else{this.unhideColumn(A)}},hideColumn:function(A){var B=this.getColumnId(A);this.css.updateRule(this.tdSelector+B,"display","none");this.css.updateRule(this.splitSelector+B,"display","none");if(Ext.isSafari){this.updateHeaders()}this.updateSplitters();this.layout()},unhideColumn:function(A){var B=this.getColumnId(A);this.css.updateRule(this.tdSelector+B,"display","");this.css.updateRule(this.splitSelector+B,"display","");if(Ext.isSafari){this.updateHeaders()}this.updateSplitters();this.layout()},insertRows:function(B,F,D,E){if(F==0&&D==B.getCount()-1){this.refresh()}else{if(!E){this.fireEvent("beforerowsinserted",this,F,D)}var C=this.getScrollState();var A=this.renderRows(F,D);this.bufferRows(A[0],this.getLockedTable(),F);this.bufferRows(A[1],this.getBodyTable(),F);this.restoreScroll(C);if(!E){this.fireEvent("rowsinserted",this,F,D);this.syncRowHeights(F,D);this.stripeRows(F);this.layout()}}},bufferRows:function(I,E,D){var G=null,H=E.rows,B=E.tBodies[0];if(D<H.length){G=H[D]}var F=document.createElement("div");F.innerHTML="<table><tbody>"+I+"</tbody></table>";var J=F.firstChild.rows;for(var A=0,C=J.length;A<C;A++){if(G){B.insertBefore(J[0],G)}else{B.appendChild(J[0])}}F.innerHTML="";F=null},deleteRows:function(B,F,D){if(B.getRowCount()<1){this.fireEvent("beforerefresh",this);this.mainBody.update("");this.lockedBody.update("");this.fireEvent("refresh",this)}else{this.fireEvent("beforerowsdeleted",this,F,D);var A=this.getBodyTable();var C=A.firstChild;var E=A.rows;for(var G=F;G<=D;G++){C.removeChild(E[F])}this.stripeRows(F);this.fireEvent("rowsdeleted",this,F,D)}},updateRows:function(D,C,B){var A=this.getScrollState();this.refresh();this.restoreScroll(A)},handleSort:function(D,C,A,B){if(!B){this.refresh()}this.updateHeaderSortState()},getScrollState:function(){var A=this.scroller.dom;return{left:A.scrollLeft,top:A.scrollTop}},stripeRows:function(F){if(!this.grid.stripeRows||this.ds.getCount()<1){return }F=F||0;var J=this.getBodyTable().rows;var D=this.getLockedTable().rows;var G=" x-grid-row-alt ";for(var B=F,C=J.length;B<C;B++){var I=J[B],E=D[B];var A=((B+1)%2==0);var H=(" "+I.className+" ").indexOf(G)!=-1;if(A==H){continue}if(A){I.className+=" x-grid-row-alt"}else{I.className=I.className.replace("x-grid-row-alt","")}if(E){E.className=I.className}}},restoreScroll:function(A){var B=this.scroller.dom;B.scrollLeft=A.left;B.scrollTop=A.top;this.syncScroll()},syncScroll:function(){var D=this.scroller.dom;var B=this.mainHd.dom;var A=this.mainBody.dom;var C=this.lockedBody.dom;B.scrollLeft=A.scrollLeft=D.scrollLeft;C.scrollTop=A.scrollTop=D.scrollTop},handleScroll:function(A){this.syncScroll();var B=this.scroller.dom;this.grid.fireEvent("bodyscroll",B.scrollLeft,B.scrollTop);A.stopEvent()},handleWheel:function(A){var B=A.getWheelDelta();this.scroller.dom.scrollTop-=B*22;this.lockedBody.dom.scrollTop=this.mainBody.dom.scrollTop=this.scroller.dom.scrollTop;A.stopEvent()},renderRows:function(J,D){var F=this.grid,H=F.colModel,B=F.dataSource,K=F.stripeRows;var I=H.getColumnCount();if(B.getCount()<1){return["",""]}var G=[];for(var E=0;E<I;E++){var A=H.getDataIndex(E);G[E]={name:typeof A=="undefined"?B.fields.get(E).name:A,renderer:H.getRenderer(E),id:H.getColumnId(E),locked:H.isLocked(E)}}J=J||0;D=typeof D=="undefined"?B.getCount()-1:D;var C=B.getRange(J,D);return this.doRender(G,C,B,J,I,K)},doRender:Ext.isGecko?function(D,G,L,A,K,P){var B=this.templates,C=B.cell,E=B.row;var T="",W="",M,F,U,N={},H={},J,I;for(var O=0,R=G.length;O<R;O++){J=G[O];M="";F="";I=(O+A);for(var Q=0;Q<K;Q++){U=D[Q];N.cellId="x-grid-cell-"+I+"-"+Q;N.id=U.id;N.css=N.attr="";N.value=U.renderer(J.data[U.name],N,J,I,Q,L);if(N.value==undefined||N.value===""){N.value="&#160;"}if(J.dirty&&typeof J.modified[U.name]!=="undefined"){N.css+=N.css?" x-grid-dirty-cell":"x-grid-dirty-cell"}var S=C.apply(N);if(!U.locked){M+=S}else{F+=S}}var V=[];if(P&&((I+1)%2==0)){V[0]="x-grid-row-alt"}if(J.dirty){V[1]=" x-grid-dirty-row"}H.cells=F;if(this.getRowClass){V[2]=this.getRowClass(J,I)}H.alt=V.join(" ");W+=E.apply(H);H.cells=M;T+=E.apply(H)}return[W,T]}:function(D,G,L,A,K,P){var B=this.templates,C=B.cell,E=B.row;var T=[],W=[],M,F,U,N={},H={},J,I;for(var O=0,R=G.length;O<R;O++){J=G[O];M=[];F=[];I=(O+A);for(var Q=0;Q<K;Q++){U=D[Q];N.cellId="x-grid-cell-"+I+"-"+Q;N.id=U.id;N.css=N.attr="";N.value=U.renderer(J.data[U.name],N,J,I,Q,L);if(N.value==undefined||N.value===""){N.value="&#160;"}if(J.dirty&&typeof J.modified[U.name]!=="undefined"){N.css+=N.css?" x-grid-dirty-cell":"x-grid-dirty-cell"}var S=C.apply(N);if(!U.locked){M[M.length]=S}else{F[F.length]=S}}var V=[];if(P&&((I+1)%2==0)){V[0]="x-grid-row-alt"}if(J.dirty){V[1]=" x-grid-dirty-row"}H.cells=F;if(this.getRowClass){V[2]=this.getRowClass(J,I)}H.alt=V.join(" ");H.cells=F.join("");W[W.length]=E.apply(H);H.cells=M.join("");T[T.length]=E.apply(H)}return[W.join(""),T.join("")]},renderBody:function(){var B=this.renderRows();var A=this.templates.body;return[A.apply({rows:B[0]}),A.apply({rows:B[1]})]},refresh:function(B){this.fireEvent("beforerefresh",this);this.grid.stopEditing();var A=this.renderBody();this.lockedBody.update(A[0]);this.mainBody.update(A[1]);if(B===true){this.updateHeaders();this.updateColumns();this.updateSplitters();this.updateHeaderSortState()}this.syncRowHeights();this.layout();this.fireEvent("refresh",this)},handleColumnMove:function(A,D,B){this.indexMap=null;var C=this.getScrollState();this.refresh(true);this.restoreScroll(C);this.afterMove(B)},afterMove:function(A){if(this.enableMoveAnim&&Ext.enableFx){this.fly(this.getHeaderCell(A).firstChild).highlight(this.hlColor)}},updateCell:function(C,E,F){var H=this.getColumnIndexByDataIndex(F);if(typeof H=="undefined"){return }var G=this.grid.colModel;var I=this.getCell(E,H);var J=this.getCellText(E,H);var A={cellId:"x-grid-cell-"+E+"-"+H,id:G.getColumnId(H),css:H==G.getColumnCount()-1?"x-grid-col-last":""};var D=G.getRenderer(H);var B=D(C.getValueAt(E,F),A,E,H,C);if(typeof B=="undefined"||B===""){B="&#160;"}J.innerHTML=B;I.className=this.cellClass+" "+A.cellId+" "+A.css;this.syncRowHeights(E,E)},calcColumnWidth:function(I,A){var H=0;if(this.grid.autoSizeHeaders){var D=this.getHeaderCellMeasure(I);H=Math.max(H,D.scrollWidth)}var B,E;if(this.cm.isLocked(I)){B=this.getLockedTable();E=I}else{B=this.getBodyTable();E=I-this.cm.getLockedCount()}if(B&&B.rows){var J=B.rows;var F=Math.min(A||J.length,J.length);for(var C=0;C<F;C++){var G=J[C].childNodes[E].firstChild;H=Math.max(H,G.scrollWidth)}}return H+5},autoSizeColumn:function(C,A,B){if(this.cm.isHidden(C)){return }if(A){var E=this.cm.getColumnId(C);this.css.updateRule(this.colSelector+E,"width",this.grid.minColumnWidth+"px");if(this.grid.autoSizeHeaders){this.css.updateRule(this.hdSelector+E,"width",this.grid.minColumnWidth+"px")}}var D=this.calcColumnWidth(C);this.cm.setColumnWidth(C,Math.max(this.grid.minColumnWidth,D),B);if(!B){this.grid.fireEvent("columnresize",C,D)}},autoSizeColumns:function(){var A=this.grid.colModel;var C=A.getColumnCount();for(var B=0;B<C;B++){this.autoSizeColumn(B,true,true)}if(A.getTotalWidth()<this.scroller.dom.clientWidth){this.fitColumns()}else{this.updateColumns();this.layout()}},fitColumns:function(C){var H=this.grid.colModel;var I=H.getColumnCount();var F=[];var B=0;var D,G;for(D=0;D<I;D++){if(!H.isHidden(D)&&!H.isFixed(D)){G=H.getColumnWidth(D);F.push(D);F.push(G);B+=G}}var E=Math.min(this.scroller.dom.clientWidth,this.el.getWidth());if(C){E-=17}var A=(E-H.getTotalWidth())/B;while(F.length){G=F.pop();D=F.pop();H.setColumnWidth(D,Math.floor(G+G*A),true)}this.updateColumns();this.layout()},onRowSelect:function(B){var A=this.getRowComposite(B);A.addClass("x-grid-row-selected")},onRowDeselect:function(B){var A=this.getRowComposite(B);A.removeClass("x-grid-row-selected")},onCellSelect:function(C,B){var A=this.getCell(C,B);if(A){Ext.fly(A).addClass("x-grid-cell-selected")}},onCellDeselect:function(C,B){var A=this.getCell(C,B);if(A){Ext.fly(A).removeClass("x-grid-cell-selected")}},updateHeaderSortState:function(){var B=this.ds.getSortState();if(!B){return }this.sortState=B;var E=this.cm.findColumnIndex(B.field);if(E!=-1){var A=B.direction;var D=this.sortClasses;var C=this.el.select(this.headerSelector).removeClass(D);C.item(E).addClass(D[A=="DESC"?1:0])}},handleHeaderClick:function(D,C){if(this.headersDisabled){return }var B=D.dataSource,A=D.colModel;if(!A.isSortable(C)){return }D.stopEditing();B.sort(A.getDataIndex(C))},destroy:function(){if(this.colMenu){this.colMenu.removeAll();Ext.menu.MenuMgr.unregister(this.colMenu);this.colMenu.getEl().remove();delete this.colMenu}if(this.hmenu){this.hmenu.removeAll();Ext.menu.MenuMgr.unregister(this.hmenu);this.hmenu.getEl().remove();delete this.hmenu}if(this.grid.enableColumnMove){var C=Ext.dd.DDM.ids["gridHeader"+this.grid.getGridEl().id];if(C){for(var A in C){if(!C[A].config.isTarget&&C[A].dragElId){var B=C[A].dragElId;C[A].unreg();Ext.get(B).remove()}else{if(C[A].config.isTarget){C[A].proxyTop.remove();C[A].proxyBottom.remove();C[A].unreg()}}if(Ext.dd.DDM.locationCache[A]){delete Ext.dd.DDM.locationCache[A]}}delete Ext.dd.DDM.ids["gridHeader"+this.grid.getGridEl().id]}}Ext.util.CSS.removeStyleSheet(this.grid.id+"-cssrules");this.bind(null,null);Ext.EventManager.removeResizeListener(this.onWindowResize,this)},handleLockChange:function(){this.refresh(true)},onDenyColumnLock:function(){},onDenyColumnHide:function(){},handleHdMenuClick:function(D){var B=this.hdCtxIndex;var A=this.cm,E=this.ds;switch(D.id){case"asc":E.sort(A.getDataIndex(B),"ASC");break;case"desc":E.sort(A.getDataIndex(B),"DESC");break;case"lock":var C=A.getLockedCount();if(A.getColumnCount(true)<=C+1){this.onDenyColumnLock();return }if(C!=B){A.setLocked(B,true,true);A.moveColumn(B,C);this.grid.fireEvent("columnmove",B,C)}else{A.setLocked(B,true)}break;case"unlock":var C=A.getLockedCount();if((C-1)!=B){A.setLocked(B,false,true);A.moveColumn(B,C-1);this.grid.fireEvent("columnmove",B,C-1)}else{A.setLocked(B,false)}break;default:B=A.getIndexById(D.id.substr(4));if(B!=-1){if(D.checked&&A.getColumnCount(true)<=1){this.onDenyColumnHide();return false}A.setHidden(B,D.checked)}}return true},beforeColMenuShow:function(){var A=this.cm,C=A.getColumnCount();this.colMenu.removeAll();for(var B=0;B<C;B++){this.colMenu.add(new Ext.menu.CheckItem({id:"col-"+A.getColumnId(B),text:A.getColumnHeader(B),checked:!A.isHidden(B),hideOnClick:false}))}},handleHdCtx:function(D,C,F){F.stopEvent();var E=this.getHeaderCell(C);this.hdCtxIndex=C;var B=this.hmenu.items,A=this.cm;B.get("asc").setDisabled(!A.isSortable(C));B.get("desc").setDisabled(!A.isSortable(C));if(this.grid.enableColLock!==false){B.get("lock").setDisabled(A.isLocked(C));B.get("unlock").setDisabled(!A.isLocked(C))}this.hmenu.show(E,"tl-bl")},handleHdOver:function(B){var A=this.findHeaderCell(B.getTarget());if(A&&!this.headersDisabled){if(this.grid.colModel.isSortable(this.getCellIndex(A))){this.fly(A).addClass("x-grid-hd-over")}}},handleHdOut:function(B){var A=this.findHeaderCell(B.getTarget());if(A){this.fly(A).removeClass("x-grid-hd-over")}},handleSplitDblClick:function(C,B){var A=this.getCellIndex(B);if(this.grid.enableColumnResize!==false&&this.cm.isResizable(A)&&!this.cm.isFixed(A)){this.autoSizeColumn(A,true);this.layout()}},render:function(){var B=this.cm;var D=B.getColumnCount();if(this.grid.monitorWindowResize===true){Ext.EventManager.onWindowResize(this.onWindowResize,this,true)}var E=this.renderHeaders();var A=this.templates.body.apply({rows:""});var C=this.templates.master.apply({lockedBody:A,body:A,lockedHeader:E[0],header:E[1]});this.grid.getGridEl().dom.innerHTML=C;this.initElements();this.scroller.on("scroll",this.handleScroll,this);this.lockedBody.on("mousewheel",this.handleWheel,this);this.mainBody.on("mousewheel",this.handleWheel,this);this.mainHd.on("mouseover",this.handleHdOver,this);this.mainHd.on("mouseout",this.handleHdOut,this);this.mainHd.on("dblclick",this.handleSplitDblClick,this,{delegate:"."+this.splitClass});this.lockedHd.on("mouseover",this.handleHdOver,this);this.lockedHd.on("mouseout",this.handleHdOut,this);this.lockedHd.on("dblclick",this.handleSplitDblClick,this,{delegate:"."+this.splitClass});if(this.grid.enableColumnResize!==false&&Ext.grid.SplitDragZone){new Ext.grid.SplitDragZone(this.grid,this.lockedHd.dom,this.mainHd.dom)}this.updateSplitters();if(this.grid.enableColumnMove&&Ext.grid.HeaderDragZone){new Ext.grid.HeaderDragZone(this.grid,this.lockedHd.dom,this.mainHd.dom);new Ext.grid.HeaderDropZone(this.grid,this.lockedHd.dom,this.mainHd.dom)}if(this.grid.enableCtxMenu!==false&&Ext.menu.Menu){this.hmenu=new Ext.menu.Menu({id:this.grid.id+"-hctx"});this.hmenu.add({id:"asc",text:this.sortAscText,cls:"xg-hmenu-sort-asc"},{id:"desc",text:this.sortDescText,cls:"xg-hmenu-sort-desc"});if(this.grid.enableColLock!==false){this.hmenu.add("-",{id:"lock",text:this.lockText,cls:"xg-hmenu-lock"},{id:"unlock",text:this.unlockText,cls:"xg-hmenu-unlock"})}if(this.grid.enableColumnHide!==false){this.colMenu=new Ext.menu.Menu({id:this.grid.id+"-hcols-menu"});this.colMenu.on("beforeshow",this.beforeColMenuShow,this);this.colMenu.on("itemclick",this.handleHdMenuClick,this);this.hmenu.add("-",{id:"columns",text:this.columnsText,menu:this.colMenu})}this.hmenu.on("itemclick",this.handleHdMenuClick,this);this.grid.on("headercontextmenu",this.handleHdCtx,this)}if((this.grid.enableDragDrop||this.grid.enableDrag)&&Ext.grid.GridDragZone){this.dd=new Ext.grid.GridDragZone(this.grid,{ddGroup:this.grid.ddGroup||"GridDD"})}this.updateHeaderSortState();this.beforeInitialResize();this.layout(true);this.renderPhase2.defer(1,this)},renderPhase2:function(){this.refresh();if(this.grid.autoSizeColumns){this.autoSizeColumns()}},beforeInitialResize:function(){},onColumnSplitterMoved:function(C,B){this.userResized=true;var A=this.grid.colModel;A.setColumnWidth(C,B,true);var D=A.getColumnId(C);this.css.updateRule(this.colSelector+D,"width",(B-this.borderWidth)+"px");this.css.updateRule(this.hdSelector+D,"width",(B-this.borderWidth)+"px");this.updateSplitters();this.layout();this.grid.fireEvent("columnresize",C,B)},syncRowHeights:function(I,E){if(this.grid.enableRowHeightSync===true&&this.cm.getLockedCount()>0){I=I||0;var F=this.getBodyTable().rows;var H=this.getLockedTable().rows;var G=F.length-1;E=Math.min(E||G,G);for(var C=I;C<=E;C++){var A=F[C],B=H[C];var D=Math.max(A.offsetHeight,B.offsetHeight);A.style.height=B.style.height=D+"px"}}},layout:function(B,C){var W=this.grid;var E=W.autoHeight;var L=16;var a=W.getGridEl(),H=this.cm,I=W.autoExpandColumn,O=this;if(!a.dom.offsetWidth){if(B){this.lockedWrap.show();this.mainWrap.show()}return }var V=this.cm.isLocked(0);var F=this.headerPanel.getHeight();var G=this.footerPanel.getHeight();if(E){var K=this.getBodyTable().offsetHeight+F+G+this.mainHd.getHeight();var U=K+a.getBorderWidth("tb");if(W.maxHeight){U=Math.min(W.maxHeight,U)}a.setHeight(U)}if(W.autoWidth){a.setWidth(H.getTotalWidth()+a.getBorderWidth("lr"))}var N=this.scroller;var T=a.getSize(true);this.el.setSize(T.width,T.height);this.headerPanel.setWidth(T.width);this.footerPanel.setWidth(T.width);var M=this.mainHd.getHeight();var Q=T.width;var d=T.height-(F+G);N.setSize(Q,d);var Z=this.getBodyTable();var S=V?Math.max(this.getLockedTable().offsetWidth,this.lockedHd.dom.firstChild.offsetWidth):0;var X=Z.offsetHeight;var J=S+Z.offsetWidth;var b=false,Y=false;this.scrollSizer.setSize(J,X+M);var D=this.lockedWrap,P=this.mainWrap;var R=this.lockedBody,A=this.mainBody;setTimeout(function(){var j=N.dom.offsetTop;var e=N.dom.clientWidth,k=N.dom.clientHeight;D.setTop(j);D.setSize(S,k);P.setLeftTop(S,j);P.setSize(e-S,k);R.setHeight(k-M);A.setHeight(k-M);if(C!==true&&!O.userResized&&I){var i=H.getIndexById(I);var f=H.getTotalWidth(false);var g=H.getColumnWidth(i);var c=Math.min(Math.max(((e-f)+g-2)-(e<=N.dom.offsetWidth?0:18),W.autoExpandMin),W.autoExpandMax);if(g!=c){H.setColumnWidth(i,c,true);O.css.updateRule(O.colSelector+I,"width",(c-O.borderWidth)+"px");O.css.updateRule(O.hdSelector+I,"width",(c-O.borderWidth)+"px");O.updateSplitters();O.layout(false,true)}}if(B){D.show();P.show()}},10)},onWindowResize:function(){if(!this.grid.monitorWindowResize||this.grid.autoHeight){return }this.layout()},appendFooter:function(A){return null},sortAscText:"Sort Ascending",sortDescText:"Sort Descending",lockText:"Lock Column",unlockText:"Unlock Column",columnsText:"Columns"});
Ext.grid.ColumnModel=function(B){this.config=B;this.lookup={};for(var C=0,A=B.length;C<A;C++){var D=B[C];if(typeof D.dataIndex=="undefined"){D.dataIndex=C}if(typeof D.renderer=="string"){D.renderer=Ext.util.Format[D.renderer]}if(typeof D.id=="undefined"){D.id=C}if(D.editor&&D.editor.isFormField){D.editor=new Ext.grid.GridEditor(D.editor)}this.lookup[D.id]=D}this.defaultWidth=100;this.defaultSortable=false;this.addEvents({"widthchange":true,"headerchange":true,"hiddenchange":true,"columnmoved":true,"columnlockchange":true});Ext.grid.ColumnModel.superclass.constructor.call(this)};Ext.extend(Ext.grid.ColumnModel,Ext.util.Observable,{getColumnId:function(A){return this.config[A].id},getColumnById:function(A){return this.lookup[A]},getIndexById:function(C){for(var B=0,A=this.config.length;B<A;B++){if(this.config[B].id==C){return B}}return -1},moveColumn:function(C,A){var B=this.config[C];this.config.splice(C,1);this.config.splice(A,0,B);this.dataMap=null;this.fireEvent("columnmoved",this,C,A)},isLocked:function(A){return this.config[A].locked===true},setLocked:function(B,C,A){if(this.isLocked(B)==C){return }this.config[B].locked=C;if(!A){this.fireEvent("columnlockchange",this,B,C)}},getTotalLockedWidth:function(){var A=0;for(var B=0;B<this.config.length;B++){if(this.isLocked(B)&&!this.isHidden(B)){this.totalWidth+=this.getColumnWidth(B)}}return A},getLockedCount:function(){for(var B=0,A=this.config.length;B<A;B++){if(!this.isLocked(B)){return B}}},getColumnCount:function(C){if(C===true){var D=0;for(var B=0,A=this.config.length;B<A;B++){if(!this.isHidden(B)){D++}}return D}return this.config.length},getColumnsBy:function(D,C){var E=[];for(var B=0,A=this.config.length;B<A;B++){var F=this.config[B];if(D.call(C||this,F,B)===true){E[E.length]=F}}return E},isSortable:function(A){if(typeof this.config[A].sortable=="undefined"){return this.defaultSortable}return this.config[A].sortable},getRenderer:function(A){if(!this.config[A].renderer){return Ext.grid.ColumnModel.defaultRenderer}return this.config[A].renderer},setRenderer:function(A,B){this.config[A].renderer=B},getColumnWidth:function(A){return this.config[A].width||this.defaultWidth},setColumnWidth:function(B,C,A){this.config[B].width=C;this.totalWidth=null;if(!A){this.fireEvent("widthchange",this,B,C)}},getTotalWidth:function(B){if(!this.totalWidth){this.totalWidth=0;for(var C=0,A=this.config.length;C<A;C++){if(B||!this.isHidden(C)){this.totalWidth+=this.getColumnWidth(C)}}}return this.totalWidth},getColumnHeader:function(A){return this.config[A].header},setColumnHeader:function(A,B){this.config[A].header=B;this.fireEvent("headerchange",this,A,B)},getColumnTooltip:function(A){return this.config[A].tooltip},setColumnTooltip:function(A,B){this.config[A].tooltip=B},getDataIndex:function(A){return this.config[A].dataIndex},setDataIndex:function(A,B){this.config[A].dataIndex=B},findColumnIndex:function(C){var D=this.config;for(var B=0,A=D.length;B<A;B++){if(D[B].dataIndex==C){return B}}return -1},isCellEditable:function(A,B){return(this.config[A].editable||(typeof this.config[A].editable=="undefined"&&this.config[A].editor))?true:false},getCellEditor:function(A,B){return this.config[A].editor},setEditable:function(A,B){this.config[A].editable=B},isHidden:function(A){return this.config[A].hidden},isFixed:function(A){return this.config[A].fixed},isResizable:function(A){return A>=0&&this.config[A].resizable!==false&&this.config[A].fixed!==true},setHidden:function(A,B){this.config[A].hidden=B;this.totalWidth=null;this.fireEvent("hiddenchange",this,A,B)},setEditor:function(A,B){this.config[A].editor=B}});Ext.grid.ColumnModel.defaultRenderer=function(A){if(typeof A=="string"&&A.length<1){return"&#160;"}return A};Ext.grid.DefaultColumnModel=Ext.grid.ColumnModel;
Ext.grid.AbstractSelectionModel=function(){this.locked=false;Ext.grid.AbstractSelectionModel.superclass.constructor.call(this)};Ext.extend(Ext.grid.AbstractSelectionModel,Ext.util.Observable,{init:function(A){this.grid=A;this.initEvents()},lock:function(){this.locked=true},unlock:function(){this.locked=false},isLocked:function(){return this.locked}});
Ext.grid.RowSelectionModel=function(A){Ext.apply(this,A);this.selections=new Ext.util.MixedCollection(false,function(B){return B.id});this.last=false;this.lastActive=false;this.addEvents({"selectionchange":true,"beforerowselect":true,"rowselect":true,"rowdeselect":true});this.locked=false};Ext.extend(Ext.grid.RowSelectionModel,Ext.grid.AbstractSelectionModel,{singleSelect:false,initEvents:function(){if(!this.grid.enableDragDrop&&!this.grid.enableDrag){this.grid.on("mousedown",this.handleMouseDown,this)}else{this.grid.on("rowclick",function(B,D,C){if(C.button===0&&!C.shiftKey&&!C.ctrlKey){this.selectRow(D,false);B.view.focusRow(D)}},this)}this.rowNav=new Ext.KeyNav(this.grid.getGridEl(),{"up":function(C){if(!C.shiftKey){this.selectPrevious(C.shiftKey)}else{if(this.last!==false&&this.lastActive!==false){var B=this.last;this.selectRange(this.last,this.lastActive-1);this.grid.getView().focusRow(this.lastActive);if(B!==false){this.last=B}}else{this.selectFirstRow()}}},"down":function(C){if(!C.shiftKey){this.selectNext(C.shiftKey)}else{if(this.last!==false&&this.lastActive!==false){var B=this.last;this.selectRange(this.last,this.lastActive+1);this.grid.getView().focusRow(this.lastActive);if(B!==false){this.last=B}}else{this.selectFirstRow()}}},scope:this});var A=this.grid.view;A.on("refresh",this.onRefresh,this);A.on("rowupdated",this.onRowUpdated,this);A.on("rowremoved",this.onRemove,this)},onRefresh:function(){var D=this.grid.dataSource,B,A=this.grid.view;var C=this.selections;C.each(function(E){if((B=D.indexOfId(E.id))!=-1){A.onRowSelect(B)}else{C.remove(E)}})},onRemove:function(A,B,C){this.selections.remove(C)},onRowUpdated:function(A,B,C){if(this.isSelected(C)){A.onRowSelect(B)}},selectRecords:function(B,E){if(!E){this.clearSelections()}var D=this.grid.dataSource;for(var C=0,A=B.length;C<A;C++){this.selectRow(D.indexOf(B[C]),true)}},getCount:function(){return this.selections.length},selectFirstRow:function(){this.selectRow(0)},selectLastRow:function(A){this.selectRow(this.grid.dataSource.getCount()-1,A)},selectNext:function(A){if(this.last!==false&&(this.last+1)<this.grid.dataSource.getCount()){this.selectRow(this.last+1,A);this.grid.getView().focusRow(this.last)}},selectPrevious:function(A){if(this.last){this.selectRow(this.last-1,A);this.grid.getView().focusRow(this.last)}},getSelections:function(){return[].concat(this.selections.items)},getSelected:function(){return this.selections.itemAt(0)},clearSelections:function(A){if(this.locked){return }if(A!==true){var C=this.grid.dataSource;var B=this.selections;B.each(function(D){this.deselectRow(C.indexOfId(D.id))},this);B.clear()}else{this.selections.clear()}this.last=false},selectAll:function(){if(this.locked){return }this.selections.clear();for(var B=0,A=this.grid.dataSource.getCount();B<A;B++){this.selectRow(B,true)}},hasSelection:function(){return this.selections.length>0},isSelected:function(A){var B=typeof A=="number"?this.grid.dataSource.getAt(A):A;return(B&&this.selections.key(B.id)?true:false)},isIdSelected:function(A){return(this.selections.key(A)?true:false)},handleMouseDown:function(E,C){var A=this.grid.getView(),F;if(this.isLocked()||(F=A.findRowIndex(C))===false){return }if(E.shiftKey&&this.last!==false){var D=this.last;this.selectRange(D,F,E.ctrlKey);this.last=D;A.focusRow(F)}else{var B=this.isSelected(F);if(E.button!==0&&B){A.focusRow(F)}else{if(E.ctrlKey&&B){this.deselectRow(F)}else{if(!B){this.selectRow(F,E.button===0&&(E.ctrlKey||E.shiftKey));A.focusRow(F)}}}}},selectRows:function(C,D){if(!D){this.clearSelections()}for(var B=0,A=C.length;B<A;B++){this.selectRow(C[B],true)}},selectRange:function(B,A,D){if(this.locked){return }if(!D){this.clearSelections()}if(B<=A){for(var C=B;C<=A;C++){this.selectRow(C,true)}}else{for(var C=B;C>=A;C--){this.selectRow(C,true)}}},deselectRange:function(C,B,A){if(this.locked){return }for(var D=C;D<=B;D++){this.deselectRow(D,A)}},selectRow:function(B,D,A){if(this.locked||(B<0||B>=this.grid.dataSource.getCount())){return }if(this.fireEvent("beforerowselect",this,B,D)!==false){if(!D||this.singleSelect){this.clearSelections()}var C=this.grid.dataSource.getAt(B);this.selections.add(C);this.last=this.lastActive=B;if(!A){this.grid.getView().onRowSelect(B)}this.fireEvent("rowselect",this,B,C);this.fireEvent("selectionchange",this)}},deselectRow:function(B,A){if(this.locked){return }if(this.last==B){this.last=false}if(this.lastActive==B){this.lastActive=false}var C=this.grid.dataSource.getAt(B);this.selections.remove(C);if(!A){this.grid.getView().onRowDeselect(B)}this.fireEvent("rowdeselect",this,B);this.fireEvent("selectionchange",this)},restoreLast:function(){if(this._last){this.last=this._last}},acceptsNav:function(C,B,A){return !A.isHidden(B)&&A.isCellEditable(B,C)},onEditorKey:function(E,D){var B=D.getKey(),F,C=this.grid,A=C.activeEditor;if(B==D.TAB){D.stopEvent();A.completeEdit();if(D.shiftKey){F=C.walkCells(A.row,A.col-1,-1,this.acceptsNav,this)}else{F=C.walkCells(A.row,A.col+1,1,this.acceptsNav,this)}}else{if(B==D.ENTER&&!D.ctrlKey){D.stopEvent();A.completeEdit();if(D.shiftKey){F=C.walkCells(A.row-1,A.col,-1,this.acceptsNav,this)}else{F=C.walkCells(A.row+1,A.col,1,this.acceptsNav,this)}}else{if(B==D.ESC){A.cancelEdit()}}}if(F){C.startEditing(F[0],F[1])}}});
Ext.grid.CellSelectionModel=function(A){Ext.apply(this,A);this.selection=null;this.addEvents({"beforecellselect":true,"cellselect":true,"selectionchange":true})};Ext.extend(Ext.grid.CellSelectionModel,Ext.grid.AbstractSelectionModel,{initEvents:function(){this.grid.on("mousedown",this.handleMouseDown,this);this.grid.getGridEl().on(Ext.isIE?"keydown":"keypress",this.handleKeyDown,this);var A=this.grid.view;A.on("refresh",this.onViewChange,this);A.on("rowupdated",this.onRowUpdated,this);A.on("beforerowremoved",this.clearSelections,this);A.on("beforerowsinserted",this.clearSelections,this);if(this.grid.isEditor){this.grid.on("beforeedit",this.beforeEdit,this)}},beforeEdit:function(A){this.select(A.row,A.column,false,true,A.record)},onRowUpdated:function(A,B,C){if(this.selection&&this.selection.record==C){A.onCellSelect(B,this.selection.cell[1])}},onViewChange:function(){this.clearSelections(true)},getSelectedCell:function(){return this.selection?this.selection.cell:null},clearSelections:function(B){var A=this.selection;if(A){if(B!==true){this.grid.view.onCellDeselect(A.cell[0],A.cell[1])}this.selection=null;this.fireEvent("selectionchange",this,null)}},hasSelection:function(){return this.selection?true:false},handleMouseDown:function(D,C){var B=this.grid.getView();if(this.isLocked()){return }var E=B.findRowIndex(C);var A=B.findCellIndex(C);if(E!==false&&A!==false){this.select(E,A)}},select:function(F,C,B,E,D){if(this.fireEvent("beforecellselect",this,F,C)!==false){this.clearSelections();D=D||this.grid.dataSource.getAt(F);this.selection={record:D,cell:[F,C]};if(!B){var A=this.grid.getView();A.onCellSelect(F,C);if(E!==true){A.focusCell(F,C)}}this.fireEvent("cellselect",this,F,C);this.fireEvent("selectionchange",this,this.selection)}},isSelectable:function(C,B,A){return !A.isHidden(B)},handleKeyDown:function(F){if(!F.isNavKeyPress()){return }var E=this.grid,J=this.selection;if(!J){F.stopEvent();var I=E.walkCells(0,0,1,this.isSelectable,this);if(I){this.select(I[0],I[1])}return }var B=this;var H=function(M,K,L){return E.walkCells(M,K,L,B.isSelectable,B)};var C=F.getKey(),A=J.cell[0],G=J.cell[1];var D;switch(C){case F.TAB:if(F.shiftKey){D=H(A,G-1,-1)}else{D=H(A,G+1,1)}break;case F.DOWN:D=H(A+1,G,1);break;case F.UP:D=H(A-1,G,-1);break;case F.RIGHT:D=H(A,G+1,1);break;case F.LEFT:D=H(A,G-1,-1);break;case F.ENTER:if(E.isEditor&&!E.editing){E.startEditing(A,G);F.stopEvent();return }break}if(D){this.select(D[0],D[1]);F.stopEvent()}},acceptsNav:function(C,B,A){return !A.isHidden(B)&&A.isCellEditable(B,C)},onEditorKey:function(E,D){var B=D.getKey(),F,C=this.grid,A=C.activeEditor;if(B==D.TAB){if(D.shiftKey){F=C.walkCells(A.row,A.col-1,-1,this.acceptsNav,this)}else{F=C.walkCells(A.row,A.col+1,1,this.acceptsNav,this)}D.stopEvent()}else{if(B==D.ENTER&&!D.ctrlKey){A.completeEdit();D.stopEvent()}else{if(B==D.ESC){A.cancelEdit()}}}if(F){C.startEditing(F[0],F[1])}}});
Ext.grid.HeaderDragZone=function(A,C,B){this.grid=A;this.view=A.getView();this.ddGroup="gridHeader"+this.grid.getGridEl().id;Ext.grid.HeaderDragZone.superclass.constructor.call(this,C);if(B){this.setHandleElId(Ext.id(C));this.setOuterHandleElId(Ext.id(B))}this.scroll=false};Ext.extend(Ext.grid.HeaderDragZone,Ext.dd.DragZone,{maxDragWidth:120,getDragData:function(C){var A=Ext.lib.Event.getTarget(C);var B=this.view.findHeaderCell(A);if(B){return{ddel:B.firstChild,header:B}}return false},onInitDrag:function(A){this.view.headersDisabled=true;var B=this.dragData.ddel.cloneNode(true);B.id=Ext.id();B.style.width=Math.min(this.dragData.header.offsetWidth,this.maxDragWidth)+"px";this.proxy.update(B);return true},afterValidDrop:function(){var A=this.view;setTimeout(function(){A.headersDisabled=false},50)},afterInvalidDrop:function(){var A=this.view;setTimeout(function(){A.headersDisabled=false},50)}});Ext.grid.HeaderDropZone=function(A,C,B){this.grid=A;this.view=A.getView();this.proxyTop=Ext.DomHelper.append(document.body,{cls:"col-move-top",html:"&#160;"},true);this.proxyBottom=Ext.DomHelper.append(document.body,{cls:"col-move-bottom",html:"&#160;"},true);this.proxyTop.hide=this.proxyBottom.hide=function(){this.setLeftTop(-100,-100);this.setStyle("visibility","hidden")};this.ddGroup="gridHeader"+this.grid.getGridEl().id;Ext.grid.HeaderDropZone.superclass.constructor.call(this,A.getGridEl().dom)};Ext.extend(Ext.grid.HeaderDropZone,Ext.dd.DropZone,{proxyOffsets:[-4,-9],fly:Ext.Element.fly,getTargetFromEvent:function(C){var A=Ext.lib.Event.getTarget(C);var B=this.view.findCellIndex(A);if(B!==false){return this.view.getHeaderCell(B)}},nextVisible:function(C){var B=this.view,A=this.grid.colModel;C=C.nextSibling;while(C){if(!A.isHidden(B.getCellIndex(C))){return C}C=C.nextSibling}return null},prevVisible:function(C){var B=this.view,A=this.grid.colModel;C=C.prevSibling;while(C){if(!A.isHidden(B.getCellIndex(C))){return C}C=C.prevSibling}return null},positionIndicator:function(D,B,E){var H=Ext.lib.Event.getPageX(E);var A=Ext.lib.Dom.getRegion(B.firstChild);var I,K,G=A.top+this.proxyOffsets[1];if((A.right-H)<=(A.right-A.left)/2){I=A.right+this.view.borderWidth;K="after"}else{I=A.left;K="before"}var F=this.view.getCellIndex(D);var J=this.view.getCellIndex(B);if(this.grid.colModel.isFixed(J)){return false}var C=this.grid.colModel.isLocked(J);if(K=="after"){J++}if(F<J){J--}if(F==J&&(C==this.grid.colModel.isLocked(F))){return false}I+=this.proxyOffsets[0];this.proxyTop.setLeftTop(I,G);this.proxyTop.show();if(!this.bottomOffset){this.bottomOffset=this.view.mainHd.getHeight()}this.proxyBottom.setLeftTop(I,G+this.proxyTop.dom.offsetHeight+this.bottomOffset);this.proxyBottom.show();return K},onNodeEnter:function(D,A,C,B){if(B.header!=D){this.positionIndicator(B.header,D,C)}},onNodeOver:function(E,B,D,C){var A=false;if(C.header!=E){A=this.positionIndicator(C.header,E,D)}if(!A){this.proxyTop.hide();this.proxyBottom.hide()}return A?this.dropAllowed:this.dropNotAllowed},onNodeOut:function(D,A,C,B){this.proxyTop.hide();this.proxyBottom.hide()},onNodeDrop:function(B,K,F,D){var E=D.header;if(E!=B){var I=this.grid.colModel;var H=Ext.lib.Event.getPageX(F);var A=Ext.lib.Dom.getRegion(B.firstChild);var L=(A.right-H)<=((A.right-A.left)/2)?"after":"before";var G=this.view.getCellIndex(E);var J=this.view.getCellIndex(B);var C=I.isLocked(J);if(L=="after"){J++}if(G<J){J--}if(G==J&&(C==I.isLocked(G))){return false}I.setLocked(G,C,true);I.moveColumn(G,J);this.grid.fireEvent("columnmove",G,J);return true}return false}});Ext.grid.GridView.ColumnDragZone=function(A,B){Ext.grid.GridView.ColumnDragZone.superclass.constructor.call(this,A,B,null);this.proxy.el.addClass("x-grid3-col-dd")};Ext.extend(Ext.grid.GridView.ColumnDragZone,Ext.grid.HeaderDragZone,{handleMouseDown:function(A){},callHandleMouseDown:function(A){Ext.grid.GridView.ColumnDragZone.superclass.handleMouseDown.call(this,A)}});
Ext.grid.SplitDragZone=function(A,C,B){this.grid=A;this.view=A.getView();this.proxy=this.view.resizeProxy;Ext.grid.SplitDragZone.superclass.constructor.call(this,C,"gridSplitters"+this.grid.getGridEl().id,{dragElId:Ext.id(this.proxy.dom),resizeFrame:false});this.setHandleElId(Ext.id(C));this.setOuterHandleElId(Ext.id(B));this.scroll=false};Ext.extend(Ext.grid.SplitDragZone,Ext.dd.DDProxy,{fly:Ext.Element.fly,b4StartDrag:function(A,D){this.view.headersDisabled=true;this.proxy.setHeight(this.view.mainWrap.getHeight());var B=this.cm.getColumnWidth(this.cellIndex);var C=Math.max(B-this.grid.minColumnWidth,0);this.resetConstraints();this.setXConstraint(C,1000);this.setYConstraint(0,0);this.minX=A-C;this.maxX=A+1000;this.startPos=A;Ext.dd.DDProxy.prototype.b4StartDrag.call(this,A,D)},handleMouseDown:function(B){ev=Ext.EventObject.setEvent(B);var A=this.fly(ev.getTarget());if(A.hasClass("x-grid-split")){this.cellIndex=this.view.getCellIndex(A.dom);this.split=A.dom;this.cm=this.grid.colModel;if(this.cm.isResizable(this.cellIndex)&&!this.cm.isFixed(this.cellIndex)){Ext.grid.SplitDragZone.superclass.handleMouseDown.apply(this,arguments)}}},endDrag:function(C){this.view.headersDisabled=false;var A=Math.max(this.minX,Ext.lib.Event.getPageX(C));var B=A-this.startPos;this.view.onColumnSplitterMoved(this.cellIndex,this.cm.getColumnWidth(this.cellIndex)+B)},autoOffset:function(){this.setDelta(0,0)}});
Ext.grid.GridDragZone=function(B,A){this.view=B.getView();Ext.grid.GridDragZone.superclass.constructor.call(this,this.view.mainBody.dom,A);if(this.view.lockedBody){this.setHandleElId(Ext.id(this.view.mainBody.dom));this.setOuterHandleElId(Ext.id(this.view.lockedBody.dom))}this.scroll=false;this.grid=B;this.ddel=document.createElement("div");this.ddel.className="x-grid-dd-wrap"};Ext.extend(Ext.grid.GridDragZone,Ext.dd.DragZone,{ddGroup:"GridDD",getDragData:function(B){var A=Ext.lib.Event.getTarget(B);var D=this.view.findRowIndex(A);if(D!==false){var C=this.grid.selModel;if(!C.isSelected(D)||B.hasModifier()){C.handleMouseDown(B,A)}return{grid:this.grid,ddel:this.ddel,rowIndex:D,selections:C.getSelections()}}return false},onInitDrag:function(B){var A=this.dragData;this.ddel.innerHTML=this.grid.getDragDropText();this.proxy.update(this.ddel)},afterRepair:function(){this.dragging=false},getRepairXY:function(B,A){return false},onEndDrag:function(A,B){},onValidDrop:function(A,B,C){this.hideProxy()},beforeInvalidDrop:function(A,B){}});
