﻿Type.registerNamespace('DDTI.Web.Map.Toolbox');

DDTI.Web.Map.Legend.DTLayerLabelControl = function(element) { 
    DDTI.Web.Map.Legend.DTLayerLabelControl.initializeBase(this, [element]);
    this._layerIndex = null;
    this._isSelectable = null;
}

DDTI.Web.Map.Legend.DTLayerLabelControl.prototype = {
    initialize : function() {
        DDTI.Web.Map.Legend.DTLayerLabelControl.callBaseMethod(this, 'initialize');
        this._onclickHandler = Function.createDelegate(this, this._onClick);
        $addHandlers ( this.get_element(), { 'click' : this._onClick }, this );
    },

    dispose : function() {
        $clearHandlers(this.get_element());
        DDTI.Web.Map.Legend.DTLayerLabelControl.callBaseMethod(this, 'dispose');
    },

    _onClick : function(e) {
        if (this._isSelectable)
            DDTI.Web.Map.Legend.DTLegendComponent.prototype.changeActiveLayer(this.get_element().parentNode.id, this._layerIndex);
    },
    
    get_layerIndex : function() {
        return this._layerIndex;
    },
    
    set_layerIndex : function(value) {
        if (this._layerIndex !== value) {
            this._layerIndex = value;
            this.raisePropertyChanged('layerIndex');
        }
    },
    
    get_isSelectable : function() {
        return this._isSelectable;
    },
    
    set_isSelectable : function(value) {
        if (this._isSelectable !== value) {
            this._isSelectable = value;
            this.raisePropertyChanged('isSelectable');
        }
    }
}

DDTI.Web.Map.Legend.DTLayerLabelControl.registerClass('DDTI.Web.Map.Legend.DTLayerLabelControl', Sys.UI.Control);

if (typeof(Sys) !== 'undefined') Sys.Application.notifyScriptLoaded();
if(typeof(Sys)!=='undefined')Sys.Application.notifyScriptLoaded();