/*
 * 
 * Copyright(c) 2007-2011, Multiple Authors.
 * 
 * This code is propietary, you have no rights to use it, besides using it in the product this is part of.
 */


Ext.override(Ext.Component,{replaceWith:function(newComponent){var ctnr=this.ownerCt;var form=newComponent.ownerForm?newComponent.ownerForm:this.refOwner.form;var i=ctnr.items.indexOf(this);Ext.applyIf(newComponent,this.initialConfig);ctnr.remove(this,true);var added=ctnr.insert(i,newComponent);if(form){form.remove(this);form.add(added);}}});Ext.override(Ext.form.HtmlEditor,{onDisable:function(){if(this.rendered){this.wrap.mask();}
Ext.form.HtmlEditor.superclass.onDisable.call(this);},onEnable:function(){if(this.rendered){this.wrap.unmask();}
Ext.form.HtmlEditor.superclass.onEnable.call(this);}});Ext.override(Ext.Container,{findByItemId:function(id){var m,ct=this;this.cascade(function(c){var vId=c.itemId||c.id;if(ct!=c&&vId===id){m=c;return false;}});return m||null;}});Ext.override(Ext.PagingToolbar,{stateEvents:["pagesizechanged"],getState:function(){return{pageSize:this.pageSize};},applyState:function(state){if(state.pageSize)this.pageSize=state.pageSize;}});

Ext.namespace('Ext.ux.grid');Ext.ux.grid.GridFilters=Ext.extend(Ext.util.Observable,{autoReload:true,filterCls:'ux-filtered-column',local:false,menuFilterText:'Filters',paramPrefix:'filter',showMenu:true,stateId:undefined,updateBuffer:500,constructor:function(config){config=config||{};this.deferredUpdate=new Ext.util.DelayedTask(this.reload,this);this.filters=new Ext.util.MixedCollection();this.filters.getKey=function(o){return o?o.dataIndex:null;};this.addFilters(config.filters);delete config.filters;Ext.apply(this,config);},init:function(grid){if(grid instanceof Ext.grid.GridPanel){this.grid=grid;this.bindStore(this.grid.getStore(),true);if(this.filters.getCount()==0){this.addFilters(this.grid.getColumnModel());}
this.grid.filters=this;this.grid.addEvents({'filterupdate':true});grid.on({scope:this,beforestaterestore:this.applyState,beforestatesave:this.saveState,beforedestroy:this.destroy,reconfigure:this.onReconfigure});if(grid.rendered){this.onRender();}else{grid.on({scope:this,single:true,render:this.onRender});}}else if(grid instanceof Ext.PagingToolbar){this.toolbar=grid;}},applyState:function(grid,state){var key,filter;this.applyingState=true;this.clearFilters();if(state.filters){for(key in state.filters){filter=this.filters.get(key);if(filter){filter.setValue(state.filters[key]);filter.setActive(true);}}}
this.deferredUpdate.cancel();if(this.local){this.reload();}
delete this.applyingState;delete state.filters;},saveState:function(grid,state){var filters={};this.filters.each(function(filter){if(filter.active){filters[filter.dataIndex]=filter.getValue();}});return(state.filters=filters);},onRender:function(){this.grid.getView().on('refresh',this.onRefresh,this);this.createMenu();},destroy:function(){this.removeAll();this.purgeListeners();if(this.filterMenu){Ext.menu.MenuMgr.unregister(this.filterMenu);this.filterMenu.destroy();this.filterMenu=this.menu.menu=null;}},removeAll:function(){if(this.filters){Ext.destroy.apply(Ext,this.filters.items);this.filters.clear();}},bindStore:function(store,initial){if(!initial&&this.store){if(this.local){store.un('load',this.onLoad,this);}else{store.un('beforeload',this.onBeforeLoad,this);}}
if(store){if(this.local){store.on('load',this.onLoad,this);}else{store.on('beforeload',this.onBeforeLoad,this);}}
this.store=store;},onReconfigure:function(){this.bindStore(this.grid.getStore());this.store.clearFilter();this.removeAll();this.addFilters(this.grid.getColumnModel());this.updateColumnHeadings();},createMenu:function(){var view=this.grid.getView(),hmenu=view.hmenu;if(this.showMenu&&hmenu){this.sep=hmenu.addSeparator();this.filterMenu=new Ext.menu.Menu({id:this.grid.id+'-filters-menu'});this.menu=hmenu.add({checked:false,itemId:'filters',text:this.menuFilterText,menu:this.filterMenu});this.menu.on({scope:this,checkchange:this.onCheckChange,beforecheckchange:this.onBeforeCheck});hmenu.on('beforeshow',this.onMenu,this);}
this.updateColumnHeadings();},getMenuFilter:function(){var view=this.grid.getView();if(!view||view.hdCtxIndex===undefined){return null;}
return this.filters.get(view.cm.config[view.hdCtxIndex].dataIndex);},onMenu:function(filterMenu){var filter=this.getMenuFilter();if(filter){this.menu.menu=filter.menu;this.menu.setChecked(filter.active,false);this.menu.setDisabled(filter.disabled===true);}
this.menu.setVisible(filter!==undefined);this.sep.setVisible(filter!==undefined);},onCheckChange:function(item,value){this.getMenuFilter().setActive(value);},onBeforeCheck:function(check,value){return!value||this.getMenuFilter().isActivatable();},onStateChange:function(event,filter){if(event==='serialize'){return;}
if(filter==this.getMenuFilter()){this.menu.setChecked(filter.active,false);}
if((this.autoReload||this.local)&&!this.applyingState){this.deferredUpdate.delay(this.updateBuffer);}
this.updateColumnHeadings();if(!this.applyingState){this.grid.saveState();}
this.grid.fireEvent('filterupdate',this,filter);},onBeforeLoad:function(store,options){options.params=options.params||{};this.cleanParams(options.params);var params=this.buildQuery(this.getFilterData());Ext.apply(options.params,params);},onLoad:function(store,options){store.filterBy(this.getRecordFilter());},onRefresh:function(){this.updateColumnHeadings();},updateColumnHeadings:function(){var view=this.grid.getView(),i,len,filter;if(view.mainHd){for(i=0,len=view.cm.config.length;i<len;i++){filter=this.getFilter(view.cm.config[i].dataIndex);Ext.fly(view.getHeaderCell(i))[filter&&filter.active?'addClass':'removeClass'](this.filterCls);}}},reload:function(){if(this.local){this.grid.store.clearFilter(true);this.grid.store.filterBy(this.getRecordFilter());}else{var start,store=this.grid.store;this.deferredUpdate.cancel();if(this.toolbar){start=store.paramNames.start;if(store.lastOptions&&store.lastOptions.params&&store.lastOptions.params[start]){store.lastOptions.params[start]=0;}}
store.reload();}},getRecordFilter:function(){var f=[],len,i;this.filters.each(function(filter){if(filter.active){f.push(filter);}});len=f.length;return function(record){for(i=0;i<len;i++){if(!f[i].validateRecord(record)){return false;}}
return true;};},addFilter:function(config){var Cls=this.getFilterClass(config.type),filter=config.menu?config:(new Cls(config));this.filters.add(filter);Ext.util.Observable.capture(filter,this.onStateChange,this);return filter;},addFilters:function(filters){if(filters){var i,len,filter,cm=false,dI;if(filters instanceof Ext.grid.ColumnModel){filters=filters.config;cm=true;}
for(i=0,len=filters.length;i<len;i++){filter=false;if(cm){dI=filters[i].dataIndex;filter=filters[i].filter||filters[i].filterable;if(filter){filter=(filter===true)?{}:filter;Ext.apply(filter,{dataIndex:dI});filter.type=filter.type||this.store.fields.get(dI).type.type;}}else{filter=filters[i];}
if(filter){this.addFilter(filter);}}}},getFilter:function(dataIndex){return this.filters.get(dataIndex);},clearFilters:function(){this.filters.each(function(filter){filter.setActive(false);});},getFilterData:function(){var filters=[],i,len;this.filters.each(function(f){if(f.active){var d=[].concat(f.serialize());for(i=0,len=d.length;i<len;i++){filters.push({field:f.dataIndex,data:d[i]});}}});return filters;},buildQuery:function(filters){var p={},i,f,root,dataPrefix,key,tmp,len=filters.length;if(!this.encode){for(i=0;i<len;i++){f=filters[i];root=[this.paramPrefix,'[',i,']'].join('');p[root+'[field]']=f.field;dataPrefix=root+'[data]';for(key in f.data){p[[dataPrefix,'[',key,']'].join('')]=f.data[key];}}}else{tmp=[];for(i=0;i<len;i++){f=filters[i];tmp.push(Ext.apply({},{field:f.field},f.data));}
if(tmp.length>0){p[this.paramPrefix]=Ext.util.JSON.encode(tmp);}}
return p;},cleanParams:function(p){if(this.encode){delete p[this.paramPrefix];}else{var regex,key;regex=new RegExp('^'+this.paramPrefix+'\[[0-9]+\]');for(key in p){if(regex.test(key)){delete p[key];}}}},getFilterClass:function(type){switch(type){case'auto':type='string';break;case'int':case'float':type='numeric';break;case'bool':type='boolean';break;}
return Ext.ux.grid.filter[type.substr(0,1).toUpperCase()+type.substr(1)+'Filter'];}});Ext.preg('gridfilters',Ext.ux.grid.GridFilters);

Ext.namespace('Ext.ux.grid.filter');Ext.ux.grid.filter.Filter=Ext.extend(Ext.util.Observable,{active:false,dataIndex:null,menu:null,updateBuffer:500,constructor:function(config){Ext.apply(this,config);this.addEvents('activate','deactivate','serialize','update');Ext.ux.grid.filter.Filter.superclass.constructor.call(this);this.menu=new Ext.menu.Menu();this.init(config);if(config&&config.value){this.setValue(config.value);this.setActive(config.active!==false,true);delete config.value;}},destroy:function(){if(this.menu){this.menu.destroy();}
this.purgeListeners();},init:Ext.emptyFn,getValue:Ext.emptyFn,setValue:Ext.emptyFn,isActivatable:function(){return true;},getSerialArgs:Ext.emptyFn,validateRecord:function(){return true;},serialize:function(){var args=this.getSerialArgs();this.fireEvent('serialize',args,this);return args;},fireUpdate:function(){if(this.active){this.fireEvent('update',this);}
this.setActive(this.isActivatable());},setActive:function(active,suppressEvent){if(this.active!=active){this.active=active;if(suppressEvent!==true){this.fireEvent(active?'activate':'deactivate',this);}}}});

Ext.ux.grid.filter.BooleanFilter=Ext.extend(Ext.ux.grid.filter.Filter,{defaultValue:false,yesText:'Yes',noText:'No',init:function(config){var gId=Ext.id();this.options=[new Ext.menu.CheckItem({text:this.yesText,group:gId,checked:this.defaultValue===true}),new Ext.menu.CheckItem({text:this.noText,group:gId,checked:this.defaultValue===false})];this.menu.add(this.options[0],this.options[1]);for(var i=0;i<this.options.length;i++){this.options[i].on('click',this.fireUpdate,this);this.options[i].on('checkchange',this.fireUpdate,this);}},getValue:function(){return this.options[0].checked;},setValue:function(value){this.options[value?0:1].setChecked(true);},getSerialArgs:function(){var args={type:'boolean',value:this.getValue()};return args;},validateRecord:function(record){return record.get(this.dataIndex)==this.getValue();}});

Ext.ux.grid.filter.DateFilter=Ext.extend(Ext.ux.grid.filter.Filter,{afterText:'After',beforeText:'Before',compareMap:{before:'lt',after:'gt',on:'eq'},dateFormat:'m/d/Y',menuItems:['before','after','-','on'],menuItemCfgs:{selectOnFocus:true,width:125},onText:'On',pickerOpts:{},init:function(config){var menuCfg,i,len,item,cfg,Cls;menuCfg=Ext.apply(this.pickerOpts,{minDate:this.minDate,maxDate:this.maxDate,format:this.dateFormat,listeners:{scope:this,select:this.onMenuSelect}});this.fields={};for(i=0,len=this.menuItems.length;i<len;i++){item=this.menuItems[i];if(item!=='-'){cfg={itemId:'range-'+item,text:this[item+'Text'],menu:new Ext.menu.DateMenu(Ext.apply(menuCfg,{itemId:item})),listeners:{scope:this,checkchange:this.onCheckChange}};Cls=Ext.menu.CheckItem;item=this.fields[item]=new Cls(cfg);}
this.menu.add(item);}},onCheckChange:function(){this.setActive(this.isActivatable());this.fireEvent('update',this);},onInputKeyUp:function(field,e){var k=e.getKey();if(k==e.RETURN&&field.isValid()){e.stopEvent();this.menu.hide(true);return;}},onMenuSelect:function(menuItem,value,picker){var fields=this.fields,field=this.fields[menuItem.itemId];field.setChecked(true);if(field==fields.on){fields.before.setChecked(false,true);fields.after.setChecked(false,true);}else{fields.on.setChecked(false,true);if(field==fields.after&&fields.before.menu.picker.value<value){fields.before.setChecked(false,true);}else if(field==fields.before&&fields.after.menu.picker.value>value){fields.after.setChecked(false,true);}}
this.fireEvent('update',this);},getValue:function(){var key,result={};for(key in this.fields){if(this.fields[key].checked){result[key]=this.fields[key].menu.picker.getValue();}}
return result;},setValue:function(value,preserve){var key;for(key in this.fields){if(value[key]){if(Ext.isString(value[key]))this.fields[key].menu.picker.setValue(Date.parseDate(value[key],"c"));else this.fields[key].menu.picker.setValue(value[key]);this.fields[key].setChecked(true);}else if(!preserve){this.fields[key].setChecked(false);}}
this.fireEvent('update',this);},isActivatable:function(){var key;for(key in this.fields){if(this.fields[key].checked){return true;}}
return false;},getSerialArgs:function(){var args=[];for(var key in this.fields){if(this.fields[key].checked){args.push({type:'date',comparison:this.compareMap[key],value:this.getFieldValue(key).format(this.dateFormat)});}}
return args;},getFieldValue:function(item){return this.fields[item].menu.picker.getValue();},getPicker:function(item){return this.fields[item].menu.picker;},validateRecord:function(record){var key,pickerValue,val=record.get(this.dataIndex);if(!Ext.isDate(val)){return false;}
val=val.clearTime(true).getTime();for(key in this.fields){if(this.fields[key].checked){pickerValue=this.getFieldValue(key).clearTime(true).getTime();if(key=='before'&&pickerValue<=val){return false;}
if(key=='after'&&pickerValue>=val){return false;}
if(key=='on'&&pickerValue!=val){return false;}}}
return true;}});

Ext.ux.grid.filter.ListFilter=Ext.extend(Ext.ux.grid.filter.Filter,{phpMode:false,init:function(config){this.dt=new Ext.util.DelayedTask(this.fireUpdate,this);if(this.menu){this.menu.destroy();}
this.menu=new Ext.ux.menu.ListMenu(config);this.menu.on('checkchange',this.onCheckChange,this);},getValue:function(){return this.menu.getSelected();},setValue:function(value){this.menu.setSelected(value);this.fireEvent('update',this);},isActivatable:function(){return this.getValue().length>0;},getSerialArgs:function(){var args={type:'list',value:this.phpMode?this.getValue().join(','):this.getValue()};return args;},onCheckChange:function(){this.dt.delay(this.updateBuffer);},validateRecord:function(record){return this.getValue().indexOf(record.get(this.dataIndex))>-1;}});

Ext.ux.grid.filter.NumericFilter=Ext.extend(Ext.ux.grid.filter.Filter,{fieldCls:Ext.form.NumberField,iconCls:{gt:'ux-rangemenu-gt',lt:'ux-rangemenu-lt',eq:'ux-rangemenu-eq'},menuItemCfgs:{emptyText:'Enter Filter Text...',selectOnFocus:true,width:125},menuItems:['lt','gt','-','eq'],init:function(config){if(this.menu){this.menu.destroy();}
this.menu=new Ext.ux.menu.RangeMenu(Ext.apply(config,{fieldCfg:this.fieldCfg||{},fieldCls:this.fieldCls,fields:this.fields||{},iconCls:this.iconCls,menuItemCfgs:this.menuItemCfgs,menuItems:this.menuItems,updateBuffer:this.updateBuffer}));this.menu.on('update',this.fireUpdate,this);},getValue:function(){return this.menu.getValue();},setValue:function(value){this.menu.setValue(value);},isActivatable:function(){var values=this.getValue();for(key in values){if(values[key]!==undefined){return true;}}
return false;},getSerialArgs:function(){var key,args=[],values=this.menu.getValue();for(key in values){args.push({type:'numeric',comparison:key,value:values[key]});}
return args;},validateRecord:function(record){var val=record.get(this.dataIndex),values=this.getValue();if(values.eq!==undefined&&val!=values.eq){return false;}
if(values.lt!==undefined&&val>=values.lt){return false;}
if(values.gt!==undefined&&val<=values.gt){return false;}
return true;}});

Ext.ux.grid.filter.StringFilter=Ext.extend(Ext.ux.grid.filter.Filter,{iconCls:'ux-gridfilter-text-icon',emptyText:'Enter Filter Text...',selectOnFocus:true,width:125,init:function(config){Ext.applyIf(config,{enableKeyEvents:true,iconCls:this.iconCls,listeners:{scope:this,keyup:this.onInputKeyUp}});this.inputItem=new Ext.form.TextField(config);this.menu.add(this.inputItem);this.updateTask=new Ext.util.DelayedTask(this.fireUpdate,this);},getValue:function(){return this.inputItem.getValue();},setValue:function(value){this.inputItem.setValue(value);this.fireEvent('update',this);},isActivatable:function(){return this.inputItem.getValue().length>0;},getSerialArgs:function(){return{type:'string',value:this.getValue()};},validateRecord:function(record){var val=record.get(this.dataIndex);if(typeof val!='string'){return(this.getValue().length===0);}
return val.toLowerCase().indexOf(this.getValue().toLowerCase())>-1;},onInputKeyUp:function(field,e){var k=e.getKey();if(k==e.RETURN&&field.isValid()){e.stopEvent();this.menu.hide(true);return;}
this.updateTask.delay(this.updateBuffer);}});

