        function updateHTML(elmId, value) {
          document.getElementById(elmId).innerHTML = value;
        }

        function setytplayerState(newState) {
          updateHTML("playerstate", newState);
        }

        function onYouTubePlayerReady(playerId) {
          document.ytplayer = document.getElementById("myytplayer");
          setInterval(updateytplayerInfo, 250);
          updateytplayerInfo();
          document.ytplayer.addEventListener("onStateChange", "onytplayerStateChange");
        }

        function onytplayerStateChange(newState) {
          setytplayerState(newState);
        }

        function updateytplayerInfo() {
          updateHTML("bytesloaded", getBytesLoaded());
          updateHTML("bytestotal", getBytesTotal());
          updateHTML("videoduration", getDuration());
          updateHTML("videotime", getCurrentTime());
          updateHTML("startbytes", getStartBytes());
          updateHTML("volume", getVolume());
        }

        // functions for the api calls
        function loadNewVideo(id, startSeconds) {
          if (document.ytplayer) {
            document.ytplayer.loadVideoById(id, parseInt(startSeconds));
          }
        }

        function cueNewVideo(id, startSeconds) {
          if (document.ytplayer) {
            document.ytplayer.cueVideoById(id, startSeconds);
          }
        }

        function play() {
          if (document.ytplayer) {
            document.ytplayer.playVideo();
          }
        }

        function pause() {
          if (document.ytplayer) {
            document.ytplayer.pauseVideo();
          }
        }

        function stop() {
          if (document.ytplayer) {
            document.ytplayer.stopVideo();
          }
        }

        function getPlayerState() {
          if (document.ytplayer) {
            return document.ytplayer.getPlayerState();
          }
        }

        function seekTo(seconds) {
          if (document.ytplayer) {
            document.ytplayer.seekTo(seconds, true);
          }
        }

        function getBytesLoaded() {
          if (document.ytplayer) {
            return document.ytplayer.getVideoBytesLoaded();
          }
        }

        function getBytesTotal() {
          if (document.ytplayer) {
            return document.ytplayer.getVideoBytesTotal();
          }
        }

        function getCurrentTime() {
          if (document.ytplayer) {
            return document.ytplayer.getCurrentTime();
          }
        }

        function getDuration() {
          if (document.ytplayer) {
            return document.ytplayer.getDuration();
          }
        }

        function getStartBytes() {
          if (document.ytplayer) {
            return document.ytplayer.getVideoStartBytes();
          }
        }

        function mute() {
          if (document.ytplayer) {
            document.ytplayer.mute();
          }
        }

        function unMute() {
          if (document.ytplayer) {
            document.ytplayer.unMute();
          }
        }
        
        function getEmbedCode() {
          alert(document.ytplayer.getVideoEmbedCode());
        }

        function getVideoUrl() {
          alert(document.ytplayer.getVideoUrl());
        }
        
        function setVolume(newVolume) {
          if (document.ytplayer) {
            document.ytplayer.setVolume(newVolume);
          }
        }

        function getVolume() {
          if (document.ytplayer) {
            return document.ytplayer.getVolume();
          }
        }

        function clearVideo() {
          if (document.ytplayer) {
            document.ytplayer.clearVideo();
          }
        }