
	// some variables to save
	var currentPosition;
	var currentVolume;
	var currentItem;

	// these functions are caught by the JavascriptView object of the player.
	function sendEvent(typ,prm) { thisMovie("thePlayerId").sendEvent(typ,prm); };
	function getUpdate(typ,pr1,pr2,pid) {
		if(typ == "time") { currentPosition = pr1; }
		else if(typ == "volume") { currentVolume = pr1; }
		else if(typ == "item") { currentItem = pr1; setTimeout("getItemData(currentItem)",100); }
		var id = document.getElementById(typ);
		id.innerHTML = typ+ ": "+Math.round(pr1);
		pr2 == undefined ? null: id.innerHTML += ", "+Math.round(pr2);
		if(pid != "null") {
			document.getElementById("pid").innerHTML = "(received from the player with id <i>"+pid+"</i>)";
		}
	};

	// These functions are caught by the feeder object of the player.
	function loadFile(obj) { thisMovie("thePlayerId").loadFile(obj); };
	function addItem(obj,idx) { thisMovie("thePlayerId").addItem(obj,idx); }
	function removeItem(idx) { thisMovie("thePlayerId").removeItem(idx); }
	function getItemData(idx) {
		var obj = thisMovie("thePlayerId").itemData(idx);
		var nodes = "";
		for(var i in obj) { 
			nodes += "<li>"+i+": "+obj[i]+"</li>"; 
		}
		//document.getElementById("data").innerHTML = nodes;
	};

	// This is a javascript handler for the player and is always needed.
	function thisMovie(movieName) {
	    if(navigator.appName.indexOf("Microsoft") != -1) {
			return window[movieName];
		} else {
			return document[movieName];
		}
	};
	
    


	/*-------------------------------------------------------------------
Player javascript API
-------------------------------------------------------------------*/
//function sendEvent(swf,typ,prm) { 
//  thisMovie(swf).sendEvent(typ,prm); 
//};
//function getUpdate(typ,pr1,pr2,swf) {};
//function thisMovie(swf) {
//  if(navigator.appName.indexOf("Microsoft") != -1) {
//    return window[swf];
//  } else {
//    return document[swf];
//  }
//};
//
function createPlayer(theFile) {
	var s = new SWFObject("flashplayer/mediaplayer.swf","thePlayerId","400","300","8");
	s.addParam("allowfullscreen","true");
	s.addVariable("file",theFile);
	s.addVariable("width","400");
	s.addVariable("height","300");
	s.addVariable("displayheight","280");
	s.addVariable("overstretch","fit");
	s.addVariable("autostart","true");
	s.addParam('allowscriptaccess','always');
	s.addVariable('enablejs','true');
	s.addVariable("javascriptid","thePlayerId");


	s.write("placeholder");
}