Ext.ns('Ext.ux.grid');Ext.ux.grid.BufferView=Ext.extend(Ext.grid.GridView,{rowHeight:19,borderHeight:2,scrollDelay:100,cacheSize:20,cleanDelay:500,initTemplates:function(){Ext.ux.grid.BufferView.superclass.initTemplates.call(this);var ts=this.templates;ts.rowHolder=new Ext.Template('<div class="x-grid3-row {alt}" style="{tstyle}"></div>');ts.rowHolder.disableFormats=true;ts.rowHolder.compile();ts.rowBody=new Ext.Template('<table class="x-grid3-row-table" border="0" cellspacing="0" cellpadding="0" style="{tstyle}">','<tbody><tr>{cells}</tr>',(this.enableRowBody?'<tr class="x-grid3-row-body-tr" style="{bodyStyle}"><td colspan="{cols}" class="x-grid3-body-cell" tabIndex="0" hidefocus="on"><div class="x-grid3-row-body">{body}</div></td></tr>':''),'</tbody></table>');ts.rowBody.disableFormats=true;ts.rowBody.compile();},getStyleRowHeight:function(){return Ext.isBorderBox?(this.rowHeight+this.borderHeight):this.rowHeight;},getCalculatedRowHeight:function(){return this.rowHeight+this.borderHeight;},getVisibleRowCount:function(){var rh=this.getCalculatedRowHeight(),visibleHeight=this.scroller.dom.clientHeight;return(visibleHeight<1)?0:Math.ceil(visibleHeight/rh);},getVisibleRows:function(){var count=this.getVisibleRowCount(),sc=this.scroller.dom.scrollTop,start=(sc===0?0:Math.floor(sc/this.getCalculatedRowHeight())-1);return{first:Math.max(start,0),last:Math.min(start+count+2,this.ds.getCount()-1)};},doRender:function(cs,rs,ds,startRow,colCount,stripe,onlyBody){var ts=this.templates,ct=ts.cell,rt=ts.row,rb=ts.rowBody,last=colCount-1,rh=this.getStyleRowHeight(),vr=this.getVisibleRows(),tstyle='width:'+this.getTotalWidth()+';height:'+rh+'px;',buf=[],cb,c,p={},rp={tstyle:tstyle},r;for(var j=0,len=rs.length;j<len;j++){r=rs[j];cb=[];var rowIndex=(j+startRow),visible=rowIndex>=vr.first&&rowIndex<=vr.last;if(visible){for(var i=0;i<colCount;i++){c=cs[i];p.id=c.id;p.css=i===0?'x-grid3-cell-first ':(i==last?'x-grid3-cell-last ':'');p.attr=p.cellAttr="";p.value=c.renderer(r.data[c.name],p,r,rowIndex,i,ds);p.style=c.style;if(p.value===undefined||p.value===""){p.value="&#160;";}
if(r.dirty&&typeof r.modified[c.name]!=='undefined'){p.css+=' x-grid3-dirty-cell';}
cb[cb.length]=ct.apply(p);}}
var alt=[];if(stripe&&((rowIndex+1)%2===0)){alt[0]="x-grid3-row-alt";}
if(r.dirty){alt[1]=" x-grid3-dirty-row";}
rp.cols=colCount;if(this.getRowClass){alt[2]=this.getRowClass(r,rowIndex,rp,ds);}
rp.alt=alt.join(" ");rp.cells=cb.join("");buf[buf.length]=!visible?ts.rowHolder.apply(rp):(onlyBody?rb.apply(rp):rt.apply(rp));}
return buf.join("");},isRowRendered:function(index){var row=this.getRow(index);return row&&row.childNodes.length>0;},syncScroll:function(){Ext.ux.grid.BufferView.superclass.syncScroll.apply(this,arguments);this.update();},update:function(){if(this.scrollDelay){if(!this.renderTask){this.renderTask=new Ext.util.DelayedTask(this.doUpdate,this);}
this.renderTask.delay(this.scrollDelay);}else{this.doUpdate();}},onRemove:function(ds,record,index,isUpdate){Ext.ux.grid.BufferView.superclass.onRemove.apply(this,arguments);if(isUpdate!==true){this.update();}},doUpdate:function(){if(this.getVisibleRowCount()>0){var g=this.grid,cm=g.colModel,ds=g.store,cs=this.getColumnData(),vr=this.getVisibleRows(),row;for(var i=vr.first;i<=vr.last;i++){if(!this.isRowRendered(i)&&(row=this.getRow(i))){var html=this.doRender(cs,[ds.getAt(i)],ds,i,cm.getColumnCount(),g.stripeRows,true);row.innerHTML=html;}}
this.clean();}},clean:function(){if(!this.cleanTask){this.cleanTask=new Ext.util.DelayedTask(this.doClean,this);}
this.cleanTask.delay(this.cleanDelay);},doClean:function(){if(this.getVisibleRowCount()>0){var vr=this.getVisibleRows();vr.first-=this.cacheSize;vr.last+=this.cacheSize;var i=0,rows=this.getRows();if(vr.first<=0){i=vr.last+1;}
for(var len=this.ds.getCount();i<len;i++){if((i<vr.first||i>vr.last)&&rows[i].innerHTML){rows[i].innerHTML='';}}}},removeTask:function(name){var task=this[name];if(task&&task.cancel){task.cancel();this[name]=null;}},destroy:function(){this.removeTask('cleanTask');this.removeTask('renderTask');Ext.ux.grid.BufferView.superclass.destroy.call(this);},layout:function(){Ext.ux.grid.BufferView.superclass.layout.call(this);this.update();}});

Ext.ns('Ext.ux.grid');Ext.ux.grid.RowEditor=Ext.extend(Ext.Panel,{floating:true,shadow:false,layout:'hbox',cls:'x-small-editor',buttonAlign:'center',baseCls:'x-row-editor',elements:'header,footer,body',frameWidth:5,buttonPad:3,clicksToEdit:'auto',monitorValid:true,focusDelay:250,errorSummary:true,saveText:'Save',cancelText:'Cancel',commitChangesText:'You need to commit or cancel your changes',errorText:'Errors',defaults:{normalWidth:true},initComponent:function(){Ext.ux.grid.RowEditor.superclass.initComponent.call(this);this.addEvents('beforeedit','canceledit','validateedit','afteredit');},init:function(grid){this.grid=grid;this.ownerCt=grid;if(this.clicksToEdit===2){grid.on('rowdblclick',this.onRowDblClick,this);}else{grid.on('rowclick',this.onRowClick,this);if(Ext.isIE){grid.on('rowdblclick',this.onRowDblClick,this);}}
grid.getStore().on('remove',function(){this.stopEditing(false);},this);grid.on({scope:this,keydown:this.onGridKey,columnresize:this.verifyLayout,columnmove:this.refreshFields,reconfigure:this.refreshFields,beforedestroy:this.beforedestroy,destroy:this.destroy,bodyscroll:{buffer:250,fn:this.positionButtons}});grid.getColumnModel().on('hiddenchange',this.verifyLayout,this,{delay:1});grid.getView().on('refresh',this.stopEditing.createDelegate(this,[]));},beforedestroy:function(){this.stopMonitoring();this.grid.getStore().un('remove',this.onStoreRemove,this);this.stopEditing(false);Ext.destroy(this.btns,this.tooltip);},refreshFields:function(){this.initFields();this.verifyLayout();},isDirty:function(){var dirty;this.items.each(function(f){if(String(this.values[f.id])!==String(f.getValue())){dirty=true;return false;}},this);return dirty;},startEditing:function(rowIndex,doFocus){if(this.editing&&this.isDirty()){this.showTooltip(this.commitChangesText);return;}
if(Ext.isObject(rowIndex)){rowIndex=this.grid.getStore().indexOf(rowIndex);}
if(this.fireEvent('beforeedit',this,rowIndex)!==false){this.editing=true;var g=this.grid,view=g.getView(),row=view.getRow(rowIndex),record=g.store.getAt(rowIndex);this.record=record;this.rowIndex=rowIndex;this.values={};if(!this.rendered){this.render(view.getEditorParent());}
var w=Ext.fly(row).getWidth();this.setSize(w);if(!this.initialized){this.initFields();}
var cm=g.getColumnModel(),fields=this.items.items,f,val;for(var i=0,len=cm.getColumnCount();i<len;i++){val=this.preEditValue(record,cm.getDataIndex(i));f=fields[i];f.setValue(val);this.values[f.id]=Ext.isEmpty(val)?'':val;}
this.verifyLayout(true);if(!this.isVisible()){this.setPagePosition(Ext.fly(row).getXY());}else{this.el.setXY(Ext.fly(row).getXY(),{duration:0.15});}
if(!this.isVisible()){this.show().doLayout();}
if(doFocus!==false){this.doFocus.defer(this.focusDelay,this);}}},stopEditing:function(saveChanges){this.editing=false;if(!this.isVisible()){return;}
if(saveChanges===false||!this.isValid()){this.hide();this.fireEvent('canceledit',this,saveChanges===false);return;}
var changes={},r=this.record,hasChange=false,cm=this.grid.colModel,fields=this.items.items;for(var i=0,len=cm.getColumnCount();i<len;i++){if(!cm.isHidden(i)){var dindex=cm.getDataIndex(i);if(!Ext.isEmpty(dindex)){var oldValue=r.data[dindex],value=this.postEditValue(fields[i].getValue(),oldValue,r,dindex);if(String(oldValue)!==String(value)){changes[dindex]=value;hasChange=true;}}}}
if(hasChange&&this.fireEvent('validateedit',this,changes,r,this.rowIndex)!==false){r.beginEdit();Ext.iterate(changes,function(name,value){r.set(name,value);});r.endEdit();this.fireEvent('afteredit',this,changes,r,this.rowIndex);}
this.hide();},verifyLayout:function(force){if(this.el&&(this.isVisible()||force===true)){var row=this.grid.getView().getRow(this.rowIndex);this.setSize(Ext.fly(row).getWidth(),Ext.isIE?Ext.fly(row).getHeight()+9:undefined);var cm=this.grid.colModel,fields=this.items.items;for(var i=0,len=cm.getColumnCount();i<len;i++){if(!cm.isHidden(i)){var adjust=0;if(i===(len-1)){adjust+=3;}else{adjust+=1;}
fields[i].show();fields[i].setWidth(cm.getColumnWidth(i)-adjust);}else{fields[i].hide();}}
this.doLayout();this.positionButtons();}},slideHide:function(){this.hide();},initFields:function(){var cm=this.grid.getColumnModel(),pm=Ext.layout.ContainerLayout.prototype.parseMargins;this.removeAll(false);for(var i=0,len=cm.getColumnCount();i<len;i++){var c=cm.getColumnAt(i),ed=c.getEditor();if(!ed){ed=c.displayEditor||new Ext.form.DisplayField();}
if(i==0){ed.margins=pm('0 1 2 1');}else if(i==len-1){ed.margins=pm('0 0 2 1');}else{if(Ext.isIE){ed.margins=pm('0 0 2 0');}
else{ed.margins=pm('0 1 2 0');}}
ed.setWidth(cm.getColumnWidth(i));ed.column=c;if(ed.ownerCt!==this){ed.on('focus',this.ensureVisible,this);ed.on('specialkey',this.onKey,this);}
this.insert(i,ed);}
this.initialized=true;},onKey:function(f,e){if(e.getKey()===e.ENTER){this.stopEditing(true);e.stopPropagation();}},onGridKey:function(e){if(e.getKey()===e.ENTER&&!this.isVisible()){var r=this.grid.getSelectionModel().getSelected();if(r){var index=this.grid.store.indexOf(r);this.startEditing(index);e.stopPropagation();}}},ensureVisible:function(editor){if(this.isVisible()){this.grid.getView().ensureVisible(this.rowIndex,this.grid.colModel.getIndexById(editor.column.id),true);}},onRowClick:function(g,rowIndex,e){if(this.clicksToEdit=='auto'){var li=this.lastClickIndex;this.lastClickIndex=rowIndex;if(li!=rowIndex&&!this.isVisible()){return;}}
this.startEditing(rowIndex,false);this.doFocus.defer(this.focusDelay,this,[e.getPoint()]);},onRowDblClick:function(g,rowIndex,e){this.startEditing(rowIndex,false);this.doFocus.defer(this.focusDelay,this,[e.getPoint()]);},onRender:function(){Ext.ux.grid.RowEditor.superclass.onRender.apply(this,arguments);this.el.swallowEvent(['keydown','keyup','keypress']);this.btns=new Ext.Panel({baseCls:'x-plain',cls:'x-btns',elements:'body',layout:'table',width:(this.minButtonWidth*2)+(this.frameWidth*2)+(this.buttonPad*4),items:[{ref:'saveBtn',itemId:'saveBtn',xtype:'button',text:this.saveText,width:this.minButtonWidth,handler:this.stopEditing.createDelegate(this,[true])},{xtype:'button',text:this.cancelText,width:this.minButtonWidth,handler:this.stopEditing.createDelegate(this,[false])}]});this.btns.render(this.bwrap);},afterRender:function(){Ext.ux.grid.RowEditor.superclass.afterRender.apply(this,arguments);this.positionButtons();if(this.monitorValid){this.startMonitoring();}},onShow:function(){if(this.monitorValid){this.startMonitoring();}
Ext.ux.grid.RowEditor.superclass.onShow.apply(this,arguments);},onHide:function(){Ext.ux.grid.RowEditor.superclass.onHide.apply(this,arguments);this.stopMonitoring();this.grid.getView().focusRow(this.rowIndex);},positionButtons:function(){if(this.btns){var g=this.grid,h=this.el.dom.clientHeight,view=g.getView(),scroll=view.scroller.dom.scrollLeft,bw=this.btns.getWidth(),width=Math.min(g.getWidth(),g.getColumnModel().getTotalWidth());this.btns.el.shift({left:(width/2)-(bw/2)+scroll,top:h-2,stopFx:true,duration:0.2});}},preEditValue:function(r,field){var value=r.data[field];return this.autoEncode&&typeof value==='string'?Ext.util.Format.htmlDecode(value):value;},postEditValue:function(value,originalValue,r,field){return this.autoEncode&&typeof value=='string'?Ext.util.Format.htmlEncode(value):value;},doFocus:function(pt){if(this.isVisible()){var index=0,cm=this.grid.getColumnModel(),c;if(pt){index=this.getTargetColumnIndex(pt);}
for(var i=index||0,len=cm.getColumnCount();i<len;i++){c=cm.getColumnAt(i);if(!c.hidden&&c.getEditor()){c.getEditor().focus();break;}}}},getTargetColumnIndex:function(pt){var grid=this.grid,v=grid.view,x=pt.left,cms=grid.colModel.config,i=0,match=false;for(var len=cms.length,c;c=cms[i];i++){if(!c.hidden){if(Ext.fly(v.getHeaderCell(i)).getRegion().right>=x){match=i;break;}}}
return match;},startMonitoring:function(){if(!this.bound&&this.monitorValid){this.bound=true;Ext.TaskMgr.start({run:this.bindHandler,interval:this.monitorPoll||200,scope:this});}},stopMonitoring:function(){this.bound=false;if(this.tooltip){this.tooltip.hide();}},isValid:function(){var valid=true;this.items.each(function(f){if(!f.isValid(true)){valid=false;return false;}});return valid;},bindHandler:function(){if(!this.bound){return false;}
var valid=this.isValid();if(!valid&&this.errorSummary){this.showTooltip(this.getErrorText().join(''));}
this.btns.saveBtn.setDisabled(!valid);this.fireEvent('validation',this,valid);},lastVisibleColumn:function(){var i=this.items.getCount()-1,c;for(;i>=0;i--){c=this.items.items[i];if(!c.hidden){return c;}}},showTooltip:function(msg){var t=this.tooltip;if(!t){t=this.tooltip=new Ext.ToolTip({maxWidth:600,cls:'errorTip',width:300,title:this.errorText,autoHide:false,anchor:'left',anchorToTarget:true,mouseOffset:[40,0]});}
var v=this.grid.getView(),top=parseInt(this.el.dom.style.top,10),scroll=v.scroller.dom.scrollTop,h=this.el.getHeight();if(top+h>=scroll){t.initTarget(this.lastVisibleColumn().getEl());if(!t.rendered){t.show();t.hide();}
t.body.update(msg);t.doAutoWidth(20);t.show();}else if(t.rendered){t.hide();}},getErrorText:function(){var data=['<ul>'];this.items.each(function(f){if(!f.isValid(true)){data.push('<li>',f.getActiveError(),'</li>');}});data.push('</ul>');return data;}});Ext.preg('roweditor',Ext.ux.grid.RowEditor);

Ext.namespace("Ext.ux.menu");Ext.ux.menu.EditableItem=Ext.extend(Ext.menu.BaseItem,{itemCls:"x-menu-item",hideOnClick:false,initComponent:function(){this.addEvents({keyup:true});this.editor=this.editor||new Ext.form.TextField();if(this.text)
this.editor.setValue(this.text);},onRender:function(container){var s=container.createChild({cls:this.itemCls,html:'<img src="'+this.icon+'" class="x-menu-item-icon" style="margin: 3px 3px 2px 2px;" />'});Ext.apply(this.config,{width:125});this.editor.render(s);this.el=s;this.relayEvents(this.editor.el,["keyup"]);if(Ext.isGecko)
s.setStyle('overflow','auto');Ext.ux.menu.EditableItem.superclass.onRender.apply(this,arguments);},getValue:function(){return this.editor.getValue();},setValue:function(value){this.editor.setValue(value);},isValid:function(preventMark){return this.editor.isValid(preventMark);}});

Ext.ns('Ext.ux.menu');Ext.ux.menu.RangeMenu=Ext.extend(Ext.menu.Menu,{constructor:function(config){Ext.ux.menu.RangeMenu.superclass.constructor.call(this,config);this.addEvents('update');this.updateTask=new Ext.util.DelayedTask(this.fireUpdate,this);var i,len,item,cfg,Cls;for(i=0,len=this.menuItems.length;i<len;i++){item=this.menuItems[i];if(item!=='-'){cfg={itemId:'range-'+item,enableKeyEvents:true,iconCls:this.iconCls[item]||'no-icon',listeners:{scope:this,keyup:this.onInputKeyUp}};Ext.apply(cfg,Ext.applyIf(this.fields[item]||{},this.fieldCfg[item]),this.menuItemCfgs);Cls=cfg.fieldCls||this.fieldCls;item=this.fields[item]=new Cls(cfg);}
this.add(item);}},fireUpdate:function(){this.fireEvent('update',this);},getValue:function(){var result={},key,field;for(key in this.fields){field=this.fields[key];if(field.isValid()&&String(field.getValue()).length>0){result[key]=field.getValue();}}
return result;},setValue:function(data){var key;for(key in this.fields){this.fields[key].setValue(data[key]!==undefined?data[key]:'');}
this.fireEvent('update',this);},onInputKeyUp:function(field,e){var k=e.getKey();if(k==e.RETURN&&field.isValid()){e.stopEvent();this.hide(true);return;}
if(field==this.fields.eq){if(this.fields.gt){this.fields.gt.setValue(null);}
if(this.fields.lt){this.fields.lt.setValue(null);}}
else{this.fields.eq.setValue(null);}
this.updateTask.delay(this.updateBuffer);}});

Ext.namespace('Ext.ux.menu');Ext.ux.menu.ListMenu=Ext.extend(Ext.menu.Menu,{labelField:'text',loadingText:'Loading...',loadOnShow:true,single:false,constructor:function(cfg){this.selected=[];this.addEvents('checkchange');Ext.ux.menu.ListMenu.superclass.constructor.call(this,cfg=cfg||{});if(!cfg.store&&cfg.options){var options=[];for(var i=0,len=cfg.options.length;i<len;i++){var value=cfg.options[i];switch(Ext.type(value)){case'array':options.push(value);break;case'object':options.push([value.id,value[this.labelField]]);break;case'string':options.push([value,value]);break;}}
this.store=new Ext.data.Store({reader:new Ext.data.ArrayReader({id:0},['id',this.labelField]),data:options,listeners:{'load':this.onLoad,scope:this}});this.loaded=true;}else{this.store.on('load',this.onLoad,this);if(this.loaded)this.onLoad(this.store,this.store.data.items);else this.add({text:this.loadingText,iconCls:'loading-indicator'});}},destroy:function(){if(this.store){this.store.destroy();}
Ext.ux.menu.ListMenu.superclass.destroy.call(this);},show:function(){var lastArgs=null;return function(){if(arguments.length===0){Ext.ux.menu.ListMenu.superclass.show.apply(this,lastArgs);}else{lastArgs=arguments;if(this.loadOnShow&&!this.loaded){this.store.load();}
Ext.ux.menu.ListMenu.superclass.show.apply(this,arguments);}};}(),onLoad:function(store,records){var visible=this.isVisible();this.hide(false);this.removeAll(true);var gid=this.single?Ext.id():null;for(var i=0,len=records.length;i<len;i++){var item=new Ext.menu.CheckItem({text:records[i].get(this.labelField),group:gid,checked:this.selected.indexOf(records[i].id)>-1,hideOnClick:false});item.itemId=records[i].id;item.on('checkchange',this.checkChange,this);this.add(item);}
this.loaded=true;if(visible){this.show();}
this.fireEvent('load',this,records);},getSelected:function(){return this.selected;},setSelected:function(value){value=this.selected=[].concat(value);if(this.loaded){this.items.each(function(item){item.setChecked(false,true);for(var i=0,len=value.length;i<len;i++){if(item.itemId==value[i]){item.setChecked(true,true);}}},this);}},checkChange:function(item,checked){var value=[];this.items.each(function(item){if(item.checked){value.push(item.itemId);}},this);this.selected=value;this.fireEvent('checkchange',item,checked);}});

