        function onYouTubePlayerReady(playerId) {

          ytplayer = document.getElementById("myytplayer");

          setInterval(updateytplayerInfo, 250);

          updateytplayerInfo();

          ytplayer.addEventListener("onStateChange", "onytplayerStateChange");

        }



        function onytplayerStateChange(newState) {

          setytplayerState(newState);

        }



         function updateytplayerInfo() {

		 if(getCurrentTime() > 0)

		 {

		 	var thisLength = getCurrentTime();

			var fullLength = getDuration();

			var value = thisLength/fullLength;

			value = (Math.round(value*100));

			value = value+'%';

		 	//value = value.substr(0,3).'%';

			

			var duration = ((Math.round(fullLength*100))/100) + ' secs';

			if(fullLength < 0)

				duration = '';

			

		 }

		 else

		 	var value = '0%';

          updateHTML("dyna", value);

          //updateHTML("bytestotal", getBytesTotal());

		  if(duration)

          	updateHTML("videoduration", duration);

          /*updateHTML("videotime", getCurrentTime());

          updateHTML("startbytes", getStartBytes());

          updateHTML("volume", getVolume());*/

        }

        // functions for the api calls
			

        function loadNewVideo(id, startSeconds) {

		ytplayer = document.getElementById("myytplayer");

          if (ytplayer) {

            ytplayer.loadVideoById(id, parseInt(startSeconds));

          }

        }



        function cueNewVideo(id, startSeconds) {

		ytplayer = document.getElementById("myytplayer");

          if (ytplayer) {

            ytplayer.cueVideoById(id, startSeconds);

          }

        }



        function play() {

          if (ytplayer) {

            ytplayer.playVideo();

          }

        }



        function pause() {

          if (ytplayer) {

            ytplayer.pauseVideo();

          }

        }



        function stop() {

          if (ytplayer) {

		  	seekTo(0);

		  	pause();

            //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) {

            return ytplayer.getCurrentTime();

          }

        }



        function getDuration() {

          if (ytplayer) {

            return ytplayer.getDuration();

          }

        }



        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();

          }

        }



		function updateHTML(elmId, value) {

          document.getElementById(elmId).innerHTML = value;

        }


// JavaScript Document