// define abc package
if (typeof com == "undefined") {
	com = {};
}
if (typeof com.abc == "undefined") {
	com.abc = {};
}
if (typeof com.abc.player == "undefined") {
	com.abc.player = {};
}
if (typeof CDNRoot == "undefined") {
	CDNRoot = 'http://changeyoucansee.com';
}

com.abc.player = {

	initialize: function() {
		this.isPlayerReady = false;
	},

	getPlayers: function( aPlayers ) {
		if( typeof aPlayers!='Object' ) {
			aPlayers = aPlayerList; //if we dont have a specified player list, return all players
		}
		return aPlayerList.collect(function(p){return $(p)});
	},

	play: function( aPlayers, oOptions ) {
		aPlayers = this.getPlayers( aPlayers );
		aPlayers.each( function(p){
			if(p) p.jsToSWF( 'play', oOptions );
		});
	},
	
	pause: function( aPlayers ) {
		aPlayers = this.getPlayers( aPlayers );
		aPlayers.each( function(p){
			if(p) p.jsToSWF( 'pause' );
		});
	},
	
	resume: function( aPlayers ) {
		aPlayers = this.getPlayers( aPlayers );
		aPlayers.each( function(p){
			if(p) p.jsToSWF( 'resume' );
		});
	},

	stop: function( aPlayers ) {
		aPlayers = this.getPlayers( aPlayers );
		aPlayers.each( function(p){
			if(p) p.jsToSWF( 'stop' );
		});
	},

	playerReady: function() {
		Event.broadcast(this,'playerReady');
		// broadcast to everyone
		Event.broadcast(window,'playerReady');
		this.isPlayerReady = true;
	}
};