﻿if (typeof SproutJS == 'undefined') {
    SproutJS = {};
}
if (typeof SproutJS.Controls == 'undefined') {
    SproutJS.Controls = {};
}

Object.extend(SproutJS.Controls, {
    OmniTrack: function(state) { //vars = {}, events = [], misc ={}, name = ""
        state = Object.extend({
            vars: {},
            events: $A(),
            name: 'default event name'
        }, state);

        var as = s_gi(s_account);

        if (state.vars.events) {
            state.events = state.events.concat(state.vars.events.split(','));
        }
        if (state.events.length > 0) {
            state.vars.events = as.linkTrackEvents = state.events.join(',');
        }
        as.linkTrackVars = $H(state.vars).keys().join(',');
        as = Object.extend(as, state.vars);
        as = Object.extend(as, state.misc);
        if (state.name) {
            as.tl(this, 'o', state.name);
        }
        if (s_code) {
            document.write(s_code);
        }
    }
});