var mtvnPlayers = [];
function mtvnPlayerLoaded( playerId ){
  mtvnPlayers[playerId]._onPlayerLoaded();
}
function MTVNPlayerController(id,onLoadFunctionName){
  mtvnPlayers[id] = this;
  this.onLoadFunctionName = onLoadFunctionName;
  this.playerLoaded = false;
  this.playerId = id;
  this.player = null;

  this._onPlayerLoaded = function(){
    this.playerLoaded = true;
    this.player = (navigator.appName.indexOf("Microsoft") != -1) ? window[this.playerId] : document[this.playerId];
    var f = eval(onLoadFunctionName);
    f(this);
  }

}

CMT = new Object();

// global vars
var controller;

CMT.NewsPlayer = new function(){
	
	this.configParams;
	this.playerMediaHost;
	this.videoUri;
	this.continuousPlay = true;
	this.fullEpisode = false;
	
	var coAdInterval;
	var onNoAdObject;
	
	
	this.init = function() {}
	
	this.addPlayer = function(host,uri,config,fullepisode) {
		var flashVersion = "9.0.115.0";		
		var configParams = config;
		this.configParams = config;
	  this.playerMediaHost = host;
	  this.videoUri = uri;
	  this.fullEpisode = fullepisode;
	
		var so = new SWFObject(CMT.NewsPlayer.playerMediaHost + "/" + CMT.NewsPlayer.videoUri, "embeddedPlayer", "100%", "100%", flashVersion, "#cccccc");
		so.addVariable("configParams", encodeURIComponent(configParams));
		
		
		so.addParam("allowFullScreen",true);
		so.addParam("allowScriptAccess","always");
		so.addParam("wmode", "transparent");
		so.addParam("swliveconnect",true);
		so.addParam("bgcolor", "#000000");
		so.write("videoPlayer");
		controller = new MTVNPlayerController("embeddedPlayer","CMT.Player.onPlayerLoaded");
		
	}
	
	this.isContinuousPlay = function() {
		return this.continuousPlay;
	}
}