Ext.ns('Ext.ux.form');Ext.ux.form.XTimeField=Ext.extend(Ext.form.TimeField,{submitFormat:'H:i:s',onRender:function(){this.altFormats+='|'+this.submitFormat;Ext.ux.form.XTimeField.superclass.onRender.apply(this,arguments);this.hiddenField=this.el.insertSibling({tag:'input',type:'hidden',name:this.name});this.hiddenName=this.name;this.el.dom.name=null;this.el.on({keyup:{scope:this,fn:this.updateHidden},blur:{scope:this,fn:this.updateHidden}});this.setValue=this.setValue.createSequence(this.updateHidden);},updateHidden:function(){var value=this.getValue();value=Ext.isDate(value)?value:Date.parseDate(value,this.format);this.hiddenField.dom.value=Ext.util.Format.date(value,this.submitFormat);}});Ext.reg('xtimefield',Ext.ux.form.XTimeField);

Ext.namespace('Ext.ux');Ext.ux.ColorPicker=Ext.extend(Ext.BoxComponent,{initComponent:function(){this.applyDefaultsCP();Ext.ux.ColorPicker.superclass.initComponent.apply(this,arguments);this.addEvents('select');},onRender:function(){Ext.ux.ColorPicker.superclass.onRender.apply(this,arguments);this.body=this.body||(this.container||(this.renderTo||Ext.DomHelper.append(Ext.getBody(),{},true)));if(!this.el){this.el=this.body;if(this.cls){Ext.get(this.el).addClass(this.cls);}}
this.renderComponent();},applyDefaultsCP:function(){Ext.apply(this,{'cls':'x-cp-mainpanel','resizable':this.resizable||false,'HSV':{h:0,s:0,v:0},updateMode:null});},renderComponent:function(){Ext.DomHelper.append(this.body,{'id':this.cpGetId('rgb'),'cls':'x-cp-rgbpicker'});Ext.DomHelper.append(this.body,{'id':this.cpGetId('hue'),'cls':'x-cp-huepicker'});this.huePicker=Ext.DomHelper.append(this.body,{'cls':'x-cp-hueslider'});this.hueDD=new Ext.dd.DD(this.huePicker,'huePicker');this.hueDD.constrainTo(this.cpGetId('hue'),{'top':-7,'right':-3,'bottom':-7,'left':-3});this.hueDD.onDrag=this.moveHuePicker.createDelegate(this);Ext.get(this.cpGetId('hue')).on('mousedown',this.clickHUEPicker.createDelegate(this));Ext.get(this.huePicker).moveTo(Ext.get(this.cpGetId('hue')).getLeft()-3,Ext.get(this.cpGetId('hue')).getTop()-7);this.rgbPicker=Ext.DomHelper.append(this.body,{'cls':'x-cp-rgbslider'});this.rgbDD=new Ext.dd.DD(this.rgbPicker,'rgbPicker');this.rgbDD.constrainTo(this.cpGetId('rgb'),-7);this.rgbDD.onDrag=this.moveRGBPicker.createDelegate(this);Ext.get(this.cpGetId('rgb')).on('mousedown',this.clickRGBPicker.createDelegate(this));Ext.get(this.rgbPicker).moveTo(Ext.get(this.cpGetId('rgb')).getLeft()-7,Ext.get(this.cpGetId('rgb')).getTop()-7);this.formPanel=new Ext.form.FormPanel({'renderTo':Ext.DomHelper.append(this.body,{'id':this.cpGetId('fCont'),'cls':'x-cp-formcontainer'},true),'frame':true,'labelAlign':'left','labelWidth':10,'baseCls':'x-panel-mc','items':[{'layout':'column','items':[{'columnWidth':.5,'layout':'form','defaultType':'numberfield','defaults':{'width':30,'value':0,'minValue':0,'maxValue':255,'allowBlank':true,'labelSeparator':''},'items':[{'fieldLabel':'R','id':this.cpGetId('iRed')},{'fieldLabel':'G','id':this.cpGetId('iGreen')},{'fieldLabel':'B','id':this.cpGetId('iBlue')}]},{'columnWidth':.5,'layout':'form','defaultType':'numberfield','defaults':{'width':30,'value':0,'minValue':0,'maxValue':255,'allowBlank':true,'labelSeparator':''},'items':[{'fieldLabel':'H','maxValue':360,'id':this.cpGetId('iHue')},{'fieldLabel':'S','id':this.cpGetId('iSat')},{'fieldLabel':'V','id':this.cpGetId('iVal')}]}]},{'layout':'form','defaultType':'textfield','labelAlign':'left','defaults':{'width':85,'value':'000000','labelSeparator':'','allowBlank':true},'id':this.cpGetId('cCont'),'items':[{'fieldLabel':'#','id':this.cpGetId('iHexa'),'value':'000000'}]}]});Ext.getCmp(this.cpGetId('iRed')).on('change',this.updateFromIRGB.createDelegate(this));Ext.getCmp(this.cpGetId('iGreen')).on('change',this.updateFromIRGB.createDelegate(this));Ext.getCmp(this.cpGetId('iBlue')).on('change',this.updateFromIRGB.createDelegate(this));Ext.getCmp(this.cpGetId('iHue')).on('change',this.updateFromIHSV.createDelegate(this));Ext.getCmp(this.cpGetId('iSat')).on('change',this.updateFromIHSV.createDelegate(this));Ext.getCmp(this.cpGetId('iVal')).on('change',this.updateFromIHSV.createDelegate(this));Ext.getCmp(this.cpGetId('iHexa')).on('change',this.updateFromIHexa.createDelegate(this));Ext.DomHelper.append(this.cpGetId('cCont'),{'cls':'x-cp-colorbox','id':this.cpGetId('cWebSafe')},true).update('Web-Sicher');Ext.DomHelper.append(this.cpGetId('cCont'),{'cls':'x-cp-colorbox','id':this.cpGetId('cInverse')},true).update('Invertiert');Ext.DomHelper.append(this.cpGetId('cCont'),{'cls':'x-cp-colorbox','id':this.cpGetId('cColor')},true).update('Farbe auswählen');Ext.get(this.cpGetId('cWebSafe')).on('click',this.updateFromBox.createDelegate(this));Ext.get(this.cpGetId('cInverse')).on('click',this.updateFromBox.createDelegate(this));Ext.get(this.cpGetId('cColor')).on('click',this.selectColor.createDelegate(this));Ext.DomHelper.append(this.body,{'tag':'br','cls':'x-cp-clearfloat'});},cpGetId:function(postfix){return this.getId()+'__'+(postfix||'cp');},updateRGBPosition:function(x,y){this.updateMode='click';x=x<0?0:x;x=x>181?181:x;y=y<0?0:y;y=y>181?181:y;this.HSV.s=this.getSaturation(x);this.HSV.v=this.getValue(y);Ext.get(this.rgbPicker).moveTo(Ext.get(this.cpGetId('rgb')).getLeft()+x-7,Ext.get(this.cpGetId('rgb')).getTop()+y-7,(this.animateMove||true));this.updateColor();},updateHUEPosition:function(y){this.updateMode='click';y=y<1?1:y;y=y>181?181:y;this.HSV.h=Math.round(360/181*(181-y));Ext.get(this.huePicker).moveTo(Ext.get(this.huePicker).getLeft(),Ext.get(this.cpGetId('hue')).getTop()+y-7,(this.animateMove||true));this.updateRGBPicker(this.HSV.h);this.updateColor();},clickRGBPicker:function(event,element){this.updateRGBPosition(event.xy[0]-Ext.get(this.cpGetId('rgb')).getLeft(),event.xy[1]-Ext.get(this.cpGetId('rgb')).getTop());},clickHUEPicker:function(event,element){this.updateHUEPosition(event.xy[1]-Ext.get(this.cpGetId('hue')).getTop());},moveRGBPicker:function(event){this.rgbDD.constrainTo(this.cpGetId('rgb'),-7);this.updateRGBPosition(Ext.get(this.rgbPicker).getLeft()-Ext.get(this.cpGetId('rgb')).getLeft()+7,Ext.get(this.rgbPicker).getTop()-Ext.get(this.cpGetId('rgb')).getTop()+7);},moveHuePicker:function(event){this.hueDD.constrainTo(this.cpGetId('hue'),{'top':-7,'right':-3,'bottom':-7,'left':-3});this.updateHUEPosition(Ext.get(this.huePicker).getTop()-Ext.get(this.cpGetId('hue')).getTop()+7);},updateRGBPicker:function(newValue){this.updateMode='click';Ext.get(this.cpGetId('rgb')).setStyle({'background-color':'#'+this.rgbToHex(this.hsvToRgb(newValue,1,1))});this.updateColor();},updateColor:function(){var rgb=this.hsvToRgb(this.HSV.h,this.HSV.s,this.HSV.v);var websafe=this.websafe(rgb);var invert=this.invert(rgb);var wsInvert=this.invert(websafe);if(this.updateMode!=='hexa'){Ext.getCmp(this.cpGetId('iHexa')).setValue(this.rgbToHex(rgb));}
if(this.updateMode!=='rgb'){Ext.getCmp(this.cpGetId('iRed')).setValue(rgb[0]);Ext.getCmp(this.cpGetId('iGreen')).setValue(rgb[1]);Ext.getCmp(this.cpGetId('iBlue')).setValue(rgb[2]);}
if(this.updateMode!=='hsv'){Ext.getCmp(this.cpGetId('iHue')).setValue(Math.round(this.HSV.h));Ext.getCmp(this.cpGetId('iSat')).setValue(Math.round(this.HSV.s*100));Ext.getCmp(this.cpGetId('iVal')).setValue(Math.round(this.HSV.v*100));}
Ext.get(this.cpGetId('cColor')).setStyle({'background':'#'+this.rgbToHex(rgb),'color':'#'+this.rgbToHex(invert)});Ext.getDom(this.cpGetId('cColor')).title='#'+this.rgbToHex(rgb);Ext.get(this.cpGetId('cInverse')).setStyle({'background':'#'+this.rgbToHex(invert),'color':'#'+this.rgbToHex(rgb)});Ext.getDom(this.cpGetId('cInverse')).title='#'+this.rgbToHex(invert);Ext.get(this.cpGetId('cWebSafe')).setStyle({'background':'#'+this.rgbToHex(websafe),'color':'#'+this.rgbToHex(wsInvert)});Ext.getDom(this.cpGetId('cWebSafe')).title='#'+this.rgbToHex(websafe);Ext.get(this.huePicker).moveTo(Ext.get(this.huePicker).getLeft(),Ext.get(this.cpGetId('hue')).getTop()+this.getHPos(Ext.getCmp(this.cpGetId('iHue')).getValue())-7,(this.animateMove||true));Ext.get(this.rgbPicker).moveTo(Ext.get(this.cpGetId('rgb')).getLeft()+this.getSPos(Ext.getCmp(this.cpGetId('iSat')).getValue()/100)-7,Ext.get(this.cpGetId('hue')).getTop()+this.getVPos(Ext.getCmp(this.cpGetId('iVal')).getValue()/100)-7,(this.animateMove||true));Ext.get(this.cpGetId('rgb')).setStyle({'background-color':'#'+this.rgbToHex(this.hsvToRgb(Ext.getCmp(this.cpGetId('iHue')).getValue(),1,1))});},setColor:function(c){if(!/^[0-9a-fA-F]{6}$/.test(c))return;Ext.getCmp(this.cpGetId('iHexa')).setValue(c);this.updateFromIHexa();},updateFromIRGB:function(input,newValue,oldValue){this.updateMode='rgb';var temp=this.rgbToHsv(Ext.getCmp(this.cpGetId('iRed')).getValue(),Ext.getCmp(this.cpGetId('iGreen')).getValue(),Ext.getCmp(this.cpGetId('iBlue')).getValue());this.HSV={h:temp[0],s:temp[1],v:temp[2]};this.updateColor();},updateFromIHSV:function(input,newValue,oldValue){this.updateMode='hsv';this.HSV={h:Ext.getCmp(this.cpGetId('iHue')).getValue(),s:Ext.getCmp(this.cpGetId('iSat')).getValue()/100,v:Ext.getCmp(this.cpGetId('iVal')).getValue()/100};this.updateColor();},updateFromIHexa:function(input,newValue,oldValue){this.updateMode='hexa';var temp=this.rgbToHsv(this.hexToRgb(Ext.getCmp(this.cpGetId('iHexa')).getValue()));this.HSV={h:temp[0],s:temp[1],v:temp[2]};this.updateColor();},updateFromBox:function(event,element){this.updateMode='click';var temp=this.rgbToHsv(this.hexToRgb(Ext.get(element).getColor('backgroundColor','','')));this.HSV={h:temp[0],s:temp[1],v:temp[2]};this.updateColor();},selectColor:function(event,element){this.fireEvent('select',this,Ext.get(element).getColor('backgroundColor','',''));},hsvToRgb:function(h,s,v){if(h instanceof Array){return this.hsvToRgb.call(this,h[0],h[1],h[2]);}
var r,g,b,i,f,p,q,t;i=Math.floor((h/60)%6);f=(h/60)-i;p=v*(1-s);q=v*(1-f*s);t=v*(1-(1-f)*s);switch(i){case 0:r=v;g=t;b=p;break;case 1:r=q;g=v;b=p;break;case 2:r=p;g=v;b=t;break;case 3:r=p;g=q;b=v;break;case 4:r=t;g=p;b=v;break;case 5:r=v;g=p;b=q;break;}
return[this.realToDec(r),this.realToDec(g),this.realToDec(b)];},rgbToHsv:function(r,g,b){if(r instanceof Array){return this.rgbToHsv.call(this,r[0],r[1],r[2]);}
r=r/255;g=g/255;b=b/255;var min,max,delta,h,s,v;min=Math.min(Math.min(r,g),b);max=Math.max(Math.max(r,g),b);delta=max-min;switch(max){case min:h=0;break;case r:h=60*(g-b)/delta;if(g<b){h+=360;}
break;case g:h=(60*(b-r)/delta)+120;break;case b:h=(60*(r-g)/delta)+240;break;}
s=(max===0)?0:1-(min/max);return[Math.round(h),s,max];},realToDec:function(n){return Math.min(255,Math.round(n*256));},rgbToHex:function(r,g,b){if(r instanceof Array){return this.rgbToHex.call(this,r[0],r[1],r[2]);}
return this.decToHex(r)+this.decToHex(g)+this.decToHex(b);},decToHex:function(n){var HCHARS='0123456789ABCDEF';n=parseInt(n,10);n=(!isNaN(n))?n:0;n=(n>255||n<0)?0:n;return HCHARS.charAt((n-n%16)/16)+HCHARS.charAt(n%16);},getHCharPos:function(c){if(c!=undefined){var HCHARS='0123456789ABCDEF';return HCHARS.indexOf(c.toUpperCase());}},hexToDec:function(hex){var s=hex.split('');return((this.getHCharPos(s[0])*16)+this.getHCharPos(s[1]));},hexToRgb:function(hex){return[this.hexToDec(hex.substr(0,2)),this.hexToDec(hex.substr(2,2)),this.hexToDec(hex.substr(4,2))];},getHue:function(y){var hue=360-Math.round(((181-y)/181)*360);return hue===360?0:hue;},getHPos:function(hue){return 181-hue*(181/360);},getSaturation:function(x){return x/181;},getSPos:function(saturation){return saturation*181;},getValue:function(y){return(181-y)/181;},getVPos:function(value){return 181-(value*181);},checkSafeNumber:function(v){if(!isNaN(v)){v=Math.min(Math.max(0,v),255);var i,next;for(i=0;i<256;i=i+51){next=i+51;if(v>=i&&v<=next){return(v-i>25)?next:i;}}}
return v;},websafe:function(r,g,b){if(r instanceof Array){return this.websafe.call(this,r[0],r[1],r[2]);}
return[this.checkSafeNumber(r),this.checkSafeNumber(g),this.checkSafeNumber(b)];},invert:function(r,g,b){if(r instanceof Array){return this.invert.call(this,r[0],r[1],r[2]);}
return[255-r,255-g,255-b];}});Ext.ux.ColorDialog=Ext.extend(Ext.Window,{initComponent:function(){this.width=(!this.width||this.width<353)?353:this.width;this.applyDefaultsCP();Ext.ux.ColorDialog.superclass.initComponent.apply(this,arguments);},onRender:function(){Ext.ux.ColorDialog.superclass.onRender.apply(this,arguments);this.renderComponent();}});Ext.applyIf(Ext.ux.ColorDialog.prototype,Ext.ux.ColorPicker.prototype);Ext.ux.ColorPanel=Ext.extend(Ext.Panel,{initComponent:function(){this.width=(!this.width||this.width<300)?300:this.width;this.applyDefaultsCP();Ext.ux.ColorPanel.superclass.initComponent.apply(this,arguments);},onRender:function(){Ext.ux.ColorPanel.superclass.onRender.apply(this,arguments);this.renderComponent();}});Ext.applyIf(Ext.ux.ColorPanel.prototype,Ext.ux.ColorPicker.prototype);Ext.reg('colorpicker',Ext.ux.ColorPicker);Ext.reg('colordialog',Ext.ux.ColorDialog);Ext.reg('colorpanel',Ext.ux.ColorPanel);

Ext.namespace("Ext.ux.menu","Ext.ux.form");Ext.ux.menu.ColorMenu=Ext.extend(Ext.menu.Menu,{enableScrolling:false,hideOnClick:true,initComponent:function(){Ext.apply(this,{plain:true,showSeparator:false,items:this.picker=new Ext.ux.ColorPicker(Ext.apply({style:'width:350px;'},this.initialConfig))});Ext.ux.menu.ColorMenu.superclass.initComponent.call(this);this.relayEvents(this.picker,['select']);this.on('select',this.menuHide,this);if(this.handler){this.on('select',this.handler,this.scope||this)}},menuHide:function(){if(this.hideOnClick){this.hide(true);}}});Ext.ux.form.ColorPickerField=Ext.extend(Ext.form.TriggerField,{initComponent:function(){Ext.ux.form.ColorPickerField.superclass.initComponent.call(this);this.menu=new Ext.ux.menu.ColorMenu({listeners:{select:function(m,c){this.setValue(c.toUpperCase());this.focus.defer(10,this);},scope:this}});},setValue:function(v){Ext.ux.form.ColorPickerField.superclass.setValue.apply(this,arguments);if(v)v=v.replace('#','');if(/^[0-9a-fA-F]{6}$/.test(v)){var i=this.menu.picker.rgbToHex(this.menu.picker.invert(this.menu.picker.hexToRgb(v)));this.el.applyStyles('background: #'+v+'; color: #'+i+';');}else{this.el.applyStyles('background: #ffffff; color: #000000;');}},onDestroy:function(){if(this.menu){this.menu.destroy();}
if(this.wrap){this.wrap.remove();}
Ext.ux.form.ColorPickerField.superclass.onDestroy.call(this);},onBlur:function(){Ext.ux.form.ColorPickerField.superclass.onBlur.call(this);this.setValue(this.getValue());},onTriggerClick:function(){if(this.disabled){return;}
this.menu.show(this.el,"tl-bl?");this.menu.picker.setColor(this.getValue());}});Ext.reg("colorpickerfield",Ext.ux.form.ColorPickerField);Ext.ux.form.SimpleColorPickerField=Ext.extend(Ext.form.TriggerField,{initComponent:function(){Ext.ux.form.SimpleColorPickerField.superclass.initComponent.call(this);this.menu=new Ext.menu.ColorMenu({listeners:{select:function(m,c){this.setValue('#'+c);this.focus.defer(10,this);},scope:this}});},setValue:function(v){Ext.ux.form.SimpleColorPickerField.superclass.setValue.apply(this,arguments);if(v)v=v.replace('#','');if(/^[0-9a-fA-F]{6}$/.test(v)){var i=this.rgbToHex(this.invert(this.hexToRgb(v)));this.el.applyStyles('background: #'+v+'; color: #'+i+';');}else{this.el.applyStyles('background: #ffffff; color: #000000;');}},onDestroy:function(){if(this.menu){this.menu.destroy();}
if(this.wrap){this.wrap.remove();}
Ext.ux.form.ColorPickerField.superclass.onDestroy.call(this);},onBlur:function(){Ext.ux.form.SimpleColorPickerField.superclass.onBlur.call(this);this.setValue(this.getValue());},onTriggerClick:function(){if(this.disabled){return;}
this.menu.show(this.el,"tl-bl?");},hexToRgb:function(hex){return[this.hexToDec(hex.substr(0,2)),this.hexToDec(hex.substr(2,2)),this.hexToDec(hex.substr(4,2))];},rgbToHex:function(r,g,b){if(r instanceof Array){return this.rgbToHex.call(this,r[0],r[1],r[2]);}
return this.decToHex(r)+this.decToHex(g)+this.decToHex(b);},decToHex:function(n){var HCHARS='0123456789ABCDEF';n=parseInt(n,10);n=(!isNaN(n))?n:0;n=(n>255||n<0)?0:n;return HCHARS.charAt((n-n%16)/16)+HCHARS.charAt(n%16);},hexToDec:function(hex){var s=hex.split('');return((this.getHCharPos(s[0])*16)+this.getHCharPos(s[1]));},getHCharPos:function(c){var HCHARS='0123456789ABCDEF';return HCHARS.indexOf(c.toUpperCase());},invert:function(r,g,b){if(r instanceof Array){return this.invert.call(this,r[0],r[1],r[2]);}
return[255-r,255-g,255-b];}});Ext.reg("simplecolorpickerfield",Ext.ux.form.SimpleColorPickerField);Ext.reg("colorfield",Ext.ux.form.SimpleColorPickerField);

