var	disabledMaskedControlsArray	=	[];
var disabledMaskedControls	=	[];

//Ext.BLANK_IMAGE_URL='dodatki/lib/ext/resources/images/default/s.gif';
Ext.BLANK_IMAGE_URL='ext/resources/images/default/s.gif';

//Sprawdzanie polozenia oraz ruch myszki w celu pokazania podpowiedzi.

//var polX = 0;
//var polY = 0;
//var polXtmp = 0;
//var polYtmp = 0;
//var czasSpoczynku = 0;

//window.setInterval(function(){
//	document.onmousemove = polozenieMyszki;
//	if(polXtmp == polX && polYtmp == polY){
//		czasSpoczynku++;
//	}else{
//		czasSpoczynku = 0;
//	}
//	
//	if(czasSpoczynku == 4){
//		Ext.Msg.alert('Ruch myszki','X:'+polX+' Y:'+polY);
//		czasSpoczynku = 0;
//	}
//	
//	polXtmp = polX;
//	polYtmp = polY;
//	
//}, 1000);

//function polozenieMyszki(e) {
//    if(Ext.isIE) { //Pobieranie położenia myszki pod IE
//    polX = event.clientX + document.body.scrollLeft
//    polY = event.clientY + document.body.scrollTop
//  } else {  // Pobieranie położenia myszki pod innymi przeglądarkami 
//    polX = e.pageX
//    polY = e.pageY
//  }
// }
//	 
//function PokażPodpowiedz(){
//	
//}



Ext.lib.Event.resolveTextNode = Ext.isGecko ? function(node){
	if(!node){
		return;
	}
	var s = HTMLElement.prototype.toString.call(node);
	if(s == '[xpconnect wrapped native prototype]' || s == '[object XULElement]'){
		return;
	}
	return node.nodeType == 3 ? node.parentNode : node;
} : function(node){
	return node && node.nodeType == 3 ? node.parentNode : node;
};

Ext.override(Ext.Window,{
	disableMaskedElements : true,
	
	pomoc : true,
	
    beforeShow : function(){
        delete this.el.lastXY;
        delete this.el.lastLT;
        if(this.x === undefined || this.y === undefined){
            var xy = this.el.getAlignToXY(this.container, 'c-c');
            var pos = this.el.translatePoints(xy[0], xy[1]);
            this.x = this.x === undefined? pos.left : this.x;
            this.y = this.y === undefined? pos.top : this.y;
        }
        this.el.setLeftTop(this.x, this.y);
 
        if(this.expandOnShow){
            this.expand(false);
        }
 
        if(this.modal){
            Ext.getBody().addClass("x-body-masked");
            this.mask.setSize(Ext.lib.Dom.getViewWidth(true), Ext.lib.Dom.getViewHeight(true));
            this.mask.show();
            if (this.disableMaskedElements == true) {
//	Następuje zliczenie elementów i ich wyłączenie aby nie przechodzić na nie za pomocą tabulatora.
                var db = Ext.fly(document.body);
                var els = db.select("input, select, a, button");
                els.each(function(el){
                    if (!el.dom.disabled && el.isVisible() && el.findParent('div[id='+this.getId()+']') == null) {
                        el.dom.disabled = true;
                        disabledMaskedControls.push(el.dom);
                    }
                }, this);
                disabledMaskedControlsArray.push(disabledMaskedControls);
            }else {
            	disabledMaskedControlsArray.push(disabledMaskedControls);
            }
        } else { disabledMaskedControlsArray.push(disabledMaskedControls);}
    },
    
    afterShow : function(){
    	
    	this.proxy.hide();
        this.el.setStyle('display', 'block');
        this.el.show();
        if(this.maximized){
            this.fitContainer();
        }
        if(Ext.isMac && Ext.isGecko){ // work around stupid FF 2.0/Mac scroll bar bug
        	this.cascade(this.setAutoScroll);
        }

        if(this.monitorResize || this.modal || this.constrain || this.constrainHeader){
            Ext.EventManager.onWindowResize(this.onWindowResize, this);
        }
        this.doConstrain();
        if(this.layout){
            this.doLayout();
        }
        if(this.keyMap){
            this.keyMap.enable();
        }
        this.toFront();
        this.updateHandles();
        this.fireEvent("show", this);
        // ponowny focus na pierwszym elemencie.
        if (Ext.isEmpty(Ext.getCmp(disabledMaskedControls[0].id))==false && Ext.getCmp(disabledMaskedControls[0].id).xtype !=='combo'){
        		disabledMaskedControls[0].focus(10);
        }
        
    },
    
    toFront : function(e){
        if(this.manager.bringToFront(this)){
            if(!e || !e.getTarget().focus){
            	// funkcja zlicza elementy w nowym oknie i ustawia focus na 1 elemencie.
            	disabledMaskedControls = [];
            	var db = Ext.fly(document.body);
                var els = db.select("input, select, a, button");
                els.each(function(el){ 
                	if (!el.dom.disabled && el.isVisible() ) {
                        disabledMaskedControls.push(el.dom);
                	}
                }, this);
                if (Ext.isEmpty(Ext.getCmp(disabledMaskedControls[0].id))==false && Ext.getCmp(disabledMaskedControls[0].id).xtype !=='combo'){
                	disabledMaskedControls[0].focus(10);
                }else{	this.focus();}
            }
        }
        return this;
        
        
        
    },
    
    afterHide : function(){
//	Włączenie elementów które zostały wyłączone przy uruchomieniu ostatniego okna.
    	disabledMaskedControls = disabledMaskedControlsArray.pop();
        Ext.each(disabledMaskedControls, function(el) {
            el.disabled = false;
        });
        
        this.proxy.hide();
        if(this.monitorResize || this.modal || this.constrain || this.constrainHeader){
            Ext.EventManager.removeResizeListener(this.onWindowResize, this);
        }
        if(this.modal){
            this.mask.hide();
            Ext.getBody().removeClass("x-body-masked");
        }
        if(this.keyMap){
            this.keyMap.disable();
        }
        this.fireEvent("hide", this);
        
        for(i=0;i<disabledMaskedControls.length;i++){
	        if(disabledMaskedControls[i].type =='text' && Ext.isEmpty(Ext.getCmp(disabledMaskedControls[0].id))==false && Ext.getCmp(disabledMaskedControls[0].id).xtype !=='combo' ){
        	disabledMaskedControls[i].focus();
	        disabledMaskedControls = [];
	        break;
	        	}
        	}
    },
    initTools : function(){
        if(this.minimizable){
            this.addTool({
                id: 'minimize',
                handler: this.minimize.createDelegate(this, [])
            });
        }
        if(this.maximizable){
            this.addTool({
                id: 'maximize',
                handler: this.maximize.createDelegate(this, [])
            });
            this.addTool({
                id: 'restore',
                handler: this.restore.createDelegate(this, []),
                hidden:true
            });
            this.header.on('dblclick', this.toggleMaximize, this);
        }
        if(this.pomoc && this.closable){
            this.addTool({
                id: 'pomoc',
                handler: function(t,tc,win){
                	var tytul = win.title;
                	if(tytul.indexOf('>') !== -1){
                		tytul = tytul.substr(tytul.indexOf('>')+1);
                	}
                	if(tytul.indexOf('&nbsp') !== -1){
                		tytul = tytul.substr(tytul.indexOf('&nbsp')+5);
                	}
                	if(tytul.indexOf(' ') == 0){
                		tytul = tytul.substr(1);
                	}
//                	alert(tytul)
                	ShowWindow('pomoc',tytul);
                }
            });
        }
        if(this.closable){
            this.addTool({
                id: 'close',
                handler: this[this.closeAction].createDelegate(this, [])
            });
        }
    }
	});

