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

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

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

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

        function updateytplayerInfo() {
          updateHTML("bytesloaded", "");
          updateHTML("bytestotal", getMbTotal());
          updateHTML("videoduration", getDuration());
          updateHTML("videotime", getCurrentTime());
          updateHTML("startbytes", "");
          updateHTML("volume", getVolume());
          updateHTML("yer", getYer());
        }

		function getMbTotal() {
          if (ytplayer) {
			  var mb = getBytesTotal();
			  mb = mb/1048576;
			  mb = mb.toFixed(2);
			  return mb;
          }
        }

        function getYer() {
          if (ytplayer) {
			  var dur = ytplayer.getDuration();
			  dur = dur/86;
			  var temp;
			  var Ausgabe = "";
			  for (var i = 0; i <= 85; i++){
				  temp = dur*i
				  Ausgabe = Ausgabe + '<a href="javascript:void(0)" onclick="seekTo('+ temp +')">></a>';
			  }
            return Ausgabe;
          }
        }

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

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

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

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

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

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

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

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

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

        function getCurrentTime() {
          if (ytplayer) {
			  var curt = ytplayer.getCurrentTime();
			  var zaman;
			  var dakika;
			  var saniye;
			  if(curt < 60){
				  if(curt<10){
					  zaman = "00:0" + parseInt(curt);
				  }
				  else
					  zaman = "00:" + parseInt(curt);
			  }
			  else if(curt > 60){
				  dakika = curt/60;
				  saniye = curt%60;
				  saniye = parseInt(saniye);
  				  dakika = parseInt(dakika);
				  if(dakika<10)
				  	dakika = "0" + dakika;
				  if(saniye<10){
					  saniye = "0" + saniye;
				  }
				  zaman = dakika + ":" + saniye;
			  }
            return zaman;
          }
        }

        function getDuration() {
          if (ytplayer) {
			  var dur = ytplayer.getDuration();
			  var dakika = dur/60;
			  var saniye = dur%60;
			  saniye = parseInt(saniye);
			  dakika = parseInt(dakika);
			  if(saniye <10){
			  	saniye = "0" + saniye;
			  }
			  dur = "0" + dakika + ":" +  saniye;
            return dur;
          }
        }

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

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

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

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

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

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