SY = {
    additionalDivStyle: "",
    rendered: false,
    widgetUrl: "http://www.stickeryou.com/widgets/widget/widgethost.aspx",
    widgetWidth: "820",
    widgetHeight: "710",
    zoneId: 0,
    widgetDiv: null,
    closeUrl: "/",
    helpUrl: "",
    redirectToTool: 1,
    renderWidget: function() {
        if (SY.rendered)
            return;
        SY.rendered = true;
        wparent = document.getElementById("StickerYouWidgetCode").parentNode;
        // create a popup with iframe and redirect to the url2
        var html = "<iframe style='border:0;overflow:hidden;width:" + SY.widgetWidth + "px; height:" + SY.widgetHeight + "px;background-position:right;' frameborder=0 SCROLLING=NO" +
                 " src='" + SY.widgetUrl + "?zoneId=" + SY.zoneId + "&redirectToTool=" + SY.redirectToTool + "&helpUrl=" + SY.helpUrl + "&_parentUrl=" + encodeURIComponent(window.location) + "' id='__syWidgetIF' >" +
                 "</iframe>";
        var divid = "syins" + Math.floor(Math.random() * 9999999);
        var div = document.createElement("div");
        var style = "overflow: hidden;width: " + SY.widgetWidth + "px; height:" + SY.widgetHeight + "px;padding: 0; display: block; position: relative; background: transparent; border: 0;" + SY.additionalDivStyle;
        div.setAttribute("id", divid);
        div.setAttribute("style", style);
        try {
            div.id = divid;
            div.style.cssText = style;
        }
        catch (e1) { }
        html = html.replace("#pid#", divid);
        div.innerHTML = html;
        wparent.appendChild(div);
        var SYPoweredBy = document.createElement("a");
        SYPoweredBy.setAttribute("title", "Create and purchase your own custom stickers. High-quality, removable, vinyl stickers");
        SYPoweredBy.setAttribute("href", "http://www.stickeryou.com");
        wparent.appendChild(SYPoweredBy);

        SY.widgetDiv = div;
        setTimeout(function() { SY.iframeChecker(); }, 100);
    },
    iframeChecker: function() {
        iframe = document.getElementById("__syWidgetIF");
        var cmd = window.location.hash;

        if (cmd.length > 1) {
            cmd = cmd.substr(1);
            window.location.hash = "#";
        }

        if (cmd == "closeWidget") {
            SY.widgetDiv.parentNode.removeChild(SY.widgetDiv);
            if (SY.closeUrl != "")
                window.location = SY.closeUrl;
        }
        else {
            setTimeout(function() { SY.iframeChecker(); }, 500);
        }
    }
};
setTimeout(function() {
    if (SY.zoneId == 1421)
        SY.additionalDivStyle = "margin-left: -237px;margin-top: -77px;";
    SY.renderWidget();
}, 1000);

 

/*
example:
<script src="http://www.stickeryou.com/widgets/appwidget.ashx" id="StickerYouWidgetCode"></script>
<script>
SY.zoneId=xxx;
// optional:
SY.widgetWidth=xxx;
SY.widgetHeight=xxx;
SY.closeUrl="xxxx";
</script>
*/