Ext.override(Ext.Button, {
	onClickDisable : true,
	
	setTooltip: function(qtipText) {
        var btnEl = this.getEl().child(this.buttonSelector)
        Ext.QuickTips.register({
            target: btnEl.id,
            text: qtipText
        });             
    },

	onClick : function(e){
	    if(e){
	        e.preventDefault();
	    }
	    if(e.button != 0){
	        return;
	    }
	    // wyłączenie przycisku po kliknięciu na niego co uniemożliwia wielokrotne naciskanie.
	    if(!this.disabled){
	    	
	    	if(this.onClickDisable == true){
			    this.disabled = true;
		    	disabledMaskedControls.push(this);
		    	
		    	this.enable.defer(5000,this);
		    	
			}
	    	
	        if(this.enableToggle && (this.allowDepress !== false || !this.pressed)){
	            this.toggle();
	        }
	        if(this.menu && !this.menu.isVisible() && !this.ignoreNextClick){
	            this.showMenu();
	        }
	        this.fireEvent("click", this, e);
	        if(this.handler){
	            //this.el.removeClass("x-btn-over");
	            this.handler.call(this.scope || this, this, e);
	        }
	    }
	},
//	Ustawienie listenera on focus
    onFocus : function(A){
        if(!this.disabled){
            this.el.addClass("x-btn-focus");
            this.fireEvent("focus", this);
        }
    },
//	Ustawienie listenera on blur
    onBlur : function(e){

        if(this.fireEvent("blur", this) === false){
             return false;
        }
        this.el.removeClass("x-btn-focus");
    }

});

Ext.override(Ext.PagingToolbar,{
	paramNames : {start: 'start', limit: 'limit'},
	
	onRender : function(ct, position){
        Ext.PagingToolbar.superclass.onRender.call(this, ct, position);
        this.first = this.addButton({
            tooltip: this.firstText,
            iconCls: "x-tbar-page-first",
            disabled: true,
            onClickDisable : false,
            handler: this.onClick.createDelegate(this, ["first"])
        });
        this.prev = this.addButton({
            tooltip: this.prevText,
            iconCls: "x-tbar-page-prev",
            disabled: true,
            onClickDisable : false,
            handler: this.onClick.createDelegate(this, ["prev"])
        });
        this.addSeparator();
        this.add(this.beforePageText);
        this.field = Ext.get(this.addDom({
           tag: "input",
           type: "text",
           size: "3",
           value: "1",
           cls: "x-tbar-page-number"
        }).el);
        this.field.on("keydown", this.onPagingKeydown, this);
        this.field.on("focus", function(){this.dom.select();});
        this.field.on("blur", this.onPagingBlur, this);
        this.afterTextEl = this.addText(String.format(this.afterPageText, 1));
        this.field.setHeight(18);
        this.addSeparator();
        this.next = this.addButton({
            tooltip: this.nextText,
            iconCls: "x-tbar-page-next",
            disabled: true,
            onClickDisable : false,
            handler: this.onClick.createDelegate(this, ["next"])
        });
        this.last = this.addButton({
            tooltip: this.lastText,
            iconCls: "x-tbar-page-last",
            disabled: true,
            onClickDisable : false,
            handler: this.onClick.createDelegate(this, ["last"])
        });
        this.addSeparator();
        this.loading = this.addButton({
            tooltip: this.refreshText,
            iconCls: "x-tbar-loading",
            onClickDisable : false,
            handler: this.onClick.createDelegate(this, ["refresh"])
        });

        if(this.displayInfo){
            this.displayEl = Ext.fly(this.el.dom).createChild({cls:'x-paging-info'});
        }
        if(this.dsLoaded){
            this.onLoad.apply(this, this.dsLoaded);
        }
    },
	// nadpisanie podstawowych parametrów pagingtoolbar i dodanie dodatkowych pól.
	doLoad : function(start){
        var o = {}, pn = this.paramNames;
        o[pn.start] = start;
        o[pn.limit] = this.pageSize;
        if(this.fireEvent('beforechange', this, o) !== false){
            var options = Ext.apply({}, this.store.lastOptions);
            options.params = Ext.applyIf(o, options.params);
            this.store.load(options);
        }

        
    }
});

Ext.override(Ext.grid.RowSelectionModel, {
	
	initEvents : function(){

    if(!this.grid.enableDragDrop && !this.grid.enableDrag){
        this.grid.on("rowmousedown", this.handleMouseDown, this);
    }else{ // allow click to work like normal
        this.grid.on("rowclick", function(grid, rowIndex, e) {
            if(e.button === 0 && !e.shiftKey && !e.ctrlKey) {
                this.selectRow(rowIndex, false);
                grid.view.focusRow(rowIndex);
            }
        }, this);
    }
    // dodanie przycisku Tabulatora do nawigacji w gridzie
    this.rowNav = new Ext.KeyNav(this.grid.getGridEl(), {
        "up" : function(e){
    		/*if(this.last == '0'){
    			this.grid.bottomToolbar.doLoad(Math.max(0, this.last));
    			this.last == this.grid.store.getCount() - 1;
    			this.selectRow(this.grid.store.getCount() - 1);			}*/
            if(!e.shiftKey || this.singleSelect){
                this.selectPrevious(false);
            }else if(this.last !== false && this.lastActive !== false){
                var last = this.last;
                this.selectRange(this.last,  this.lastActive-1);
                this.grid.getView().focusRow(this.lastActive);
                if(last !== false){
                    this.last = last;
                }
            }else{
                this.selectFirstRow();
            }
        },
        "down" : function(e){
        	/*if(this.last == this.grid.store.getCount() - 1){
        		this.grid.bottomToolbar.doLoad(this.last+1);
        		this.last == '0';
        		this.selectRow(0);			}*/
            if(!e.shiftKey || this.singleSelect){
                this.selectNext(false);
            }else if(this.last !== false && this.lastActive !== false){
                var last = this.last;
                this.selectRange(this.last,  this.lastActive+1);
                this.grid.getView().focusRow(this.lastActive);
                if(last !== false){
                    this.last = last;
                }
            }else{
                this.selectFirstRow();
            }
        },
        "tab" : function(e){
            if(!e.shiftKey || this.singleSelect){
                this.selectNext(false);
            }else if(this.last !== false && this.lastActive !== false){
                var last = this.last;
                this.selectRange(this.last,  this.lastActive+1);
                this.grid.getView().focusRow(this.lastActive);
                if(last !== false){
                    this.last = last;
                }
            }else{
                this.selectFirstRow();
            }
            
        },
        scope: this
    });

    var view = this.grid.view;
    view.on("refresh", this.onRefresh, this);
    view.on("rowupdated", this.onRowUpdated, this);
    view.on("rowremoved", this.onRemove, this);
}
	
});

