// dient dem verstecken von Feld und Label

Ext.override(Ext.form.Field, {
showContainer: function() {
this.enable();
this.show();
this.getEl().up('.x-form-item').setDisplayed(true); // show entire container and children (including label if applicable)
},

hideContainer: function() {
this.disable(); // for validation
this.hide();
this.getEl().up('.x-form-item').setDisplayed(false); // hide container and children (including label if applicable)
},

setContainerVisible: function(visible) {
if (visible) {
this.showContainer();
} else {
this.hideContainer();
}
return this;
}
});



// die scrollbars?
// oder doch was mit den werten?
Ext.override(Ext.form.Checkbox, {
	getValue : function(){
		if(this.rendered){
			return this.el.dom.checked;
		}
		return this.checked;
	},

	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);
		}

		if(checked != this.checked){
			this.fireEvent("check", this, this.checked);
			if(this.handler){
				this.handler.call(this.scope || this, this, this.checked);
			}
		}
	}
});


// md5 bei passwort verschlüsselung

Ext.override(Ext.form.Field,{

	/**
	 * Returns the normalized data value (undefined or emptyText will be returned as '').  To return the raw value see {@link #getRawValue}.
	 * @return {Mixed} value The field value
	 */
	getValue : function(){
		
	    if(!this.rendered) {
	        return this.value;
	    }
	    var v = this.el.getValue();
	    if(v === this.emptyText || v === undefined){
	        v = '';
	    }
	
		if(this.inputType == "password"){
			
			v = Ext.util.MD5(v);
			
		}
		
		if(this.inputType == "number"){

		}
		
	    return v;
		


	}	
	
});


// komma zu punkt
Ext.override(Ext.form.NumberField,{

decimalSeparator:',',


getValue:function()
{
	var str = this.fixPrecision(this.parseValue(Ext.form.NumberField.superclass.getValue.call(this)));
		
	if(typeof str == 'string'){
		return str.replace(',','.');
	}else{
		return str;
	}
    
}
	
	
});


// bei der combobox editable standardmäßig auf false setzen
Ext.override(Ext.form.ComboBox,{ editable:false });

Ext.override(Ext.Window,{
	y:80,
	constrain:true
});



// standards für tabellen
Ext.override(Ext.grid.GridPanel, {
	enableColumnHide:false,
	enableHdMenu:false,
	cls:'vline-on'
});



//standards für combobox
Ext.override(Ext.form.ComboBox,{
	
	// valueNotFoundText:'NICHT GEFUNDEN'
	
});


//  http://extjs.com/forum/showthread.php?t=44603&highlight=checkbox+label+value

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.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
			});
		}
		//this.imageEl = this.innerWrap.createChild({
			//tag: 'img',
			//src: Ext.BLANK_IMAGE_URL,
			//cls: this.baseCls
		//}, this.el);
		if(this.checked){
			this.setValue(true);
		}else{
			this.checked = this.el.dom.checked;
		}
		this.originalValue = this.checked;
	},
	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);
	},
	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) {
			if (e.getTarget() !== this.el.dom) {
				this.el.focus();
			}
			if (!this.disabled && !this.readOnly) {
				this.toggleValue();
			}
		}
		//e.stopEvent();
	},
	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;
	}
});



// warten bildschirm schließbar machen
// 
// 
// 
// Ext.override(Ext.ProgressBar,{
// 
// 	wait:function(msg, title, config){
// 		console.log('test');
// 		this.show({
//             title : title,
//             msg : msg,
//             buttons: false,
//             closable:true,
//             wait:true,
//             modal:true,
//             minWidth: this.minProgressWidth,
//             waitConfig: config
//         });
//         return this;
// 	}
// 	
// });




