// JavaScript Document
// some variables to save
var currentPosition;
var currentRemaining;
var currentVolume;
var currentItem;
var currentState;
var currentLoad;
var currentXsize;
var currentYsize;

// this function is caught by the JavascriptView object of the player.
function sendEvent(typ,prm) { thisMovie("playerID").sendEvent(typ,prm); };


// these functions is called by the JavascriptView object of the player.
function getUpdate(typ,pr1,pr2,swf) { 
	if(typ == "time") { currentPosition = pr1; pr2 == undefined ? null: currentRemaining = Math.round(pr2); }
	else if(typ == "volume") { currentVolume = pr1; } 
	else if(typ == "item") { currentItem = pr1; setTimeout("getItemData(currentItem)",100);}
	else if(typ == "state") { currentState = pr1; }
	else if(typ == "load") { currentLoad = pr1; }
	else if(typ == "size") { currentXsize = "X=" + pr1; pr2 == undefined ? null: currentYsize = "Y=" + Math.round(pr2); } 

	var tmp = document.getElementById("pid"); if ((tmp)&&(swf != "null")) { tmp.innerHTML = "(received from the player with the id: <i><b>"+swf+"</b></i>)"; } 
};

function getItemData(idx) {
	var obj = thisMovie("playerID").itemData(idx);

	var tmp = document.getElementById("title"); if (tmp) { tmp.innerHTML = obj["title"]; }   
};


// These functions are caught by the feeder object of the player.
function loadFile(obj) { thisMovie("playerID").loadFile(obj); };
function addItem(obj,idx) { thisMovie("playerID").addItem(obj,idx); };
function removeItem(idx) { thisMovie("playerID").removeItem(idx); };
function getLength(swf) { return(thisMovie(swf).getLength()); };


// 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];
	}
};