Ext.override(Ext.form.TextField,{
	enableKeyEvents: true

//	initEvents : function(){
//    Ext.form.TextField.superclass.initEvents.call(this);
//    if(this.validationEvent == 'keyup'){
//        this.validationTask = new Ext.util.DelayedTask(this.validate, this);
//        this.el.on('keyup', this.filterValidation, this);
//    }
//    else if(this.validationEvent !== false){
//        this.el.on(this.validationEvent, this.validate, this, {buffer: this.validationDelay});
//    }
//    if(this.selectOnFocus || this.emptyText){
//        this.on("focus", this.preFocus, this);
//        this.el.on('mousedown', function(){
//            if(!this.hasFocus){
//                this.el.on('mouseup', function(e){
//                    e.preventDefault();
//                }, this, {single:true});
//            }
//        }, this);
//        if(this.emptyText){
//            this.on('blur', this.postBlur, this);
//            this.applyEmptyText();
//        }
//    }
//    if(this.maskRe || (this.vtype && this.disableKeyFilter !== true && (this.maskRe = Ext.form.VTypes[this.vtype+'Mask']))){
//        this.el.on("keypress", this.filterKeys, this);
//    }
//    if(this.grow){
//        this.el.on("keyup", this.onKeyUpBuffered,  this, {buffer:50});
//        this.el.on("click", this.autoSize,  this);
//    }
//
//    if(this.enableKeyEvents){
//        this.el.on("keyup", this.onKeyUp, this);
//        this.el.on("keydown", this.onKeyDown, this);
//        this.el.on("keypress", this.onKeyPress, this);
//    	}
//	},
//
//	onKeyDown : function(e){
//	if(e.getKey() == e.ENTER){
//	    
//	} else {
//    this.fireEvent('keydown', this, e);
//		}
//	}
});

Ext.override(Ext.form.ComboBox,{
	forceSelection: true,
    typeAhead: true
});
//wyłączenie przycisków w menu po kliknięciu
Ext.override(Ext.menu.Menu,{
	onClickDisable : true,
	
	onClick : function(e){
	    var t;
	    if(t = this.findTargetItem(e)){
	        if(t.menu && this.ignoreParentClicks){
	            t.expandMenu();
	        }else{
	            t.onClick(e);
	            if(this.onClickDisable){
				    t.disabled = true;
			    	disabledMaskedControls.push(t);
			    	t.enable.defer(3000,t);
				}
	            this.fireEvent("click", this, t, e);
	        }
	    }
	}
});

