Bill.reg.SpamActions = Ext.extend(Ext.form.CompositeField, {
    initComponent: function() { 
        this.url =  'captcha/cap.php'; 
	//this.url = BillextHome + 'lib/captcha/cap.php';  
	//console.log(this.url);
        
        this.image = new Ext.Panel({
            html: "<img src='" + this.url + "?PHPSESSID='"+ Ext.id() +">",
            border: false,
            width: 170,
            height: 70
            //flex: 1
        });

        this.key = new Ext.form.TextField({
            xtype: 'textfield',
            name: 'userKey',
            allowBlank: false,
            width: 100
            //flex: 2
        });
    
        Ext.apply(this, {
            hideLabel: true,
            items: [
                this.image,
            {
                xtype: 'button',
                iconCls: 'arrow-circle-double-135',
                handler: this.update,
                scope: this
            },
               this.key  
            ]   
        });
        Bill.reg.SpamActions.superclass.initComponent.apply(this, arguments); 
    },
    
    reset: function() {
        this.update();
        this.key.reset();           
    },

    update: function() {
        var val = Ext.id();
        var html = "<img src='" + this.url +"?key=" + val + "'>";
        this.image.update(html, true); 
    }
});
Ext.reg('bill-reg-spamactions', Bill.reg.SpamActions);


Bill.reg.SpamFilter = Ext.extend(Bill.reg.FieldSet, {
    initComponent: function() {    
        Ext.apply(this, {
            title: 'Защита от спама. Введите текст картинки:',
            items: [{
                xtype: 'bill-reg-spamactions'
            }]
        });
        Bill.reg.SpamFilter.superclass.initComponent.apply(this, arguments);
        this.spam = this.items.itemAt(0);
    },
    
    reset: function() {
        this.spam.reset();
    }
});
Ext.reg('bill-reg-spam-filter', Bill.reg.SpamFilter);


