﻿/// <reference path="vswd-ext_2.1.js"/>
/// <reference path="ImageButton.js" />

Ext.onReady(function()
{

var xmlData = new Ext.data.XmlReader({
   record: 'reg',
   totalRecords:'/Total/Total/'
}, ['Link','Titulo','Introducao','Secao']);


var ds = new Ext.data.Store({
    url: '/busca.aspx',
    reader: xmlData,
    autoLoad:true
});

// como item de um FormPanel 

    // Custom rendering Template
    var resultTpl = new Ext.XTemplate(
        '<tpl for="." style="text-align:left"><div class="search-item" style="text-align:left; padding:3px;">',
            '<div style="padding:4px; margin:5px;"><h3>&bull; {Secao} / {Titulo}</h3>{Introducao}</div>',
        '</div></tpl>'
    );
        
var top = new Ext.FormPanel({
        url: 'Busca.aspx',
        width: 200,
        border: false,
        items: [ 
 new Ext.form.ComboBox({
        store: ds,
        name:'CriterioBusca',
        displayField:'title',
        hideLabel : true,
        typeAhead: false,
        loadingText: 'Aguarde, buscando informações...',
        pageSize:10,
        width: 185,
        listWidth: 500,
        fieldClass: 'TxtBusca',
        listAlign:'tr-br',
        renderTo:'TxtBusca',
        hideTrigger:true,
        itemSelector: 'div.search-item',
        tpl: resultTpl,
	emptyText:'Busque no web site',
	        onSelect: function(record){ // override default onSelect to do redirect
            window.location =
                String.format(record.data.Link);
        }

    })
    ]
   });



});