Ext.MessageBox = function(){
    var dlg, opt, mask, waitTimer;
    var bodyEl, msgEl, textboxEl, textareaEl, progressBar, pp, iconEl, spacerEl;
    var buttons, activeTextEl, bwidth, iconCls = '';

    // private
    var handleButton = function(button){
        if(dlg.isVisible()){
            dlg.hide();
            Ext.callback(opt.fn, opt.scope||window, [button, activeTextEl.dom.value, opt], 1);
        }
    };

    // private
    var handleHide = function(){
        if(opt && opt.cls){
            dlg.el.removeClass(opt.cls);
        }
        progressBar.reset();
    };

    // private
    var handleEsc = function(d, k, e){
        if(opt && opt.closable !== false){
            dlg.hide();
        }
        if(e){
            e.stopEvent();
        }
    };

    // private
    var updateButtons = function(b){
        var width = 0;
        if(!b){
            buttons["ok"].hide();
            buttons["cancel"].hide();
            buttons["yes"].hide();
            buttons["no"].hide();
            return width;
        }
        dlg.footer.dom.style.display = '';
        for(var k in buttons){
            if(typeof buttons[k] != "function"){
                if(b[k]){
                    buttons[k].show();
                    buttons[k].setText(typeof b[k] == "string" ? b[k] : Ext.MessageBox.buttonText[k]);
                    width += buttons[k].el.getWidth()+15;
                }else{
                    buttons[k].hide();
                }
            }
        }
        return width;
    };

    return {
        
        getDialog : function(titleText){
           if(!dlg){
                dlg = new Ext.Window({
                    autoCreate : true,
                    title:titleText,
                    resizable:false,
                    constrain:true,
                    constrainHeader:true,
                    minimizable : false,
                    maximizable : false,
                    stateful: false,
                    pomoc:false,
                    modal: true,
                    shim:true,
                    buttonAlign:"center",
                    width:400,
                    height:100,
                    minHeight: 80,
                    plain:true,
                    footer:true,
                    closable:true,
                    close : function(){
                        if(opt && opt.buttons && opt.buttons.no && !opt.buttons.cancel){
                            handleButton("no");
                        }else{
                            handleButton("cancel");
                        }
                    }
                });
                buttons = {};
                var bt = this.buttonText;
                //TODO: refactor this block into a buttons config to pass into the Window constructor
                buttons["ok"] = dlg.addButton({text: bt["ok"], onClickDisable : false}, handleButton.createCallback("ok"));
                buttons["yes"] = dlg.addButton({text: bt["yes"], onClickDisable : false}, handleButton.createCallback("yes"));
                buttons["no"] = dlg.addButton({text: bt["no"], onClickDisable : false}, handleButton.createCallback("no"));
                buttons["cancel"] = dlg.addButton({text: bt["cancel"], onClickDisable : false}, handleButton.createCallback("cancel"));
                buttons["ok"].hideMode = buttons["yes"].hideMode = buttons["no"].hideMode = buttons["cancel"].hideMode = 'offsets';
                dlg.render(document.body);
                dlg.getEl().addClass('x-window-dlg');
                mask = dlg.mask;
                bodyEl = dlg.body.createChild({
                    html:'<div class="ext-mb-icon"></div><div class="ext-mb-content"><span class="ext-mb-text"></span><br /><div class="ext-mb-fix-cursor"><input type="text" class="ext-mb-input" /><textarea class="ext-mb-textarea"></textarea></div></div>'
                });
                iconEl = Ext.get(bodyEl.dom.firstChild);
                var contentEl = bodyEl.dom.childNodes[1];
                msgEl = Ext.get(contentEl.firstChild);
                textboxEl = Ext.get(contentEl.childNodes[2].firstChild);
                textboxEl.enableDisplayMode();
                textboxEl.addKeyListener([10,13], function(){
                    if(dlg.isVisible() && opt && opt.buttons){
                        if(opt.buttons.ok){
                            handleButton("ok");
                        }else if(opt.buttons.yes){
                            handleButton("yes");
                        }
                    }
                });
                textareaEl = Ext.get(contentEl.childNodes[2].childNodes[1]);
                textareaEl.enableDisplayMode();
                progressBar = new Ext.ProgressBar({
                    renderTo:bodyEl
                });
               bodyEl.createChild({cls:'x-clear'});
            }
            return dlg;
        },

        
        updateText : function(text){
            if(!dlg.isVisible() && !opt.width){
                dlg.setSize(this.maxWidth, 100); // resize first so content is never clipped from previous shows
            }
            msgEl.update(text || '&#160;');

            var iw = iconCls != '' ? (iconEl.getWidth() + iconEl.getMargins('lr')) : 0;
            var mw = msgEl.getWidth() + msgEl.getMargins('lr');
            var fw = dlg.getFrameWidth('lr');
            var bw = dlg.body.getFrameWidth('lr');
            if (Ext.isIE && iw > 0){
                //3 pixels get subtracted in the icon CSS for an IE margin issue,
                //so we have to add it back here for the overall width to be consistent
                iw += 3;
            }
            var w = Math.max(Math.min(opt.width || iw+mw+fw+bw, this.maxWidth),
                        Math.max(opt.minWidth || this.minWidth, bwidth || 0));

            if(opt.prompt === true){
                activeTextEl.setWidth(w-iw-fw-bw);
            }
            if(opt.progress === true || opt.wait === true){
                progressBar.setSize(w-iw-fw-bw);
            }
            if(Ext.isIE && w == bwidth){
                w += 4; //Add offset when the content width is smaller than the buttons.    
            }
            dlg.setSize(w, 'auto').center();
            return this;
        },

        
        updateProgress : function(value, progressText, msg){
            progressBar.updateProgress(value, progressText);
            if(msg){
                this.updateText(msg);
            }
            return this;
        },

        
        isVisible : function(){
            return dlg && dlg.isVisible();
        },

        
        hide : function(){
            var proxy = dlg.activeGhost;
            if(this.isVisible() || proxy) {
                dlg.hide();
                handleHide();
                if (proxy) {
                    proxy.hide();
                } 
            }
            return this;
        },

        
        show : function(options){
            if(this.isVisible()){
                this.hide();
            }
            opt = options;
            var d = this.getDialog(opt.title || "&#160;");

            d.setTitle(opt.title || "&#160;");
            var allowClose = (opt.closable !== false && opt.progress !== true && opt.wait !== true);
            d.tools.close.setDisplayed(allowClose);
            activeTextEl = textboxEl;
            opt.prompt = opt.prompt || (opt.multiline ? true : false);
            if(opt.prompt){
                if(opt.multiline){
                    textboxEl.hide();
                    textareaEl.show();
                    textareaEl.setHeight(typeof opt.multiline == "number" ?
                        opt.multiline : this.defaultTextHeight);
                    activeTextEl = textareaEl;
                }else{
                    textboxEl.show();
                    textareaEl.hide();
                }
            }else{
                textboxEl.hide();
                textareaEl.hide();
            }
            activeTextEl.dom.value = opt.value || "";
            if(opt.prompt){
                d.focusEl = activeTextEl;
            }else{
                var bs = opt.buttons;
                var db = null;
                if(bs && bs.ok){
                    db = buttons["ok"];
                }else if(bs && bs.yes){
                    db = buttons["yes"];
                }
                if (db){
                    d.focusEl = db;
                }
            }
            if(opt.iconCls){
              d.setIconClass(opt.iconCls);
            }
            this.setIcon(opt.icon);
            bwidth = updateButtons(opt.buttons);
            progressBar.setVisible(opt.progress === true || opt.wait === true);
            this.updateProgress(0, opt.progressText);
            this.updateText(opt.msg);
            if(opt.cls){
                d.el.addClass(opt.cls);
            }
            d.proxyDrag = opt.proxyDrag === true;
            d.modal = opt.modal !== false;
            d.mask = opt.modal !== false ? mask : false;
            if(!d.isVisible()){
                // force it to the end of the z-index stack so it gets a cursor in FF
                document.body.appendChild(dlg.el.dom);
                d.setAnimateTarget(opt.animEl);
                d.show(opt.animEl);
            }

            //workaround for window internally enabling keymap in afterShow
            d.on('show', function(){
                if(allowClose === true){
                    d.keyMap.enable();
                }else{
                    d.keyMap.disable();
                }
            }, this, {single:true});

            if(opt.wait === true){
                progressBar.wait(opt.waitConfig);
            }
            return this;
        },

        
        setIcon : function(icon){
            if(icon && icon != ''){
                iconEl.removeClass('x-hidden');
                iconEl.replaceClass(iconCls, icon);
                iconCls = icon;
            }else{
                iconEl.replaceClass(iconCls, 'x-hidden');
                iconCls = '';
            }
            return this;
        },

        
        progress : function(title, msg, progressText){
            this.show({
                title : title,
                msg : msg,
                buttons: false,
                progress:true,
                closable:false,
                minWidth: this.minProgressWidth,
                progressText: progressText
            });
            return this;
        },

        
        wait : function(msg, title, config){
            this.show({
                title : title,
                msg : msg,
                buttons: false,
                closable:false,
                wait:true,
                modal:true,
                minWidth: this.minProgressWidth,
                waitConfig: config
            });
            return this;
        },

        
        alert : function(title, msg, fn, scope){
            this.show({
                title : title,
                msg : msg,
                buttons: this.OK,
                fn: fn,
                scope : scope
            });
            return this;
        },

        
        confirm : function(title, msg, fn, scope){
            this.show({
                title : title,
                msg : msg,
                buttons: this.YESNO,
                fn: fn,
                scope : scope,
                icon: this.QUESTION
            });
            return this;
        },

        
        prompt : function(title, msg, fn, scope, multiline, value){
            this.show({
                title : title,
                msg : msg,
                buttons: this.OKCANCEL,
                fn: fn,
                minWidth:250,
                scope : scope,
                prompt:true,
                multiline: multiline,
                value: value
            });
            return this;
        },

        
        OK : {ok:true},
        
        CANCEL : {cancel:true},
        
        OKCANCEL : {ok:true, cancel:true},
        
        YESNO : {yes:true, no:true},
        
        YESNOCANCEL : {yes:true, no:true, cancel:true},
        
        INFO : 'ext-mb-info',
        
        WARNING : 'ext-mb-warning',
        
        QUESTION : 'ext-mb-question',
        
        ERROR : 'ext-mb-error',

        
        defaultTextHeight : 75,
        
        maxWidth : 600,
        
        minWidth : 100,
        
        minProgressWidth : 250,
        
        buttonText : {
            ok : "OK",
            cancel : "Cancel",
            yes : "Yes",
            no : "No"
        }
    };
}();

