
Ext.BLANK_IMAGE_URL = 'plugins/libextjs/resources/images/default/s.gif';

Ext.override(Ext.Panel, {
	setIconCls: function(i){
		if (this.ownerCt) {
			Ext.fly(this.ownerCt.getTabEl(this)).child('.x-tab-strip-text').replaceClass(this.iconCls, i);
			this.setIconClass(i);
		}
	}	
});


Ext.form.ComboBox.prototype.initQuery = Ext.form.ComboBox.prototype.initQuery.createInterceptor(function(e)
    {
        var v = this.getRawValue(); 
        if (typeof v === 'undefined' || v === null || Ext.util.Format.trim(v) === ''){
            this.clearValue();
            
		}
			
    });




Ext.override(Ext.form.Field, {
	markInvalid : function(msg){
		if(!this.rendered || this.preventMark){
			return;
		}
		var markEl = this.markEl || this.el;
		markEl.addClass(this.invalidClass);
		msg = msg || this.invalidText;		
		switch(this.msgTarget){
			case 'qtip':
				markEl.dom.qtip = msg;
				markEl.dom.qclass = 'x-form-invalid-tip';
				if(Ext.QuickTips){
					Ext.QuickTips.enable();
				}
				break;
			case 'title':
				markEl.dom.title = msg;
				break;
			case 'under':
				if(!this.errorEl){
					var elp = this.getErrorCt();
					if(!elp){
						markEl.dom.title = msg;
						break;
					}
					this.errorEl = elp.createChild({cls:'x-form-invalid-msg'});
					this.errorEl.setWidth(elp.getWidth(true)-20);
				}
				this.errorEl.update(msg);
				Ext.form.Field.msgFx[this.msgFx].show(this.errorEl, this);
				break;
			case 'side':
				if(!this.errorIcon){
					var elp = this.getErrorCt();
					if(!elp){
						markEl.dom.title = msg;
						break;
					}
					this.errorIcon = elp.createChild({cls:'x-form-invalid-icon'});
				}
				this.alignErrorIcon();
				this.errorIcon.dom.qtip = msg;
				this.errorIcon.dom.qclass = 'x-form-invalid-tip';
				this.errorIcon.show();
				this.on('resize', this.alignErrorIcon, this);
				break;
			default:
				var t = Ext.getDom(this.msgTarget);
				if (t) {
				t.innerHTML = msg;
				t.style.display = this.msgDisplay;
				}
				break;
		}
		this.fireEvent('invalid', this, msg);
	},
	clearInvalid : function(){
		if(!this.rendered || this.preventMark){
			return;
		}
		var markEl = this.markEl || this.el;
		markEl.removeClass(this.invalidClass);
		switch(this.msgTarget){
			case 'qtip':
				markEl.dom.qtip = '';
				break;
			case 'title':
				markEl.dom.title = '';
				break;
			case 'under':
				if(this.errorEl){
					Ext.form.Field.msgFx[this.msgFx].hide(this.errorEl, this);
				}else{
					markEl.dom.title = '';
				}
				break;
			case 'side':
				if(this.errorIcon){
					this.errorIcon.dom.qtip = '';
					this.errorIcon.hide();
					this.un('resize', this.alignErrorIcon, this);
				}else{
					markEl.dom.title = '';
				}
				break;
			default:
				var t = Ext.getDom(this.msgTarget);
				if (t) {
					t.innerHTML = '';
					t.style.display = 'none';
				}
				break;
		}
		this.fireEvent('valid', this);
	},
	alignErrorIcon : function(){
		this.errorIcon.alignTo(this.markEl || this.el, 'tl-tr', [2, 0]);
	}
});

/*
Ext.override(Ext.form.Checkbox, {
	onRender: function(ct, position){
		Ext.form.Checkbox.superclass.onRender.call(this, ct, position);
		if(this.inputValue !== undefined){
			this.el.dom.value = this.inputValue;
		}
		this.el.removeClass(this.baseCls);
		//this.el.addClass('x-hidden');
		this.innerWrap = this.el.wrap({
			//tabIndex: this.tabIndex,
			cls: this.baseCls+'-wrap-inner'
		});
		this.wrap = this.innerWrap.wrap({cls: this.baseCls+'-wrap'});
		this.imageEl = this.innerWrap.createChild({
			tag: 'img',
			src: Ext.BLANK_IMAGE_URL,
			cls: this.baseCls
		});
		if(this.boxLabel){
			this.labelEl = this.innerWrap.createChild({
				tag: 'label',
				htmlFor: this.el.id,
				cls: 'x-form-cb-label',
				html: this.boxLabel
			});
		}

		if(this.checked){
			this.setValue(true);
		}else{
			this.checked = this.el.dom.checked;
		}
		this.originalValue = this.checked;
		this.markEl = this.innerWrap;
	},
	afterRender: function(){
		Ext.form.Checkbox.superclass.afterRender.call(this);
		//this.wrap[this.checked ? 'addClass' : 'removeClass'](this.checkedCls);
		this.imageEl[this.checked ? 'addClass' : 'removeClass'](this.checkedCls);
	},
	initCheckEvents: function(){
		//this.innerWrap.removeAllListeners();
		this.innerWrap.addClassOnOver(this.overCls);
		this.innerWrap.addClassOnClick(this.mouseDownCls);
		this.innerWrap.on('click', this.onClick, this);
		//this.innerWrap.on('keyup', this.onKeyUp, this);
		if(this.validationEvent !== false){
			this.el.on(this.validationEvent, this.validate, this, {buffer: this.validationDelay});
		}
	},
	onFocus: function(e) {
		Ext.form.Checkbox.superclass.onFocus.call(this, e);
		//this.el.addClass(this.focusCls);
		this.innerWrap.addClass(this.focusCls);
	},
	onBlur: function(e) {
		Ext.form.Checkbox.superclass.onBlur.call(this, e);
		//this.el.removeClass(this.focusCls);
		this.innerWrap.removeClass(this.focusCls);
	},
	onClick: function(e){

		if (e.getTarget().htmlFor != this.el.dom.id) {
			//e.stopEvent();
			//console.log(" was hier ");
			if (e.getTarget() != this.el.dom) {
				this.el.focus();
			}
			if (!this.disabled && !this.readOnly) {
				this.toggleValue();
			}
		}

	},
	onEnable: Ext.form.Checkbox.superclass.onEnable,
	onDisable: Ext.form.Checkbox.superclass.onDisable,
	onKeyUp: undefined,
	setValue: function(v) {
		var checked = this.checked;
		this.checked = (v === true || v === 'true' || v == '1' || String(v).toLowerCase() == 'on');
		if(this.rendered){
			this.el.dom.checked = this.checked;
			this.el.dom.defaultChecked = this.checked;
			//this.wrap[this.checked ? 'addClass' : 'removeClass'](this.checkedCls);
			this.imageEl[this.checked ? 'addClass' : 'removeClass'](this.checkedCls);
		}
		if(checked != this.checked){
			this.fireEvent("check", this, this.checked);
			if(this.handler){
				this.handler.call(this.scope || this, this, this.checked);
			}
		}
	},
	getResizeEl: function() {
		//if(!this.resizeEl){
			//this.resizeEl = Ext.isSafari ? this.wrap : (this.wrap.up('.x-form-element', 5) || this.wrap);
		//}
		//return this.resizeEl;
		return this.wrap;
	},
	markInvalid: Ext.form.Checkbox.superclass.markInvalid,
	clearInvalid: Ext.form.Checkbox.superclass.clearInvalid,
	validationEvent: 'click',
	validateOnBlur: false,
	validateValue: function(value){
		if(this.vtype){
			var vt = Ext.form.VTypes;
			if(!vt[this.vtype](value, this)){
				this.markInvalid(this.vtypeText || vt[this.vtype +'Text']);
				return false;
			}
		}
		if(typeof this.validator == "function"){
			var msg = this.validator(value);
			if(msg !== true){
				this.markInvalid(msg);
				return false;
			}
		}
		return true;
	}
});


*/
Ext.override(Ext.form.Radio, {
	checkedCls: 'x-form-radio-checked',
	markInvalid: Ext.form.Radio.superclass.markInvalid,
	clearInvalid: Ext.form.Radio.superclass.clearInvalid
});

