var player = null;
//this function is called by player.swf when loaded
function playerReady(obj) {	
	player = document.getElementById(obj['id']);	
};

function hidePlayer(obj) {
	if (obj.newstate == "COMPLETED") {
		$('flvIntegration').setStyle('top', 452);
	}
}

//start player if var player is not null
function startPlayer() {
	if (player != null) {		
		player.sendEvent("PLAY", "true");		 
		player.addModelListener("STATE", "hidePlayer");	
	} else {
		setTimeout('startPlayer()', 100);
	}
}

window.addEvent('domready', function() {
	//if a video is included, the createPlayer-function will be there
	if (typeof(createPlayer) == 'function') {
		//create player via swf-object on domready	
		createPlayer();
		//avoid dotted line around image
		$('buttonPlay').getElement('a').setProperty('onfocus','if(this.blur)this.blur();');
	    $('buttonPlay').addEvent('click', function() {    	
	    	//would be nice to use visibility, but that would cause a more buggy behaviour related to wmode
	    	$('flvIntegration').setStyle('top', 0);
	    	//because player-initialization is buggy with wmode-param, we have to check for finished initialization until itīs finished
	    	setTimeout('startPlayer()', 100);
		return false;
	    });
	}
});