Ext.Msg = Ext.MessageBox;

Ext.override(Ext.form.NumberField, {
	
	forceDecimal:true,
	
	initEvents : function(){
        Ext.form.NumberField.superclass.initEvents.call(this);
        var allowed = this.baseChars+',';
        if(this.allowDecimals){
            allowed += this.decimalSeparator;
        }
        if(this.allowNegative){
            allowed += "-";
        }
        this.stripCharsRe = new RegExp('[^'+allowed+']', 'gi');
        var keyPress = function(e){
            var k = e.getKey();
            if(!Ext.isIE && (e.isSpecialKey() || k == e.BACKSPACE || k == e.DELETE)){
                return;
            }
            var c = e.getCharCode();
            if(allowed.indexOf(String.fromCharCode(c)) === -1){
                e.stopEvent();
            }
        };
        this.el.on("keypress", keyPress, this);
    },
    
    validateValue : function(value){
        if(!Ext.form.NumberField.superclass.validateValue.call(this, value)){
            return false;
        }
        if(value.length < 1){ // if it's blank and textfield didn't flag it then it's valid
             return true;
        }
        value = String(value).replace(this.decimalSeparator, ".").replace(",", ".");
        if(isNaN(value)){
            this.markInvalid(String.format(this.nanText, value));
            return false;
        }
        var num = this.parseValue(value);
        if(num < this.minValue){
            this.markInvalid(String.format(this.minText, this.minValue));
            return false;
        }
        if(num > this.maxValue){
            this.markInvalid(String.format(this.maxText, this.maxValue));
            return false;
        }
        return true;
    },
    
    setValue : function(v){
    	if(this.forceDecimal==true){
        	v = typeof v == 'number' ? v : String(v).replace(this.decimalSeparator, ".").replace(",", ".");
    	}else{
    		v = typeof v == 'number' ? v : parseFloat(String(v).replace(this.decimalSeparator, ".").replace(",", "."));
    	}
        v = isNaN(v) ? '' : String(v).replace(".", this.decimalSeparator);
        return Ext.form.NumberField.superclass.setValue.call(this, v);
    },
    
    parseValue : function(value){
        value = parseFloat(String(value).replace(this.decimalSeparator, ".").replace(",", "."));
        return isNaN(value) ? '' : value;
    },
    
    fixPrecision : function(value){
        var nan = isNaN(value);
        if(!this.allowDecimals || this.decimalPrecision == -1 || nan || !value){
           return nan ? '' : value;
        }
        if(this.forceDecimal==true){
        	return parseFloat(value).toFixed(this.decimalPrecision);
        }else{
        	return parseFloat(parseFloat(value).toFixed(this.decimalPrecision));
        }
    }
});

Ext.override(Ext.form.BasicForm, {
	 afterAction : function(action, success){
        this.activeAction = null;
        var o = action.options;
        if(o.waitMsg){
            if(this.waitMsgTarget === true){
                this.el.unmask();
            }else if(this.waitMsgTarget){
                this.waitMsgTarget.unmask();
            }else{
                Ext.MessageBox.updateProgress(1);
                Ext.MessageBox.hide();
            }
        }
        if(success){
            if(o.reset){
                this.reset();
            }
            Ext.callback(o.success, o.scope, [this, action]);
            this.fireEvent('actioncomplete', this, action);
        }else{
            if(this.isValid()){
            	Ext.callback(o.failure, o.scope, [this, action]);
            }else {
            	Ext.Msg.alert('Błąd!', 'Nie wypełniono wszystkich wymaganych pól i/lub nie są poprawnie wypełnione.');
            }
            this.fireEvent('actionfailed', this, action);
        }
    }
});

Ext.override(Ext.grid.EditorGridPanel, {
	forceAfter:false,
	onEditComplete : function(ed, value, startValue){
        this.editing = false;
        this.activeEditor = null;
        ed.un("specialkey", this.selModel.onEditorKey, this.selModel);
		var r = ed.record;
        var field = this.colModel.getDataIndex(ed.col);
        value = this.postEditValue(value, startValue, r, field);
        if(String(value) !== String(startValue) || this.forceAfter){
            var e = {
                grid: this,
                record: r,
                field: field,
                originalValue: startValue,
                value: value,
                row: ed.row,
                column: ed.col,
                cancel:false
            };
            if(this.fireEvent("validateedit", e) !== false && !e.cancel){
                r.set(field, e.value);
                delete e.cancel;
                this.fireEvent("afteredit", e);
            }
        }
        this.view.focusCell(ed.row, ed.col);
    }
});