// languages 



Ext.apply(Ext.form.VTypes, {
    daterange : function(val, field) {
        var date = field.parseDate(val);

        if(!date){
            return;
        }
        if (field.startDateField && (!this.dateRangeMax || (date.getTime() != this.dateRangeMax.getTime()))) {
            var start = Ext.getCmp(field.startDateField);
            start.setMaxValue(date);
            start.validate();
            this.dateRangeMax = date;
        } 
        else if (field.endDateField && (!this.dateRangeMin || (date.getTime() != this.dateRangeMin.getTime()))) {
            var end = Ext.getCmp(field.endDateField);
            end.setMinValue(date);
            end.validate();
            this.dateRangeMin = date;
        }
        /*
         * Always return true since we're only using this vtype to set the
         * min/max allowed values (these are tested for after the vtype test)
         */
        return true;
    },

    password : function(val, field) {
        if (field.initialPassField) {
            var pwd = Ext.getCmp(field.initialPassField);
            return (val == pwd.getValue());
        }
        return true;
    },

    passwordText : 'Kennwoerter stimmen nicht ueber ein!'
});





Ext.override(Ext.menu.Menu, { 
	autoWidth : function(){ 
	    var ua = navigator.userAgent.toLowerCase(); 
	    var isIE8 = !Ext.isOpera && ua.indexOf("msie 8") > -1; 
	    var el = this.el, ul = this.ul; 
	    if(!el){ 
		return; 
	    } 
	    var w = this.width; 
	    if(w){ 
		el.setWidth(w); 
	    }else if(Ext.isIE && !isIE8){ 
		el.setWidth(this.minWidth); 
		var t = el.dom.offsetWidth; // force recalc 
		el.setWidth(ul.getWidth()+el.getFrameWidth("lr")); 
	    } 
	} 
    });