Ext.namespace("Ext.ux.form");Ext.ux.form.Spinner=function(config){Ext.ux.form.Spinner.superclass.constructor.call(this,config);this.addEvents({'spin':true,'spinup':true,'spindown':true});};Ext.extend(Ext.ux.form.Spinner,Ext.form.TriggerField,{triggerClass:'x-form-spinner-trigger',splitterClass:'x-form-spinner-splitter',alternateKey:Ext.EventObject.shiftKey,strategy:undefined,onRender:function(ct,position){Ext.ux.form.Spinner.superclass.onRender.call(this,ct,position);this.splitter=this.wrap.createChild({tag:'div',cls:this.splitterClass,style:'width:13px; height:2px;'});this.splitter.show().setRight((Ext.isIE)?1:-124);this.splitter.show().setTop(10);this.proxy=this.trigger.createProxy('',this.splitter,true);this.proxy.addClass("x-form-spinner-proxy");this.proxy.setSize(14,1);this.proxy.hide();this.dd=new Ext.dd.DDProxy(this.splitter.dom.id,"SpinnerDrag",{dragElId:this.proxy.id});this.initSpinner();},initTrigger:function(){this.trigger.addClassOnOver('x-form-trigger-over');this.trigger.addClassOnClick('x-form-trigger-click');},initSpinner:function(){this.keyNav=new Ext.KeyNav(this.el,{"up":function(e){e.preventDefault();this.onSpinUp();},"down":function(e){e.preventDefault();this.onSpinDown();},"pageUp":function(e){e.preventDefault();this.onSpinUpAlternate();},"pageDown":function(e){e.preventDefault();this.onSpinDownAlternate();},scope:this});this.repeater=new Ext.util.ClickRepeater(this.trigger);this.repeater.on("click",this.onTriggerClick,this,{preventDefault:true});this.trigger.on("mouseover",this.onMouseOver,this,{preventDefault:true});this.trigger.on("mouseout",this.onMouseOut,this,{preventDefault:true});this.trigger.on("mousemove",this.onMouseMove,this,{preventDefault:true});this.trigger.on("mousedown",this.onMouseDown,this,{preventDefault:true});this.trigger.on("mouseup",this.onMouseUp,this,{preventDefault:true});this.wrap.on("mousewheel",this.handleMouseWheel,this);this.dd.setXConstraint(0,0,10);this.dd.setYConstraint(1500,1500,10);this.dd.endDrag=this.endDrag.createDelegate(this);this.dd.startDrag=this.startDrag.createDelegate(this);this.dd.onDrag=this.onDrag.createDelegate(this);if('object'==typeof this.strategy&&this.strategy.xtype){switch(this.strategy.xtype){case'number':this.strategy=new Ext.ux.form.Spinner.NumberStrategy(this.strategy);break;case'date':this.strategy=new Ext.ux.form.Spinner.DateStrategy(this.strategy);break;case'time':this.strategy=new Ext.ux.form.Spinner.TimeStrategy(this.strategy);break;default:delete(this.strategy);break;}
delete(this.strategy.xtype);}
if(this.strategy==undefined){this.strategy=new Ext.ux.form.Spinner.NumberStrategy();}},onMouseOver:function(){if(this.disabled){return;}
var middle=this.getMiddle();this.__tmphcls=(Ext.EventObject.getPageY()<middle)?'x-form-spinner-overup':'x-form-spinner-overdown';this.trigger.addClass(this.__tmphcls);},onMouseOut:function(){this.trigger.removeClass(this.__tmphcls);},onMouseMove:function(){if(this.disabled){return;}
var middle=this.getMiddle();if(((Ext.EventObject.getPageY()>middle)&&this.__tmphcls=="x-form-spinner-overup")||((Ext.EventObject.getPageY()<middle)&&this.__tmphcls=="x-form-spinner-overdown")){}},onMouseDown:function(){if(this.disabled){return;}
var middle=this.getMiddle();this.__tmpccls=(Ext.EventObject.getPageY()<middle)?'x-form-spinner-clickup':'x-form-spinner-clickdown';this.trigger.addClass(this.__tmpccls);},onMouseUp:function(){this.trigger.removeClass(this.__tmpccls);},onTriggerClick:function(){if(this.disabled||this.getEl().dom.readOnly){return;}
var middle=this.getMiddle();var ud=(Ext.EventObject.getPageY()<middle)?'Up':'Down';this['onSpin'+ud]();},getMiddle:function(){var t=this.trigger.getTop();var h=this.trigger.getHeight();var middle=t+(h/2);return middle;},isSpinnable:function(){if(this.disabled||this.getEl().dom.readOnly){Ext.EventObject.preventDefault();return false;}
return true;},handleMouseWheel:function(e){if(this.wrap.hasClass('x-trigger-wrap-focus')==false){return;}
var delta=e.getWheelDelta();if(delta>0){this.onSpinUp();e.stopEvent();}else if(delta<0){this.onSpinDown();e.stopEvent();}},startDrag:function(){this.proxy.show();this._previousY=Ext.fly(this.dd.getDragEl()).getTop();},endDrag:function(){this.proxy.hide();},onDrag:function(){if(this.disabled){return;}
var y=Ext.fly(this.dd.getDragEl()).getTop();var ud='';if(this._previousY>y){ud='Up';}
if(this._previousY<y){ud='Down';}
if(ud!=''){this['onSpin'+ud]();}
this._previousY=y;},onSpinUp:function(){if(this.isSpinnable()==false){return;}
if(Ext.EventObject.shiftKey==true){this.onSpinUpAlternate();return;}else{this.strategy.onSpinUp(this);}
this.fireEvent("spin",this);this.fireEvent("spinup",this);},onSpinDown:function(){if(this.isSpinnable()==false){return;}
if(Ext.EventObject.shiftKey==true){this.onSpinDownAlternate();return;}else{this.strategy.onSpinDown(this);}
this.fireEvent("spin",this);this.fireEvent("spindown",this);},onSpinUpAlternate:function(){if(this.isSpinnable()==false){return;}
this.strategy.onSpinUpAlternate(this);this.fireEvent("spin",this);this.fireEvent("spinup",this);},onSpinDownAlternate:function(){if(this.isSpinnable()==false){return;}
this.strategy.onSpinDownAlternate(this);this.fireEvent("spin",this);this.fireEvent("spindown",this);}});Ext.reg('uxspinner',Ext.ux.form.Spinner);

Ext.ux.form.Spinner.Strategy=function(config){Ext.apply(this,config);};Ext.extend(Ext.ux.form.Spinner.Strategy,Ext.util.Observable,{defaultValue:0,minValue:undefined,maxValue:undefined,incrementValue:1,alternateIncrementValue:5,validationTask:new Ext.util.DelayedTask(),onSpinUp:function(field){this.spin(field,false,false);},onSpinDown:function(field){this.spin(field,true,false);},onSpinUpAlternate:function(field){this.spin(field,false,true);},onSpinDownAlternate:function(field){this.spin(field,true,true);},spin:function(field,down,alternate){this.validationTask.delay(500,function(){field.validate();});},fixBoundries:function(value){return value;}});Ext.ux.form.Spinner.NumberStrategy=function(config){Ext.ux.form.Spinner.NumberStrategy.superclass.constructor.call(this,config);};Ext.extend(Ext.ux.form.Spinner.NumberStrategy,Ext.ux.form.Spinner.Strategy,{allowDecimals:true,decimalPrecision:2,spin:function(field,down,alternate){Ext.ux.form.Spinner.NumberStrategy.superclass.spin.call(this,field,down,alternate);var v=parseFloat(field.getValue());var incr=(alternate==true)?this.alternateIncrementValue:this.incrementValue;(down==true)?v-=incr:v+=incr;v=(isNaN(v))?this.defaultValue:v;v=this.fixBoundries(v);field.setRawValue(v);},fixBoundries:function(value){var v=value;if(this.minValue!=undefined&&v<this.minValue){v=this.minValue;}
if(this.maxValue!=undefined&&v>this.maxValue){v=this.maxValue;}
return this.fixPrecision(v);},fixPrecision:function(value){var nan=isNaN(value);if(!this.allowDecimals||this.decimalPrecision==-1||nan||!value){return nan?'':value;}
return parseFloat(parseFloat(value).toFixed(this.decimalPrecision));}});Ext.ux.form.Spinner.DateStrategy=function(config){Ext.ux.form.Spinner.DateStrategy.superclass.constructor.call(this,config);};Ext.extend(Ext.ux.form.Spinner.DateStrategy,Ext.ux.form.Spinner.Strategy,{defaultValue:new Date(),format:"Y-m-d",incrementValue:1,incrementConstant:Date.DAY,alternateIncrementValue:1,alternateIncrementConstant:Date.MONTH,spin:function(field,down,alternate){Ext.ux.form.Spinner.DateStrategy.superclass.spin.call(this);var v=field.getRawValue();v=Date.parseDate(v,this.format);var dir=(down==true)?-1:1;var incr=(alternate==true)?this.alternateIncrementValue:this.incrementValue;var dtconst=(alternate==true)?this.alternateIncrementConstant:this.incrementConstant;if(typeof this.defaultValue=='string'){this.defaultValue=Date.parseDate(this.defaultValue,this.format);}
v=(v)?v.add(dtconst,dir*incr):this.defaultValue;v=this.fixBoundries(v);field.setRawValue(Ext.util.Format.date(v,this.format));},fixBoundries:function(date){var dt=date;var min=(typeof this.minValue=='string')?Date.parseDate(this.minValue,this.format):this.minValue;var max=(typeof this.maxValue=='string')?Date.parseDate(this.maxValue,this.format):this.maxValue;if(this.minValue!=undefined&&dt<min){dt=min;}
if(this.maxValue!=undefined&&dt>max){dt=max;}
return dt;}});Ext.ux.form.Spinner.TimeStrategy=function(config){Ext.ux.form.Spinner.TimeStrategy.superclass.constructor.call(this,config);};Ext.extend(Ext.ux.form.Spinner.TimeStrategy,Ext.ux.form.Spinner.DateStrategy,{format:"H:i",incrementValue:1,incrementConstant:Date.MINUTE,alternateIncrementValue:1,alternateIncrementConstant:Date.HOUR});

Ext.ns('Ext.ux.form');Ext.ux.form.FileUploadField=Ext.extend(Ext.form.TextField,{buttonText:'Browse...',buttonOnly:false,buttonOffset:3,readOnly:true,autoSize:Ext.emptyFn,initComponent:function(){Ext.ux.form.FileUploadField.superclass.initComponent.call(this);this.addEvents('fileselected');},onRender:function(ct,position){Ext.ux.form.FileUploadField.superclass.onRender.call(this,ct,position);this.wrap=this.el.wrap({cls:'x-form-field-wrap x-form-file-wrap'});this.el.addClass('x-form-file-text');this.el.dom.removeAttribute('name');this.createFileInput();var btnCfg=Ext.applyIf(this.buttonCfg||{},{text:this.buttonText,tooltip:this.buttonCfg.tooltip});this.button=new Ext.Button(Ext.apply(btnCfg,{renderTo:this.wrap,cls:'x-form-file-btn'+(btnCfg.iconCls?' x-btn-icon':'')}));if(this.buttonOnly){this.el.hide();this.wrap.setWidth(this.button.getEl().getWidth());}
this.bindListeners();this.resizeEl=this.positionEl=this.wrap;},bindListeners:function(){this.fileInput.on({scope:this,mouseenter:function(){this.button.addClass(['x-btn-over','x-btn-focus'])},mouseleave:function(){this.button.removeClass(['x-btn-over','x-btn-focus','x-btn-click'])},mousedown:function(){this.button.addClass('x-btn-click')},mouseup:function(){this.button.removeClass(['x-btn-over','x-btn-focus','x-btn-click'])},change:function(){var v=this.fileInput.dom.value;this.setValue(v);this.fireEvent('fileselected',this,v);}});},createFileInput:function(){this.fileInput=this.wrap.createChild({id:this.getFileInputId(),name:this.name||this.getId(),cls:'x-form-file',tag:'input',type:'file',title:this.buttonCfg.tooltip+'',size:1});},reset:function(){this.fileInput.remove();this.createFileInput();this.bindListeners();Ext.ux.form.FileUploadField.superclass.reset.call(this);},getFileInputId:function(){return this.id+'-file';},onResize:function(w,h){Ext.ux.form.FileUploadField.superclass.onResize.call(this,w,h);this.wrap.setWidth(w);if(!this.buttonOnly){var w=this.wrap.getWidth()-this.button.getEl().getWidth()-this.buttonOffset;this.el.setWidth(w);}},onDestroy:function(){Ext.ux.form.FileUploadField.superclass.onDestroy.call(this);Ext.destroy(this.fileInput,this.button,this.wrap);},onDisable:function(){Ext.ux.form.FileUploadField.superclass.onDisable.call(this);this.doDisable(true);},onEnable:function(){Ext.ux.form.FileUploadField.superclass.onEnable.call(this);this.doDisable(false);},doDisable:function(disabled){this.fileInput.dom.disabled=disabled;this.button.setDisabled(disabled);},preFocus:Ext.emptyFn,alignErrorIcon:function(){this.errorIcon.alignTo(this.wrap,'tl-tr',[2,0]);}});Ext.reg('fileuploadfield',Ext.ux.form.FileUploadField);Ext.form.FileUploadField=Ext.ux.form.FileUploadField;

Ext.ns('Ext.ux.window');Ext.ux.window.MessageWindowGroup=function(config){config=config||{};var mgr=new Ext.WindowGroup();mgr.positions=[];Ext.apply(mgr,config);return mgr;};Ext.ux.window.MessageWindowMgr=Ext.ux.window.MessageWindowGroup();Ext.ux.window.MessageWindow=Ext.extend(Ext.Window,{autoDestroy:true,autoHide:true,autoHeight:false,bodyStyle:'text-align:left;padding:10px;',buttonAlign:'center',cls:'x-notification',constrain:true,constrainHeader:true,draggable:true,floating:true,frame:true,handleHelp:Ext.emptyFn,help:true,hideFx:{delay:5000},hoverCls:'msg-over',iconCls:'x-icon-information',minHeight:40,minWidth:200,msgs:[],monitorResize:true,pinOnClick:true,pinState:'unpin',plain:false,resizable:false,textHelp:'Get help',textPin:'Pin this to prevent closing',textUnpin:'Unpin this to close',initHidden:true,initComponent:function(){Ext.apply(this,{collapsible:false,footer:false,minHeight:20,stateful:false});if(this.interval){this.startAutoRefresh();}
if(this.autoHide){if(this.pinState==='unpin'){this.task=new Ext.util.DelayedTask(this.hide,this);}}
else{this.closable=true;}
Ext.ux.window.MessageWindow.superclass.initComponent.call(this);this.on({hide:{scope:this,fn:function(){if(this.autoDestroy){if(this.fireEvent("beforeclose",this)!==false){this.fireEvent('close',this);this.destroy();}}}},mouseout:{scope:this,fn:this.onMouseout}});this.addEvents('afterpin','afterunpin','click');},initEvents:function(){this.manager=this.manager||Ext.ux.window.MessageWindowMgr;Ext.ux.window.MessageWindow.superclass.initEvents.call(this);},focus:function(){Ext.ux.window.MessageWindow.superclass.focus.call(this);},toFront:function(){if(this.manager.bringToFront(this)){if(this.focusOnShow){this.focus();}}
return this;},initTools:function(){this.addTool({id:'unpin',handler:this.handlePin,hidden:(!this.pinState||this.pinState==='pin'),qtip:this.textPin,scope:this});this.addTool({id:'pin',handler:this.handleUnpin,hidden:(!this.pinState||this.pinState==='unpin'),qtip:this.textUnpin,scope:this});if(this.help){this.addTool({id:'help',handler:this.handleHelp,qtip:this.textHelp,scope:this});}},onRender:function(ct,position){Ext.ux.window.MessageWindow.superclass.onRender.call(this,ct,position);if(this.clip){switch(this.clip){case'bottom':Ext.destroy(this.getEl().child('.'+this.baseCls+'-bl'));break;}}
if(true){this.el.addClassOnOver(this.hoverCls);}
Ext.fly(this.body.dom).on('click',this.handleClick,this);},togglePinState:function(event){if(this.tools.unpin.isVisible()){this.handlePin(event,this.tools.unpin,this);}else{this.handleUnpin(event,this.tools.pin,this);}},createElement:function(name,pnode){if(this.shiftHeader){switch(name){case'header':return;case'tbar':Ext.ux.window.MessageWindow.superclass.createElement.call(this,'header',pnode);Ext.ux.window.MessageWindow.superclass.createElement.call(this,name,pnode);return;}}
Ext.ux.window.MessageWindow.superclass.createElement.call(this,name,pnode);},focus:Ext.emptyFn,getState:function(){return Ext.apply(Ext.ux.window.MessageWindow.superclass.getState.call(this)||{},this.getBox());},handleClick:function(event){this.fireEvent('click',this,this.msg);this.togglePinState(event);},handlePin:function(event,toolEl,panel){toolEl.hide();this.tools.pin.show();this.cancelHiding();this.fireEvent('afterpin',this);},handleUnpin:function(event,toolEl,panel){toolEl.hide();this.tools.unpin.show();this.hide();this.fireEvent('afterunpin',this);},cancelHiding:function(){this.addClass('fixed');if(this.autoHide){if(this.pinState==='unpin'){this.task.cancel();}}
this.tools.pin.show();this.tools.unpin.hide();},animHide:function(){this.manager.positions.remove(this.pos);var w,fx=this.hideFx||{};if(fx.useProxy){w=this.proxy;this.proxy.setOpacity(0.5);this.proxy.show();var tb=this.getBox(false);this.proxy.setBox(tb);this.el.hide();Ext.apply(fx,tb);}else{w=this.el;}
Ext.applyIf(fx,{block:false,callback:this.afterHide,easing:'easeOut',remove:this.autoDestroy,scope:this});switch(fx.mode){case'none':break;case'slideIn':w[fx.mode]("b",fx);break;case'custom':Ext.callback(fx.callback,fx.scope,[this,w,fx]);break;case'standard':fx.duration=fx.duration||0.25;fx.opacity=0;w.shift(fx);break;default:fx.duration=fx.duration||1;w.ghost("t",fx);break;}},afterShow:function(){Ext.ux.window.MessageWindow.superclass.afterShow.call(this);this.on('move',function(){this.manager.positions.remove(this.pos);this.cancelHiding();},this);if(this.autoHide){if(this.pinState==='unpin'){this.task.delay(this.hideFx.delay);}}},animShow:function(){if(this.el.isVisible()&&this.el.hasClass(this.hoverCls)){return;}
if(this.msgs.length>1){this.updateMsg();}
var w=this.el,fx=this.showFx||{};this.origin=this.origin||{};Ext.applyIf(this.origin,{el:Ext.getDoc(),increment:true,pos:"br-br",offX:-20,offY:-20,spaY:5});this.pos=0;if(this.origin.increment){while(this.manager.positions.indexOf(this.pos)>-1){this.pos++;}
this.manager.positions.push(this.pos);}
var y=this.origin.offY-((this.getSize().height+this.origin.spaY)*this.pos);this.setSize(this.width||this.minWidth,this.height||this.minHeight);if(this.origin.increment){y=this.origin.offY-((this.getSize().height+this.origin.spaY)*this.pos);}else{y=0;}
w.alignTo(this.origin.el,this.origin.pos,[this.origin.offX,y]);w.slideIn('t',{duration:fx.duration||1,callback:this.afterShow,scope:this});},onMouseout:function(){},positionPanel:function(el,x,y){if(x&&typeof x[1]=='number'){y=x[1];x=x[0];}
el.pageX=x;el.pageY=y;if(x===undefined||y===undefined){return;}
if(y<0){y=10;}
var p=el.translatePoints(x,y);el.setLocation(p.left,p.top);return el;},setMessage:function(msg){this.body.update(msg);},setTitle:function(title,iconCls){Ext.ux.window.MessageWindow.superclass.setTitle.call(this,title,iconCls||this.iconCls);},startAutoRefresh:function(update){if(update){this.updateMsg(true);}
if(this.autoRefreshProcId){clearInterval(this.autoRefreshProcId);}
this.autoRefreshProcId=setInterval(this.animShow.createDelegate(this,[]),this.interval);},stopAutoRefresh:function(){if(this.autoRefreshProcId){clearInterval(this.autoRefreshProcId);}},updateMsg:function(msg){if(this.el&&!this.el.hasClass(this.hoverCls)){if(msg){}else{this.msgIndex=this.msgs[this.msgIndex+1]?this.msgIndex+1:0;this.msg=this.msgs[this.msgIndex];}
this.body.update(this.msg.text);}else{}}});Ext.reg('message-window',Ext.ux.window.MessageWindow);