Ext.override(Ext.DatePicker,{
	onRender : function(container, position){
        var m = [
             '<table cellspacing="0">',
                '<tr><td class="x-date-left"><a href="#" title="', this.prevText ,'">&#160;</a></td><td class="x-date-middle" align="center"></td><td class="x-date-right"><a href="#" title="', this.nextText ,'">&#160;</a></td></tr>',
                '<tr><td colspan="3"><table class="x-date-inner" cellspacing="0"><thead><tr>'];
        var dn = this.dayNames;
        for(var i = 0; i < 7; i++){
            var d = this.startDay+i;
            if(d > 6){
                d = d-7;
            }
            m.push("<th><span>", dn[d].substr(0,1), "</span></th>");
        }
        m[m.length] = "</tr></thead><tbody><tr>";
        for(var i = 0; i < 42; i++) {
            if(i % 7 == 0 && i != 0){
                m[m.length] = "</tr><tr>";
            }
            m[m.length] = '<td><a href="#" hidefocus="on" class="x-date-date" tabIndex="1"><em><span></span></em></a></td>';
        }
        m.push('</tr></tbody></table></td></tr>', 
                this.showToday ? '<tr><td colspan="3" class="x-date-bottom" align="center"></td></tr>' : '', 
                '</table><div class="x-date-mp"></div>');

        var el = document.createElement("div");
        el.className = "x-date-picker";
        el.innerHTML = m.join("");

        container.dom.insertBefore(el, position);

        this.el = Ext.get(el);
        this.eventEl = Ext.get(el.firstChild);

        this.leftClickRpt = new Ext.util.ClickRepeater(this.el.child("td.x-date-left a"), {
            handler: this.showPrevMonth,
            scope: this,
            preventDefault:true,
            stopDefault:true
        });

        this.rightClickRpt = new Ext.util.ClickRepeater(this.el.child("td.x-date-right a"), {
            handler: this.showNextMonth,
            scope: this,
            preventDefault:true,
            stopDefault:true
        });

        this.eventEl.on("mousewheel", this.handleMouseWheel,  this);

        this.monthPicker = this.el.down('div.x-date-mp');
        this.monthPicker.enableDisplayMode('block');
        
        var kn = new Ext.KeyNav(this.eventEl, {
            "left" : function(e){
                e.ctrlKey ?
                    this.showPrevMonth() :
                    this.update(this.activeDate.add("d", -1));
            },

            "right" : function(e){
                e.ctrlKey ?
                    this.showNextMonth() :
                    this.update(this.activeDate.add("d", 1));
            },

            "up" : function(e){
                e.ctrlKey ?
                    this.showNextYear() :
                    this.update(this.activeDate.add("d", -7));
            },

            "down" : function(e){
                e.ctrlKey ?
                    this.showPrevYear() :
                    this.update(this.activeDate.add("d", 7));
            },

            "pageUp" : function(e){
                this.showNextMonth();
            },

            "pageDown" : function(e){
                this.showPrevMonth();
            },

            "enter" : function(e){
                e.stopPropagation();
                return true;
            },

            scope : this
        });

        this.eventEl.on("click", this.handleDateClick,  this, {delegate: "a.x-date-date"});

        this.el.unselectable();
        
        this.cells = this.el.select("table.x-date-inner tbody td");
        this.textNodes = this.el.query("table.x-date-inner tbody span");

        this.mbtn = new Ext.Button({
            text: "&#160;",
            tooltip: this.monthYearText,
            renderTo: this.el.child("td.x-date-middle", true)
        });

        this.mbtn.on('click', this.showMonthPicker, this);
        this.mbtn.el.child(this.mbtn.menuClassTarget).addClass("x-btn-with-menu");

        if(this.showToday){
            this.todayKeyListener = this.eventEl.addKeyListener(Ext.EventObject.SPACE, this.selectToday,  this);
            var today = (new Date()).dateFormat(this.format);
            this.todayBtn = new Ext.Button({
                renderTo: this.el.child("td.x-date-bottom", true),
                text: String.format(this.todayText, today),
                tooltip: String.format(this.todayTip, today),
                handler: this.selectToday,
                onClickDisable : false,
                scope: this
            });
        }
        
        if(Ext.isIE){
            this.el.repaint();
        }
        this.update(this.value);
    }
});

/*
 * Rozszerzenie pola textfield w celu podpowiadania "-" do numerów telefonów.
 */

Ext.ux.TelefonField = Ext.extend(Ext.form.TextField, {
	init:function(e){
		if(e.stacjonarny){
			e.on('keyup',this.sprawdzanieTelefonu);
		}else{
			e.on('keyup',this.sprawdzanieKomorkowego);
		}
	},
	sprawdzanieTelefonu:function(evt,t,o){
		var v = this.getValue();
		if(v.length==2){
			this.setValue(v+'-');
		}else if(v.length==6){
			this.setValue(v+'-');
		}else if(v.length==9){
			this.setValue(v+'-');
		}
	},
	sprawdzanieKomorkowego:function(evt,t,o){
		var v = this.getValue();
		if(v.length==3){
			this.setValue(v+'-');
		}else if(v.length==7){
			this.setValue(v+'-');
		}
	}
});

/**
 * Provides a drop down field with multiple checkboxes
 * @author Tony Landis http://www.tonylandis.com/
 * @copyright Free for all use and modification. The author and copyright must be remain intact here.
 *
 * @class Ext.form.MultiSelectField
 * @extends Ext.form.TriggerField
 */
Ext.form.MultiSelectField = Ext.extend(Ext.form.TriggerField,  {
    triggerClass : 'x-form-trigger', 
    defaultAutoCreate : {tag: "input", type: "text", size: "10", autocomplete: "off"},
    readOnly: true, 
    lazyInit : false,
    hiddenValue: '',
    value: null,
    valueSeparator: ',',
    textSeparator: ';',
    loadingText: 'Loading list...', 
    
    
    // store defaults
    store: null, 
    mode: 'remote',
    valueField: 'value',
    displayField: 'text',
           
    initComponent : function(){  
        Ext.form.MultiSelectField.superclass.initComponent.call(this);  
 
        //auto-configure store from local array data 
        if(Ext.isArray(this.store)){ 
			if (Ext.isArray(this.store[0])){
				this.store = new Ext.data.SimpleStore({
					id: 'value',
				    fields: ['value','text'],
				    data: this.store
				});
		        this.valueField = 'value';
			}else{
				this.store = new Ext.data.Store({
					id: 'text',
				    fields: ['text'],
				    data: this.store,
				    expandData: true
				});
		        this.valueField = 'text';
			}
			this.displayField = 'text';
			this.mode = 'local';
		} 
    }, 
    
     
    onRender : function(ct, position){ 
        Ext.form.MultiSelectField.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);
            this.hiddenField.value =
                this.hiddenValue !== undefined ? this.hiddenValue :
                this.value !== undefined ? this.value : '';

            // prevent input submission
            this.el.dom.removeAttribute('name');
        }
        
		// build the menu
        if(this.menu == null) 	
        { 
        	this.menu = new Ext.menu.Menu({onClickDisable:false}); 
        	this.store.each(function(r) { 
        		this.menu.add(
        			new Ext.menu.CheckItem({
        				text: r.data[this.displayField],
        				value: r.data[this.valueField], 
        				hideOnClick: false
        			})
        		).on('click', this.clickHandler, this);  
        	}, this); 
        }
 
        if(!this.lazyInit){
           //this.populateList(this.value);
        }else{
            //this.on('focus', this.setValues, this, {single: true});
        } 
    },  
     
    
    
    onTriggerClick : function(){ 
        if(this.disabled){
            return;
        } 
        this.menu.show(this.el, "tl-bl?");
        this.populateList(this.value); 
    },    
     
    validateBlur : function(){ 
        return !this.menu || !this.menu.isVisible();
    },
     
    getValue : function(){   
    	if(this.hiddenField){
    		return this.hiddenField.value || "";    	
    	}else if(this.valueField){
            return typeof this.value != 'undefined' ? this.value : '';
        }else{
            return Ext.form.MultiSelectField.superclass.getValue.call(this);
        } 
    },
    
    setValue : function(value, text){ 
    	if(text == undefined && value != undefined) {  
    		this.setValues(value.split(this.valueSeparator));
    		return;
    	} if(value==undefined) {
    		value='';
    		text='';
    	}
    	
    	this.lastSelectionText = text;
        if(this.hiddenField){
            this.hiddenField.value = value;
        }
        Ext.form.MultiSelectField.superclass.setValue.call(this, text);
        this.value = value;    	
    },
    
    setValues : function(keys){ 
    	// assemble full text and hidden value
    	var text  = '';
    	var value = '';
    	for(var i=0; i<keys.length; i++) 
    	{
    		if(keys[i] != undefined)
    		{
	    		// get the full store object
	    		var item = this.store.query(this.valueField, keys[i]).items[0];
	    		if(item != undefined) {
		   			value += (value!='' ? this.valueSeparator:'') + item.data[this.valueField] ;
		    		text += (text!='' ? this.textSeparator:'') + item.data[this.displayField];  
	    		}
    		}
    	}
		this.setValue(value,text);   
    },  
    
    selPush : function(key) {   
    	// rip current value into array
    	var keys = this.value.split(this.valueSeparator);
    	var i = keys.length++;
    	keys[i] = key; 
    	this.setValues(keys);
    },
    
    selDrop : function(key) {
    	// rip current value into array
    	var keys = this.value.split(this.valueSeparator);
    	for(var i=0; i<keys.length; i++) { 
    		if(keys[i].toString() == key.toString()) { 
    			keys[i]=undefined;
    		}
    	}  
    	this.setValues(keys);
    }, 

    onDestroy : function(){  
        if(this.menu) {
            this.menu.destroy();
        }
        if(this.wrap){
            this.wrap.remove();
        }
        Ext.form.MultiSelectField.superclass.onDestroy.call(this);
    }, 
    
    clickHandler: function(i,c){ 
        if(i.checked == false){ 
        	this.selPush(i.value, i.text); 
        } else { 
        	this.selDrop(i.value);
        }
   	}, 

    populateList: function(v)  { 
    	if(v==undefined || v==null) v=this.value;
    	 
    	// uncheck everything
    	if(this.menu) {
	    	this.menu.items.each(function(item) 
	    	{
	    		item.setChecked(false);
	    	});
    	}  
    	  
		// populate preset values
		if(v != undefined && v != '' && v!=null) 
		{   
			var sel = v.split(this.valueSeparator); 
			for(i=0; i<sel.length; i++) 
			{  
				try {
					var value = this.store.query(this.valueField, sel[i]).items[0].data[this.valueField];
					this.menu.items.each(function(mi){ 
						if(mi.value == value) mi.setChecked(true); 
					}, this); 
				}catch(e) { }
			} 
		} 
    }
});

