var jsButtons = new Object();

function JsButton() {
    
    this.DOM = typeof(document.hasChildNodes) == 'function' || 
               typeof(document.hasChildNodes) == 'object';
    
    this.Button = new Array();
    this.ButtonActive = new Array();
    this.image_size = 0;
    
    this.load = function(path, prefix, buttonType) {
        var length = 0;
        if(buttonType == 'text') {
            this.Button[length] = new Image();
            this.Button[length].src = path + prefix + 'left.gif';
            length = this.Button.length;
            this.Button[length] = new Image();
            this.Button[length].src = path + prefix + 'top.gif';
            length = this.Button.length;
            this.Button[length] = new Image();
            this.Button[length].src = path + prefix + 'bottom.gif';
            length = this.Button.length;
            this.Button[length] = new Image();
            this.Button[length].src = path + prefix + 'right.gif';

            length = 0;
            this.ButtonActive[length] = new Image();
            this.ButtonActive[length].src = path + prefix + 'left_active.gif';
            length = this.ButtonActive.length;
            this.ButtonActive[length] = new Image();
            this.ButtonActive[length].src = path + prefix + 'top_active.gif';
            length = this.ButtonActive.length;
            this.ButtonActive[length] = new Image();
            this.ButtonActive[length].src = path + prefix + 'bottom_active.gif';
            length = this.ButtonActive.length;
            this.ButtonActive[length] = new Image();
            this.ButtonActive[length].src = path + prefix + 'right_active.gif';

            length = null;
            this.image_size = 4;
        } else if(buttonType == 'image') {
            this.Button[0] = new Image();
            this.Button[0].src = path + prefix + '.gif';
            this.ButtonActive[0] = new Image();
            this.ButtonActive[0].src = path + prefix + '_active.gif';
            this.image_size = 1;
        }
    }
    
    this.setActive = function(button, active) {
        if(this.DOM) {
            var button_elements = button.getElementsByTagName('img');
            if(button_elements.length == this.image_size) {
                var setButton = this.Button;
                if(active) {
                    setButton = this.ButtonActive;
                }
                for(var i=0;i<this.image_size;i++) {
                    button_elements[i].src = setButton[i].src;
                }
            }
        }
    }
}