﻿/// <reference name="MicrosoftAjax.js"/>

Type.registerNamespace("OfficialCommunity.Common.WebControls.Analytics");

OfficialCommunity.Common.WebControls.Analytics.GoogleControlExtenderClientBehavior = function(element) {
    OfficialCommunity.Common.WebControls.Analytics.GoogleControlExtenderClientBehavior.initializeBase(this, [element]);

    this._eventToAttachTo = null;
    this._category = null;
    this._action = null;
    this._label = null;
    this._value = null;
}

OfficialCommunity.Common.WebControls.Analytics.GoogleControlExtenderClientBehavior.prototype = {
    initialize: function() {
        OfficialCommunity.Common.WebControls.Analytics.GoogleControlExtenderClientBehavior.callBaseMethod(this, 'initialize');

        var e = this.get_element();
        this._onEventDelegate = Function.createDelegate(this, this._onEventDelegate);

        $addHandler(e, this._eventToAttachTo, this._onEventDelegate);
    },

    _onEventDelegate: function() {
        try {
            if (this._label == null)
            { pageTracker._trackEvent(this._category, this._action); }
            else if (this._value == null)
            { pageTracker._trackEvent(this._category, this._action, this._label); }
            else
            { pageTracker._trackEvent(this._category, this._action, this._label, this._value); }
        } catch (err) { }
    },

    get_eventToAttachTo: function() {
        return this._eventToAttachTo;
    },

    set_eventToAttachTo: function(value) {
        this._eventToAttachTo = value;
    },

    get_category: function() {
        return this._category;
    },

    set_category: function(value) {
        this._category = value;
    },

    get_action: function() {
        return this._action;
    },

    set_action: function(value) {
        this._action = value;
    },

    get_label: function() {
        return this._label;
    },

    set_label: function(value) {
        this._label = value;
    },

    get_value: function() {
        return this._value;
    },

    set_value: function(value) {
        this._value = value;
    },

    dispose: function() {
        $clearHandlers(this.get_element());
        OfficialCommunity.Common.WebControls.Analytics.GoogleControlExtenderClientBehavior.callBaseMethod(this, 'dispose');
    }
}
OfficialCommunity.Common.WebControls.Analytics.GoogleControlExtenderClientBehavior.registerClass('OfficialCommunity.Common.WebControls.Analytics.GoogleControlExtenderClientBehavior', Sys.UI.Behavior);

if (typeof (Sys) !== 'undefined') Sys.Application.notifyScriptLoaded();
if(typeof(Sys)!=='undefined')Sys.Application.notifyScriptLoaded();