﻿Btv.TVLeaguePanel = new function() {
    var oThis = this;
    var panel;
    var widgetPanel;

    oThis.unescapeHTML = function(html) {
        var htmlNode = document.createElement("DIV");
        htmlNode.innerHTML = html;
        return htmlNode.innerHTML;
    }

    oThis.HidePicksWidget = function() {
        if (widgetPanel) {
            widgetPanel.hide();
        }
    }

    oThis.CreatePicksWidget = function(widgetHtml) {

        var bodyElem = document.getElementById("InstructionsPopup");
        if (bodyElem) {
            bodyElem.className = bodyElem.className + " yui-skin-sam";
        } else {
            setTimeout("Btv.TVLeaguePanel.CreatePicksWidget('" + widgetHtml + "');", 100);
            return;
        }

        widgetHtml = oThis.unescapeHTML(widgetHtml)

        var bodyText = widgetHtml;

        if (!widgetPanel) {
            // Instantiate a Panel from script
            widgetPanel = new YAHOO.widget.Panel("panel", { visible: true, draggable: false, close: true, zIndex: 999, modal: 'true', context: ["ctx", "tl", "bl", ["beforeShow", "windowResize"]] });
            //panel.setHeader("Panel #2 from Script");
            widgetPanel.setBody(bodyText);
            //panel.setFooter("End of Panel #2");
            widgetPanel.render("InstructionsPopup");
        }
        else {
            widgetPanel.show();
        }
    }

    oThis.CreatePanel = function() {
        var bodyText = '<div style="width:550px">';
        bodyText += '                 <h2>How to Play Fantasy TV Leagues</h2>';
        bodyText += '                 <div class="howtoplay_1">     ';
        bodyText += '                    Join a leage for your favorite show.';
        bodyText += '                 </div>  ';
        bodyText += '                 <div class="howtoplay_2">    ';
        bodyText += '                    Each week, you will need to pick three candidates that you think will be eliminated in the upcoming episode.<br /><br />';
        bodyText += '                    Drag the candidates from the blue box over to the yellow box.';
        bodyText += '                    <br />';
        bodyText += '                    <center><img src="/images/tvl_picks.jpg"></center>';
        bodyText += '                    If your 1st pick candidate gets eliminated, you will earn 2,000 points.<br /><br />';
        bodyText += '                    If your 2nd pick candidate gets eliminated, you will earn 1,250 points.<br /><br />';
        bodyText += '                    If your 3rd pick candidate gets eliminated, you will earn 750 points.';
        bodyText += '                 </div>';
        bodyText += '                 <div class="howtoplay_3"> ';
        bodyText += '                    Click the <img src="/images/save-my-picks_btn.jpg" align=absmiddle border=0> button to save your picks.';
        bodyText += '                    <br /><br />';
        bodyText += '                    After each episode airs on TV, points will be rewarded to each player who picked the correct candidate that was eliminated. <br /><br />';
        bodyText += '                    You will need to return to pick your candidates for elimination every week until there is a winner!       ';
        bodyText += '                 </div>  ';
        bodyText += '                 <div align=right><a href="/feedback.aspx">Have Feedback?</a></div>';
        bodyText += '           	    <div style="clear:both;"></div>';
        bodyText += '    </div>';

        var bodyElem = document.getElementById("InstructionsPopup");
        if (bodyElem) {
            bodyElem.className = bodyElem.className + " yui-skin-sam";
        }

        if (!panel) {
            // Instantiate a Panel from script
            panel = new YAHOO.widget.Panel("panel", { visible: true, draggable: false, close: true, zIndex: 999, modal: 'true', context: ["ctx", "tl", "bl", ["beforeShow", "windowResize"]] });
            //panel.setHeader("Panel #2 from Script");
            panel.setBody(bodyText);
            //panel.setFooter("End of Panel #2");
            panel.render("InstructionsPopup");
        }
        else {
            panel.show();
        }
    }
}