var article_amount = "12";

var player    		= null;
var playlist 		= null;
var currentItem 	= -1;

function playerReady(thePlayer) {
	player = document.getElementById(thePlayer.id);
	addListeners();
};

function addListeners() {
	playlist = player.getPlaylist();

	if (playlist.length > 0) {
		player.addControllerListener ('ITEM','itemMonitor');
		player.addModelListener('STATE','stateMonitor');
		itemMonitor({index:0});
	} else {
		setTimeout("addListeners()",100);
	}
};		

function itemMonitor(obj) {
	currentItem = obj.index;
}

function stateMonitor(obj) {
	if(obj.newstate == 'PLAYING'){
	gid("vod_player").style.backgroundImage='url('+ playlist[currentItem]['image'] +')';
	}
};

function gid(name) {
	return document.getElementById(name);
};

// not used to swfobject issue // - Arno
function CorpPlayer() {
	var wwe_hp_player = encodeURIComponent('/xml/playlist.xml?cache=' + Math.round(1000 * Math.random()));
	var flashvars = {
		'file'		: wwe_hp_player,
		'repeat'	: 'always',
		'abouttext'	: 'World Wrestling Entertainment, Inc',
		'aboutlink'	: 'http://corporate.wwe.com/company/overview.jsp',
		'controlbar': 'over',
		'backcolor'	: '0x000000',
		'frontcolor': '0xCCCCCC',
		'stretching': 'autofill',
		'lightcolor': '0x840000',
		'autostart'	: 'true'
    };
	var params = {
			'allowfullscreen'	: 'true',
			'allowscriptaccess'	: 'always',
			'wmode'				: 'opaque'
			};
	var attributes = {
				'id'	: 'wwe_player',
				'name'	: 'wwe_player'
		};
		
		var userAgent = navigator.userAgent.toLowerCase();
			if ((userAgent.indexOf("chrome") > -1) || (userAgent.indexOf("safari") > -1))
			{
				swfobject.embedSWF('/v2/js/libraries/mediaplayer/player.swf', 'vod_player', '534', '300', '9', 'false', flashvars, params, attributes);
			} else {
				swfobject.embedSWF('/v2/js/libraries/mediaplayer/player.swf', 'vod_player', '537', '300', '9', 'false', flashvars, params, attributes);
			}	
		
};


function PlayVideo() {
	document.getElementById('vod_player').innerHTML ='<object width="537" height="300" id="wwe_player" name="wwe_player" type="application/x-shockwave-flash" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" ><param name="movie" value="/v2/js/libraries/mediaplayer/player.swf" /><param name="quality" value="high" /><param name="bgcolor" value="#000000" /><param name="allowfullscreen" value="true" /><param name="wmode" value="Opaque" /><param name="flashvars" value="file=/xml/playlist.xml&controlbar=over&backcolor=0x000000&frontcolor=0xCCCCCC&lightcolor=0x840000&stretching=autofill&autostart=true&repeat=none&abouttext=World Wrestling Entertainment, Inc&aboutlink=http://corporate.wwe.com/company/overview.jsp"><embed src="/v2/js/libraries/mediaplayer/player.swf" height="300" wmode="Opaque" width="537" id="videoPlayer" quality="high" bgcolor="#000000" name="videoPlayer" allowfullscreen="true" pluginspage="http://www.adobe.com/go/getflashplayer" flashvars="file=/xml/playlist.xml&controlbar=over&backcolor=0x000000&frontcolor=0xCCCCCC&lightcolor=0x840000&stretching=autofill&autostart=true&repeat=none&abouttext=World Wrestling Entertainment, Inc&aboutlink=http://corporate.wwe.com/company/overview.jsp" type="application/x-shockwave-flash"></object>';
}
