﻿Type.registerNamespace("Mcw.Rijksoverheid.GoogleMaps");

Mcw.Rijksoverheid.GoogleMaps.Tag = function (element) {
    Mcw.Rijksoverheid.GoogleMaps.Tag.initializeBase(this, [element]);

    this._element = element;
    this._node = null;
    this._intID = null;
    this._strName = null;
    this._blIsActiveTag = null;
    this._intTagGroupID = null;
}

Mcw.Rijksoverheid.GoogleMaps.Tag.prototype = {
    initialize: function () {
        Mcw.Rijksoverheid.GoogleMaps.Tag.callBaseMethod(this, 'initialize');

        var context = this;
        var chkbx = $(this._element).find("input");
        var lbl = $(this._element).find("label");

        // Set properties.
        this._intID = this._node.getAttribute("id");
        this._strName = this._node.getAttribute("name");
        this._blIsActiveTag = false;

        // Set element properties.
        $(this._element).id = "tag_" + this._intID;
        chkbx.attr('name', 'tg_' + this._intTagGroupID);
        chkbx.attr('id', 'inptTag_' + this._intID);
        lbl.attr('for', 'inptTag_' + this._intID);
        lbl.text(this._strName);

        // Add ID to selected TagIDs collection.
        Array.add(Mcw.Rijksoverheid.GoogleMaps.MapViewerControl.Instance.get_SelectedTagIDs(), this._intID);

        // Add checkbox change event handler.
        chkbx.change(function (event) {
            Mcw.Rijksoverheid.GoogleMaps.MapViewerControl.Instance.toggleSelectedFilter(context._intID);
        });
    },
    dispose: function () {
        Mcw.Rijksoverheid.GoogleMaps.Tag.callBaseMethod(this, 'dispose');
    },

    get_Node: function () {
        return this._node;
    },
    set_Node: function (value) {
        this._node = value;
    },
    get_TagGroupID: function () {
        return this._intTagGroupID;
    },
    set_TagGroupID: function (value) {
        this._intTagGroupID = value;
    }
}

Mcw.Rijksoverheid.GoogleMaps.Tag.registerClass("Mcw.Rijksoverheid.GoogleMaps.Tag", Sys.UI.Control);
