﻿//-------------------- lazySelect.js

function LazySelect(id) {
    this.id = id;
    this.select = document.getElementById(id);

    this.selectedIndex = 0;
    if (this.select.selectedIndex >= 0)
    {
        this.currentValue = this.select.options[this.select.selectedIndex].value;
        this.currentText = this.select.options[this.select.selectedIndex].text;
    }

    this.show = false;

    var thisObj = this;
    this.select.onchange = function() { thisObj.selectChanged() };
    this.select.onfocus = function() { thisObj.selectFocused() };
}

LazySelect.prototype = {
    
    selectChanged: function() {
        // call LazySelect_onChange "event" in calling page
        if ( typeof( window.LazySelect_onChange ) == 'function' )
        {
           window.LazySelect_onChange( this ) ;
        }
    
    },

    selectFocused: function() {
        // call LazySelect_onClick "event" in calling page
        if ( typeof( window.LazySelect_onFocus) == 'function' )
        {
            window.LazySelect_onFocus( this ) ;
        }
    
    }

};


