// JavaScript Document

	var flag = true;
	var currentState = "NONE";
	
	var player = null;
	function playerReady(thePlayer) {
		player = window.document[thePlayer.id];
		addListeners();
	}

	function addListeners() {
		if (player) { 
			player.addModelListener("STATE", "stateListener");
		} else {
			setTimeout("addListeners()",100);
		}
	}

	function stateListener(obj) { //IDLE, BUFFERING, PLAYING, PAUSED, COMPLETED
		currentState = obj.newstate; 
		if ((currentState  == "PLAYING")&&(flag)) { 
			flag = false;
			setTimeout("stopPlayer()", 1000);
		}
	}

	function stopPlayer() {
		player.sendEvent('PLAY');
		//flag = true;
	}
	
	function createplayer(file, width, height) {
		if (typeof width === 'undefined') width = 500;
		if (typeof height === 'undefined') height = 350;
		
		var so = new SWFObject('/scripts/mediaplayer/player.swf','ply',width,height,'9',"#FFFFFF");
		so.addParam('allowscriptaccess','always');
		so.addParam('allowfullscreen','true');
		so.addParam('wmode','opaque');
		so.addParam('flashvars','&file=' + file + '&fullscreen=true&backcolor=022952&frontcolor=FFFFFF&lightcolor=868686&abouttext=Copyright Sellafield Ltd&aboutlink=http://www.sellafieldsites.com/legal&stretching=fill&bufferlength=0&autostart=true');
		so.write('player1');
	}
