
Ext.override(Ext.Container,{render:function(){Ext.Container.superclass.render.apply(this,arguments);if(this.layout){if(typeof this.layout=='string'){this.layout=new Ext.Container.LAYOUTS[this.layout.toLowerCase()](this.layoutConfig);}
this.setLayout(this.layout);if(this.activeItem!==undefined){var item=this.activeItem;delete this.activeItem;this.layout.setActiveItem(item);}}
if(!this.ownerCt){this.doLayout();}
if(this.monitorResize===true){Ext.EventManager.onWindowResize(this.doLayout,this,[false]);}}});Ext.override(Ext.layout.Accordion,{setActiveItem:function(c){c=this.container.getComponent(c);if(this.activeItem!=c){if(c.rendered&&c.collapsed){c.expand();}else{this.activeItem=c;}}},renderItem:function(c){if(this.animate===false){c.animCollapse=false;}
c.collapsible=true;if(this.autoWidth){c.autoWidth=true;}
if(this.titleCollapse){c.titleCollapse=true;}
if(this.hideCollapseTool){c.hideCollapseTool=true;}
if(this.collapseFirst!==undefined){c.collapseFirst=this.collapseFirst;}
if(!this.activeItem&&!c.collapsed){this.activeItem=c;}else if(this.activeItem){c.collapsed=this.activeItem!=c;}
Ext.layout.Accordion.superclass.renderItem.apply(this,arguments);c.header.addClass('x-accordion-hd');c.on('beforeexpand',this.beforeExpand,this);}});Ext.override(Ext.layout.TableLayout,{onLayout:function(ct,target){var cs=ct.items.items,len=cs.length,c,i;if(!this.table){target.addClass('x-table-layout-ct');this.table=target.createChild({tag:'table',cls:'x-table-layout',cellspacing:0,cn:{tag:'tbody'}},null,true);}
this.renderAll(ct,target);}});Ext.override(Ext.menu.Item,{onRender:function(container,position){var el=document.createElement("a");el.hideFocus=true;el.unselectable="on";el.href=this.href||"#";if(this.hrefTarget){el.target=this.hrefTarget;}
el.className=this.itemCls+(this.menu?" x-menu-item-arrow":"")+(this.cls?" "+this.cls:"");el.innerHTML=String.format('<img src="{0}" class="x-menu-item-icon {2}" />{1}',this.icon||Ext.BLANK_IMAGE_URL,this.itemText||this.text,this.iconCls||'');if((typeof this.tooltip)!="undefined")
{var tt=new Ext.ToolTip({target:el,autoHide:true,dismissDelay:0,showDelay:200,html:this.tooltip});}
this.el=el;Ext.menu.Item.superclass.onRender.call(this,container,position);}});Ext.override(Ext.tree.TreeNodeUI,{onDblClick:function(e){e.preventDefault();if(this.disabled){return;}
if(this.checkbox){this.toggleCheck();}
if(this.fireEvent("dblclick",this.node,e)!==false){if(!this.animating&&this.node.hasChildNodes()){this.node.toggle();}}}});Ext.tree.ColumnTree=Ext.extend(Ext.tree.TreePanel,{lines:false,borderWidth:Ext.isBorderBox?0:2,cls:'x-column-tree',mask:true,maskConfig:{msg:"Loading tree items..."},onRender:function(){Ext.tree.ColumnTree.superclass.onRender.apply(this,arguments);if(this.mask){this.createMask.call(this);}
this.headers=this.body.createChild({cls:'x-tree-headers'},this.innerCt.dom);var cols=this.columns,c;var totalWidth=0;for(var i=0,len=cols.length;i<len;i++){c=cols[i];totalWidth+=c.width;this.headers.createChild({cls:'x-tree-hd '+(c.cls?c.cls+'-hd':''),cn:{cls:'x-tree-hd-text',html:c.header},style:'width:'+(c.width-this.borderWidth)+'px;'});}
this.headers.createChild({cls:'x-clear'});this.headers.setWidth(totalWidth);this.innerCt.setWidth(totalWidth);},createMask:function(){var mask=new Ext.LoadMask(this.getEl(),this.maskConfig);mask.show();this.on('beforeload',mask.show,mask);this.on('load',mask.hide,mask);}});Ext.tree.ColumnNodeUI=Ext.extend(Ext.tree.TreeNodeUI,{focus:Ext.emptyFn,renderElements:function(n,a,targetNode,bulkRender){this.indentMarkup=n.parentNode?n.parentNode.ui.getChildIndent():'';var t=n.getOwnerTree();var cols=t.columns;var bw=t.borderWidth;var c=cols[0];var buf=['<li class="x-tree-node"><div ext:tree-node-id="',n.id,'" class="x-tree-node-el x-tree-node-leaf ',a.cls,'">','<div class="x-tree-col" style="width:',c.width-bw,'px;">','<span class="x-tree-node-indent">',this.indentMarkup,"</span>",'<img src="',this.emptyIcon,'" class="x-tree-ec-icon x-tree-elbow">','<img src="',a.icon||this.emptyIcon,'" class="x-tree-node-icon',(a.icon?" x-tree-node-inline-icon":""),(a.iconCls?" "+a.iconCls:""),'" unselectable="on">','<a hidefocus="on" class="x-tree-node-anchor" href="',a.href?a.href:"#",'" tabIndex="1" ',a.hrefTarget?' target="'+a.hrefTarget+'"':"",'>','<span unselectable="on">',n.text||(c.renderer?c.renderer(a[c.dataIndex],n,a):a[c.dataIndex]),"</span></a>","</div>"];for(var i=1,len=cols.length;i<len;i++){c=cols[i];buf.push('<div class="x-tree-col ',(c.cls?c.cls:''),'" style="width:',c.width-bw,'px;">','<div class="x-tree-col-text">',(c.renderer?c.renderer(a[c.dataIndex],n,a):a[c.dataIndex]),"</div>","</div>");}
buf.push('<div class="x-clear"></div></div>','<ul class="x-tree-node-ct" style="display:none;"></ul>',"</li>");if(bulkRender!==true&&n.nextSibling&&n.nextSibling.ui.getEl()){this.wrap=Ext.DomHelper.insertHtml("beforeBegin",n.nextSibling.ui.getEl(),buf.join(""));}else{this.wrap=Ext.DomHelper.insertHtml("beforeEnd",targetNode,buf.join(""));}
this.elNode=this.wrap.childNodes[0];this.ctNode=this.wrap.childNodes[1];var cs=this.elNode.firstChild.childNodes;this.indentNode=cs[0];this.ecNode=cs[1];this.iconNode=cs[2];this.anchor=cs[3];this.textNode=cs[3].firstChild;}});Ext.reg("columntree",Ext.tree.ColumnTree);Ext.ux.DDView=function(config){if(!config.itemSelector){var tpl=config.tpl;if(this.classRe.test(tpl)){config.tpl=tpl.replace(this.classRe,'class=$1x-combo-list-item $2$1');}
else{config.tpl=tpl.replace(this.tagRe,'$1 class="x-combo-list-item" $2');}
config.itemSelector=".x-combo-list-item";}
Ext.ux.DDView.superclass.constructor.call(this,Ext.apply(config,{border:false}));};Ext.extend(Ext.ux.DDView,Ext.DataView,{sortDir:'ASC',isFormField:true,classRe:/class=(['"])(.*)\1/,tagRe:/(<\w*)(.*?>)/,reset:Ext.emptyFn,clearInvalid:Ext.form.Field.prototype.clearInvalid,afterRender:function(){Ext.ux.DDView.superclass.afterRender.call(this);if(this.dragGroup){this.setDraggable(this.dragGroup.split(","));}
if(this.dropGroup){this.setDroppable(this.dropGroup.split(","));}
if(this.deletable){this.setDeletable();}
this.isDirtyFlag=false;this.addEvents("drop");},validate:function(){return true;},destroy:function(){this.purgeListeners();this.getEl().removeAllListeners();this.getEl().remove();if(this.dragZone){if(this.dragZone.destroy){this.dragZone.destroy();}}
if(this.dropZone){if(this.dropZone.destroy){this.dropZone.destroy();}}},getName:function(){return this.name;},setValue:function(v){if(!this.store){throw"DDView.setValue(). DDView must be constructed with a valid Store";}
var data={};data[this.store.reader.meta.root]=v?[].concat(v):[];this.store.proxy=new Ext.data.MemoryProxy(data);this.store.load();},getValue:function(){var result='(';this.store.each(function(rec){result+=rec.id+',';});return result.substr(0,result.length-1)+')';},getIds:function(){var i=0,result=new Array(this.store.getCount());this.store.each(function(rec){result[i++]=rec.id;});return result;},isDirty:function(){return this.isDirtyFlag;},getTargetFromEvent:function(e){var target=e.getTarget();while((target!==null)&&(target.parentNode!=this.el.dom)){target=target.parentNode;}
if(!target){target=this.el.dom.lastChild||this.el.dom;}
return target;},getDragData:function(e){var target=this.findItemFromChild(e.getTarget());if(target){if(!this.isSelected(target)){delete this.ignoreNextClick;this.onItemClick(target,this.indexOf(target),e);this.ignoreNextClick=true;}
var dragData={sourceView:this,viewNodes:[],records:[],copy:this.copy||(this.allowCopy&&e.ctrlKey)};if(this.getSelectionCount()==1){var i=this.getSelectedIndexes()[0];var n=this.getNode(i);dragData.viewNodes.push(dragData.ddel=n);dragData.records.push(this.store.getAt(i));dragData.repairXY=Ext.fly(n).getXY();}else{dragData.ddel=document.createElement('div');dragData.ddel.className='multi-proxy';this.collectSelection(dragData);}
return dragData;}
return false;},getRepairXY:function(e){return this.dragData.repairXY;},collectSelection:function(data){data.repairXY=Ext.fly(this.getSelectedNodes()[0]).getXY();if(this.preserveSelectionOrder===true){Ext.each(this.getSelectedIndexes(),function(i){var n=this.getNode(i);var dragNode=n.cloneNode(true);dragNode.id=Ext.id();data.ddel.appendChild(dragNode);data.records.push(this.store.getAt(i));data.viewNodes.push(n);},this);}else{var i=0;this.store.each(function(rec){if(this.isSelected(i)){var n=this.getNode(i);var dragNode=n.cloneNode(true);dragNode.id=Ext.id();data.ddel.appendChild(dragNode);data.records.push(this.store.getAt(i));data.viewNodes.push(n);}
i++;},this);}},setDraggable:function(ddGroup){if(ddGroup instanceof Array){Ext.each(ddGroup,this.setDraggable,this);return;}
if(this.dragZone){this.dragZone.addToGroup(ddGroup);}else{this.dragZone=new Ext.dd.DragZone(this.getEl(),{containerScroll:true,ddGroup:ddGroup});if(!this.multiSelect){this.singleSelect=true;}
this.dragZone.getDragData=this.getDragData.createDelegate(this);this.dragZone.getRepairXY=this.getRepairXY;this.dragZone.onEndDrag=this.onEndDrag;}},setDroppable:function(ddGroup){if(ddGroup instanceof Array){Ext.each(ddGroup,this.setDroppable,this);return;}
if(this.dropZone){this.dropZone.addToGroup(ddGroup);}else{this.dropZone=new Ext.dd.DropZone(this.getEl(),{owningView:this,containerScroll:true,ddGroup:ddGroup});this.dropZone.getTargetFromEvent=this.getTargetFromEvent.createDelegate(this);this.dropZone.onNodeEnter=this.onNodeEnter.createDelegate(this);this.dropZone.onNodeOver=this.onNodeOver.createDelegate(this);this.dropZone.onNodeOut=this.onNodeOut.createDelegate(this);this.dropZone.onNodeDrop=this.onNodeDrop.createDelegate(this);}},getDropPoint:function(e,n,dd){if(n==this.el.dom){return"above";}
var t=Ext.lib.Dom.getY(n),b=t+n.offsetHeight;var c=t+(b-t)/2;var y=Ext.lib.Event.getPageY(e);if(y<=c){return"above";}else{return"below";}},isValidDropPoint:function(pt,n,data){if(!data.viewNodes||(data.viewNodes.length!=1)){return true;}
var d=data.viewNodes[0];if(d==n){return false;}
if((pt=="below")&&(n.nextSibling==d)){return false;}
if((pt=="above")&&(n.previousSibling==d)){return false;}
return true;},onNodeEnter:function(n,dd,e,data){if(this.highlightColor&&(data.sourceView!=this)){this.el.highlight(this.highlightColor);}
return false;},onNodeOver:function(n,dd,e,data){var dragElClass=this.dropNotAllowed;var pt=this.getDropPoint(e,n,dd);if(this.isValidDropPoint(pt,n,data)){if(this.appendOnly||this.sortField){return"x-tree-drop-ok-below";}
if(pt){var targetElClass;if(pt=="above"){dragElClass=n.previousSibling?"x-tree-drop-ok-between":"x-tree-drop-ok-above";targetElClass="x-view-drag-insert-above";}else{dragElClass=n.nextSibling?"x-tree-drop-ok-between":"x-tree-drop-ok-below";targetElClass="x-view-drag-insert-below";}
if(this.lastInsertClass!=targetElClass){Ext.fly(n).replaceClass(this.lastInsertClass,targetElClass);this.lastInsertClass=targetElClass;}}}
return dragElClass;},onNodeOut:function(n,dd,e,data){this.removeDropIndicators(n);},onNodeDrop:function(n,dd,e,data){if(this.fireEvent("drop",this,n,dd,e,data)===false){return false;}
var pt=this.getDropPoint(e,n,dd);var insertAt=(this.appendOnly||(n==this.el.dom))?this.store.getCount():n.viewIndex;if(pt=="below"){insertAt++;}
if(data.sourceView==this){if(pt=="below"){if(data.viewNodes[0]==n){data.viewNodes.shift();}}else{if(data.viewNodes[data.viewNodes.length-1]==n){data.viewNodes.pop();}}
if(!data.viewNodes.length){return false;}
if(insertAt>this.store.indexOf(data.records[0])){insertAt--;}}
if(data.node instanceof Ext.tree.TreeNode){var r=data.node.getOwnerTree().recordFromNode(data.node);if(r){data.records=[r];}}
if(!data.records){alert("Programming problem. Drag data contained no Records");return false;}
for(var i=0;i<data.records.length;i++){var r=data.records[i];var dup=this.store.getById(r.id);if(dup&&(dd!=this.dragZone)){if(!this.allowDup&&!this.allowTrash){Ext.fly(this.getNode(this.store.indexOf(dup))).frame("red",1);return true}
var x=new Ext.data.Record();r.id=x.id;delete x;}
if(data.copy){this.store.insert(insertAt++,r.copy());}else{if(data.sourceView){data.sourceView.isDirtyFlag=true;data.sourceView.store.remove(r);}
if(!this.allowTrash)this.store.insert(insertAt++,r);}
if(this.sortField){this.store.sort(this.sortField,this.sortDir);}
this.isDirtyFlag=true;}
this.dragZone.cachedTarget=null;return true;},onEndDrag:function(data,e){var d=Ext.get(this.dragData.ddel);if(d&&d.hasClass("multi-proxy")){d.remove();}},removeDropIndicators:function(n){if(n){Ext.fly(n).removeClass(["x-view-drag-insert-above","x-view-drag-insert-left","x-view-drag-insert-right","x-view-drag-insert-below"]);this.lastInsertClass="_noclass";}},setDeletable:function(imageUrl){if(!this.singleSelect&&!this.multiSelect){this.singleSelect=true;}
var c=this.getContextMenu();this.contextMenu.on("itemclick",function(item){switch(item.id){case"delete":this.remove(this.getSelectedIndexes());break;}},this);this.contextMenu.add({icon:imageUrl||AU.resolveUrl("/images/delete.gif"),id:"delete",text:AU.getMessage("deleteItem")});},getContextMenu:function(){if(!this.contextMenu){this.contextMenu=new Ext.menu.Menu({id:this.id+"-contextmenu"});this.el.on("contextmenu",this.showContextMenu,this);}
return this.contextMenu;},disableContextMenu:function(){if(this.contextMenu){this.el.un("contextmenu",this.showContextMenu,this);}},showContextMenu:function(e,item){item=this.findItemFromChild(e.getTarget());if(item){e.stopEvent();this.select(this.getNode(item),this.multiSelect&&e.ctrlKey,true);this.contextMenu.showAt(e.getXY());}},remove:function(selectedIndices){selectedIndices=[].concat(selectedIndices);for(var i=0;i<selectedIndices.length;i++){var rec=this.store.getAt(selectedIndices[i]);this.store.remove(rec);}},onDblClick:function(e){var item=this.findItemFromChild(e.getTarget());if(item){if(this.fireEvent("dblclick",this,this.indexOf(item),item,e)===false){return false;}
if(this.dragGroup){var targets=Ext.dd.DragDropMgr.getRelated(this.dragZone,true);while(targets.indexOf(this.dropZone)!==-1){targets.remove(this.dropZone);}
if((targets.length==1)&&(targets[0].owningView)){this.dragZone.cachedTarget=null;var el=Ext.get(targets[0].getEl());var box=el.getBox(true);targets[0].onNodeDrop(el.dom,{target:el.dom,xy:[box.x,box.y+box.height-1]},null,this.getDragData(e));}}}},onItemClick:function(item,index,e){if(this.ignoreNextClick){delete this.ignoreNextClick;return;}
if(this.fireEvent("beforeclick",this,index,item,e)===false){return false;}
if(this.multiSelect||this.singleSelect){if(this.multiSelect&&e.shiftKey&&this.lastSelection){this.select(this.getNodes(this.indexOf(this.lastSelection),index),false);}else if(this.isSelected(item)&&e.ctrlKey){this.deselect(item);}else{this.deselect(item);this.select(item,this.multiSelect&&e.ctrlKey);this.lastSelection=item;}
e.preventDefault();}
return true;}});Ext.ux.Multiselect=Ext.extend(Ext.form.Field,{appendOnly:false,dataFields:[],data:[],width:100,height:100,displayField:0,valueField:1,allowBlank:true,minLength:0,maxLength:Number.MAX_VALUE,blankText:Ext.form.TextField.prototype.blankText,minLengthText:'Minimum {0} item(s) required',maxLengthText:'Maximum {0} item(s) allowed',delimiter:',',copy:false,allowDup:false,allowTrash:false,focusClass:undefined,sortDir:'ASC',defaultAutoCreate:{tag:"div"},initComponent:function(){Ext.ux.Multiselect.superclass.initComponent.call(this);this.addEvents({'dblclick':true,'click':true,'change':true,'drop':true});},onRender:function(ct,position){Ext.ux.Multiselect.superclass.onRender.call(this,ct,position);var cls='ux-mselect';var fs=new Ext.form.FieldSet({renderTo:this.el,title:this.legend,height:this.height,width:this.width,style:"padding:0;",tbar:this.tbar});fs.body.addClass(cls);var tpl='<tpl for="."><div class="'+cls+'-item';if(Ext.isIE||Ext.isIE7){tpl+='" unselectable=on';}else{tpl+=' x-unselectable"';}
tpl+='>{'+this.displayField+'}</div></tpl>';if(!this.store){this.store=new Ext.data.SimpleStore({fields:this.dataFields,data:this.data});}
this.view=new Ext.ux.DDView({multiSelect:true,store:this.store,selectedClass:cls+"-selected",tpl:tpl,allowDup:this.allowDup,copy:this.copy,allowTrash:this.allowTrash,dragGroup:this.dragGroup,dropGroup:this.dropGroup,itemSelector:"."+cls+"-item",isFormField:false,applyTo:fs.body,appendOnly:this.appendOnly,sortField:this.sortField,sortDir:this.sortDir});fs.add(this.view);this.view.on('click',this.onViewClick,this);this.view.on('beforeClick',this.onViewBeforeClick,this);this.view.on('dblclick',this.onViewDblClick,this);this.view.on('drop',function(ddView,n,dd,e,data){return this.fireEvent("drop",ddView,n,dd,e,data);},this);this.hiddenName=this.name;var hiddenTag={tag:"input",type:"hidden",value:"",name:this.name};if(this.isFormField){this.hiddenField=this.el.createChild(hiddenTag);}else{this.hiddenField=Ext.get(document.body).createChild(hiddenTag);}
fs.doLayout();},initValue:Ext.emptyFn,onViewClick:function(vw,index,node,e){var arrayIndex=this.preClickSelections.indexOf(index);if(arrayIndex!=-1)
{this.preClickSelections.splice(arrayIndex,1);this.view.clearSelections(true);this.view.select(this.preClickSelections);}
this.fireEvent('change',this,this.getValue(),this.hiddenField.dom.value);this.hiddenField.dom.value=this.getValue();this.fireEvent('click',this,e);this.validate();},onViewBeforeClick:function(vw,index,node,e){this.preClickSelections=this.view.getSelectedIndexes();if(this.disabled){return false;}},onViewDblClick:function(vw,index,node,e){return this.fireEvent('dblclick',vw,index,node,e);},getValue:function(valueField){var returnArray=[];var selectionsArray=this.view.getSelectedIndexes();if(selectionsArray.length==0){return'';}
for(var i=0;i<selectionsArray.length;i++){returnArray.push(this.store.getAt(selectionsArray[i]).get(((valueField!=null)?valueField:this.valueField)));}
return returnArray.join(this.delimiter);},setValue:function(values){var index;var selections=[];this.view.clearSelections();this.hiddenField.dom.value='';if(!values||(values=='')){return;}
if(!(values instanceof Array)){values=values.split(this.delimiter);}
for(var i=0;i<values.length;i++){index=this.view.store.indexOf(this.view.store.query(this.valueField,new RegExp('^'+values[i]+'$',"i")).itemAt(0));selections.push(index);}
this.view.select(selections);this.hiddenField.dom.value=this.getValue();this.validate();},reset:function(){this.setValue('');},getRawValue:function(valueField){var tmp=this.getValue(valueField);if(tmp.length){tmp=tmp.split(this.delimiter);}
else{tmp=[];}
return tmp;},setRawValue:function(values){setValue(values);},validateValue:function(value){if(value.length<1){if(this.allowBlank){this.clearInvalid();return true;}else{this.markInvalid(this.blankText);return false;}}
if(value.length<this.minLength){this.markInvalid(String.format(this.minLengthText,this.minLength));return false;}
if(value.length>this.maxLength){this.markInvalid(String.format(this.maxLengthText,this.maxLength));return false;}
return true;}});Ext.reg("multiselect",Ext.ux.Multiselect);Ext.namespace('Ext.ux.dd');Ext.ux.dd.GridReorderDropTarget=function(grid,config){this.target=new Ext.dd.DropTarget(grid.getEl(),{ddGroup:grid.ddGroup||'GridDD',grid:grid,gridDropTarget:this,notifyDrop:function(dd,e,data){var t=Ext.lib.Event.getTarget(e);var rindex=this.grid.getView().findRowIndex(t);if(rindex===false)return false;if(rindex==data.rowIndex)return false;if(this.gridDropTarget.fireEvent(this.copy?'beforerowcopy':'beforerowmove',this.gridDropTarget,data.rowIndex,rindex,data.selections)===false)return false;var ds=this.grid.getStore();if(!this.copy){for(i=0;i<data.selections.length;i++){ds.remove(ds.getById(data.selections[i].id));}}
ds.insert(rindex,data.selections);var sm=this.grid.getSelectionModel();if(sm)sm.selectRecords(data.selections);this.gridDropTarget.fireEvent(this.copy?'afterrowcopy':'afterrowmove',this.gridDropTarget,data.rowIndex,rindex,data.selections);return true;},notifyOver:function(dd,e,data){var t=Ext.lib.Event.getTarget(e);var rindex=this.grid.getView().findRowIndex(t);if(rindex==data.rowIndex)rindex=false;return(rindex===false)?this.dropNotAllowed:this.dropAllowed;}});if(config){Ext.apply(this.target,config);if(config.listeners)Ext.apply(this,{listeners:config.listeners});}
this.addEvents({"beforerowmove":true,"afterrowmove":true,"beforerowcopy":true,"afterrowcopy":true});Ext.ux.dd.GridReorderDropTarget.superclass.constructor.call(this);};Ext.extend(Ext.ux.dd.GridReorderDropTarget,Ext.util.Observable,{getTarget:function(){return this.target;},getGrid:function(){return this.target.grid;},getCopy:function(){return this.target.copy?true:false;},setCopy:function(b){this.target.copy=b?true:false;}});Ext.ux.MaskTree=Ext.extend(Ext.tree.TreePanel,{mask:true,maskConfig:{msg:"Loading tree items..."},initComponent:function(){Ext.ux.MaskTree.superclass.initComponent.apply(this,arguments);if(this.mask){this.on('render',this.createMask,this);}},createMask:function(){var mask=new Ext.LoadMask(this.getEl(),this.maskConfig);this.getLoader().on('beforeload',mask.show,mask);this.getLoader().on('load',mask.hide,mask);}});Ext.reg('masktree',Ext.ux.MaskTree);Ext.ux.CustomCombo=Ext.extend(Ext.form.ComboBox,{findText:false,replaceText:false,initComponent:function(){Ext.ux.CustomCombo.superclass.initComponent.call(this);},setValue:function(c){Ext.ux.CustomCombo.superclass.setValue.call(this,c);if(this.findText!==false&&this.replaceText!==false)
{var text=this.lastSelectionText;if(Ext.isArray(this.findText))
{var repl;for(var i=0;i<this.findText.length;i++)
{if(Ext.isArray(this.replaceText))
repl=this.replaceText[i];else
repl=this.replaceText;text=text.replace(this.findText[i],repl,'gi');}}
else
{text=text.replace(this.findText,this.replaceText,'gi');}
Ext.form.ComboBox.superclass.setValue.call(this,text);this.lastSelectionText=text;}}});Ext.reg('customcombo',Ext.ux.CustomCombo);Ext.namespace('Ext.ux.plugins');Ext.ux.plugins.MultiLineHeader=function(config){Ext.apply(this,config);};Ext.extend(Ext.ux.plugins.MultiLineHeader,Ext.util.Observable,{init:function(grid){var view=grid.getView();view.beforeMethod('initTemplates',this.initTemplates);view.on('refresh',this.setHeaderHeight,grid);},initTemplates:function(){var ts=this.templates||{};if(!ts.hcell){ts.hcell=new Ext.Template('<td class="x-grid3-hd x-grid3-cell x-grid3-td-{id}" style="{style}"><div {attr} class="x-grid3-hd-inner x-grid3-hd-{id}" unselectable="on" style="{istyle}"><div {tooltip} class="ux-grid3-hd-wrap">',this.grid.enableHdMenu?'<a class="x-grid3-hd-btn" href="#"></a>':'','{value}<img class="x-grid3-sort-icon" src="',Ext.BLANK_IMAGE_URL,'" />',"</div></div></td>");}
this.templates=ts;},setHeaderHeight:function(){var columns=this.getColumnModel().config.length;var height=this.getView().mainHd.getComputedHeight();var xView=this.getView()
for(var c=0;c<columns;c++){var headerCellObj=Ext.get(xView.getHeaderCell([c]).firstChild);var headerWrapObj=Ext.get(headerCellObj.child('.ux-grid3-hd-wrap'));var headerBtnObj=Ext.get(headerWrapObj.child('.x-grid3-hd-btn'));headerCellObj.setHeight(height);headerWrapObj.setHeight(height-headerCellObj.getPadding('tb'));if(height>50){headerBtnObj.addClass('ux-grid3-hd-btn-large');}else{headerBtnObj.removeClass('ux-grid3-hd-btn-large');}}}});Ext.ns('Ext.ux.grid');Ext.ux.grid.GridSummary=function(config){Ext.apply(this,config);};Ext.extend(Ext.ux.grid.GridSummary,Ext.util.Observable,{init:function(grid){this.grid=grid;this.cm=grid.getColumnModel();this.view=grid.getView();var v=this.view;v.onLayout=this.onLayout;v.afterMethod('render',this.refreshSummary,this);v.afterMethod('refresh',this.refreshSummary,this);v.afterMethod('syncScroll',this.syncSummaryScroll,this);v.afterMethod('onColumnWidthUpdated',this.doWidth,this);v.afterMethod('onAllColumnWidthsUpdated',this.doAllWidths,this);v.afterMethod('onColumnHiddenUpdated',this.doHidden,this);grid.store.on({add:this.refreshSummary,remove:this.refreshSummary,clear:this.refreshSummary,update:this.refreshSummary,scope:this});if(!this.rowTpl){this.rowTpl=new Ext.Template('<div class="x-grid3-summary-row x-grid3-gridsummary-row-offset">','<table class="x-grid3-summary-table" border="0" cellspacing="0" cellpadding="0" style="{tstyle}">','<tbody><tr>{cells}</tr></tbody>','</table>','</div>');this.rowTpl.disableFormats=true;}
this.rowTpl.compile();if(!this.cellTpl){this.cellTpl=new Ext.Template('<td class="x-grid3-col x-grid3-cell x-grid3-td-{id} {css}" style="{style}">','<div class="x-grid3-cell-inner x-grid3-col-{id}" unselectable="on" {attr}>{value}</div>',"</td>");this.cellTpl.disableFormats=true;}
this.cellTpl.compile();},calculate:function(rs,cm){var data={},cfg=cm.config;for(var i=0,len=cfg.length;i<len;i++){var cf=cfg[i],cname=cf.dataIndex;data[cname]=0;if(cf.summaryType){for(var j=0,jlen=rs.length;j<jlen;j++){var r=rs[j];data[cname]=Ext.ux.grid.GridSummary.Calculations[cf.summaryType](r.get(cname),r,cname,data,j);}}}
return data;},onLayout:function(vw,vh){if(Ext.type(vh)!='number'){return;}
if(!this.grid.getGridEl().hasClass('x-grid-hide-gridsummary')){this.scroller.setHeight(vh-this.summary.getHeight());}},syncSummaryScroll:function(){var mb=this.view.scroller.dom;this.view.summaryWrap.dom.scrollLeft=mb.scrollLeft;this.view.summaryWrap.dom.scrollLeft=mb.scrollLeft;},doWidth:function(col,w,tw){var s=this.view.summary.dom;s.firstChild.style.width=tw;s.firstChild.rows[0].childNodes[col].style.width=w;},doAllWidths:function(ws,tw){var s=this.view.summary.dom,wlen=ws.length;s.firstChild.style.width=tw;var cells=s.firstChild.rows[0].childNodes;for(var j=0;j<wlen;j++){cells[j].style.width=ws[j];}},doHidden:function(col,hidden,tw){var s=this.view.summary.dom,display=hidden?'none':'';s.firstChild.style.width=tw;s.firstChild.rows[0].childNodes[col].style.display=display;},renderSummary:function(o,cs,cm){cs=cs||this.view.getColumnData();var cfg=cm.config,buf=[],last=cs.length-1;for(var i=0,len=cs.length;i<len;i++){var c=cs[i],cf=cfg[i],p={};p.id=c.id;p.style=c.style;p.css=i==0?'x-grid3-cell-first ':(i==last?'x-grid3-cell-last ':'');if(cf.summaryType||cf.summaryRenderer){p.value=(cf.summaryRenderer||c.renderer)(o.data[c.name],p,o);}else{p.value='';}
if(p.value==undefined||p.value==="")p.value="*";buf[buf.length]=this.cellTpl.apply(p);}
return this.rowTpl.apply({tstyle:'width:'+this.view.getTotalWidth()+';',cells:buf.join('')});},refreshSummary:function(){var g=this.grid,ds=g.store,cs=this.view.getColumnData(),cm=this.cm,rs=ds.getRange(),data=this.calculate(rs,cm),buf=this.renderSummary({data:data},cs,cm);if(!this.view.summaryWrap){this.view.summaryWrap=Ext.DomHelper.insertAfter(this.view.scroller,{tag:'div',cls:'x-grid3-gridsummary-row-inner'},true);}
this.view.summary=this.view.summaryWrap.update(buf).first();},toggleSummary:function(visible){var el=this.grid.getGridEl();if(el){if(visible===undefined){visible=el.hasClass('x-grid-hide-gridsummary');}
el[visible?'removeClass':'addClass']('x-grid-hide-gridsummary');this.view.layout();}},getSummaryNode:function(){return this.view.summary}});Ext.reg('gridsummary',Ext.ux.grid.GridSummary);Ext.ux.grid.GridSummary.Calculations={sum:function(v,record,colName,data,rowIdx){return data[colName]+Ext.num(v,0);},count:function(v,record,colName,data,rowIdx){return rowIdx+1;},max:function(v,record,colName,data,rowIdx){return Math.max(Ext.num(v,0),data[colName]);},min:function(v,record,colName,data,rowIdx){return Math.min(Ext.num(v,0),data[colName]);},average:function(v,record,colName,data,rowIdx){var t=data[colName]+Ext.num(v,0),count=record.store.getCount();return rowIdx==count-1?(t/count):t;}}
Ext.ns('Ext.ux.grid');Ext.ux.grid.CheckColumn=function(config){Ext.apply(this,config);if(!this.id){this.id=Ext.id();}
this.renderer=this.renderer.createDelegate(this);};Ext.ux.grid.CheckColumn.prototype={init:function(grid){this.grid=grid;this.grid.on('render',function(){var view=this.grid.getView();view.mainBody.on('mousedown',this.onMouseDown,this);},this);},onMouseDown:function(e,t){if(t.className&&t.className.indexOf('x-grid3-cc-'+this.id)!=-1){e.stopEvent();var index=this.grid.getView().findRowIndex(t);var record=this.grid.store.getAt(index);record.set(this.dataIndex,!record.data[this.dataIndex]);}},renderer:function(v,p,record){p.css+=' x-grid3-check-col-td';return'<div class="x-grid3-check-col'+(v?'-on':'')+' x-grid3-cc-'+this.id+'">&#160;</div>';}};Ext.grid.CheckColumn=Ext.ux.grid.CheckColumn;Ext.ns('Ext.ux.data');Ext.ux.data.PagingStore=Ext.extend(Ext.data.Store,{destroy:function(){if(this.storeId||this.id){Ext.StoreMgr.unregister(this);}
delete this.data;delete this.allData;delete this.snapshot;this.purgeListeners();},add:function(records){records=[].concat(records);if(records.length<1){return;}
for(var i=0,len=records.length;i<len;i++){records[i].join(this);}
var index=this.data.length;this.data.addAll(records);if(this.allData){this.allData.addAll(records);}
if(this.snapshot){this.snapshot.addAll(records);}
this.fireEvent("add",this,records,index);},remove:function(record){var index=this.data.indexOf(record);this.data.removeAt(index);if(this.allData){this.allData.remove(record);}
if(this.snapshot){this.snapshot.remove(record);}
if(this.pruneModifiedRecords){this.modified.remove(record);}
this.fireEvent("remove",this,record,index);},removeAll:function(){this.data.clear();if(this.allData){this.allData.clear();}
if(this.snapshot){this.snapshot.clear();}
if(this.pruneModifiedRecords){this.modified=[];}
this.fireEvent("clear",this);},insert:function(index,records){records=[].concat(records);for(var i=0,len=records.length;i<len;i++){this.data.insert(index,records[i]);records[i].join(this);}
if(this.allData){this.allData.addAll(records);}
if(this.snapshot){this.snapshot.addAll(records);}
this.fireEvent("add",this,records,index);},getById:function(id){return(this.snapshot||this.allData||this.data).key(id);},load:function(options){options=options||{};if(this.fireEvent("beforeload",this,options)!==false){this.storeOptions(options);var p=Ext.apply({},options.params,this.baseParams);if(this.sortInfo&&this.remoteSort){var pn=this.paramNames;p[pn["sort"]]=this.sortInfo.field;p[pn["dir"]]=this.sortInfo.direction;}
if(this.isPaging(p)){(function(){if(this.allData){this.data=this.allData;delete this.allData;}
this.applyPaging();this.fireEvent("datachanged",this);var r=[].concat(this.data.items);this.fireEvent("load",this,r,options);if(options.callback){options.callback.call(options.scope||this,r,options,true);}}).defer(1,this);return true;}
this.proxy.load(p,this.reader,this.loadRecords,this,options);return true;}else{return false;}},loadRecords:function(o,options,success){if(!o||success===false){if(success!==false){this.fireEvent("load",this,[],options);}
if(options.callback){options.callback.call(options.scope||this,[],options,false);}
return;}
var r=o.records,t=o.totalRecords||r.length;if(!options||options.add!==true){if(this.pruneModifiedRecords){this.modified=[];}
for(var i=0,len=r.length;i<len;i++){r[i].join(this);}
if(this.allData){this.data=this.allData;delete this.allData;}
if(this.snapshot){this.data=this.snapshot;delete this.snapshot;}
this.data.clear();this.data.addAll(r);this.totalLength=t;this.applySort();if(!this.allData){this.applyPaging();}
if(r.length!=this.getCount()){r=[].concat(this.data.items);}
this.fireEvent("datachanged",this);}else{this.totalLength=Math.max(t,this.data.length+r.length);this.add(r);}
this.fireEvent("load",this,r,options);if(options.callback){options.callback.call(options.scope||this,r,options,true);}},loadData:function(o,append){this.isPaging(Ext.apply({},this.lastOptions?this.lastOptions.params:null,this.baseParams));var r=this.reader.readRecords(o);this.loadRecords(r,{add:append},true);},getTotalCount:function(){return this.allData?this.allData.getCount():this.totalLength||0;},sortData:function(f,direction){direction=direction||'ASC';var st=this.fields.get(f).sortType;var fn=function(r1,r2){var v1=st(r1.data[f]),v2=st(r2.data[f]);return v1>v2?1:(v1<v2?-1:0);};if(this.allData){this.data=this.allData;delete this.allData;}
this.data.sort(direction,fn);if(this.snapshot&&this.snapshot!=this.data){this.snapshot.sort(direction,fn);}
this.applyPaging();},filterBy:function(fn,scope){this.snapshot=this.snapshot||this.allData||this.data;delete this.allData;this.data=this.queryBy(fn,scope||this);this.applyPaging();this.fireEvent("datachanged",this);},queryBy:function(fn,scope){var data=this.snapshot||this.allData||this.data;return data.filterBy(fn,scope||this);},collect:function(dataIndex,allowNull,bypassFilter){var d=(bypassFilter===true?this.snapshot||this.allData||this.data:this.data).items;var v,sv,r=[],l={};for(var i=0,len=d.length;i<len;i++){v=d[i].data[dataIndex];sv=String(v);if((allowNull||!Ext.isEmpty(v))&&!l[sv]){l[sv]=true;r[r.length]=v;}}
return r;},clearFilter:function(suppressEvent){if(this.isFiltered()){this.data=this.snapshot;delete this.allData;delete this.snapshot;this.applyPaging();if(suppressEvent!==true){this.fireEvent("datachanged",this);}}},isFiltered:function(){return this.snapshot&&this.snapshot!=(this.allData||this.data);},isPaging:function(params){var pn=this.paramNames,start=params[pn.start],limit=params[pn.limit];if((typeof start!='number')||(typeof limit!='number')){delete this.start;delete this.limit;this.lastParams=params;return false;}
this.start=start;this.limit=limit;delete params[pn.start];delete params[pn.limit];var lastParams=this.lastParams;this.lastParams=params;if(!this.proxy){return true;}
if(!lastParams){return false;}
for(var param in params){if(params.hasOwnProperty(param)&&(params[param]!==lastParams[param])){return false;}}
for(param in lastParams){if(lastParams.hasOwnProperty(param)&&(params[param]!==lastParams[param])){return false;}}
return true;},applyPaging:function(){var start=this.start,limit=this.limit;if((typeof start=='number')&&(typeof limit=='number')){var allData=this.data,data=new Ext.util.MixedCollection(allData.allowFunctions,allData.getKey);data.items=allData.items.slice(start,start+limit);data.keys=allData.keys.slice(start,start+limit);var len=data.length=data.items.length;var map={};for(var i=0;i<len;i++){var item=data.items[i];map[data.getKey(item)]=item;}
data.map=map;this.allData=allData;this.data=data;}}});Ext.ux.data.SimplePagingStore=function(config){Ext.ux.data.SimplePagingStore.superclass.constructor.call(this,Ext.apply(config,{reader:new Ext.data.ArrayReader(config)}));};Ext.extend(Ext.ux.data.SimplePagingStore,Ext.ux.data.PagingStore,{loadData:function(data,append){if(this.expandData===true){var r=[];for(var i=0,len=data.length;i<len;i++){r[r.length]=[data[i]];}
data=r;}
Ext.ux.data.SimplePagingStore.superclass.loadData.call(this,data,append);}});Ext.ux.data.JsonPagingStore=function(config){Ext.ux.data.JsonPagingStore.superclass.constructor.call(this,Ext.apply(config,{reader:new Ext.data.JsonReader(config)}));};Ext.extend(Ext.ux.data.JsonPagingStore,Ext.ux.data.PagingStore);