Javascript issue

I seem to be running into an issue where, after initializing the Youtube API, I try to run any of the javascript functions and I’m getting “Browser Message: Uncaught ReferenceError: ytplayer is not defined”.

Here’s the code:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
	<html xmlns="http://www.w3.org/1999/xhtml">
	  <head>
		<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
		<title>YouTube Player API Sample</title>
		<style type="text/css">
		  #videoDiv {
			margin-right: 3px;
		  }
		  #videoInfo {
			margin-left: 3px;
		  }
		</style>
		<script src="http://www.google.com/jsapi" type="text/javascript"></script>
		<script type="text/javascript">
		  google.load("swfobject", "2.1");
		</script>    
		<script type="text/javascript">
		  /*
		   * Chromeless player has no controls.
		   */
		  
		  // This function is called when an error is thrown by the player
		  function onPlayerError(errorCode) {
			alert("An error occured of type:" + errorCode);
		  }
		  
		  // Allow the user to set the volume from 0-100
		  function setVideoVolume() {
			var volume = parseInt(document.getElementById("volumeSetting").value);
			if(isNaN(volume) || volume < 0 || volume > 100) {
			  alert("Please enter a valid volume between 0 and 100.");
			}
			else if(ytplayer){
			  ytplayer.setVolume(volume);
			}
		  }
		  
		  function playVideo() {
			if (ytplayer) {
			  ytplayer.playVideo();
			}
		  }
		  
		  function pauseVideo() {
			if (ytplayer) {
			  ytplayer.pauseVideo();
			}
		  }
		  
		  function muteVideo() {
			if(ytplayer) {
			  ytplayer.mute();
			}
		  }
		  
		  function unMuteVideo() {
			if(ytplayer) {
			  ytplayer.unMute();
			}
		  }
		  
		  function changeVideo(video, time) {
			if(ytplayer) {
			  ytplayer.loadVideoById(video, time);
			}
		  }
		  
		  // This function is automatically called by the player once it loads
		  function onYouTubePlayerReady(playerId) {
			ytplayer = document.getElementById("ytPlayer");
			ytplayer.addEventListener("onError", "onPlayerError");
			//Load an initial video into the player
			ytplayer.loadVideoById("%s", %d);
		  }
		  
		  // The "main method" of this sample. Called when someone clicks "Run".
		  function loadPlayer() {
			// Lets Flash from another domain call JavaScript
			var params = { allowScriptAccess: "always" };
			// The element id of the Flash embed
			var atts = { id: "ytPlayer" };
			// All of the magic handled by SWFObject (http://code.google.com/p/swfobject/)
			swfobject.embedSWF("http://www.youtube.com/apiplayer?&enablejsapi=1&playerapiid=ytPlayer",
							   "videoDiv", "]] .. m_YTResX .. [[", "]] .. m_YTResY .. [[", "8", null, null, params, atts);
		  }
		  
		  function _run() {
			loadPlayer();
		  }
		  
		  google.setOnLoadCallback(_run);
		</script>
	  </head>
	  <body style="font-family: Arial;border: 0 none;">
		<div id="videoDiv">Loading...</div></td>
	  </body>
	</html>

And yes, this is a lua-based question, as I’m trying to run this code through an HTML panel.

I tried this also, I could only get it to work through the IFrame API

Mmk, thanks.