<%namespace name='static' file='/static_content.html'/>
<html>
	<head>
    ## It'd be better to have this in a place like lms/css/vendor/candy,
    ## but the candy_res/ folder contains images and other junk, and it
    ## all needs to stay together for the Candy.js plugin to work.
    <link rel="stylesheet" href="${static.url('candy_res/default.css')}" />
    <link rel="stylesheet" href="${static.url('candy_res/candy_custom.css')}" />

    ## Load in jQuery from standard edX location.
    <script type="text/javascript" src="${static.url('js/vendor/jquery.min.js')}"></script>

    ## Include the Candy.js libraries. Wooooo.
    <script type="text/javascript" src="${static.url('js/vendor/candy_libs/libs.min.js')}"></script>
    <script type="text/javascript" src="${static.url('js/vendor/candy.min.js')}"></script>
	</head>
	<body>
    ## Candy.js renders itself in an element with #candy
		<div id="candy"></div>

    ## Initialize the Candy.js plugin
    <script type="text/javascript">
      $(document).ready(function() {
        Candy.init("${bosh_url}", {
          core: { debug: true, autojoin: ["${course_room}"] },
          //core: { debug: true, autojoin: ["dev@conference.jabber.class.stanford.edu"] },
          view: { resources: "${static.url('candy_res/')}"}
        });
	
	$('#chat-toolbar #chat-sound-control').remove();

        /* After a period of inactivity, users will be disconnected
         * from the chat server and prompted to log in again. They
         * won't know their username/password, however, since we take
         * care of that for them.
         *
         * Therefore, we override this function so that the user
         * never sees a true login form. We just give them a button
         * to click when they're ready to (re)connect.
         */
        Candy.View.Pane.Chat.Modal.showLoginForm = function(message, presetJid) {
          var loginMsg = "Click below to connect to the chat server" +
                         "<p>&nbsp</p>" +
                         "<button id='connect'>Connect</button>";
          Candy.View.Pane.Chat.Modal.show(loginMsg);
          $("#connect").click(function() {
            Candy.Core.connect("${username}", "${password}");
          });
        }

        Candy.Core.connect("${username}", "${password}");
	
	$("#candy").focus();
      });
    </script>
	</body>
</html>
