﻿if (typeof(cspWidget_GetWidgetBtn) == "undefined") {
    cspWidget_GetWidgetBtn = {};

    cspWidget_GetWidgetBtn.open = function(userName) {
    
        var config = new WIDGETBOX.subscriber.WidgetMenuConfig();
        config.regId = 'c75664ab-c3f3-4a97-951c-c87172bf7cbf';
        config.sourceId = 'c6d41f4e-a82a-468f-94f9-743b26c02a0b';
        config.context = "wild";
        config.location = window.location.href;
        config.galleryUrl = 'http://www.widgetbox.com';
        config.syndUrl = 'http://widgetserver.com/syndication';
        config.configData = cspWidget_GetWidgetBtn.readConfig(userName);
        
        WIDGETBOX.subscriber.Main.renderGetWidget(config);
    }

    cspWidget_GetWidgetBtn.render = function(htmlToRender) {
       cspWidget_GetWidgetBtn.load();
       document.write(htmlToRender);
    }

    cspWidget_GetWidgetBtn.load = function() {
    
            var head = document.getElementsByTagName("head")[0];
            script = document.createElement("script");
            script.type = "text/javascript";
            script.src = "http://widgetserver.com/syndication/subscriber/Main.js";
            head.appendChild(script);
    }

    cspWidget_GetWidgetBtn.readConfig = function(userName) {
        var cfgData = "UserName=" + userName;
        return cfgData;
    }
};