﻿//Extendemos la clase listbox para que lance un evento cuando cambie el valor seleccionado
//Al crear un nuevo objeto listboxExtended se le debe pasar como parámetro,
//la función que se ejecutará cuando el valor de la lista cambie 
//(solo funcionará si se utilizan las funciones setValue o setIndex para cambiar el valor)
function listboxExtended(onValueChangedCallBack)
{
    this.setValue = lst_setValue;
    this.setIndex = lst_setIndex;
    this.onValueChanged = onValueChangedCallBack;
}
listboxExtended.prototype = new listbox();

function lst_setValue(value)
{
    for (i=0;i<this.object.options.length;i++)
    {
	    if (this.object.options[i].value==value)
	    {
		    this.object.options[i].selected = true;
		    break;
        }
    }
   this.onValueChanged(this, value)
   return;
}

function lst_setIndex(index)
{
   this.object.options.selectedIndex = index;
   this.onValueChanged(this, this.object.options[index].value);
   return;
}