Ext.ux.Portal=Ext.extend(Ext.Panel,{layout:'column',autoScroll:true,cls:'x-portal',defaultType:'portalcolumn',initComponent:function(){Ext.ux.Portal.superclass.initComponent.call(this);this.addEvents({validatedrop:true,beforedragover:true,dragover:true,beforedrop:true,drop:true});},initEvents:function(){Ext.ux.Portal.superclass.initEvents.call(this);this.dd=new Ext.ux.Portal.DropZone(this,this.dropConfig);}});Ext.reg('portal',Ext.ux.Portal);Ext.ux.Portal.DropZone=function(portal,cfg){this.portal=portal;Ext.dd.ScrollManager.register(portal.body);Ext.ux.Portal.DropZone.superclass.constructor.call(this,portal.bwrap.dom,cfg);portal.body.ddScrollConfig=this.ddScrollConfig;};Ext.extend(Ext.ux.Portal.DropZone,Ext.dd.DropTarget,{ddScrollConfig:{vthresh:50,hthresh:-1,animate:true,increment:200},createEvent:function(dd,e,data,col,c,pos){return{portal:this.portal,panel:data.panel,columnIndex:col,column:c,position:pos,data:data,source:dd,rawEvent:e,status:this.dropAllowed};},notifyOver:function(dd,e,data){var xy=e.getXY(),portal=this.portal,px=dd.proxy;if(!this.grid){this.grid=this.getGrid();}
var cw=portal.body.dom.clientWidth;if(!this.lastCW){this.lastCW=cw;}else if(this.lastCW!=cw){this.lastCW=cw;portal.doLayout();this.grid=this.getGrid();}
var col=0,xs=this.grid.columnX,cmatch=false;for(var len=xs.length;col<len;col++){if(xy[0]<(xs[col].x+xs[col].w)){cmatch=true;break;}}
if(!cmatch){col--;}
var p,match=false,pos=0,c=portal.items.itemAt(col),items=c.items.items;for(var len=items.length;pos<len;pos++){p=items[pos];var h=p.el.getHeight();if(h!==0&&(p.el.getY()+(h/2))>xy[1]){match=true;break;}}
var overEvent=this.createEvent(dd,e,data,col,c,match&&p?pos:c.items.getCount());if(portal.fireEvent('validatedrop',overEvent)!==false&&portal.fireEvent('beforedragover',overEvent)!==false){px.getProxy().setWidth('auto');if(p){px.moveProxy(p.el.dom.parentNode,match?p.el.dom:null);}else{px.moveProxy(c.el.dom,null);}
this.lastPos={c:c,col:col,p:match&&p?pos:false};this.scrollPos=portal.body.getScroll();portal.fireEvent('dragover',overEvent);return overEvent.status;;}else{return overEvent.status;}},notifyOut:function(){delete this.grid;},notifyDrop:function(dd,e,data){delete this.grid;if(!this.lastPos){return;}
var c=this.lastPos.c,col=this.lastPos.col,pos=this.lastPos.p;var dropEvent=this.createEvent(dd,e,data,col,c,pos!==false?pos:c.items.getCount());if(this.portal.fireEvent('validatedrop',dropEvent)!==false&&this.portal.fireEvent('beforedrop',dropEvent)!==false){dd.proxy.getProxy().remove();dd.panel.el.dom.parentNode.removeChild(dd.panel.el.dom);if(pos!==false){c.insert(pos,dd.panel);}else{c.add(dd.panel);}
c.doLayout();this.portal.fireEvent('drop',dropEvent);var st=this.scrollPos.top;if(st){var d=this.portal.body.dom;setTimeout(function(){d.scrollTop=st;},10);}}
delete this.lastPos;},getGrid:function(){var box=this.portal.bwrap.getBox();box.columnX=[];this.portal.items.each(function(c){box.columnX.push({x:c.el.getX(),w:c.el.getWidth()});});return box;}});

Ext.ux.PortalColumn=Ext.extend(Ext.Container,{layout:'anchor',autoEl:'div',defaultType:'portlet',cls:'x-portal-column'});Ext.reg('portalcolumn',Ext.ux.PortalColumn);

Ext.ux.Portlet=Ext.extend(Ext.Panel,{anchor:'100%',frame:true,collapsible:true,draggable:false,cls:'x-portlet',stateful:true,stateEvents:['collapse','expand'],autoScroll:true,getState:function()
{var state={};state.collapsed=this.collapsed;return state;}});Ext.reg('portlet',Ext.ux.Portlet);

Ext.namespace('Ext.ux');Ext.ux.GMapPanel=Ext.extend(Ext.Panel,{initComponent:function(){var defConfig={plain:true,zoomLevel:3,yaw:180,pitch:0,zoom:0,gmapType:'map',border:false};Ext.applyIf(this,defConfig);Ext.ux.GMapPanel.superclass.initComponent.call(this);},afterRender:function(){var wh=this.ownerCt.getSize();Ext.applyIf(this,wh);Ext.ux.GMapPanel.superclass.afterRender.call(this);if(this.gmapType==='map'){this.gmap=new GMap2(this.body.dom);}
if(this.gmapType==='panorama'){this.gmap=new GStreetviewPanorama(this.body.dom);}
if(typeof this.addControl=='object'&&this.gmapType==='map'){this.getMap().addControl(this.addControl);}
this.addMapControls();this.addOptions();if(typeof this.setCenter==='object'){if(typeof this.setCenter.geoCodeAddr==='string'){this.geoCodeLookup(this.setCenter.geoCodeAddr);}else{if(this.gmapType==='map'){var point=new GLatLng(this.setCenter.lat,this.setCenter.lng);this.getMap().setCenter(point,this.zoomLevel);}
if(typeof this.setCenter.marker==='object'&&typeof point==='object'){this.addMarker(point,this.setCenter.marker,this.setCenter.marker.clear);}}
if(this.gmapType==='panorama'){this.getMap().setLocationAndPOV(new GLatLng(this.setCenter.lat,this.setCenter.lng),{yaw:this.yaw,pitch:this.pitch,zoom:this.zoom});}}
GEvent.bind(this.gmap,'load',this,function(){this.onMapReady();});},onMapReady:function(){this.addMarkers(this.markers);},onResize:function(w,h){if(typeof this.getMap()=='object'){this.getMap().checkResize();}
Ext.ux.GMapPanel.superclass.onResize.call(this,w,h);},setSize:function(width,height,animate){if(typeof this.getMap()=='object'){this.getMap().checkResize();}
Ext.ux.GMapPanel.superclass.setSize.call(this,width,height,animate);},getMap:function(){return this.gmap;},getCenter:function(){return this.getMap().getCenter();},getCenterLatLng:function(){var ll=this.getCenter();return{lat:ll.lat(),lng:ll.lng()};},addMarkers:function(markers){if(Ext.isArray(markers)){for(var i=0;i<markers.length;i++){var mkr_point=new GLatLng(markers[i].lat,markers[i].lng);this.addMarker(mkr_point,markers[i].marker,false,markers[i].setCenter,markers[i].listeners);}}},addMarker:function(point,marker,clear,center,listeners){Ext.applyIf(marker,G_DEFAULT_ICON);if(clear===true){this.getMap().clearOverlays();}
if(center===true){this.getMap().setCenter(point,this.zoomLevel);}
var mark=new GMarker(point,marker);if(typeof listeners==='object'){for(evt in listeners){GEvent.bind(mark,evt,this,listeners[evt]);}}
this.getMap().addOverlay(mark);},addMapControls:function(){if(this.gmapType==='map'){if(Ext.isArray(this.mapControls)){for(i=0;i<this.mapControls.length;i++){this.addMapControl(this.mapControls[i]);}}else if(typeof this.mapControls==='string'){this.addMapControl(this.mapControls);}else if(typeof this.mapControls==='object'){this.getMap().addControl(this.mapControls);}}},addMapControl:function(mc){var mcf=window[mc];if(typeof mcf==='function'){this.getMap().addControl(new mcf());}},addOptions:function(){if(Ext.isArray(this.mapConfOpts)){var mc;for(i=0;i<this.mapConfOpts.length;i++){this.addOption(this.mapConfOpts[i]);}}else if(typeof this.mapConfOpts==='string'){this.addOption(this.mapConfOpts);}},addOption:function(mc){var mcf=this.getMap()[mc];if(typeof mcf==='function'){this.getMap()[mc]();}},geoCodeLookup:function(addr){this.geocoder=new GClientGeocoder();this.geocoder.getLocations(addr,this.addAddressToMap.createDelegate(this));},addAddressToMap:function(response){if(!response||response.Status.code!=200){Ext.MessageBox.alert('Error','Code '+response.Status.code+' Error Returned');}else{place=response.Placemark[0];addressinfo=place.AddressDetails;accuracy=addressinfo.Accuracy;if(accuracy===0){Ext.MessageBox.alert('Unable to Locate Address','Unable to Locate the Address you provided');}else{if(accuracy<7){Ext.MessageBox.alert('Address Accuracy','The address provided has a low accuracy.<br><br>Level '+accuracy+' Accuracy (8 = Exact Match, 1 = Vague Match)');}else{point=new GLatLng(place.Point.coordinates[1],place.Point.coordinates[0]);if(typeof this.setCenter.marker==='object'&&typeof point==='object'){this.addMarker(point,this.setCenter.marker,this.setCenter.marker.clear,true,this.setCenter.listeners);}}}}}});Ext.reg('gmappanel',Ext.ux.GMapPanel);

