Ext.lib.Ajax.forceActiveX = true;
Ext.BLANK_IMAGE_URL = './core/images/s.gif'; 

Ext.onReady(function(){

	
	Ext.QuickTips.init();
	Ext.state.Manager.setProvider(new Ext.state.CookieProvider());
	
	Ext.app.SearchField = Ext.extend(Ext.form.TwinTriggerField, {
	    initComponent : function(){
	        Ext.app.SearchField.superclass.initComponent.call(this);
	        this.on('specialkey', function(f, e){
	            if(e.getKey() == e.ENTER){
	                this.onTrigger2Click();
	            }
	        }, this);
	    },
	
	    validationEvent:false,
	    validateOnBlur:false,
	    trigger1Class:'x-form-clear-trigger',
	    trigger2Class:'x-form-search-trigger',
	    hideTrigger1:true,
	    width:180,
	    hasSearch : false,
	    paramName : 'query',
	
	    onTrigger1Click : function(){
	        if(this.hasSearch){
	            this.el.dom.value = '';
	            var o = {id: this.id, id_domain: this.id_domain, start: 0, limit: 25};
	            this.store.baseParams = this.store.baseParams || {};
	            this.store.baseParams[this.paramName] = '';
	            this.store.reload({params:o});
	            this.triggers[0].hide();
	            this.hasSearch = false;
	        }
	    },
	
	    onTrigger2Click : function(){
	        var v = this.getRawValue();
	        if(v.length < 1){
	            this.onTrigger1Click();
	            return;
	        }
	        var o = {id: this.id, id_domain: this.id_domain, start: 0, limit: 25};
	        this.store.baseParams = this.store.baseParams || {};
	        this.store.baseParams[this.paramName] = v;
	        this.store.reload({params:o});
	        this.hasSearch = true;
	        this.triggers[0].show();
	    }
	});
	
	var viewport = new Ext.Viewport({
		layout:'border',
		loadMask: true,
		items:[
			{
				region: 'north',
				bodyStyle: 'text-align:right;',
				html: '<span> Добро пожаловать, <b>'+User_Name+'</b> > [ <a class="hlinks" href="index.php?logout=true">Выход</a> ] </span>',
				frame:true,
				margins: '5 5 0 5'
			},
			new Ext.TabPanel({
				id:'main-tabs',
				region:'center',
				deferredRender:false,
				margins:'5 0 5 0',
				enableTabScroll:true,
				activeTab:0,
				items:[{
					title: 'Главная',
					autoScroll:true,
					layout: 'absolute',
					defaults: {
						bodyStyle: 'padding:15px;',
						width: 200,
						height: 100,
						frame: true
					},
					items:[{
					    title: 'Ghost',
					    x: '43%',
					    y: '35%',
					    html: '<center>Версия: '+Version+' <br> Создатель <a href="http://filingsa.net" target="_blank">filings</a></center>'
					}]
				}]
			}),
			tree
		]
	});
	
	
});