Ext.reg('multiselect', Ext.form.MultiSelectField);


/*!
 * Ext JS Library 3.0+
 * Copyright(c) 2006-2009 Ext JS, LLC
 * licensing@extjs.com
 * http://www.extjs.com/license
 */
Ext.ns('Ext.ux.grid');

/**
 * @class Ext.ux.grid.CheckColumn
 * @extends Object
 * GridPanel plugin to add a column with check boxes to a grid.
 * <p>Example usage:</p>
 * <pre><code>
// create the column
var checkColumn = new Ext.grid.CheckColumn({
   header: 'Indoor?',
   dataIndex: 'indoor',
   id: 'check',
   width: 55
});

// add the column to the column model
var cm = new Ext.grid.ColumnModel([{
       header: 'Foo',
       ...
    },
    checkColumn
]);

// create the grid
var grid = new Ext.grid.EditorGridPanel({
    ...
    cm: cm,
    plugins: [checkColumn], // include plugin
    ...
});
 * </code></pre>
 * In addition to storing a Boolean value within the record data, this
 * class toggles a css class between <tt>'x-grid3-check-col'</tt> and
 * <tt>'x-grid3-check-col-on'</tt> to alter the background image used for
 * a column.
 */
Ext.ux.grid.CheckColumn = function(config){
    Ext.apply(this, config);
    if(!this.id){
        this.id = Ext.id();
    }
    this.renderer = this.renderer.createDelegate(this);
};

Ext.ux.grid.CheckColumn.prototype ={
    init : function(grid){
        this.grid = grid;
        this.grid.on('render', function(){
            var view = this.grid.getView();
            view.mainBody.on('mousedown', this.onMouseDown, this);
        }, this);
    },

    onMouseDown : function(e, t){
        if(t.className && t.className.indexOf('x-grid3-cc-'+this.id) != -1){
            e.stopEvent();
            var index = this.grid.getView().findRowIndex(t);
            var record = this.grid.store.getAt(index);
            record.set(this.dataIndex, !record.data[this.dataIndex]);
        }
    },

    renderer : function(v, p, record){
        p.css += ' x-grid3-check-col-td'; 
        return '<div class="x-grid3-check-col'+(v?'-on':'')+' x-grid3-cc-'+this.id+'">&#160;</div>';
    }
};

// register ptype
Ext.reg('checkcolumn', Ext.ux.grid.CheckColumn);

// backwards compat
Ext.grid.CheckColumn = Ext.ux.grid.CheckColumn;

//Wyłączenie menu pod prawym przyciskiem myszy
function onContextMenu(e, target) {
	e.preventDefault();
};

/*
*Zmiana  pierwszej litery na dużą.
*/

function NazwyWlasne(pole){
	var str = pole.getValue();
	str = str.slice(0,1).toUpperCase() + str.slice(1);
	return (pole.setValue(str));
	}

/*
 *Funkcja ShowWindow wczytuje okno, nastepnie je wyswietla.
 */
 
function ShowWindow(WindowName,parametryOkna) {
	 
	if (Ext.isEmpty(parametryOkna)==true) {
	 
		parametryOkna=false;
	 
	}
	 
	Ext.Ajax.request({
		url: getHost() + 'silnik/silnikWeryfikacjaOkien.php',
		method: 'post',
		params:{okno:WindowName},
		success: function(result, request) {
		 	var Jresponse = Ext.util.JSON.decode(result.responseText);
		 	Jresponse = Jresponse.window(parametryOkna);
		 	Jresponse = null;
		 	return result.responseText = null
	 	},
	    failure: function(result, request) {
	 		alert("Wystąpił problem z wybranym adresem URL.");
	 	}
			
	});
}
 /*----------------------------------------------------------------------------------------------*/
function ShowWindowFromPanel(WindowName,el) {
	 
	Ext.Ajax.request({
		url: getHost() + 'silnik/silnikWeryfikacjaOkien.php',
		method: 'post',
		params:{okno:WindowName},
		success: function(result, request) {
			if (typeof(Ext.getCmp('kolo'))!=='undefined') {
				Ext.getCmp('kolo').hide();
			}
	    	el.el.on("click", function() {
    			ShowWindowFromPanel(WindowName,el);
    		},
    		this,{single:true});
	    	var Jresponse = Ext.util.JSON.decode(result.responseText);
	        Jresponse = Jresponse.window();
	        Jresponse = null;
	        return result.responseText = null
	 	},
	    failure: function(result, request) {
	 		alert("Wystąpił problem z wybranym adresem URL.");
	 	}
			
	});
}

