﻿/// <reference path="ImageButton.js" />

Ext.onReady(function() {
    Ext.QuickTips.init();
    Ext.form.Field.prototype.msgTarget = 'qtip';

    var txtReferencia = new Ext.form.TextField({
        id: 'txtReferencia',
        name: 'txtReferencia',
        labelSeparator: '',
        width: 115,
        emptyText: 'Digite a referência',
        renderTo: 'divTxtBuscaRef',
        tabIndex: 1
    });

    var btnPesquisar = new Ext.ImageButton({
        id: 'btnPesquisar',
        text: 'OK',
        imgPath: '/img/btn_ok2.jpg',
        tooltip: 'OK',
        tabIndex: 2,
        renderTo: 'divBotaoBuscaRef',
        handler: function() {
            if (FormBusca.form.isValid())
                if (!isNaN(txtReferencia.getValue()) && txtReferencia.isValid() && txtReferencia.getValue() != "")
                    window.location = 'Detalhe_Imovel.aspx?IdRef=' + txtReferencia.getValue();
            else
                Ext.Msg.alert('Locall Imóveis - Pesquisa', 'Digite o numero da referencia para pesquisar.');
        }
    });

    var FormBusca = new Ext.form.FormPanel({
        labelWidth: 1,
        url: 'Detalhe_Imovel.aspx',
        width: 150,
        border: false,
        frame: false,
        defaultType: 'textfield',
        bodyStyle: 'background-color: transparent;',
        items: [
            txtReferencia
        ],
        buttons: [
            btnPesquisar
        ]
    });
});