
var movies = Array();
var movies_count = 0;
var movies_index = -1;
var myListener = new Object();
var movies_replay = 0;

/**
 * Initialisation
 */
myListener.onInit = function()
{
	//tymczasowo!!!
	//getFlashObject().SetVariable("method:setVolume",0);
	
	playerNext();
};
/**
 * onClick event on the video
 */
myListener.onClick = function()
{
	playerPause();
};
/**
 * onComplete event
 */
myListener.onFinished = function()
{
	getFlashObject().SetVariable("method:stop", "");
	
	if (movies_replay==1) {
		playerNext();
	}
};
/**
 * Update
 */
myListener.onUpdate = function()
{

};

function getFlashObject()
{
	return document.getElementById("mediaplayer");
}
function playerPlay()
{
	getFlashObject().SetVariable("method:play", "");
}
function playerPause()
{
	getFlashObject().SetVariable("method:pause", "");
}
function playerStop()
{
	getFlashObject().SetVariable("method:stop", "");
}

/*
function playerAutoNext() {
	getFlashObject().SetVariable("method:stop", "");
	if (movies_index+1>=movies_count && movies_replay==1) {
		playerNext();
	}
}
*/

function playerNext()
{
	movies_index++;
	
	if (movies_index>=movies_count) {
		movies_index = 0;
	}
	
	getFlashObject().SetVariable("method:stop", "");
	getFlashObject().SetVariable("method:setUrl", movies[movies_index]);
	getFlashObject().SetVariable("method:play", "");
}
