/*
 * Ext JS Library 2.0
 * Copyright(c) 2006-2007, Ext JS, LLC.
 * licensing@extjs.com
 * 
 * http://extjs.com/license
 */

Ext.onReady(function(){

				Ext.QuickTips.init();
				
				Ext.BLANK_IMAGE_URL = url + '/bibliotecas/extjs/resources/images/default/s.gif';

   if (Ext.get('div-marca')) {
								// Marca
								var dsMarca = new Ext.data.Store({
												proxy: new Ext.data.ScriptTagProxy({
																url: url + '/modulos/marca/marca.listar.php?loja=' + lojaId
												}),
												reader: new Ext.data.JsonReader({
																root: 'resultado',
																totalProperty: 'total',
																fields: [
																				{name: 'id', type: 'int'},
																				{name: 'titulo', type: 'string'}
																]
												}),
												remoteSort: true
								});
								dsMarca.setDefaultSort('titulo', 'asc');
								dsMarca.load();
				
								// ComboBox Marca
								var marca = new Ext.form.ComboBox({
												fieldLabel: 'Escolha por marca',
												labelStyle: 'font-weight:bold;',
												hiddenName: 'marca',
												store: dsMarca,
												valueField: 'id',
												displayField: 'titulo',
												typeAhead: true,
												mode: 'remote',
												triggerAction: 'all',
												emptyText: 'Escolha...',
												selectOnFocus: true,
												editable: false,
												anchor: '100%'
								});
				
								// Form ----------------------------------------------------
								var formMarca = new Ext.FormPanel({
												el: 'div-marca',
												bodyStyle: 'background-color:transparent;',
												autoWidth: true,
												labelAlign: 'top',
												labelWidth: 45,
												border: false,
												autoWidth: true,
												autoHeight: true,
												items: [marca]
								});
				
								formMarca.render();
				
								marca.on('select', function(){
															window.location = url + '/?loja=' + lojaId + '&modulo=marca&mostrar=marca&marca=' + marca.getValue();
											}
								);
			}
});