/*
 * Funkcja HideKolo ukrywa okragłe menu po kliknieciu na jakiekolwiek miejsce w aplikacji innym niż okrągłe menu
 */

function HideKolo(evt,t){
	var naKole = false;
	while(t.tagName !== 'body' || t.tagName !== 'BODY'){
		if(t.id == 'kolo' || t.id == 'buttonPierwszy' || t.id == 'buttonDrugi' || t.id == 'buttonTrzeci' || t.id == 'buttonCzwarty' || t.id == 'buttonPiaty'){
			naKole = true
			break;
		}
		if(Ext.isEmpty(t.parentNode)){
			break;
		}else{
			t=t.parentNode;
		}
	}
	if(typeof(Ext.getCmp('kolo'))!=='undefined' && naKole == false){
		Ext.getCmp('kolo').hide();
	}
}

 /*-----------------------------------------------------------------------------------------------*/
 

/*
 * Funkcja Wyszukiwanie pobiera z formularza wyszukiwania wypelnione pola i przeładowuje store używając ich jako parametrów wyszukiwania.
 */
function Wyszukiwanie(formularz,store,limit){
  	var polaWyszukania = Ext.fly(formularz.body).select('input');
	var filtr = '{';
	polaWyszukania.each(function(el){
		if(Ext.isEmpty(el.dom.value) == false && Ext.isEmpty(el.dom.name) == false && el.dom.value !== '>>WSZYSTKIE<<' && el.dom.value !== '>>WSZYSCY<<'){
			filtr+='"'+el.dom.name+'":"'+el.dom.value+'",';
		}
	});
	if(filtr.length>1){
		filtr = filtr.substring(0, filtr.length - 1);
	}
	filtr += '}';
	store.load({params:{
		start: 0,
		limit: limit,
		filtr: filtr,
		akcja:'lista'
      }
	});
}
 
 function check_pesel(pesel) {

		var factor = new Array(1,3,7,9,1,3,7,9,1,3);

		s = 0;

		for (i=0;i<=9;i++)
		s += pesel.charAt(i)*factor[i];


		eleven = (10-s%10)%10;
		if (eleven==pesel.charAt(10)){
		return true;}
		else{
		return false;}
}

function SprawdzRachunek(rachunek) {
	if (rachunek.length == 26) {
		return true;
	} else {
		return false;
	}
}

function SprawdzNip(nip) {
	while (nip.indexOf('-') != -1) {
		nip = nip.replace('-', '');
	}
	if (nip.length == 10) {
		return true;
	} else {
		return false;
	}
}

function SprawdzRegon(regon) {
	if (regon.length == 9) {
		return true;
	} else {
		return false;
	}
}

function getHost() {
	var url = window.location.href;
	var urlparts = url.split("/");
	var p = '';
	for(i in urlparts){
	p +=urlparts[i]+"/";
		if ( urlparts[i].indexOf("lingis") !== -1 ) {
			break;
		}	
	}			
	return p;
}

function OstatniDzienMiesiaca	(miesiac){
	miesiac = parseFloat(miesiac)-1
	return (new Date(new Date(new Date().format('Y'),miesiac+1)-1))
}


/*
 *Typy weryfikacji dla pól formularza
 */

Ext.form.VTypes["literyVal"] = /^[a-zA-ZąćęłńóśźżĄĆĘŁŃÓŚŹŻ \-]*$/;
Ext.form.VTypes["literyMask"] = /[a-zA-ZąćęłńóśźżĄĆĘŁŃÓŚŹŻ \-]/;
Ext.form.VTypes["literyText"] = 'Prosze nie wpisywa cyfr i znaków specjalnych';
Ext.form.VTypes["litery"]=function(v){return Ext.form.VTypes["literyVal"].test(v);};

Ext.form.VTypes["literyICyfryVal"] = /^[0-9a-zA-ZąćęłńóśźżĄĆĘŁŃÓŚŹŻ \-\.\,]*$/;
Ext.form.VTypes["literyICyfryMask"] = /[0-9a-zA-ZąćęłńóśźżĄĆĘŁŃÓŚŹŻ \-\.\,]/;
Ext.form.VTypes["literyICyfry"]=function(v){return Ext.form.VTypes["literyICyfryVal"].test(v);};

Ext.form.VTypes["stawkiVatVal"] = /^[0-9a-zA-ZąćęłńóśźżĄĆĘŁŃÓŚŹŻ \-\.\,\%\+]*$/;
Ext.form.VTypes["stawkiVatMask"] = /[0-9a-zA-ZąćęłńóśźżĄĆĘŁŃÓŚŹŻ \-\.\,\%\+]/;
Ext.form.VTypes["stawkiVat"]=function(v){return Ext.form.VTypes["stawkiVatVal"].test(v);};

Ext.form.VTypes["telefonVal"] = /^[0-9]{2}-[0-9]{3}-[0-9]{2}-[0-9]{2}$/;
Ext.form.VTypes["telefonMask"] = /[-0-9]/;
Ext.form.VTypes["telefonText"] = 'Zły format numeru telefonu.Prosze podac numer w formacie : XX-XXX-XX-XX';
Ext.form.VTypes["telefon"]=function(v){ return Ext.form.VTypes["telefonVal"].test(v); };


Ext.form.VTypes["telefon_kVal"] = /^\d{3}\-\d{3}\-\d{3}$/;
Ext.form.VTypes["telefon_kMask"] = /[-0-9]/;
Ext.form.VTypes["telefon_kText"] = 'Zły format numeru telefonu.Prosze wpisac numer w formacie : XXX-XXX-XXX';
Ext.form.VTypes["telefon_k"]=function(v){return Ext.form.VTypes["telefon_kVal"].test(v);};

Ext.form.VTypes["kod_pocztowyVal"] = /^\d{2}\-\d{3}$/;
Ext.form.VTypes["kod_pocztowyMask"] = /[-0-9]/;
Ext.form.VTypes["kod_pocztowyText"] = 'Zły format kodu pocztowego.Prosze podac kod pocztowy w formacie : XX-XXX';
Ext.form.VTypes["kod_pocztowy"]=function(v){return Ext.form.VTypes["kod_pocztowyVal"].test(v);};

Ext.form.VTypes["cyfryVal"] = /[0-9.,]$/;
Ext.form.VTypes["cyfryMask"] = /[.,0-9]/;
Ext.form.VTypes["cyfryText"] = 'Prosze wpisać poprawną wartość';
Ext.form.VTypes["cyfry"]=function(v){return Ext.form.VTypes["cyfryVal"].test(v);};

