﻿derive(InputLookup, ClassDataInput);
function InputLookup() {

    this.Items = new Object();

    override(this, 'Init');
    this.Init = function() {
        this.ClassDataInput_Init(arguments[0],arguments[1],arguments[2],arguments[3]);
        if(Designer_obj) {
            this.Property_Add(1, 'Lista', 'PlainText', 'ItemsList', 'ItemsList');
            this.Property_Add(40, 'Campo', 'Field', 'DataItemFieldOne', 'DataItemFieldOne');
            this.Property_Add(41, 'Alineaci&oacute;n', 'Combo', 'HAlign', 'HAlign', 'Left,Center,Right');
            this.Property_Add(42, 'Cambio de linea', 'Checkbox', 'Wordwrap', 'Wordwrap');
            this.Property_Add(43, 'Tipo', 'Combo', 'Type', 'Type', '0|PlainText,1|Id de Cuenta,2|RichText');
            this.Property_Add(44, 'Permite vacio', 'Combo', 'BlankItem', 'BlankItem', '1|Si,0|No');
        }
    }

    this.RenderSelection = function(aMark) {
        if(aMark && this.get_SelectedIndex() >= 0 && this.get_DataKeys().length && this.get_DataKeys().length > 0) {
            document.getElementById(this.ClientId).innerHTML = this.Items['Key' + this.get_DataKeys()[this.get_SelectedIndex()]];
        } else
            document.getElementById(this.ClientId).innerHTML = '';
    }

    this.set_Focus = function() {
        
    }
    
    this.set_HAlign = function(aValue) {
        var lref = document.getElementById(this.ClientId);
        lref.style.textAlign = aValue;
        this.Frm[this.FrmCount + 1] = this.get_HAlign();
    }
    this.get_HAlign = function() {
        var lref = document.getElementById(this.ClientId);
        return lref.style.textAlign.substr(0,1).toUpperCase() + lref.style.textAlign.substr(1);
    }
    
    this.get_DataItemField = function() {
        return this.Frm[this.FrmCount + 2];
    }
    
    this.set_DataItemField = function(aValue) {
        this.Frm[this.FrmCount + 2] = aValue;
    }

    this.get_DataItemFieldOne = function() {
        return this.Frm[this.FrmCount + 2].split('_')[0].split('.')[0];
    }
    this.set_DataItemFieldOne = function(aValue) {
        this.Frm[this.FrmCount + 2] = aValue;
    }
    
    this.set_ItemsList = function(aValue) {
        /*this.Items = new Object();
        var lDataKeys = new Array();
        var lArr = aValue.split('\r\n');
        for(var i = 0; i < lArr.length; i++) {
            this.Items['Key' + i] = lArr[i];
            lDataKeys[i] = i.toString();
        }
        this.set_DataKeys(lDataKeys);
        if(this.get_SelectedIndex() == -1)
            this.set_SelectedIndex(0);
        this.RenderSelection(true);
        this.Frm[this.FrmCount + 3] = aValue;*/
        this.Frm[this.FrmCount + 3] = aValue;
        if(Designer_obj)
            setTimeout('Designer_obj.Render()',500);
    }
    this.get_ItemsList = function() {
        /*var lRes = '';
        for(var att in this.Items)
            lRes += (lRes == '' ? '' : '\r\n') + this.Items[att];*/
        return this.Frm[this.FrmCount + 3];
    }    
    
    this.set_Wordwrap = function(aValue) {
        var lref = document.getElementById(this.ClientId);
        lref.style.wordWrap = aValue ? 'break-word' : '';
        this.Frm[this.FrmCount + 4] = aValue;
    }
    this.get_Wordwrap = function() {
        return this.Frm[this.FrmCount + 4];
    }
    
	this.set_HiddenClient = function(aValue) {
        var lref = document.getElementById(this.ClientId);
        lref.style.display = aValue ? 'none' : 'inline-block';
	}

    this.get_Type = function() {
        return this.Frm[this.FrmCount + 5];
    }
    this.set_Type = function(aValue) {
        this.Frm[this.FrmCount + 5] = aValue;
    }

    this.get_BlankItem = function() {
        return this.Frm[this.FrmCount + 6];
    }
    this.set_BlankItem = function(aValue) {
        this.Frm[this.FrmCount + 6] = aValue;
    }
}

