<?
header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); // Date in the past
?>
<!DOCTYPE html>
<html>
    <head>
        <title>Scratch HTML5 vs. Flash</title>
        <meta charset="utf-8">
        <style type="text/css">
            body {
                background: #222;
                color: #fff;
                margin: 0;
            }
        </style>
        <link href="player.css" type="text/css" rel="stylesheet" />
        <script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
        <script src="//ajax.googleapis.com/ajax/libs/swfobject/2.2/swfobject.js"></script>
        <script src="js/util/Timer.js"></script>
        <script src="js/util/OffsetBuffer.js"></script>
        <script src="js/util/Color.js"></script>
        <script src="js/util/Rectangle.js"></script>
        <script src="js/Sprite.js"></script>
        <script src="js/Reporter.js"></script>
        <script src="js/Stage.js"></script>
        <script src="js/sound/WAVFile.js"></script>
        <script src="js/sound/SoundDecoder.js"></script>
        <script src="js/sound/SoundBank.js"></script>
        <script src="js/sound/NotePlayer.js"></script>
        <script src="soundbank/Instr.js"></script>
        <script src="js/IO.js"></script>
        <script src="js/primitives/VarListPrims.js"></script>
        <script src="js/primitives/MotionAndPenPrims.js"></script>
        <script src="js/primitives/LooksPrims.js"></script>
        <script src="js/primitives/SensingPrims.js"></script>
        <script src="js/primitives/SoundPrims.js"></script>
        <script src="js/primitives/Primitives.js"></script>
        <script src="js/Interpreter.js"></script>
        <script src="js/Runtime.js"></script>
        <script src="js/Scratch.js"></script>
        <script type="text/javascript">
            if (window.location.hash) {
                var project_id = parseInt(window.location.hash.substr(1));
            } else {
                var project_id = 10000160; // Default project for display
            }
        </script>
        <script>
            $(function() {
                // The flashvars tell flash about the project data (and autostart=true)
                var flashvars = {
                    server: encodeURIComponent('scratch.mit.edu'),
                    project_id: project_id
                };

                // Pass in the cloud token for the project
                if (window.getCloudToken) {
                    flashvars.cloud_token = encodeURIComponent(getCloudToken());
                }

                var params = {
                    allowscriptaccess: 'always',
                    allowfullscreen: 'false',
                    wmode: 'direct',
                    menu: 'false'
                };

                var flashPlayer = null;
                    //var swf_url = "http://cdn.scratch.mit.edu/scratchr2/static/Scratch.swf";
                var swf_url = "http://jiggler.media.mit.edu/shanemc/scratchr2/static/Scratch.swf";
                swfobject.embedSWF(swf_url, "flashScratch", "480", "400", "10.2.0",
                    "http://cdn.scratch.mit.edu/scratchr2/static/expressInstall.swf",
                    flashvars, params, null, function(e) {
                        $('#flashScratch').css('visibility', 'visible');
                        if (e.success) flashPlayer = e.ref;
                    });

                $('#trigger_green_flag, #greenSlide').click(function() {
                    flashPlayer.ASstartRunning();
                });

                // Stop button behavior
                $('#trigger_stop').click(function() {
                    flashPlayer.ASstopRunning();
                });
            });
        </script>
    </head>
    <body>
    <div style="display: inline-block;">
        <div id="up">&nbsp;</div>
        <div id="left">&nbsp;</div>
        <div id="overContainer">
            <div id="greenSlide"><div id="greenSlideFg"><img src="img/greenflag.png"></div></div>
            <div id="container"></div>
        </div>
        <div id="right">&nbsp;</div>
        <div id="down">&nbsp;</div>
    </div>
    <div style="display: inline-block;">
        <div id="flashScratch" style="text-align:center;visibility:hidden;">
            <p style="color:#aaa;font-size:22px;margin-top:14px;line-height:28px;">Oh Noes! Scratch project cannot display.<br/>Flash player is disabled, missing, or less than version 10.2.</p>
            <a href="http://www.adobe.com/go/getflashplayer">
                <img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" target="_blank" />
            </a>
        </div>
    </div>
        <div id="info">Loading...</div>

        <button id="trigger_green_flag">Green flag</button>
        <button id="trigger_stop">Stop</button>

        <input type="text" name="project_id" id="project_id" /><button id='go_project'>Go!</button>
    </body>
</html>