Ext.override(Ext.form.ComboBox, {
    initList : function(){
        if(!this.list){
		
            var cls = 'x-combo-list';
            this.list = new Ext.Layer({
                shadow: this.shadow, cls: [cls, this.listClass].join(' '), constrain:false
            });
            var lw = this.listWidth || Math.max(this.wrap.getWidth(), this.minListWidth);
            this.list.setWidth(lw);
            this.list.swallowEvent('mousewheel');
            this.assetHeight = 0;
            if(this.title){
                this.header = this.list.createChild({cls:cls+'-hd', html: this.title});
                this.assetHeight += this.header.getHeight();
            }
            this.innerList = this.list.createChild({cls:cls+'-inner'});
            this.innerList.on('mouseover', this.onViewOver, this);
            this.innerList.on('mousemove', this.onViewMove, this);
            this.innerList.setWidth(lw - this.list.getFrameWidth('lr'));
			
			
			
			
			
            if(this.statusBar){
                this.footer = this.list.createChild({cls:cls+'-ft'});				
                this.statusBar= new Ext.StatusBar({                    
                    renderTo:this.footer                    
                });
				 
                this.assetHeight += this.footer.getHeight();
			}else if  (this.pageSize){
                this.footer = this.list.createChild({cls:cls+'-ft'});				
				 this.pageTb = new Ext.PagingToolbar({
                    store:this.store,
                    pageSize: this.pageSize,
                    renderTo:this.footer
                });
                this.assetHeight += this.footer.getHeight();
            }
            if(!this.tpl){
                this.tpl = '<tpl for="."><div class="'+cls+'-item">{' + this.displayField + '}</div></tpl>';
            }
            this.view = new Ext.DataView({
                applyTo: this.innerList,
                tpl: this.tpl,
                singleSelect: true,
                selectedClass: this.selectedClass,
                itemSelector: this.itemSelector || '.' + cls + '-item',
				emptyText: 'MEIN TEXT'
            });
            this.view.on('click', this.onViewClick, this);
            this.bindStore(this.store, true);
            if(this.resizable){
                this.resizer = new Ext.Resizable(this.list,  {
                   pinned:true, handles:'se'
                });
                this.resizer.on('resize', function(r, w, h){
                    this.maxHeight = h-this.handleHeight-this.list.getFrameWidth('tb')-this.assetHeight;
                    this.listWidth = w;
                    this.innerList.setWidth(w - this.list.getFrameWidth('lr'));
                    this.restrictHeight();
                }, this);
                this[this.pageSize?'footer':'innerList'].setStyle('margin-bottom', this.handleHeight+'px');
            }
        }
    },
	
	onRender : function(ct, position){
        Ext.form.ComboBox.superclass.onRender.call(this, ct, position);
        if(this.hiddenName){
            this.hiddenField = this.el.insertSibling({tag:'input', type:'hidden', name: this.hiddenName,
                    id: (this.hiddenId||this.hiddenName)}, 'before', true);
			if (this.mode=='remote')		
				this.el.dom.setAttribute('name', 'typedIn'+this.el.dom.getAttribute('name'));
			else
				this.el.dom.removeAttribute('name');
			
        }
        if(Ext.isGecko){
            this.el.dom.setAttribute('autocomplete', 'off');
        }

        if(!this.lazyInit){
            this.initList();
        }else{
            this.on('focus', this.initList, this, {single: true});
        }

        if(!this.editable){
            this.editable = true;
            this.setEditable(false);
        }
    }
});









 
 
 
 function inputFieldMarkedInvalid (formField, msg) {
 /* hide helper element while displaying error message */
 
  infoEl = Ext.getDom(formField.name+'HelpMessage');

	if (infoEl)	{
		infoEl.style.display = "none";
		infoEl.style.backgroundImage = "url(/plugins/libextjs/resources/icons/smallInfoIcon.gif)";
	}
	
	/*if (Modalbox) {
		  Modalbox.resizeToContent();
	  }*/
 
 }
 
 
 
 function inputFieldMarkedValid (formField) {
 /* hide helper element while displaying error message */
 
  infoEl = Ext.getDom(formField.name+'HelpMessage');
  
  if (infoEl) {
	infoEl.style.display = "block";  
	infoEl.style.backgroundImage = "url(/plugins/libextjs/resources/icons/smallOkIcon.gif)";
  }
  
 /* if (Modalbox) {
	  Modalbox.resizeToContent();
  }*/
 }
 
 
 
 
 Ext.grid.RowExpander = function(config){
	    Ext.apply(this, config);

	    this.addEvents({
	        beforeexpand : true,
	        expand: true,
	        beforecollapse: true,
	        collapse: true
	    });

	    Ext.grid.RowExpander.superclass.constructor.call(this);

	    if(this.tpl){
	        if(typeof this.tpl == 'string'){
	            this.tpl = new Ext.Template(this.tpl);
	        }
	        this.tpl.compile();
	    }
	    
	    this.state = {};
	    this.bodyContent = {};
	};

	Ext.extend(Ext.grid.RowExpander, Ext.util.Observable, {
	    header: "",
	    width: 20,
	    sortable: false,
	    fixed:true,
	    menuDisabled:true,
	    dataIndex: '',
	    id: 'expander',
	    lazyRender : true,
	    enableCaching: true,

	    getRowClass : function(record, rowIndex, p, ds){
	        p.cols = p.cols-1;
	        var content = this.bodyContent[record.id];
	        if(!content && !this.lazyRender){
	            content = this.getBodyContent(record, rowIndex);
	        }
	        if(content){
	            p.body = content;
	        }
	        return this.state[record.id] ? 'x-grid3-row-expanded' : 'x-grid3-row-collapsed';
	    },
	    onGridDblClicked : function (grid, rowIndex, cellIndex, e){
	    	   e.stopEvent();
	            var row = e.getTarget('.x-grid3-row');
	            this.toggleRow(row);
	    },
		
	    init : function(grid){
	        this.grid = grid;

	        var view = grid.getView();
	        view.getRowClass = this.getRowClass.createDelegate(this);

	        view.enableRowBody = true;

	        grid.on('render', function(){
	            view.mainBody.on('mousedown', this.onMouseDown, this);
	        }, this);
	        if (this.usedblClick){
	        	
	        	grid.on('celldblclick', this.onGridDblClicked, this);
		        	
	        }
	        
	    },

	    getBodyContent : function(record, index){
	    	record.data.rowIndex = index;
	        if(!this.enableCaching){
	            return this.tpl.apply(record.data);
	        }
	        var content = this.bodyContent[record.id];
	        if(!content){
	            content = this.tpl.apply(record.data);
	            this.bodyContent[record.id] = content;
	        }
	        return content;
	    },

	    onMouseDown : function(e, t){
	        if(t.className == 'x-grid3-row-expander'){
	            e.stopEvent();
	            var row = e.getTarget('.x-grid3-row');
	            this.toggleRow(row);
	        }
	    },

	    renderer : function(v, p, record){
	        p.cellAttr = 'rowspan="2"';
	        return '<div class="x-grid3-row-expander">&#160;</div>';
	    },

	    beforeExpand : function(record, body, rowIndex){
	        if(this.fireEvent('beforeexpand', this, record, body, rowIndex) !== false){
	            if(this.tpl && this.lazyRender){
	                body.innerHTML = this.getBodyContent(record, rowIndex);
	            }
	            return true;
	        }else{
	            return false;
	        }
	    },

	    toggleRow : function(row){
	        if(typeof row == 'number'){
	            row = this.grid.view.getRow(row);
	        }
	        this[Ext.fly(row).hasClass('x-grid3-row-collapsed') ? 'expandRow' : 'collapseRow'](row);
	    },

	    expandRow : function(row){
	        if(typeof row == 'number'){
	            row = this.grid.view.getRow(row);
	        }
	        var record = this.grid.store.getAt(row.rowIndex);
	        var body = Ext.DomQuery.selectNode('tr:nth(2) div.x-grid3-row-body', row);
	        if(this.beforeExpand(record, body, row.rowIndex)){
	            this.state[record.id] = true;
	            Ext.fly(row).replaceClass('x-grid3-row-collapsed', 'x-grid3-row-expanded');
	            this.fireEvent('expand', this, record, body, row.rowIndex);
	        }
	    },

	    collapseRow : function(row){
	        if(typeof row == 'number'){
	            row = this.grid.view.getRow(row);
	        }
	        var record = this.grid.store.getAt(row.rowIndex);
	        var body = Ext.fly(row).child('tr:nth(1) div.x-grid3-row-body', true);
	        if(this.fireEvent('beforecollapse', this, record, body, row.rowIndex) !== false){
	            this.state[record.id] = false;
	            Ext.fly(row).replaceClass('x-grid3-row-expanded', 'x-grid3-row-collapsed');
	            this.fireEvent('collapse', this, record, body, row.rowIndex);
	        }
	    }
	});
	
	function roundFunction(x) 
	{
				
	  n = 2;
	  var e = Math.pow(10, n);
	  var k = (Math.round(x * e) / e).toString();
	  if (k.indexOf('.') == -1) k += '.';
	  k += e.toString().substring(1);
	  return k.substring(0, k.indexOf('.') + n+1);

	}

	
	
	Ext.ux.DDView = function(config) {
	    if (!config.itemSelector) {
	        var tpl = config.tpl;
	        if (this.classRe.test(tpl)) {
	            config.tpl = tpl.replace(this.classRe, 'class=$1x-combo-list-item $2$1');
	        }
	        else {
	            config.tpl = tpl.replace(this.tagRe, '$1 class="x-combo-list-item" $2');
	        }
	        config.itemSelector = ".x-combo-list-item";
	    }
	    Ext.ux.DDView.superclass.constructor.call(this, Ext.apply(config, {
	        border: false
	    }));
	};

	Ext.extend(Ext.ux.DDView, Ext.DataView, {
	    /**
	     * @cfg {String/Array} dragGroup The ddgroup name(s) for the View's DragZone (defaults to undefined).
	     */
	    /**
	     * @cfg {String/Array} dropGroup The ddgroup name(s) for the View's DropZone (defaults to undefined).
	     */
	    /**
	     * @cfg {Boolean} copy Causes drag operations to copy nodes rather than move (defaults to false).
	     */
	    /**
	     * @cfg {Boolean} allowCopy Causes ctrl/drag operations to copy nodes rather than move (defaults to false).
	     */
	    /**
	     * @cfg {String} sortDir Sort direction for the view, 'ASC' or 'DESC' (defaults to 'ASC').
	     */
	    sortDir: 'ASC',

	    // private
	    isFormField: true,
	    classRe: /class=(['"])(.*)\1/,
	    tagRe: /(<\w*)(.*?>)/,
	    reset: Ext.emptyFn,
	    clearInvalid: Ext.form.Field.prototype.clearInvalid,

	    // private
	    afterRender: function() {
	        Ext.ux.DDView.superclass.afterRender.call(this);
	        if (this.dragGroup) {
	            this.setDraggable(this.dragGroup.split(","));
	        }
	        if (this.dropGroup) {
	            this.setDroppable(this.dropGroup.split(","));
	        }
	        if (this.deletable) {
	            this.setDeletable();
	        }
	        this.isDirtyFlag = false;
	        this.addEvents(
	            "drop"
	        );
	    },

	    // private
	    validate: function() {
	        return true;
	    },

	    // private
	    destroy: function() {
	        this.purgeListeners();
	        this.getEl().removeAllListeners();
	        this.getEl().remove();
	        if (this.dragZone) {
	            if (this.dragZone.destroy) {
	                this.dragZone.destroy();
	            }
	        }
	        if (this.dropZone) {
	            if (this.dropZone.destroy) {
	                this.dropZone.destroy();
	            }
	        }
	    },

		/**
		 * Allows this class to be an Ext.form.Field so it can be found using {@link Ext.form.BasicForm#findField}.
		 */
	    getName: function() {
	        return this.name;
	    },

		/**
		 * Loads the View from a JSON string representing the Records to put into the Store.
	     * @param {String} value The JSON string
		 */
	    setValue: function(v) {
	        if (!this.store) {
	            throw "DDView.setValue(). DDView must be constructed with a valid Store";
	        }
	        var data = {};
	        data[this.store.reader.meta.root] = v ? [].concat(v) : [];
	        this.store.proxy = new Ext.data.MemoryProxy(data);
	        this.store.load();
	    },

		/**
		 * Returns the view's data value as a list of ids.
	     * @return {String} A parenthesised list of the ids of the Records in the View, e.g. (1,3,8).
		 */
	    getValue: function() {
	        var result = '(';
	        this.store.each(function(rec) {
	            result += rec.id + ',';
	        });
	        return result.substr(0, result.length - 1) + ')';
	    },

	    getIds: function() {
	        var i = 0, result = new Array(this.store.getCount());
	        this.store.each(function(rec) {
	            result[i++] = rec.id;
	        });
	        return result;
	    },

	    /**
	     * Returns true if the view's data has changed, else false.
	     * @return {Boolean}
	     */
	    isDirty: function() {
	        return this.isDirtyFlag;
	    },

		/**
		 * Part of the Ext.dd.DropZone interface. If no target node is found, the
		 * whole Element becomes the target, and this causes the drop gesture to append.
		 */
	    getTargetFromEvent : function(e) {
	        var target = e.getTarget();
	        while ((target !== null) && (target.parentNode != this.el.dom)) {
	            target = target.parentNode;
	        }
	        if (!target) {
	            target = this.el.dom.lastChild || this.el.dom;
	        }
	        return target;
	    },

		/**
		 * Create the drag data which consists of an object which has the property "ddel" as
		 * the drag proxy element.
		 */
	    getDragData : function(e) {
	        var target = this.findItemFromChild(e.getTarget());
	        if(target) {
	            if (!this.isSelected(target)) {
	                delete this.ignoreNextClick;
	                this.onItemClick(target, this.indexOf(target), e);
	                this.ignoreNextClick = true;
	            }
	            var dragData = {
	                sourceView: this,
	                viewNodes: [],
	                records: [],
	                copy: this.copy || (this.allowCopy && e.ctrlKey)
	            };
	            if (this.getSelectionCount() == 1) {
	                var i = this.getSelectedIndexes()[0];
	                var n = this.getNode(i);
	                dragData.viewNodes.push(dragData.ddel = n);
	                dragData.records.push(this.store.getAt(i));
	                dragData.repairXY = Ext.fly(n).getXY();
	            } else {
	                dragData.ddel = document.createElement('div');
	                dragData.ddel.className = 'multi-proxy';
	                this.collectSelection(dragData);
	            }
	            return dragData;
	        }
	        return false;
	    },

	    // override the default repairXY.
	    getRepairXY : function(e){
	        return this.dragData.repairXY;
	    },

		// private
	    collectSelection: function(data) {
	        data.repairXY = Ext.fly(this.getSelectedNodes()[0]).getXY();
	        if (this.preserveSelectionOrder === true) {
	            Ext.each(this.getSelectedIndexes(), function(i) {
	                var n = this.getNode(i);
	                var dragNode = n.cloneNode(true);
	                dragNode.id = Ext.id();
	                data.ddel.appendChild(dragNode);
	                data.records.push(this.store.getAt(i));
	                data.viewNodes.push(n);
	            }, this);
	        } else {
	            var i = 0;
	            this.store.each(function(rec){
	                if (this.isSelected(i)) {
	                    var n = this.getNode(i);
	                    var dragNode = n.cloneNode(true);
	                    dragNode.id = Ext.id();
	                    data.ddel.appendChild(dragNode);
	                    data.records.push(this.store.getAt(i));
	                    data.viewNodes.push(n);
	                }
	                i++;
	            }, this);
	        }
	    },

		/**
		 * Specify to which ddGroup items in this DDView may be dragged.
	     * @param {String} ddGroup The DD group name to assign this view to.
		 */
	    setDraggable: function(ddGroup) {
	        if (ddGroup instanceof Array) {
	            Ext.each(ddGroup, this.setDraggable, this);
	            return;
	        }
	        if (this.dragZone) {
	            this.dragZone.addToGroup(ddGroup);
	        } else {
	            this.dragZone = new Ext.dd.DragZone(this.getEl(), {
	                containerScroll: true,
	                ddGroup: ddGroup
	            });
	            // Draggability implies selection. DragZone's mousedown selects the element.
	            if (!this.multiSelect) { this.singleSelect = true; }

	            // Wire the DragZone's handlers up to methods in *this*
	            this.dragZone.getDragData = this.getDragData.createDelegate(this);
	            this.dragZone.getRepairXY = this.getRepairXY;
	            this.dragZone.onEndDrag = this.onEndDrag;
	        }
	    },

		/**
		 * Specify from which ddGroup this DDView accepts drops.
	     * @param {String} ddGroup The DD group name from which to accept drops.
		 */
	    setDroppable: function(ddGroup) {
	        if (ddGroup instanceof Array) {
	            Ext.each(ddGroup, this.setDroppable, this);
	            return;
	        }
	        if (this.dropZone) {
	            this.dropZone.addToGroup(ddGroup);
	        } else {
	            this.dropZone = new Ext.dd.DropZone(this.getEl(), {
	                owningView: this,
	                containerScroll: true,
	                ddGroup: ddGroup
	            });

	            // Wire the DropZone's handlers up to methods in *this*
	            this.dropZone.getTargetFromEvent = this.getTargetFromEvent.createDelegate(this);
	            this.dropZone.onNodeEnter = this.onNodeEnter.createDelegate(this);
	            this.dropZone.onNodeOver = this.onNodeOver.createDelegate(this);
	            this.dropZone.onNodeOut = this.onNodeOut.createDelegate(this);
	            this.dropZone.onNodeDrop = this.onNodeDrop.createDelegate(this);
	        }
	    },

		// private
	    getDropPoint : function(e, n, dd){
	        if (n == this.el.dom) { return "above"; }
	        var t = Ext.lib.Dom.getY(n), b = t + n.offsetHeight;
	        var c = t + (b - t) / 2;
	        var y = Ext.lib.Event.getPageY(e);
	        if(y <= c) {
	            return "above";
	        }else{
	            return "below";
	        }
	    },

	    // private
	    isValidDropPoint: function(pt, n, data) {
	        if (!data.viewNodes || (data.viewNodes.length != 1)) {
	            return true;
	        }
	        var d = data.viewNodes[0];
	        if (d == n) {
	            return false;
	        }
	        if ((pt == "below") && (n.nextSibling == d)) {
	            return false;
	        }
	        if ((pt == "above") && (n.previousSibling == d)) {
	            return false;
	        }
	        return true;
	    },

	    // private
	    onNodeEnter : function(n, dd, e, data){
	        if (this.highlightColor && (data.sourceView != this)) {
	            this.el.highlight(this.highlightColor);
	        }
	        return false;
	    },

	    // private
	    onNodeOver : function(n, dd, e, data){
	        var dragElClass = this.dropNotAllowed;
	        var pt = this.getDropPoint(e, n, dd);
	        if (this.isValidDropPoint(pt, n, data)) {
	            if (this.appendOnly || this.sortField) {
	                return "x-tree-drop-ok-below";
	            }

	            // set the insert point style on the target node
	            if (pt) {
	                var targetElClass;
	                if (pt == "above"){
	                    dragElClass = n.previousSibling ? "x-tree-drop-ok-between" : "x-tree-drop-ok-above";
	                    targetElClass = "x-view-drag-insert-above";
	                } else {
	                    dragElClass = n.nextSibling ? "x-tree-drop-ok-between" : "x-tree-drop-ok-below";
	                    targetElClass = "x-view-drag-insert-below";
	                }
	                if (this.lastInsertClass != targetElClass){
	                    Ext.fly(n).replaceClass(this.lastInsertClass, targetElClass);
	                    this.lastInsertClass = targetElClass;
	                }
	            }
	        }
	        return dragElClass;
	    },

	    // private
	    onNodeOut : function(n, dd, e, data){
	        this.removeDropIndicators(n);
	    },

	    // private
	    onNodeDrop : function(n, dd, e, data){
	        if (this.fireEvent("drop", this, n, dd, e, data) === false) {
	            return false;
	        }
	        var pt = this.getDropPoint(e, n, dd);
	        var insertAt = (this.appendOnly || (n == this.el.dom)) ? this.store.getCount() : n.viewIndex;
	        if (pt == "below") {
	            insertAt++;
	        }

	        // Validate if dragging within a DDView
	        if (data.sourceView == this) {
	            // If the first element to be inserted below is the target node, remove it
	            if (pt == "below") {
	                if (data.viewNodes[0] == n) {
	                    data.viewNodes.shift();
	                }
	            } else {  // If the last element to be inserted above is the target node, remove it
	                if (data.viewNodes[data.viewNodes.length - 1] == n) {
	                    data.viewNodes.pop();
	                }
	            }

	            // Nothing to drop...
	            if (!data.viewNodes.length) {
	                return false;
	            }

	            // If we are moving DOWN, then because a store.remove() takes place first,
	            // the insertAt must be decremented.
	            if (insertAt > this.store.indexOf(data.records[0])) {
	                insertAt--;
	            }
	        }

	        // Dragging from a Tree. Use the Tree's recordFromNode function.
	        if (data.node instanceof Ext.tree.TreeNode) {
	            var r = data.node.getOwnerTree().recordFromNode(data.node);
	            if (r) {
	                data.records = [ r ];
	            }
	        }

	        if (!data.records) {
	            alert("Programming problem. Drag data contained no Records");
	            return false;
	        }

	        for (var i = 0; i < data.records.length; i++) {
	            var r = data.records[i];
	            var dup = this.store.getById(r.id);
	            if (dup && (dd != this.dragZone)) {
	                if(!this.allowDup && !this.allowTrash){
	                    Ext.fly(this.getNode(this.store.indexOf(dup))).frame("red", 1);
	                    return true
	                }
	                var x=new Ext.data.Record();
	                r.id=x.id;
	                delete x;
	            }
	            if (data.copy) {
	                this.store.insert(insertAt++, r.copy());
	            } else {
	                if (data.sourceView) {
	                    data.sourceView.isDirtyFlag = true;
	                    data.sourceView.store.remove(r);
	                }
	                if(!this.allowTrash)this.store.insert(insertAt++, r);
	            }
	            if(this.sortField){
	                this.store.sort(this.sortField, this.sortDir);
	            }
	            this.isDirtyFlag = true;
	        }
	        this.dragZone.cachedTarget = null;
	        return true;
	    },

	    // private
	    onEndDrag: function(data, e) {
	        var d = Ext.get(this.dragData.ddel);
	        if (d && d.hasClass("multi-proxy")) {
	            d.remove();
	            //delete this.dragData.ddel;
	        }
	    },

	    // private
	    removeDropIndicators : function(n){
	        if(n){
	            Ext.fly(n).removeClass([
	                "x-view-drag-insert-above",
	                "x-view-drag-insert-left",
	                "x-view-drag-insert-right",
	                "x-view-drag-insert-below"]);
	            this.lastInsertClass = "_noclass";
	        }
	    },

		/**
		 * Add a delete option to the DDView's context menu.
		 * @param {String} imageUrl The URL of the "delete" icon image.
		 */
	    setDeletable: function(imageUrl) {
	        if (!this.singleSelect && !this.multiSelect) {
	            this.singleSelect = true;
	        }
	        var c = this.getContextMenu();
	        this.contextMenu.on("itemclick", function(item) {
	            switch (item.id) {
	                case "delete":
	                    this.remove(this.getSelectedIndexes());
	                    break;
	            }
	        }, this);
	        this.contextMenu.add({
	            icon: imageUrl || AU.resolveUrl("/images/delete.gif"),
	            id: "delete",
	            text: AU.getMessage("deleteItem")
	        });
	    },

		/**
		 * Return the context menu for this DDView.
	     * @return {Ext.menu.Menu} The context menu
		 */
	    getContextMenu: function() {
	        if (!this.contextMenu) {
	            // Create the View's context menu
	            this.contextMenu = new Ext.menu.Menu({
	                id: this.id + "-contextmenu"
	            });
	            this.el.on("contextmenu", this.showContextMenu, this);
	        }
	        return this.contextMenu;
	    },

	    /**
	     * Disables the view's context menu.
	     */
	    disableContextMenu: function() {
	        if (this.contextMenu) {
	            this.el.un("contextmenu", this.showContextMenu, this);
	        }
	    },

	    // private
	    showContextMenu: function(e, item) {
	        item = this.findItemFromChild(e.getTarget());
	        if (item) {
	            e.stopEvent();
	            this.select(this.getNode(item), this.multiSelect && e.ctrlKey, true);
	            this.contextMenu.showAt(e.getXY());
	        }
	    },

		/**
		 * Remove {@link Ext.data.Record}s at the specified indices.
		 * @param {Array/Number} selectedIndices The index (or Array of indices) of Records to remove.
		 */
	    remove: function(selectedIndices) {
	        selectedIndices = [].concat(selectedIndices);
	        for (var i = 0; i < selectedIndices.length; i++) {
	            var rec = this.store.getAt(selectedIndices[i]);
	            this.store.remove(rec);
	        }
	    },

		/**
		 * Double click fires the {@link #dblclick} event. Additionally, if this DDView is draggable, and there is only one other
		 * related DropZone that is in another DDView, it drops the selected node on that DDView.
		 */
	    onDblClick : function(e){
	        var item = this.findItemFromChild(e.getTarget());
	        if(item){
	            if (this.fireEvent("dblclick", this, this.indexOf(item), item, e) === false) {
	                return false;
	            }
	            if (this.dragGroup) {
	                var targets = Ext.dd.DragDropMgr.getRelated(this.dragZone, true);

	                // Remove instances of this View's DropZone
	                while (targets.indexOf(this.dropZone) !== -1) {
	                    targets.remove(this.dropZone);
	                }

	                // If there's only one other DropZone, and it is owned by a DDView, then drop it in
	                if ((targets.length == 1) && (targets[0].owningView)) {
	                    this.dragZone.cachedTarget = null;
	                    var el = Ext.get(targets[0].getEl());
	                    var box = el.getBox(true);
	                    targets[0].onNodeDrop(el.dom, {
	                        target: el.dom,
	                        xy: [box.x, box.y + box.height - 1]
	                    }, null, this.getDragData(e));
	                }
	            }
	        }
	    },

	    // private
	    onItemClick : function(item, index, e){
	        // The DragZone's mousedown->getDragData already handled selection
	        if (this.ignoreNextClick) {
	            delete this.ignoreNextClick;
	            return;
	        }

	        if(this.fireEvent("beforeclick", this, index, item, e) === false){
	            return false;
	        }
	        if(this.multiSelect || this.singleSelect){
	            if(this.multiSelect && e.shiftKey && this.lastSelection){
	                this.select(this.getNodes(this.indexOf(this.lastSelection), index), false);
	            } else if (this.isSelected(item) && e.ctrlKey) {
	                this.deselect(item);
	            }else{
	                this.deselect(item);
	                this.select(item, this.multiSelect && e.ctrlKey);
	                this.lastSelection = item;
	            }
	            e.preventDefault();
	        }
	        return true;
	    }
	});



		Ext.form.FileUploadField = Ext.extend(Ext.form.TextField,  {
		    /**
		     * @cfg {String} buttonText The button text to display on the upload button (defaults to
		     * 'Browse...').  Note that if you supply a value for {@link #buttonCfg}, the buttonCfg.text
		     * value will be used instead if available.
		     */
		    buttonText: 'Durchsuchen...',
		    /**
		     * @cfg {Boolean} buttonOnly True to display the file upload field as a button with no visible
		     * text field (defaults to false).  If true, all inherited TextField members will still be available.
		     */
		    buttonOnly: false,
		    /**
		     * @cfg {Number} buttonOffset The number of pixels of space reserved between the button and the text field
		     * (defaults to 3).  Note that this only applies if {@link #buttonOnly} = false.
		     */
		    buttonOffset: 3,
		    /**
		     * @cfg {Object} buttonCfg A standard {@link Ext.Button} config object.
		     */

		    // private
		    readOnly: true,
		    
		    /**
		     * @hide 
		     * @method autoSize
		     */
		    autoSize: Ext.emptyFn,
		    
		    // private
		    initComponent: function(){
		        Ext.form.FileUploadField.superclass.initComponent.call(this);
		        
		        this.addEvents(
		            /**
		             * @event fileselected
		             * Fires when the underlying file input field's value has changed from the user
		             * selecting a new file from the system file selection dialog.
		             * @param {Ext.form.FileUploadField} this
		             * @param {String} value The file value returned by the underlying file input field
		             */
		            'fileselected'
		        );
		    },
		    
		    // private
		    onRender : function(ct, position){
		        Ext.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.fileInput = this.wrap.createChild({
		            id: this.getFileInputId(),
		            name: this.name||this.getId(),
		            cls: 'x-form-file',
		            tag: 'input', 
		            type: 'file',
		            size: 1
		        });
		        
		        var btnCfg = Ext.applyIf(this.buttonCfg || {}, {
		            text: this.buttonText
		        });
		        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.fileInput.on('change', function(){
		            var v = this.fileInput.dom.value;
		            this.setValue(v);
		            this.fireEvent('fileselected', this, v);
		        }, this);
		    },
		    
		    // private
		    getFileInputId: function(){
		        return this.id+'-file';
		    },
		    
		    // private
		    onResize : function(w, h){
		        Ext.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);
		        }
		    },
		    
		    // private
		    preFocus : Ext.emptyFn,
		    
		    // private
		    getResizeEl : function(){
		        return this.wrap;
		    },

		    // private
		    getPositionEl : function(){
		        return this.wrap;
		    },

		    // private
		    alignErrorIcon : function(){
		        this.errorIcon.alignTo(this.wrap, 'tl-tr', [2, 0]);
		    }
		    
		});
		Ext.reg('fileuploadfield', Ext.form.FileUploadField);	

		
		
		
		Ext.ux.Multiselect = Ext.extend(Ext.form.Field,  {
		    /**
		     * @cfg {String} legend Wraps the object with a fieldset and specified legend.
		     */
		    /**
		     * @cfg {Store} store The {@link Ext.data.Store} used by the underlying Ext.ux.DDView.
		     */
		    /**
		     * @cfg {Ext.ux.DDView} view The Ext.ux.DDView used to render the multiselect list.
		     */
		    /**
		     * @cfg {String/Array} dragGroup The ddgroup name(s) for the DDView's DragZone (defaults to undefined). 
		     */ 
		    /**
		     * @cfg {String/Array} dropGroup The ddgroup name(s) for the DDView's DropZone (defaults to undefined). 
		     */ 
		    /**
		     * @cfg {Object/Array} tbar The top toolbar of the control. This can be a {@link Ext.Toolbar} object, a 
		     * toolbar config, or an array of buttons/button configs to be added to the toolbar.
		     */
		    /**
		     * @cfg {String} fieldName The name of the field to sort by when sorting is enabled.
		     */
		    /**
		     * @cfg {String} appendOnly True if the list should only allow append drops when drag/drop is enabled 
		     * (use for lists which are sorted, defaults to false).
		     */
		    appendOnly:false,
		    /**
		     * @cfg {Array} dataFields Inline data definition when not using a pre-initialised store. Known to cause problems 
		     * in some browswers for very long lists. Use store for large datasets.
		     */
		    dataFields:[],
		    /**
		     * @cfg {Array} data Inline data when not using a pre-initialised store. Known to cause problems in some 
		     * browswers for very long lists. Use store for large datasets.
		     */
		    data:[],
		    /**
		     * @cfg {Number} width Width in pixels of the control (defaults to 100).
		     */
		    width:100,
		    /**
		     * @cfg {Number} height Height in pixels of the control (defaults to 100).
		     */
		    height:100,
		    /**
		     * @cfg {String/Number} displayField Name/Index of the desired display field in the dataset (defaults to 0).
		     */
		    displayField:0,
		    /**
		     * @cfg {String/Number} valueField Name/Index of the desired value field in the dataset (defaults to 1).
		     */
		    valueField:1,
		    /**
		     * @cfg {Boolean} allowBlank True to require at least one item in the list to be selected, false to allow no 
		     * selection (defaults to true).
		     */
		    allowBlank:true,
		    /**
		     * @cfg {Number} minLength Minimum number of selections allowed (defaults to 0).
		     */
		    minLength:0,
		    /**
		     * @cfg {Number} maxLength Maximum number of selections allowed (defaults to Number.MAX_VALUE). 
		     */
		    maxLength:Number.MAX_VALUE,
		    /**
		     * @cfg {String} blankText Default text displayed when the control contains no items (defaults to the same value as
		     * {@link Ext.form.TextField#blankText}.
		     */
		    blankText:Ext.form.TextField.prototype.blankText,
		    /**
		     * @cfg {String} minLengthText Validation message displayed when {@link #minLength} is not met (defaults to 'Minimum {0} 
		     * item(s) required').  The {0} token will be replaced by the value of {@link #minLength}.
		     */
		    minLengthText:'Minimum {0} item(s) required',
		    /**
		     * @cfg {String} maxLengthText Validation message displayed when {@link #maxLength} is not met (defaults to 'Maximum {0} 
		     * item(s) allowed').  The {0} token will be replaced by the value of {@link #maxLength}.
		     */
		    maxLengthText:'Maximum {0} item(s) allowed',
		    /**
		     * @cfg {String} delimiter The string used to delimit between items when set or returned as a string of values
		     * (defaults to ',').
		     */
		    delimiter:',',
		    
		    // DDView settings
		    copy:false,
		    allowDup:false,
		    allowTrash:false,
		    focusClass:undefined,
		    sortDir:'ASC',
		    
		    // private
		    defaultAutoCreate : {tag: "div"},
		    
		    // private
		    initComponent: function(){
		        Ext.ux.Multiselect.superclass.initComponent.call(this);
		        this.addEvents({
		            'dblclick' : true,
		            'click' : true,
		            'change' : true,
		            'drop' : true
		        });     
		    },
		    
		    // private
		    onRender: function(ct, position){
		        Ext.ux.Multiselect.superclass.onRender.call(this, ct, position);
		        
		        var cls = 'ux-mselect';
		        var fs = new Ext.form.FieldSet({
		            renderTo:this.el,
		            title:this.legend,
		            height:this.height,
		            width:this.width,
		            style:"padding:0;",
		            tbar:this.tbar
		        });
		        //if(!this.legend)fs.el.down('.'+fs.headerCls).remove();
		        fs.body.addClass(cls);

		        var tpl = '<tpl for="."><div class="' + cls + '-item';
		        if(Ext.isIE || Ext.isIE7){
		            tpl+='" unselectable=on';
		        }else{
		            tpl+=' x-unselectable"';
		        }
		        tpl+='>{' + this.displayField + '}</div></tpl>';

		        if(!this.store){
		            this.store = new Ext.data.SimpleStore({
		                fields: this.dataFields,
		                data : this.data
		            });
		        }

		        this.view = new Ext.ux.DDView({
		            multiSelect: true, 
		            store: this.store, 
		            selectedClass: cls+"-selected", 
		            tpl:tpl,
		            allowDup:this.allowDup, 
		            copy: this.copy, 
		            allowTrash: this.allowTrash, 
		            dragGroup: this.dragGroup, 
		            dropGroup: this.dropGroup, 
		            itemSelector:"."+cls+"-item",
		            isFormField:false, 
		            applyTo:fs.body,
		            appendOnly:this.appendOnly,
		            sortField:this.sortField, 
		            sortDir:this.sortDir
		        });

		        fs.add(this.view);
		        
		        this.view.on('click', this.onViewClick, this);
		        this.view.on('beforeClick', this.onViewBeforeClick, this);
		        this.view.on('dblclick', this.onViewDblClick, this);
		        this.view.on('drop', function(ddView, n, dd, e, data){
		            return this.fireEvent("drop", ddView, n, dd, e, data);
		        }, this);
		        
		        this.hiddenName = this.name;
		        var hiddenTag={tag: "input", type: "hidden", value: "", name:this.name};
		        if (this.isFormField) { 
		            this.hiddenField = this.el.createChild(hiddenTag);
		        } else {
		            this.hiddenField = Ext.get(document.body).createChild(hiddenTag);
		        }
		        fs.doLayout();
		    },
		    
		    // private
		    initValue:Ext.emptyFn,
		    
		    // private
		    onViewClick: function(vw, index, node, e) {
		        var arrayIndex = this.preClickSelections.indexOf(index);
		        if (arrayIndex  != -1)
		        {
		            this.preClickSelections.splice(arrayIndex, 1);
		            this.view.clearSelections(true);
		            this.view.select(this.preClickSelections);
		        }
		        this.fireEvent('change', this, this.getValue(), this.hiddenField.dom.value);
		        this.hiddenField.dom.value = this.getValue();
		        this.fireEvent('click', this, e);
		        this.validate();        
		    },

		    // private
		    onViewBeforeClick: function(vw, index, node, e) {
		        this.preClickSelections = this.view.getSelectedIndexes();
		        if (this.disabled) {return false;}
		    },

		    // private
		    onViewDblClick : function(vw, index, node, e) {
		        return this.fireEvent('dblclick', vw, index, node, e);
		    },  
		    
		    /**
		     * Returns an array of data values for the selected items in the list. The values will be separated
		     * by {@link #delimiter}.
		     * @return {Array} value An array of string data values
		     */
		    getValue: function(valueField){
		        var returnArray = [];
		        var selectionsArray = this.view.getSelectedIndexes();
		        if (selectionsArray.length == 0) {return '';}
		        for (var i=0; i<selectionsArray.length; i++) {
		            returnArray.push(this.store.getAt(selectionsArray[i]).get(((valueField != null)? valueField : this.valueField)));
		        }
		        return returnArray.join(this.delimiter);
		    },

		    /**
		     * Sets a delimited string (using {@link #delimiter}) or array of data values into the list.
		     * @param {String/Array} values The values to set
		     */
		    setValue: function(values) {
		        var index;
		        var selections = [];
		        this.view.clearSelections();
		        this.hiddenField.dom.value = '';
		        
		        if (!values || (values == '')) { return; }
		        
		        if (!(values instanceof Array)) { values = values.split(this.delimiter); }
		        for (var i=0; i<values.length; i++) {
		            index = this.view.store.indexOf(this.view.store.query(this.valueField, 
		                new RegExp('^' + values[i] + '$', "i")).itemAt(0));
		            selections.push(index);
		        }
		        this.view.select(selections);
		        this.hiddenField.dom.value = this.getValue();
		        this.validate();
		    },
		    
		    // inherit docs
		    reset : function() {
		        this.setValue('');
		    },
		    
		    // inherit docs
		    getRawValue: function(valueField) {
		        var tmp = this.getValue(valueField);
		        if (tmp.length) {
		            tmp = tmp.split(this.delimiter);
		        }
		        else{
		            tmp = [];
		        }
		        return tmp;
		    },

		    // inherit docs
		    setRawValue: function(values){
		        setValue(values);
		    },

		    // inherit docs
		    validateValue : function(value){
		        if (value.length < 1) { // if it has no value
		             if (this.allowBlank) {
		                 this.clearInvalid();
		                 return true;
		             } else {
		                 this.markInvalid(this.blankText);
		                 return false;
		             }
		        }
		        if (value.length < this.minLength) {
		            this.markInvalid(String.format(this.minLengthText, this.minLength));
		            return false;
		        }
		        if (value.length > this.maxLength) {
		            this.markInvalid(String.format(this.maxLengthText, this.maxLength));
		            return false;
		        }
		        return true;
		    }
		});

		Ext.reg("multiselect", Ext.ux.Multiselect);
		
		

		
		function checkBoxGroupValidator (groupName,elements,validCountMin,validCountMax) {
			
			
			
			var ccounter =0; 
			for(var i = 0, len = elements.length; i < len; i++){
				var elId = groupName +'_'+ elements[i];
				
				var el = Ext.getCmp(elId);
				el.clearInvalid();
				if (el) {
					if (el.checked) {
						ccounter++;
					}
				}
				
	        }
			if (validCountMin> 0) {
				if (ccounter< validCountMin)	return false;
			}
			if (validCountMax> 0) {
				if (ccounter> validCountMax)	return false;
			}
			return true;
		}
		
		function updateCheckBoxGroupHiddenValues (cbElement, newValue, oldValue) {
			var itemsArray = cbElement.items;
			var value;
			for(var i = 0, len = itemsArray.length; i < len; i++){
				var elId = cbElement.groupid +'_'+ itemsArray[i];
				var el = Ext.getCmp(elId);
				if (el) {
					if (el.checked) {
						if (value) {
							value += ','+ itemsArray[i]; 
						}else {
							value = itemsArray[i]; 
						}
					}
				}
				
	        }
			var hiddenInputElement = Ext.get('hidden'+cbElement.groupid);
			if (hiddenInputElement) {
				
				hiddenInputElement.dom.value = value;
			}

			
		}
	
		
		
		// curency utils
		
		
		function currencyInputElementFocused (inputEl) {
			var row = Ext.get(inputEl.id + '_row');
			
			row.addClass( 'rowFocused');	
		return true;

		}
		function currencyInputElementLostFocus(inputEl) {


			var value = inputEl.getValue().replace(/\s*€/,'');
			value = value.replace(/\./,'');
			value = value.replace(/,/,'.');
			if (!value) value =0;
			value = parseFloat(value).toFixed(2)+' €'
			
/*			
			var fnum = value.toString();
			 
			
			psplit = fnum.split('.');
			 
			var cnum = psplit[0],
				parr = [],
				j = cnum.length,
				m = Math.floor(j / 3),
				n = cnum.length % 3 || 3; // n cannot be ZERO or causes infinite loop
	 
			// break the number into chunks of 3 digits; first chunk may be less than 3
			for (var i = 0; i < j; i += n) {
				if (i != 0) {n = 3;}
				parr[parr.length] = cnum.substr(i, n);
				m -= 1;
			}
	 
			// put chunks back together, separated by comma
			fnum = parr.join('.');
			if (psplit[1]) {fnum += ',' + psplit[1];}
			value = fnum;
*/			
			
			
			
			value = value.replace(/\./,',');
			inputEl.setValue (value);


			var row = Ext.get(inputEl.id + '_row');
			row.removeClass( 'rowFocused');

			return true;

		}
		
		/*

		Number.prototype.format = function(format) {
			if (! isType(format, 'string')) {return '';} // sanity check
		 
			var hasComma = -1 &lt; format.indexOf(','),
				psplit = format.stripNonNumeric().split('.'),
				that = this;
		 
			// compute precision
			if (1 == psplit.length) {
				// fix number precision
				that = that.toFixed(psplit[1].length);
			}
			// error: too many periods
			else if (2 == psplit.length) {
				throw('NumberFormatException: invalid format, formats should have no more than 1 period: ' + format);
			}
			// remove precision
			else {
				that = that.toFixed(0);
			}
		 
			// get the string now that precision is correct
			var fnum = that.toString();
		 
			// format has comma, then compute commas
			if (hasComma) {
				// remove precision for computation
				psplit = fnum.split('.');
		 
				var cnum = psplit[0],
					parr = [],
					j = cnum.length,
					m = Math.floor(j / 3),
					n = cnum.length % 3 || 3; // n cannot be ZERO or causes infinite loop
		 
				// break the number into chunks of 3 digits; first chunk may be less than 3
				for (var i = 0; i &lt; j; i += n) {
					if (i != 0) {n = 3;}
					parr[parr.length] = cnum.substr(i, n);
					m -= 1;
				}
		 
				// put chunks back together, separated by comma
				fnum = parr.join(',');
		 
				// add the precision back in
				if (psplit[1]) {fnum += '.' + psplit[1];}
			}
		 
			// replace the number portion of the format with fnum
			return format.replace(/[d,?.?]+/, fnum);
		};
		*/
		function __old__currencyInputElementLostFocus(inputEl) {


			   var value = inputEl.getValue().replace(/\s*€/,'');
			   value = value.replace(/,/,'.');
			   if (!value) value =0;
			   value = parseFloat(value).toFixed(2)+' €'
			   value = value.replace(/\./,',');
			   inputEl.setValue (value);

				
			var row = Ext.get(inputEl.id + '_row');
			row.removeClass( 'rowFocused');	
		return true;

		}
