                    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");
					ytplayer.addEventListener("onError", "onPlayerError");
					}

					function onPlayerError(errorCode) {
					alert("An error occured: " + errorCode);
					}

					function onytplayerStateChange(newState) {
					setytplayerState(newState);
					}

					

					// functions for the api calls
					function loadNewVideo(id, startSeconds) {
					if (ytplayer) {
					ytplayer.loadVideoById(id, parseInt(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 getEmbedCode() {
					alert(ytplayer.getVideoEmbedCode());
					}

					function getVideoUrl() {
					alert(ytplayer.getVideoUrl());
					}