Ext.ns('Ext.ux.grid');Ext.ux.grid.ColumnHeaderGroup=Ext.extend(Ext.util.Observable,{constructor:function(config){this.config=config;},init:function(grid){Ext.applyIf(grid.colModel,this.config);Ext.apply(grid.getView(),this.viewConfig);},viewConfig:{initTemplates:function(){this.constructor.prototype.initTemplates.apply(this,arguments);var ts=this.templates||{};if(!ts.gcell){ts.gcell=new Ext.XTemplate('<td class="x-grid3-hd x-grid3-gcell x-grid3-td-{id} ux-grid-hd-group-row-{row} {cls}" style="{style}">','<div {tooltip} class="x-grid3-hd-inner x-grid3-hd-{id}" unselectable="on" style="{istyle}">',this.grid.enableHdMenu?'<a class="x-grid3-hd-btn" href="#"></a>':'','{value}</div></td>');}
this.templates=ts;this.hrowRe=new RegExp("ux-grid-hd-group-row-(\\d+)","");},renderHeaders:function(){var ts=this.templates,headers=[],cm=this.cm,rows=cm.rows,tstyle='width:'+this.getTotalWidth()+';';for(var row=0,rlen=rows.length;row<rlen;row++){var r=rows[row],cells=[];for(var i=0,gcol=0,len=r.length;i<len;i++){var group=r[i];group.colspan=group.colspan||1;var id=this.getColumnId(group.dataIndex?cm.findColumnIndex(group.dataIndex):gcol),gs=Ext.ux.grid.ColumnHeaderGroup.prototype.getGroupStyle.call(this,group,gcol);cells[i]=ts.gcell.apply({cls:'ux-grid-hd-group-cell',id:id,row:row,style:'width:'+gs.width+';'+(gs.hidden?'display:none;':'')+(group.align?'text-align:'+group.align+';':''),tooltip:group.tooltip?(Ext.QuickTips.isEnabled()?'ext:qtip':'title')+'="'+group.tooltip+'"':'',istyle:group.align=='right'?'padding-right:16px':'',btn:this.grid.enableHdMenu&&group.header,value:group.header||'&nbsp;'});gcol+=group.colspan;}
headers[row]=ts.header.apply({tstyle:tstyle,cells:cells.join('')});}
headers.push(this.constructor.prototype.renderHeaders.apply(this,arguments));return headers.join('');},onColumnWidthUpdated:function(){this.constructor.prototype.onColumnWidthUpdated.apply(this,arguments);Ext.ux.grid.ColumnHeaderGroup.prototype.updateGroupStyles.call(this);},onAllColumnWidthsUpdated:function(){this.constructor.prototype.onAllColumnWidthsUpdated.apply(this,arguments);Ext.ux.grid.ColumnHeaderGroup.prototype.updateGroupStyles.call(this);},onColumnHiddenUpdated:function(){this.constructor.prototype.onColumnHiddenUpdated.apply(this,arguments);Ext.ux.grid.ColumnHeaderGroup.prototype.updateGroupStyles.call(this);},getHeaderCell:function(index){return this.mainHd.query(this.cellSelector)[index];},findHeaderCell:function(el){return el?this.fly(el).findParent('td.x-grid3-hd',this.cellSelectorDepth):false;},findHeaderIndex:function(el){var cell=this.findHeaderCell(el);return cell?this.getCellIndex(cell):false;},updateSortIcon:function(col,dir){var sc=this.sortClasses,hds=this.mainHd.select(this.cellSelector).removeClass(sc);hds.item(col).addClass(sc[dir=="DESC"?1:0]);},handleHdDown:function(e,t){var el=Ext.get(t);if(el.hasClass('x-grid3-hd-btn')){e.stopEvent();var hd=this.findHeaderCell(t);Ext.fly(hd).addClass('x-grid3-hd-menu-open');var index=this.getCellIndex(hd);this.hdCtxIndex=index;var ms=this.hmenu.items,cm=this.cm;ms.get('asc').setDisabled(!cm.isSortable(index));ms.get('desc').setDisabled(!cm.isSortable(index));this.hmenu.on('hide',function(){Ext.fly(hd).removeClass('x-grid3-hd-menu-open');},this,{single:true});this.hmenu.show(t,'tl-bl?');}else if(el.hasClass('ux-grid-hd-group-cell')||Ext.fly(t).up('.ux-grid-hd-group-cell')){e.stopEvent();}},handleHdMove:function(e,t){var hd=this.findHeaderCell(this.activeHdRef);if(hd&&!this.headersDisabled&&!Ext.fly(hd).hasClass('ux-grid-hd-group-cell')){var hw=this.splitHandleWidth||5,r=this.activeHdRegion,x=e.getPageX(),ss=hd.style,cur='';if(this.grid.enableColumnResize!==false){if(x-r.left<=hw&&this.cm.isResizable(this.activeHdIndex-1)){cur=Ext.isAir?'move':Ext.isWebKit?'e-resize':'col-resize';}else if(r.right-x<=(!this.activeHdBtn?hw:2)&&this.cm.isResizable(this.activeHdIndex)){cur=Ext.isAir?'move':Ext.isWebKit?'w-resize':'col-resize';}}
ss.cursor=cur;}},handleHdOver:function(e,t){var hd=this.findHeaderCell(t);if(hd&&!this.headersDisabled){this.activeHdRef=t;this.activeHdIndex=this.getCellIndex(hd);var fly=this.fly(hd);this.activeHdRegion=fly.getRegion();if(!(this.cm.isMenuDisabled(this.activeHdIndex)||fly.hasClass('ux-grid-hd-group-cell'))){fly.addClass('x-grid3-hd-over');this.activeHdBtn=fly.child('.x-grid3-hd-btn');if(this.activeHdBtn){this.activeHdBtn.dom.style.height=(hd.firstChild.offsetHeight-1)+'px';}}}},handleHdOut:function(e,t){var hd=this.findHeaderCell(t);if(hd&&(!Ext.isIE||!e.within(hd,true))){this.activeHdRef=null;this.fly(hd).removeClass('x-grid3-hd-over');hd.style.cursor='';}},handleHdMenuClick:function(item){var index=this.hdCtxIndex,cm=this.cm,ds=this.ds,id=item.getItemId();switch(id){case'asc':ds.sort(cm.getDataIndex(index),'ASC');break;case'desc':ds.sort(cm.getDataIndex(index),'DESC');break;default:if(id.substr(0,6)=='group-'){var i=id.split('-'),row=parseInt(i[1],10),col=parseInt(i[2],10),r=this.cm.rows[row],group,gcol=0;for(var i=0,len=r.length;i<len;i++){group=r[i];if(col>=gcol&&col<gcol+group.colspan){break;}
gcol+=group.colspan;}
if(item.checked){var max=cm.getColumnsBy(this.isHideableColumn,this).length;for(var i=gcol,len=gcol+group.colspan;i<len;i++){if(!cm.isHidden(i)){max--;}}
if(max<1){this.onDenyColumnHide();return false;}}
for(var i=gcol,len=gcol+group.colspan;i<len;i++){if(cm.config[i].fixed!==true&&cm.config[i].hideable!==false){cm.setHidden(i,item.checked);}}}else if(id.substr(0,4)=='col-'){index=cm.getIndexById(id.substr(4));if(index!=-1){if(item.checked&&cm.getColumnsBy(this.isHideableColumn,this).length<=1){this.onDenyColumnHide();return false;}
cm.setHidden(index,item.checked);}}
if(id.substr(0,6)=='group-'||id.substr(0,4)=='col-'){item.checked=!item.checked;if(item.menu){var updateChildren=function(menu){menu.items.each(function(childItem){if(!childItem.disabled){childItem.setChecked(item.checked,false);if(childItem.menu){updateChildren(childItem.menu);}}});}
updateChildren(item.menu);}
var parentMenu=item,parentItem;while(parentMenu=parentMenu.parentMenu){if(!parentMenu.parentMenu||!(parentItem=parentMenu.parentMenu.items.get(parentMenu.getItemId()))||!parentItem.setChecked){break;}
var checked=parentMenu.items.findIndexBy(function(m){return m.checked;})>=0;parentItem.setChecked(checked,true);}
item.checked=!item.checked;}}
return true;},beforeColMenuShow:function(){var cm=this.cm,rows=this.cm.rows;this.colMenu.removeAll();for(var col=0,clen=cm.getColumnCount();col<clen;col++){var menu=this.colMenu,title=cm.getColumnHeader(col),text=[];if(cm.config[col].fixed!==true&&cm.config[col].hideable!==false){for(var row=0,rlen=rows.length;row<rlen;row++){var r=rows[row],group,gcol=0;for(var i=0,len=r.length;i<len;i++){group=r[i];if(col>=gcol&&col<gcol+group.colspan){break;}
gcol+=group.colspan;}
if(group&&group.header){if(cm.hierarchicalColMenu){var gid='group-'+row+'-'+gcol,item=menu.items?menu.getComponent(gid):null,submenu=item?item.menu:null;if(!submenu){submenu=new Ext.menu.Menu({itemId:gid});submenu.on("itemclick",this.handleHdMenuClick,this);var checked=false,disabled=true;for(var c=gcol,lc=gcol+group.colspan;c<lc;c++){if(!cm.isHidden(c)){checked=true;}
if(cm.config[c].hideable!==false){disabled=false;}}
menu.add({itemId:gid,text:group.header,menu:submenu,hideOnClick:false,checked:checked,disabled:disabled});}
menu=submenu;}else{text.push(group.header);}}}
text.push(title);menu.add(new Ext.menu.CheckItem({itemId:"col-"+cm.getColumnId(col),text:text.join(' '),checked:!cm.isHidden(col),hideOnClick:false,disabled:cm.config[col].hideable===false}));}}},afterRenderUI:function(){this.constructor.prototype.afterRenderUI.apply(this,arguments);Ext.apply(this.columnDrop,Ext.ux.grid.ColumnHeaderGroup.prototype.columnDropConfig);Ext.apply(this.splitZone,Ext.ux.grid.ColumnHeaderGroup.prototype.splitZoneConfig);}},splitZoneConfig:{allowHeaderDrag:function(e){return!e.getTarget(null,null,true).hasClass('ux-grid-hd-group-cell');}},columnDropConfig:{getTargetFromEvent:function(e){var t=Ext.lib.Event.getTarget(e);return this.view.findHeaderCell(t);},positionIndicator:function(h,n,e){var data=Ext.ux.grid.ColumnHeaderGroup.prototype.getDragDropData.call(this,h,n,e);if(data===false){return false;}
var px=data.px+this.proxyOffsets[0];this.proxyTop.setLeftTop(px,data.r.top+this.proxyOffsets[1]);this.proxyTop.show();this.proxyBottom.setLeftTop(px,data.r.bottom);this.proxyBottom.show();return data.pt;},onNodeDrop:function(n,dd,e,data){var h=data.header;if(h!=n){var d=Ext.ux.grid.ColumnHeaderGroup.prototype.getDragDropData.call(this,h,n,e);if(d===false){return false;}
var cm=this.grid.colModel,right=d.oldIndex<d.newIndex,rows=cm.rows;for(var row=d.row,rlen=rows.length;row<rlen;row++){var r=rows[row],len=r.length,fromIx=0,span=1,toIx=len;for(var i=0,gcol=0;i<len;i++){var group=r[i];if(d.oldIndex>=gcol&&d.oldIndex<gcol+group.colspan){fromIx=i;}
if(d.oldIndex+d.colspan-1>=gcol&&d.oldIndex+d.colspan-1<gcol+group.colspan){span=i-fromIx+1;}
if(d.newIndex>=gcol&&d.newIndex<gcol+group.colspan){toIx=i;}
gcol+=group.colspan;}
var groups=r.splice(fromIx,span);rows[row]=r.splice(0,toIx-(right?span:0)).concat(groups).concat(r);}
for(var c=0;c<d.colspan;c++){var oldIx=d.oldIndex+(right?0:c),newIx=d.newIndex+(right?-1:c);cm.moveColumn(oldIx,newIx);this.grid.fireEvent("columnmove",oldIx,newIx);}
return true;}
return false;}},getGroupStyle:function(group,gcol){var width=0,hidden=true;for(var i=gcol,len=gcol+group.colspan;i<len;i++){if(!this.cm.isHidden(i)){var cw=this.cm.getColumnWidth(i);if(typeof cw=='number'){width+=cw;}
hidden=false;}}
return{width:(Ext.isBorderBox||(Ext.isWebKit&&!Ext.isSafari2)?width:Math.max(width-this.borderWidth,0))+'px',hidden:hidden};},updateGroupStyles:function(col){var tables=this.mainHd.query('.x-grid3-header-offset > table'),tw=this.getTotalWidth(),rows=this.cm.rows;for(var row=0;row<tables.length;row++){tables[row].style.width=tw;if(row<rows.length){var cells=tables[row].firstChild.firstChild.childNodes;for(var i=0,gcol=0;i<cells.length;i++){var group=rows[row][i];if((typeof col!='number')||(col>=gcol&&col<gcol+group.colspan)){var gs=Ext.ux.grid.ColumnHeaderGroup.prototype.getGroupStyle.call(this,group,gcol);cells[i].style.width=gs.width;cells[i].style.display=gs.hidden?'none':'';}
gcol+=group.colspan;}}}},getGroupRowIndex:function(el){if(el){var m=el.className.match(this.hrowRe);if(m&&m[1]){return parseInt(m[1],10);}}
return this.cm.rows.length;},getGroupSpan:function(row,col){if(row<0){return{col:0,colspan:this.cm.getColumnCount()};}
var r=this.cm.rows[row];if(r){for(var i=0,gcol=0,len=r.length;i<len;i++){var group=r[i];if(col>=gcol&&col<gcol+group.colspan){return{col:gcol,colspan:group.colspan};}
gcol+=group.colspan;}
return{col:gcol,colspan:0};}
return{col:col,colspan:1};},getDragDropData:function(h,n,e){if(h.parentNode!=n.parentNode){return false;}
var cm=this.grid.colModel,x=Ext.lib.Event.getPageX(e),r=Ext.lib.Dom.getRegion(n.firstChild),px,pt;if((r.right-x)<=(r.right-r.left)/2){px=r.right+this.view.borderWidth;pt="after";}else{px=r.left;pt="before";}
var oldIndex=this.view.getCellIndex(h),newIndex=this.view.getCellIndex(n);if(cm.isFixed(newIndex)){return false;}
var row=Ext.ux.grid.ColumnHeaderGroup.prototype.getGroupRowIndex.call(this.view,h),oldGroup=Ext.ux.grid.ColumnHeaderGroup.prototype.getGroupSpan.call(this.view,row,oldIndex),newGroup=Ext.ux.grid.ColumnHeaderGroup.prototype.getGroupSpan.call(this.view,row,newIndex),oldIndex=oldGroup.col;newIndex=newGroup.col+(pt=="after"?newGroup.colspan:0);if(newIndex>=oldGroup.col&&newIndex<=oldGroup.col+oldGroup.colspan){return false;}
var parentGroup=Ext.ux.grid.ColumnHeaderGroup.prototype.getGroupSpan.call(this.view,row-1,oldIndex);if(newIndex<parentGroup.col||newIndex>parentGroup.col+parentGroup.colspan){return false;}
return{r:r,px:px,pt:pt,row:row,oldIndex:oldIndex,newIndex:newIndex,colspan:oldGroup.colspan};}});

Ext.ns('Ext.ux.grid');Ext.ux.grid.RecordForm=function(config){Ext.apply(this,config);Ext.ux.grid.RecordForm.superclass.constructor.call(this);};Ext.extend(Ext.ux.grid.RecordForm,Ext.util.Observable,{autoHide:true,cancelIconCls:'icon-cancel',cancelText:'Cancel',columnCount:1,defaultFormConfig:{border:false,frame:true,autoHeight:true,labelWidth:100},defaultWindowConfig:{border:false,width:480,autoHeight:true,layout:'fit',closeAction:'hide',modal:true},dirtyRowCls:'ux-grid3-dirty-row',focusDefer:200,mapping:{'auto':'textfield','boolean':'checkbox','date':'datefield','float':'numberfield','int':'numberfield','string':'textfield'},newRowCls:'ux-grid3-new-row',okIconCls:'icon-ok',okText:'OK',showButtons:true,init:function(grid){grid.afterRender=grid.afterRender.createSequence(function(){if('function'===typeof grid.view.getRowClass){grid.view.getRowClass=grid.view.getRowClass.createSequence(this.getRowClass,this);}
else{grid.view.getRowClass=this.getRowClass.createDelegate(this);}
if(this.autoShow){this.show({data:{}});}},this);this.grid=grid;grid.reconfigure=grid.reconfigure.createSequence(this.reconfigure,this);this.reconfigure();},afterUpdateRecord:Ext.emptyFn,createFormConfig:function(){if(this.form){return;}
var cm=this.grid.getColumnModel();var fields=this.grid.store.recordType.prototype.fields;var store=this.grid.store;this.form=Ext.apply({xtype:'form',items:[{layout:'column',anchor:'100%',border:false,monitorValid:true,autoHeight:true,defaults:{columnWidth:1/this.columnCount,autoHeight:true,border:false,layout:'form',hideLabel:true},items:(function(){var items=[];for(var i=0;i<this.columnCount;i++){items.push({defaults:{anchor:'-25'},items:[]});}
return items;}).createDelegate(this)()}],buttons:(function(){if(this.showButtons){return[{text:this.okText,iconCls:this.okIconCls,scope:this,handler:this.onOK,formBind:true},{text:this.cancelText,iconCls:this.cancelIconCls,scope:this,handler:this.onCancel}];}
else{return[];}}).createDelegate(this)(),keys:[{key:[10,13],scope:this,stopEvent:true,fn:this.onOK}]},this.formConfig,this.defaultFormConfig);var colIndex=0;var tabIndex=1;fields.each(function(f,i){if(this.ignoreFields&&this.ignoreFields[f.name]){return;}
var c=this.findConfig(cm,f.name);var o={};if(c&&c.editor&&c.editor.field){Ext.apply(o,{xtype:c.editor.field.getXType(),fieldLabel:c.header},c.editor.field.initialConfig);}
else{Ext.apply(o,{fieldLabel:(c&&c.header?c.header:f.name),xtype:this.mapping[f.type]||'textfield'});if('date'===f.type&&f.dateFormat){o.format=f.dateFormat;}}
if(this.readonlyFields&&true===this.readonlyFields[f.name]){o.readOnly=true;}
if(this.disabledFields&&true===this.disabledFields[f.name]){o.disabled=true;}
o.name=f.name;o.tabIndex=tabIndex++;if('datefield'===o.xtype||'timefield'===o.xtype||'datetime'===o.xtype){o.anchor='';}
if('textarea'===o.xtype){o.grow=false;o.autoHeight=true;}
this.form.items[0].items[colIndex++].items.push(o);colIndex=colIndex===this.columnCount?0:colIndex;},this);},findConfig:function(cm,dataIndex){var config=null;Ext.each(cm.config,function(c,i){if(config){return;}
if(dataIndex===c.dataIndex){config=c;}});return config;},getRowClass:function(record){if(record.get('newRecord')){return this.newRowCls;}
if(record.dirty){return this.dirtyRowCls;}
return'';},onDestroy:function(){if(this.window){this.window.destroy();this.window=null;this.form=null;}
else if(this.form){if('function'===typeof this.form.destroy){this.form.destroy();}
this.form=null;}},onOK:function(){this.updateRecord();if(this.autoHide){this.window.hide(null);}},onCancel:function(){if(this.record.get('newRecord')&&!this.record.dirty){this.record.store.remove(this.record);}
if(this.autoHide){this.window.hide(null);}},reconfigure:function(){this.onDestroy();this.createFormConfig();},getPanel:function(){if(this.window){return this.window;}
if(this.formCt){var panel=Ext.getCmp(this.formCt);if(panel){panel.add(this.form);panel.doLayout();}
else{panel=Ext.fly(this.formCt);if(panel){panel=new Ext.Panel({renderTo:panel,items:this.form});}}}
else{var config=Ext.apply({},this.defaultWindowConfig);config=Ext.apply(config,this.windowConfig);Ext.applyIf(config,{title:this.title||this.grid.title,iconCls:this.iconCls||this.grid.iconCls,items:this.form,listeners:{show:{scope:this,delay:this.focusDefer,fn:function(){this.form.startMonitoring();var basicForm=this.form.getForm();basicForm.items.itemAt(0).focus();basicForm.isValid();}},hide:{scope:this,fn:function(){this.form.stopMonitoring();}}}});var window=new Ext.Window(config);this.form=window.items.itemAt(0);return window;}
panel.on({show:{scope:this,delay:this.focusDefer,fn:function(){this.form.startMonitoring();var basicForm=this.form.getForm();basicForm.items.itemAt(0).focus();basicForm.isValid();}},hide:{scope:this,fn:function(){this.form.stopMonitoring();}}});this.form=panel.items.itemAt(0);return panel;},show:function(record,animEl){if(!this.window){this.window=this.getPanel();}
this.window.show(animEl);var basicForm=this.form.getForm();basicForm.loadRecord(record);this.record=record;},setRecord:function(record)
{if(!this.window){this.window=this.getPanel();}
var basicForm=this.form.getForm();basicForm.loadRecord(record);this.record=record;},updateRecord:function(){this.form.getForm().items.each(function(item,i){this.record.set(item.name,item.getValue());},this);this.afterUpdateRecord(this.record);}});Ext.reg('gridrecordform',Ext.ux.grid.RecordForm);

Ext.namespace('Ext.ux.Andrie');Ext.ux.Andrie.pPageSize=function(config){Ext.apply(this,config);};Ext.extend(Ext.ux.Andrie.pPageSize,Ext.util.Observable,{beforeText:'Show',afterText:'items',addBefore:'-',addAfter:null,dynamic:false,variations:[5,10,20,50,100,200,500,1000],comboCfg:undefined,init:function(pagingToolbar){this.pagingToolbar=pagingToolbar;this.pagingToolbar.pageSizeCombo=this;this.pagingToolbar.setPageSize=this.setPageSize.createDelegate(this);this.pagingToolbar.getPageSize=function(){return this.pageSize;};this.pagingToolbar.on('render',this.onRender,this);this.pagingToolbar.addEvents("pagesizechanged");},addSize:function(value){if(value>0){this.sizes.push([value]);}},updateStore:function(){if(this.dynamic){var middleValue=this.pagingToolbar.pageSize,start;middleValue=(middleValue>0)?middleValue:1;this.sizes=[];var v=this.variations;for(var i=0,len=v.length;i<len;i++){this.addSize(middleValue-v[v.length-1-i]);}
this.addToStore(middleValue);for(var i=0,len=v.length;i<len;i++){this.addSize(middleValue+v[i]);}}else{if(!this.staticSizes){this.sizes=[];var v=this.variations;var middleValue=0;for(var i=0,len=v.length;i<len;i++){this.addSize(middleValue+v[i]);}
this.staticSizes=this.sizes.slice(0);}else{this.sizes=this.staticSizes.slice(0);}}
this.combo.store.loadData(this.sizes);this.combo.collapse();this.combo.setValue(this.pagingToolbar.pageSize);},setPageSize:function(value,forced){this.pagingToolbar.fireEvent("pagesizechanged");var pt=this.pagingToolbar;this.combo.collapse();value=parseInt(value)||parseInt(this.combo.getValue());value=(value>0)?value:1;if(value==pt.pageSize){return;}else if(value<pt.pageSize){pt.pageSize=value;var ap=Math.round(pt.cursor/value)+1;var cursor=(ap-1)*value;var store=pt.store;if(cursor>store.getTotalCount()){this.pagingToolbar.pageSize=value;this.pagingToolbar.doLoad(cursor-value);}else{store.suspendEvents();for(var i=0,len=cursor-pt.cursor;i<len;i++){store.remove(store.getAt(0));}
while(store.getCount()>value){store.remove(store.getAt(store.getCount()-1));}
store.resumeEvents();store.fireEvent('datachanged',store);pt.cursor=cursor;var d=pt.getPageData();pt.afterTextEl.el.innerHTML=String.format(pt.afterPageText,d.pages);pt.field.dom.value=ap;pt.first.setDisabled(ap==1);pt.prev.setDisabled(ap==1);pt.next.setDisabled(ap==d.pages);pt.last.setDisabled(ap==d.pages);pt.updateInfo();}}else{this.pagingToolbar.pageSize=value;this.pagingToolbar.doLoad(Math.floor(this.pagingToolbar.cursor/this.pagingToolbar.pageSize)*this.pagingToolbar.pageSize);}
this.updateStore();},onRender:function(){this.combo=Ext.ComponentMgr.create(Ext.applyIf(this.comboCfg||{},{store:new Ext.data.SimpleStore({fields:['pageSize'],data:[]}),displayField:'pageSize',valueField:'pageSize',mode:'local',triggerAction:'all',width:50,xtype:'combo'}));this.combo.on('select',this.setPageSize,this);this.updateStore();if(this.addBefore){this.pagingToolbar.add(this.addBefore);}
if(this.beforeText){this.pagingToolbar.add(this.beforeText);}
this.pagingToolbar.add(this.combo);if(this.afterText){this.pagingToolbar.add(this.afterText);}
if(this.addAfter){this.pagingToolbar.add(this.addAfter);}}});

