﻿if (typeof SproutJS == 'undefined') {
    SproutJS = {};
}
if (typeof SproutJS.Controls == 'undefined') {
    SproutJS.Controls = {};
}

Object.extend(SproutJS.Controls, {
    Anfo: function(_obj) {
        var create = function() {
            obj.flashvars = buildFlashVars();
            var test = UFO.create(obj, obj.replacementId);
            return obj;
        };
        var buildFlashVars = function() {
            //enables us to use functions to set flash vars at creation time
            if (obj.variables) {
                var tmp = $H(obj.variables);
                tmp.each(function(pair) {
                    if (Object.isFunction(pair.value)) {
                        tmp.set(pair.key, pair.value());
                    }
                });
                return tmp.toQueryString();
            }
        };
        var obj = Object.extend(_obj, { create: create });
        return obj;
    }
});