var SWFUpload;if(SWFUpload==undefined){SWFUpload=function(settings){this.initSWFUpload(settings);};}
SWFUpload.prototype.initSWFUpload=function(settings){try{this.customSettings={};this.settings=settings;this.eventQueue=[];this.movieName="SWFUpload_"+SWFUpload.movieCount++;this.movieElement=null;SWFUpload.instances[this.movieName]=this;this.initSettings();this.loadFlash();this.displayDebugInfo();}catch(ex){delete SWFUpload.instances[this.movieName];throw ex;}};SWFUpload.instances={};SWFUpload.movieCount=0;SWFUpload.version="2.2.0 2009-03-25";SWFUpload.QUEUE_ERROR={QUEUE_LIMIT_EXCEEDED:-100,FILE_EXCEEDS_SIZE_LIMIT:-110,ZERO_BYTE_FILE:-120,INVALID_FILETYPE:-130};SWFUpload.UPLOAD_ERROR={HTTP_ERROR:-200,MISSING_UPLOAD_URL:-210,IO_ERROR:-220,SECURITY_ERROR:-230,UPLOAD_LIMIT_EXCEEDED:-240,UPLOAD_FAILED:-250,SPECIFIED_FILE_ID_NOT_FOUND:-260,FILE_VALIDATION_FAILED:-270,FILE_CANCELLED:-280,UPLOAD_STOPPED:-290};SWFUpload.FILE_STATUS={QUEUED:-1,IN_PROGRESS:-2,ERROR:-3,COMPLETE:-4,CANCELLED:-5};SWFUpload.BUTTON_ACTION={SELECT_FILE:-100,SELECT_FILES:-110,START_UPLOAD:-120};SWFUpload.CURSOR={ARROW:-1,HAND:-2};SWFUpload.WINDOW_MODE={WINDOW:"window",TRANSPARENT:"transparent",OPAQUE:"opaque"};SWFUpload.completeURL=function(url){if(typeof(url)!=="string"||url.match(/^https?:\/\//i)||url.match(/^\//)){return url;}
var currentURL=window.location.protocol+"//"+window.location.hostname+(window.location.port?":"+window.location.port:"");var indexSlash=window.location.pathname.lastIndexOf("/");if(indexSlash<=0){path="/";}else{path=window.location.pathname.substr(0,indexSlash)+"/";}
return path+url;};SWFUpload.prototype.initSettings=function(){this.ensureDefault=function(settingName,defaultValue){this.settings[settingName]=(this.settings[settingName]==undefined)?defaultValue:this.settings[settingName];};this.ensureDefault("upload_url","");this.ensureDefault("preserve_relative_urls",false);this.ensureDefault("file_post_name","Filedata");this.ensureDefault("post_params",{});this.ensureDefault("use_query_string",false);this.ensureDefault("requeue_on_error",false);this.ensureDefault("http_success",[]);this.ensureDefault("assume_success_timeout",0);this.ensureDefault("file_types","*.*");this.ensureDefault("file_types_description","All Files");this.ensureDefault("file_size_limit",0);this.ensureDefault("file_upload_limit",0);this.ensureDefault("file_queue_limit",0);this.ensureDefault("flash_url","swfupload.swf");this.ensureDefault("prevent_swf_caching",true);this.ensureDefault("button_image_url","");this.ensureDefault("button_width",1);this.ensureDefault("button_height",1);this.ensureDefault("button_text","");this.ensureDefault("button_text_style","color: #000000; font-size: 16pt;");this.ensureDefault("button_text_top_padding",0);this.ensureDefault("button_text_left_padding",0);this.ensureDefault("button_action",SWFUpload.BUTTON_ACTION.SELECT_FILES);this.ensureDefault("button_disabled",false);this.ensureDefault("button_placeholder_id","");this.ensureDefault("button_placeholder",null);this.ensureDefault("button_cursor",SWFUpload.CURSOR.ARROW);this.ensureDefault("button_window_mode",SWFUpload.WINDOW_MODE.WINDOW);this.ensureDefault("debug",false);this.settings.debug_enabled=this.settings.debug;this.settings.return_upload_start_handler=this.returnUploadStart;this.ensureDefault("swfupload_loaded_handler",null);this.ensureDefault("file_dialog_start_handler",null);this.ensureDefault("file_queued_handler",null);this.ensureDefault("file_queue_error_handler",null);this.ensureDefault("file_dialog_complete_handler",null);this.ensureDefault("upload_start_handler",null);this.ensureDefault("upload_progress_handler",null);this.ensureDefault("upload_error_handler",null);this.ensureDefault("upload_success_handler",null);this.ensureDefault("upload_complete_handler",null);this.ensureDefault("debug_handler",this.debugMessage);this.ensureDefault("custom_settings",{});this.customSettings=this.settings.custom_settings;if(!!this.settings.prevent_swf_caching){this.settings.flash_url=this.settings.flash_url+(this.settings.flash_url.indexOf("?")<0?"?":"&")+"preventswfcaching="+new Date().getTime();}
if(!this.settings.preserve_relative_urls){this.settings.upload_url=SWFUpload.completeURL(this.settings.upload_url);this.settings.button_image_url=SWFUpload.completeURL(this.settings.button_image_url);}
delete this.ensureDefault;};SWFUpload.prototype.loadFlash=function(){var targetElement,tempParent;if(document.getElementById(this.movieName)!==null){throw"ID "+this.movieName+" is already in use. The Flash Object could not be added";}
targetElement=document.getElementById(this.settings.button_placeholder_id)||this.settings.button_placeholder;if(targetElement==undefined){throw"Could not find the placeholder element: "+this.settings.button_placeholder_id;}
tempParent=document.createElement("div");tempParent.innerHTML=this.getFlashHTML();targetElement.parentNode.replaceChild(tempParent.firstChild,targetElement);if(window[this.movieName]==undefined){window[this.movieName]=this.getMovieElement();}};SWFUpload.prototype.getFlashHTML=function(){return['<object id="',this.movieName,'" type="application/x-shockwave-flash" data="',this.settings.flash_url,'" width="',this.settings.button_width,'" height="',this.settings.button_height,'" class="swfupload">','<param name="wmode" value="',this.settings.button_window_mode,'" />','<param name="movie" value="',this.settings.flash_url,'" />','<param name="quality" value="high" />','<param name="menu" value="false" />','<param name="allowScriptAccess" value="always" />','<param name="flashvars" value="'+this.getFlashVars()+'" />','</object>'].join("");};SWFUpload.prototype.getFlashVars=function(){var paramString=this.buildParamString();var httpSuccessString=this.settings.http_success.join(",");return["movieName=",encodeURIComponent(this.movieName),"&amp;uploadURL=",encodeURIComponent(this.settings.upload_url),"&amp;useQueryString=",encodeURIComponent(this.settings.use_query_string),"&amp;requeueOnError=",encodeURIComponent(this.settings.requeue_on_error),"&amp;httpSuccess=",encodeURIComponent(httpSuccessString),"&amp;assumeSuccessTimeout=",encodeURIComponent(this.settings.assume_success_timeout),"&amp;params=",encodeURIComponent(paramString),"&amp;filePostName=",encodeURIComponent(this.settings.file_post_name),"&amp;fileTypes=",encodeURIComponent(this.settings.file_types),"&amp;fileTypesDescription=",encodeURIComponent(this.settings.file_types_description),"&amp;fileSizeLimit=",encodeURIComponent(this.settings.file_size_limit),"&amp;fileUploadLimit=",encodeURIComponent(this.settings.file_upload_limit),"&amp;fileQueueLimit=",encodeURIComponent(this.settings.file_queue_limit),"&amp;debugEnabled=",encodeURIComponent(this.settings.debug_enabled),"&amp;buttonImageURL=",encodeURIComponent(this.settings.button_image_url),"&amp;buttonWidth=",encodeURIComponent(this.settings.button_width),"&amp;buttonHeight=",encodeURIComponent(this.settings.button_height),"&amp;buttonText=",encodeURIComponent(this.settings.button_text),"&amp;buttonTextTopPadding=",encodeURIComponent(this.settings.button_text_top_padding),"&amp;buttonTextLeftPadding=",encodeURIComponent(this.settings.button_text_left_padding),"&amp;buttonTextStyle=",encodeURIComponent(this.settings.button_text_style),"&amp;buttonAction=",encodeURIComponent(this.settings.button_action),"&amp;buttonDisabled=",encodeURIComponent(this.settings.button_disabled),"&amp;buttonCursor=",encodeURIComponent(this.settings.button_cursor)].join("");};SWFUpload.prototype.getMovieElement=function(){if(this.movieElement==undefined){this.movieElement=document.getElementById(this.movieName);}
if(this.movieElement===null){throw"Could not find Flash element";}
return this.movieElement;};SWFUpload.prototype.buildParamString=function(){var postParams=this.settings.post_params;var paramStringPairs=[];if(typeof(postParams)==="object"){for(var name in postParams){if(postParams.hasOwnProperty(name)){paramStringPairs.push(encodeURIComponent(name.toString())+"="+encodeURIComponent(postParams[name].toString()));}}}
return paramStringPairs.join("&amp;");};SWFUpload.prototype.destroy=function(){try{this.cancelUpload(null,false);var movieElement=null;movieElement=this.getMovieElement();if(movieElement&&typeof(movieElement.CallFunction)==="unknown"){for(var i in movieElement){try{if(typeof(movieElement[i])==="function"){movieElement[i]=null;}}catch(ex1){}}
try{movieElement.parentNode.removeChild(movieElement);}catch(ex){}}
window[this.movieName]=null;SWFUpload.instances[this.movieName]=null;delete SWFUpload.instances[this.movieName];this.movieElement=null;this.settings=null;this.customSettings=null;this.eventQueue=null;this.movieName=null;return true;}catch(ex2){return false;}};SWFUpload.prototype.displayDebugInfo=function(){this.debug(["---SWFUpload Instance Info---\n","Version: ",SWFUpload.version,"\n","Movie Name: ",this.movieName,"\n","Settings:\n","\t","upload_url:               ",this.settings.upload_url,"\n","\t","flash_url:                ",this.settings.flash_url,"\n","\t","use_query_string:         ",this.settings.use_query_string.toString(),"\n","\t","requeue_on_error:         ",this.settings.requeue_on_error.toString(),"\n","\t","http_success:             ",this.settings.http_success.join(", "),"\n","\t","assume_success_timeout:   ",this.settings.assume_success_timeout,"\n","\t","file_post_name:           ",this.settings.file_post_name,"\n","\t","post_params:              ",this.settings.post_params.toString(),"\n","\t","file_types:               ",this.settings.file_types,"\n","\t","file_types_description:   ",this.settings.file_types_description,"\n","\t","file_size_limit:          ",this.settings.file_size_limit,"\n","\t","file_upload_limit:        ",this.settings.file_upload_limit,"\n","\t","file_queue_limit:         ",this.settings.file_queue_limit,"\n","\t","debug:                    ",this.settings.debug.toString(),"\n","\t","prevent_swf_caching:      ",this.settings.prevent_swf_caching.toString(),"\n","\t","button_placeholder_id:    ",this.settings.button_placeholder_id.toString(),"\n","\t","button_placeholder:       ",(this.settings.button_placeholder?"Set":"Not Set"),"\n","\t","button_image_url:         ",this.settings.button_image_url.toString(),"\n","\t","button_width:             ",this.settings.button_width.toString(),"\n","\t","button_height:            ",this.settings.button_height.toString(),"\n","\t","button_text:              ",this.settings.button_text.toString(),"\n","\t","button_text_style:        ",this.settings.button_text_style.toString(),"\n","\t","button_text_top_padding:  ",this.settings.button_text_top_padding.toString(),"\n","\t","button_text_left_padding: ",this.settings.button_text_left_padding.toString(),"\n","\t","button_action:            ",this.settings.button_action.toString(),"\n","\t","button_disabled:          ",this.settings.button_disabled.toString(),"\n","\t","custom_settings:          ",this.settings.custom_settings.toString(),"\n","Event Handlers:\n","\t","swfupload_loaded_handler assigned:  ",(typeof this.settings.swfupload_loaded_handler==="function").toString(),"\n","\t","file_dialog_start_handler assigned: ",(typeof this.settings.file_dialog_start_handler==="function").toString(),"\n","\t","file_queued_handler assigned:       ",(typeof this.settings.file_queued_handler==="function").toString(),"\n","\t","file_queue_error_handler assigned:  ",(typeof this.settings.file_queue_error_handler==="function").toString(),"\n","\t","upload_start_handler assigned:      ",(typeof this.settings.upload_start_handler==="function").toString(),"\n","\t","upload_progress_handler assigned:   ",(typeof this.settings.upload_progress_handler==="function").toString(),"\n","\t","upload_error_handler assigned:      ",(typeof this.settings.upload_error_handler==="function").toString(),"\n","\t","upload_success_handler assigned:    ",(typeof this.settings.upload_success_handler==="function").toString(),"\n","\t","upload_complete_handler assigned:   ",(typeof this.settings.upload_complete_handler==="function").toString(),"\n","\t","debug_handler assigned:             ",(typeof this.settings.debug_handler==="function").toString(),"\n"].join(""));};SWFUpload.prototype.addSetting=function(name,value,default_value){if(value==undefined){return(this.settings[name]=default_value);}else{return(this.settings[name]=value);}};SWFUpload.prototype.getSetting=function(name){if(this.settings[name]!=undefined){return this.settings[name];}
return"";};SWFUpload.prototype.callFlash=function(functionName,argumentArray){argumentArray=argumentArray||[];var movieElement=this.getMovieElement();var returnValue,returnString;try{returnString=movieElement.CallFunction('<invoke name="'+functionName+'" returntype="javascript">'+__flash__argumentsToXML(argumentArray,0)+'</invoke>');returnValue=eval(returnString);}catch(ex){throw"Call to "+functionName+" failed";}
if(returnValue!=undefined&&typeof returnValue.post==="object"){returnValue=this.unescapeFilePostParams(returnValue);}
return returnValue;};SWFUpload.prototype.selectFile=function(){this.callFlash("SelectFile");};SWFUpload.prototype.selectFiles=function(){this.callFlash("SelectFiles");};SWFUpload.prototype.startUpload=function(fileID){this.callFlash("StartUpload",[fileID]);};SWFUpload.prototype.cancelUpload=function(fileID,triggerErrorEvent){if(triggerErrorEvent!==false){triggerErrorEvent=true;}
this.callFlash("CancelUpload",[fileID,triggerErrorEvent]);};SWFUpload.prototype.stopUpload=function(){this.callFlash("StopUpload");};SWFUpload.prototype.getStats=function(){return this.callFlash("GetStats");};SWFUpload.prototype.setStats=function(statsObject){this.callFlash("SetStats",[statsObject]);};SWFUpload.prototype.getFile=function(fileID){if(typeof(fileID)==="number"){return this.callFlash("GetFileByIndex",[fileID]);}else{return this.callFlash("GetFile",[fileID]);}};SWFUpload.prototype.addFileParam=function(fileID,name,value){return this.callFlash("AddFileParam",[fileID,name,value]);};SWFUpload.prototype.removeFileParam=function(fileID,name){this.callFlash("RemoveFileParam",[fileID,name]);};SWFUpload.prototype.setUploadURL=function(url){this.settings.upload_url=url.toString();this.callFlash("SetUploadURL",[url]);};SWFUpload.prototype.setPostParams=function(paramsObject){this.settings.post_params=paramsObject;this.callFlash("SetPostParams",[paramsObject]);};SWFUpload.prototype.addPostParam=function(name,value){this.settings.post_params[name]=value;this.callFlash("SetPostParams",[this.settings.post_params]);};SWFUpload.prototype.removePostParam=function(name){delete this.settings.post_params[name];this.callFlash("SetPostParams",[this.settings.post_params]);};SWFUpload.prototype.setFileTypes=function(types,description){this.settings.file_types=types;this.settings.file_types_description=description;this.callFlash("SetFileTypes",[types,description]);};SWFUpload.prototype.setFileSizeLimit=function(fileSizeLimit){this.settings.file_size_limit=fileSizeLimit;this.callFlash("SetFileSizeLimit",[fileSizeLimit]);};SWFUpload.prototype.setFileUploadLimit=function(fileUploadLimit){this.settings.file_upload_limit=fileUploadLimit;this.callFlash("SetFileUploadLimit",[fileUploadLimit]);};SWFUpload.prototype.setFileQueueLimit=function(fileQueueLimit){this.settings.file_queue_limit=fileQueueLimit;this.callFlash("SetFileQueueLimit",[fileQueueLimit]);};SWFUpload.prototype.setFilePostName=function(filePostName){this.settings.file_post_name=filePostName;this.callFlash("SetFilePostName",[filePostName]);};SWFUpload.prototype.setUseQueryString=function(useQueryString){this.settings.use_query_string=useQueryString;this.callFlash("SetUseQueryString",[useQueryString]);};SWFUpload.prototype.setRequeueOnError=function(requeueOnError){this.settings.requeue_on_error=requeueOnError;this.callFlash("SetRequeueOnError",[requeueOnError]);};SWFUpload.prototype.setHTTPSuccess=function(http_status_codes){if(typeof http_status_codes==="string"){http_status_codes=http_status_codes.replace(" ","").split(",");}
this.settings.http_success=http_status_codes;this.callFlash("SetHTTPSuccess",[http_status_codes]);};SWFUpload.prototype.setAssumeSuccessTimeout=function(timeout_seconds){this.settings.assume_success_timeout=timeout_seconds;this.callFlash("SetAssumeSuccessTimeout",[timeout_seconds]);};SWFUpload.prototype.setDebugEnabled=function(debugEnabled){this.settings.debug_enabled=debugEnabled;this.callFlash("SetDebugEnabled",[debugEnabled]);};SWFUpload.prototype.setButtonImageURL=function(buttonImageURL){if(buttonImageURL==undefined){buttonImageURL="";}
this.settings.button_image_url=buttonImageURL;this.callFlash("SetButtonImageURL",[buttonImageURL]);};SWFUpload.prototype.setButtonDimensions=function(width,height){this.settings.button_width=width;this.settings.button_height=height;var movie=this.getMovieElement();if(movie!=undefined){movie.style.width=width+"px";movie.style.height=height+"px";}
this.callFlash("SetButtonDimensions",[width,height]);};SWFUpload.prototype.setButtonText=function(html){this.settings.button_text=html;this.callFlash("SetButtonText",[html]);};SWFUpload.prototype.setButtonTextPadding=function(left,top){this.settings.button_text_top_padding=top;this.settings.button_text_left_padding=left;this.callFlash("SetButtonTextPadding",[left,top]);};SWFUpload.prototype.setButtonTextStyle=function(css){this.settings.button_text_style=css;this.callFlash("SetButtonTextStyle",[css]);};SWFUpload.prototype.setButtonDisabled=function(isDisabled){this.settings.button_disabled=isDisabled;this.callFlash("SetButtonDisabled",[isDisabled]);};SWFUpload.prototype.setButtonAction=function(buttonAction){this.settings.button_action=buttonAction;this.callFlash("SetButtonAction",[buttonAction]);};SWFUpload.prototype.setButtonCursor=function(cursor){this.settings.button_cursor=cursor;this.callFlash("SetButtonCursor",[cursor]);};SWFUpload.prototype.queueEvent=function(handlerName,argumentArray){if(argumentArray==undefined){argumentArray=[];}else if(!(argumentArray instanceof Array)){argumentArray=[argumentArray];}
var self=this;if(typeof this.settings[handlerName]==="function"){this.eventQueue.push(function(){this.settings[handlerName].apply(this,argumentArray);});setTimeout(function(){self.executeNextEvent();},0);}else if(this.settings[handlerName]!==null){throw"Event handler "+handlerName+" is unknown or is not a function";}};SWFUpload.prototype.executeNextEvent=function(){var f=this.eventQueue?this.eventQueue.shift():null;if(typeof(f)==="function"){f.apply(this);}};SWFUpload.prototype.unescapeFilePostParams=function(file){var reg=/[$]([0-9a-f]{4})/i;var unescapedPost={};var uk;if(file!=undefined){for(var k in file.post){if(file.post.hasOwnProperty(k)){uk=k;var match;while((match=reg.exec(uk))!==null){uk=uk.replace(match[0],String.fromCharCode(parseInt("0x"+match[1],16)));}
unescapedPost[uk]=file.post[k];}}
file.post=unescapedPost;}
return file;};SWFUpload.prototype.testExternalInterface=function(){try{return this.callFlash("TestExternalInterface");}catch(ex){return false;}};SWFUpload.prototype.flashReady=function(){var movieElement=this.getMovieElement();if(!movieElement){this.debug("Flash called back ready but the flash movie can't be found.");return;}
this.cleanUp(movieElement);this.queueEvent("swfupload_loaded_handler");};SWFUpload.prototype.cleanUp=function(movieElement){try{if(this.movieElement&&typeof(movieElement.CallFunction)==="unknown"){this.debug("Removing Flash functions hooks (this should only run in IE and should prevent memory leaks)");for(var key in movieElement){try{if(typeof(movieElement[key])==="function"){movieElement[key]=null;}}catch(ex){}}}}catch(ex1){}
window["__flash__removeCallback"]=function(instance,name){try{if(instance){instance[name]=null;}}catch(flashEx){}};};SWFUpload.prototype.fileDialogStart=function(){this.queueEvent("file_dialog_start_handler");};SWFUpload.prototype.fileQueued=function(file){file=this.unescapeFilePostParams(file);this.queueEvent("file_queued_handler",file);};SWFUpload.prototype.fileQueueError=function(file,errorCode,message){file=this.unescapeFilePostParams(file);this.queueEvent("file_queue_error_handler",[file,errorCode,message]);};SWFUpload.prototype.fileDialogComplete=function(numFilesSelected,numFilesQueued,numFilesInQueue){this.queueEvent("file_dialog_complete_handler",[numFilesSelected,numFilesQueued,numFilesInQueue]);};SWFUpload.prototype.uploadStart=function(file){file=this.unescapeFilePostParams(file);this.queueEvent("return_upload_start_handler",file);};SWFUpload.prototype.returnUploadStart=function(file){var returnValue;if(typeof this.settings.upload_start_handler==="function"){file=this.unescapeFilePostParams(file);returnValue=this.settings.upload_start_handler.call(this,file);}else if(this.settings.upload_start_handler!=undefined){throw"upload_start_handler must be a function";}
if(returnValue===undefined){returnValue=true;}
returnValue=!!returnValue;this.callFlash("ReturnUploadStart",[returnValue]);};SWFUpload.prototype.uploadProgress=function(file,bytesComplete,bytesTotal){file=this.unescapeFilePostParams(file);this.queueEvent("upload_progress_handler",[file,bytesComplete,bytesTotal]);};SWFUpload.prototype.uploadError=function(file,errorCode,message){file=this.unescapeFilePostParams(file);this.queueEvent("upload_error_handler",[file,errorCode,message]);};SWFUpload.prototype.uploadSuccess=function(file,serverData,responseReceived){file=this.unescapeFilePostParams(file);this.queueEvent("upload_success_handler",[file,serverData,responseReceived]);};SWFUpload.prototype.uploadComplete=function(file){file=this.unescapeFilePostParams(file);this.queueEvent("upload_complete_handler",file);};SWFUpload.prototype.debug=function(message){this.queueEvent("debug_handler",message);};SWFUpload.prototype.debugMessage=function(message){if(this.settings.debug){var exceptionMessage,exceptionValues=[];if(typeof message==="object"&&typeof message.name==="string"&&typeof message.message==="string"){for(var key in message){if(message.hasOwnProperty(key)){exceptionValues.push(key+": "+message[key]);}}
exceptionMessage=exceptionValues.join("\n")||"";exceptionValues=exceptionMessage.split("\n");exceptionMessage="EXCEPTION: "+exceptionValues.join("\nEXCEPTION: ");SWFUpload.Console.writeLine(exceptionMessage);}else{SWFUpload.Console.writeLine(message);}}};SWFUpload.Console={};SWFUpload.Console.writeLine=function(message){var console,documentForm;try{console=document.getElementById("SWFUpload_Console");if(!console){documentForm=document.createElement("form");document.getElementsByTagName("body")[0].appendChild(documentForm);console=document.createElement("textarea");console.id="SWFUpload_Console";console.style.fontFamily="monospace";console.setAttribute("wrap","off");console.wrap="off";console.style.overflow="auto";console.style.width="700px";console.style.height="350px";console.style.margin="5px";documentForm.appendChild(console);}
console.value+=message+"\n";console.scrollTop=console.scrollHeight-console.clientHeight;}catch(ex){alert("Exception: "+ex.name+" Message: "+ex.message);}};

Date.prototype.getElapsed=function(A){return Math.abs((A||new Date()).getTime()-this.getTime());};UploadDialog=Ext.extend(Ext.Window,{fileList:null,swfupload:null,progressBar:null,progressInfo:null,uploadInfoPanel:null,constructor:function(config){this.progressInfo={filesTotal:0,filesUploaded:0,bytesTotal:0,bytesUploaded:0,currentCompleteBytes:0,lastBytes:0,lastElapsed:1,lastUpdate:null,timeElapsed:1};this.uploadInfoPanel=new Ext.Panel({region:'south',height:65,baseCls:'',collapseMode:'mini',split:true,border:false});this.addEvents({"uploadComplete":true});this.progressBar=new Ext.ProgressBar({text:'Fortschritt 0 %'});var autoExpandColumnId=Ext.id('fileName');this.fileList=new Ext.grid.GridPanel({border:false,enableColumnMove:false,enableHdMenu:false,columns:[new Ext.grid.RowNumberer(),{header:'Dateiname',width:100,dataIndex:'fileName',sortable:false,fixed:true,renderer:this.formatFileName,id:autoExpandColumnId},{header:'Größe',width:80,dataIndex:'fileSize',sortable:false,fixed:true,renderer:this.formatFileSize,align:'right'},{header:'Dateityp',width:60,dataIndex:'fileType',sortable:false,fixed:true,renderer:this.formatIcon,align:'center'},{header:'Status',width:100,dataIndex:'',sortable:false,fixed:true,renderer:this.formatProgressBar,align:'center'},{header:'&nbsp;',width:28,dataIndex:'fileState',renderer:this.formatState,sortable:false,fixed:true,align:'center'}],autoExpandColumn:autoExpandColumnId,ds:new Ext.data.SimpleStore({fields:['fileId','fileName','fileSize','fileType','fileState']}),tbar:new Ext.Toolbar(),bbar:[]});this.uploadInfoPanel.on('render',function(){this.getProgressTemplate().overwrite(this.uploadInfoPanel.body,{filesUploaded:0,filesTotal:0,bytesUploaded:'0 bytes',bytesTotal:'0 bytes',timeElapsed:'00:00:00',timeLeft:'00:00:00',speedLast:'0 bytes/s',speedAverage:'0 bytes/s'});},this);this.fileList.on('cellclick',function(grid,rowIndex,columnIndex,e){if(columnIndex==5){var record=grid.getSelectionModel().getSelected();var fileId=record.data.fileId;var file=this.swfupload.getFile(fileId);if(file){if(file.filestatus!=SWFUpload.FILE_STATUS.CANCELLED){this.swfupload.cancelUpload(fileId);if(record.data.fileState!=SWFUpload.FILE_STATUS.CANCELLED){record.set('fileState',SWFUpload.FILE_STATUS.CANCELLED);record.commit();this.onCancelQueue(fileId);}}}}},this);this.fileList.on('render',function(){this.fileList.getBottomToolbar().add(this.progressBar);var tb=this.fileList.getTopToolbar();tb.add({text:'Hinzufügen',iconCls:'db-icn-add'});tb.add({text:'Hochladen',iconCls:'db-icn-upload_',handler:this.startUpload,scope:this});tb.add({text:'Stoppen',iconCls:'db-icn-stop',handler:this.stopUpload,scope:this});tb.add({text:'Abbrechen',iconCls:'db-icn-cross',handler:this.cancelQueue,scope:this});tb.add({text:'Löschen',iconCls:'db-icn-trash',handler:this.clearList,scope:this});tb.doLayout();var em=this.fileList.getTopToolbar().items.first().el.child('em');var placeHolderId=Ext.id();em.setStyle({position:'relative',display:'block'});em.createChild({tag:'div',id:placeHolderId});var settings={upload_url:this.uploadUrl,post_params:Ext.isEmpty(this.postParams)?{}:this.postParams,flash_url:Ext.isEmpty(this.flashUrl)?'http://www.swfupload.org/swfupload.swf':this.flashUrl,file_post_name:Ext.isEmpty(this.filePostName)?'myUpload':this.filePostName,file_size_limit:Ext.isEmpty(this.fileSize)?'100 MB':this.fileSize,file_types:Ext.isEmpty(this.fileTypes)?'*.*':this.fileTypes,file_types_description:this.fileTypesDescription,debug:false,button_width:'83',button_height:'20',button_placeholder_id:placeHolderId,button_window_mode:SWFUpload.WINDOW_MODE.TRANSPARENT,button_cursor:SWFUpload.CURSOR.HAND,custom_settings:{scope_handler:this},file_queued_handler:this.onFileQueued,file_queue_error_handler:this.onFileQueueError,file_dialog_complete_handler:this.onFileDialogComplete,upload_start_handler:this.onUploadStart,upload_progress_handler:this.onUploadProgress,upload_error_handler:this.onUploadError,upload_success_handler:this.onUploadSuccess,upload_complete_handler:this.onUploadComplete};this.swfupload=new SWFUpload(settings);this.swfupload.uploadStopped=false;Ext.get(this.swfupload.movieName).setStyle({position:'absolute',top:0,left:"-2px"});this.resizeProgressBar();this.on('resize',this.resizeProgressBar,this);},this);UploadDialog.superclass.constructor.call(this,Ext.applyIf(config||{},{title:'Dateien hochladen',closeAction:'close',layout:'border',iconCls:'db-icn-upload-local',width:500,height:500,minWidth:450,minHeight:500,split:true,buttons:[{text:'Schließen',handler:this.onClose,scope:this}],items:[this.uploadInfoPanel,{region:'center',layout:'fit',margins:'0 -1 0 -1',items:[this.fileList]}]}));},resizeProgressBar:function(){this.progressBar.setWidth(this.el.getWidth()-18);},startUpload:function(){if(this.swfupload){this.swfupload.uploadStopped=false;var post_params=this.swfupload.settings.post_params;post_params.path=encodeURI(this.currentPath);var cookies={},c=document.cookie+";",re=/\s?(.*?)=(.*?);/g,matches,name,value;while((matches=re.exec(c))!=null){name=matches[1];value=matches[2];if(name=="PHPSESSID")post_params.PHPSESSID=value;}
this.swfupload.setPostParams(post_params);this.swfupload.startUpload();}},stopUpload:function(){if(this.swfupload){this.swfupload.uploadStopped=true;this.swfupload.stopUpload();}},cancelQueue:function(){if(this.swfupload){this.swfupload.stopUpload();var stats=this.swfupload.getStats();while(stats.files_queued>0){this.swfupload.cancelUpload();stats=this.swfupload.getStats();}
this.fileList.getStore().each(function(record){switch(record.data.fileState){case SWFUpload.FILE_STATUS.QUEUED:case SWFUpload.FILE_STATUS.IN_PROGRESS:record.set('fileState',SWFUpload.FILE_STATUS.CANCELLED);record.commit();this.onCancelQueue(record.data.fileId);break;default:break;}},this);}},clearList:function(){var store=this.fileList.getStore();store.each(function(record){if(record.data.fileState!=SWFUpload.FILE_STATUS.QUEUED&&record.data.fileState!=SWFUpload.FILE_STATUS.IN_PROGRESS){store.remove(record);}});},getProgressTemplate:function(){var tpl=new Ext.Template('<table class="upload-progress-table"><tbody>','<tr><td class="upload-progress-label"><nobr>Anzahl Uploads:</nobr></td>','<td class="upload-progress-value"><nobr>{filesUploaded} / {filesTotal}</nobr></td>','<td class="upload-progress-label"><nobr>Upload-Status:</nobr></td>','<td class="upload-progress-value"><nobr>{bytesUploaded} / {bytesTotal}</nobr></td></tr>','<tr><td class="upload-progress-label"><nobr>Abgelaufene Zeit:</nobr></td>','<td class="upload-progress-value"><nobr>{timeElapsed}</nobr></td>','<td class="upload-progress-label"><nobr>Rest:</nobr></td>','<td class="upload-progress-value"><nobr>{timeLeft}</nobr></td></tr>','<tr><td class="upload-progress-label"><nobr>Geschwindigkeit:</nobr></td>','<td class="upload-progress-value"><nobr>{speedLast}</nobr></td>','<td class="upload-progress-label"><nobr>Durchschnitt:</nobr></td>','<td class="upload-progress-value"><nobr>{speedAverage}</nobr></td></tr>','</tbody></table>');tpl.compile();return tpl;},updateProgressInfo:function(){this.getProgressTemplate().overwrite(this.uploadInfoPanel.body,this.formatProgress(this.progressInfo));},formatProgress:function(info){var r={};r.filesUploaded=String.leftPad(info.filesUploaded,3,'&nbsp;');r.filesTotal=info.filesTotal;r.bytesUploaded=String.leftPad(Ext.util.Format.fileSize(info.bytesUploaded),6,'&#160;');r.bytesTotal=Ext.util.Format.fileSize(info.bytesTotal);r.timeElapsed=this.formatTime(info.timeElapsed);r.speedAverage=Ext.util.Format.fileSize(Math.ceil(1000*info.bytesUploaded/info.timeElapsed))+'/s';r.timeLeft=this.formatTime((info.bytesUploaded===0)?0:info.timeElapsed*(info.bytesTotal-info.bytesUploaded)/info.bytesUploaded);var caleSpeed=1000*info.lastBytes/info.lastElapsed;r.speedLast=Ext.util.Format.fileSize(caleSpeed<0?0:caleSpeed)+'/s';var p=info.bytesUploaded/info.bytesTotal;p=p||0;this.progressBar.updateProgress(p,"Upload "+Math.ceil(p*100)+" %");return r;},formatTime:function(milliseconds){var seconds=parseInt(milliseconds/1000,10);var s=0;var m=0;var h=0;if(3599<seconds){h=parseInt(seconds/3600,10);seconds-=h*3600;}
if(59<seconds){m=parseInt(seconds/60,10);seconds-=m*60;}
m=String.leftPad(m,2,'0');h=String.leftPad(h,2,'0');s=String.leftPad(seconds,2,'0');return h+':'+m+':'+s;},formatFileSize:function(_v,celmeta,record){return'<div id="fileSize_'+record.data.fileId+'">'+Ext.util.Format.fileSize(_v)+'</div>';},formatFileName:function(_v,cellmeta,record){return'<div id="fileName_'+record.data.fileId+'">'+_v+'</div>';},formatIcon:function(_v,cellmeta,record){var returnValue='';var extensionName=_v.substring(1);var fileId=record.data.fileId;if(_v){var css='.db-ft-'+extensionName.toLowerCase()+'-small';if(Ext.isEmpty(Ext.util.CSS.getRule(css),true)){returnValue='<div id="fileType_'+fileId+'" class="db-ft-unknown-small" style="height: 16px;background-repeat: no-repeat;">'
+'&nbsp;&nbsp;&nbsp;&nbsp;'+extensionName.toUpperCase()+'</div>';}else{returnValue='<div id="fileType_'+fileId+'" class="db-ft-'+extensionName.toLowerCase()
+'-small" style="height: 16px;background-repeat: no-repeat;"/>&nbsp;&nbsp;&nbsp;&nbsp;'
+extensionName.toUpperCase()+'</div>';}
return returnValue;}
return'<div id="fileType_'+fileId+'" class="db-ft-unknown-small" style="height: 16px;background-repeat: no-repeat;"/>&nbsp;&nbsp;&nbsp;&nbsp;'
+extensionName.toUpperCase()+'</div>';},formatProgressBar:function(_v,cellmeta,record){var returnValue='';switch(record.data.fileState){case SWFUpload.FILE_STATUS.COMPLETE:if(Ext.isIE){returnValue='<div class="x-progress-wrap" style="height: 18px">'+'<div class="x-progress-inner">'+'<div style="width: 100%;" class="x-progress-bar x-progress-text">'+'100 %'+'</div>'+'</div>'+'</div>';}else{returnValue='<div class="x-progress-wrap" style="height: 18px">'+'<div class="x-progress-inner">'+'<div id="progressBar_'+record.data.fileId+'" style="width: 100%;" class="x-progress-bar">'+'</div>'+'<div id="progressText_'+record.data.fileId+'" style="width: 100%;" class="x-progress-text x-progress-text-back" />100 %</div>'+'</div>'+'</div>';}
break;default:returnValue='<div class="x-progress-wrap" style="height: 18px">'+'<div class="x-progress-inner">'+'<div id="progressBar_'+record.data.fileId+'" style="width: 0%;" class="x-progress-bar">'+'</div>'+'<div id="progressText_'+record.data.fileId+'" style="width: 100%;" class="x-progress-text x-progress-text-back" />0 %</div>'+'</div>'+'</div>';break;}
return returnValue;},formatState:function(_v,cellmeta,record){var returnValue='';switch(_v){case SWFUpload.FILE_STATUS.QUEUED:returnValue='<span id="'+record.id+'"><div id="fileId_'+record.data.fileId+'" class="ux-cell-icon-delete"/></span>';break;case SWFUpload.FILE_STATUS.CANCELLED:returnValue='<span id="'+record.id+'"><div id="fileId_'+record.data.fileId+'" class="ux-cell-icon-clear"/></span>';break;case SWFUpload.FILE_STATUS.COMPLETE:returnValue='<span id="'+record.id+'"><div id="fileId_'+record.data.fileId+'" class="ux-cell-icon-completed"/></span>';break;default:alert('没有设置图表状态');break;}
return returnValue;},onClose:function(){this.close();},onCancelQueue:function(fileId){Ext.getDom('fileName_'+fileId).className='ux-cell-color-gray';Ext.getDom('fileSize_'+fileId).className='ux-cell-color-gray';Ext.DomHelper.applyStyles('fileType_'+fileId,'font-style:italic;text-decoration: line-through;color:gray');},onFileQueued:function(file){var thiz=this.customSettings.scope_handler;thiz.fileList.getStore().add(new UploadDialog.FileRecord({fileId:file.id,fileName:file.name,fileSize:file.size,fileType:file.type,fileState:file.filestatus}));thiz.progressInfo.filesTotal+=1;thiz.progressInfo.bytesTotal+=file.size;thiz.updateProgressInfo();},onQueueError:function(file,errorCode,message){var thiz=this.customSettings.scope_handler;try{if(errorCode!=SWFUpload.UPLOAD_ERROR.UPLOAD_STOPPED){thiz.progressInfo.filesTotal-=1;thiz.progressInfo.bytesTotal-=file.size;}
thiz.progressInfo.bytesUploaded-=fpg.getBytesCompleted();thiz.updateProgressInfo();}catch(ex){this.debug(ex);}},onFileDialogComplete:function(selectedFilesCount,queuedFilesCount){},onUploadStart:function(file){},onUploadProgress:function(file,completeBytes,bytesTotal){var percent=Math.ceil((completeBytes/bytesTotal)*100);Ext.getDom('progressBar_'+file.id).style.width=percent+"%";Ext.getDom('progressText_'+file.id).innerHTML=percent+" %";var thiz=this.customSettings.scope_handler;var bytes_added=completeBytes-thiz.progressInfo.currentCompleteBytes;thiz.progressInfo.bytesUploaded+=Math.abs(bytes_added<0?0:bytes_added);thiz.progressInfo.currentCompleteBytes=completeBytes;if(thiz.progressInfo.lastUpdate){thiz.progressInfo.lastElapsed=thiz.progressInfo.lastUpdate.getElapsed();thiz.progressInfo.timeElapsed+=thiz.progressInfo.lastElapsed;}
thiz.progressInfo.lastBytes=bytes_added;thiz.progressInfo.lastUpdate=new Date();thiz.updateProgressInfo();},onUploadError:function(file,errorCode,message){var thiz=this.customSettings.scope_handler;switch(errorCode){case SWFUpload.UPLOAD_ERROR.FILE_CANCELLED:thiz.progressInfo.filesTotal-=1;thiz.progressInfo.bytesTotal-=file.size;thiz.updateProgressInfo();break;case SWFUpload.UPLOAD_ERROR.UPLOAD_STOPPED:}},onUploadSuccess:function(file,serverData){var thiz=this.customSettings.scope_handler;if(Ext.util.JSON.decode(serverData).success){var record=thiz.fileList.getStore().getById(Ext.getDom('fileId_'+file.id).parentNode.id);record.set('fileState',file.filestatus);record.commit();}
thiz.progressInfo.filesUploaded+=1;thiz.updateProgressInfo();},onUploadComplete:function(file){if(this.getStats().files_queued>0&&this.uploadStopped==false){this.startUpload();}
else
{this.customSettings.scope_handler.fireEvent("uploadComplete");}}});UploadDialog.FileRecord=Ext.data.Record.create([{name:'fileId'},{name:'fileName'},{name:'fileSize'},{name:'fileType'},{name:'fileState'}]);

