// Customized For Downelink and 365gay.com
var mtvnPlayers = [];
var player;
var siteName = "logotv.com";

LOGO = new Object();
LOGO.Player = new function(){
	this.controller;
	this.cp = 'cp~';
	this.playerMediaHost = "http://media.mtvnservices.com/";
	this.autoPlay = 'true';
	this.vid = null;
	this.id = null;
	this.fullEpisodeMode = false;
	this.playerTarget = 'videoPlayer';
	this.embedString = '';
	this.instance = "logo";
	this.sid = this.instance;
	this.metadata;
	
	
	var continuousPlayCookieName = "mtvnContinuousPlay";
	var continuousPlayConfigValue;
	var suspendContinuousPlay;
	
	this.init = function(){
		LOGO.Player.setContinuousPlayConfigValue(true);	
	}
	
	//CONTINUOUS PLAY
		this.setContinuousPlayConfigValue = function(val){
			continuousPlayConfigValue = true;
			//hardcoding to true
		}
		
		this.getContinuousPlayValue = function(){
			return LOGO.Player.getContinuousPlayConfigValue();
		}
		
		this.getContinuousPlayConfigValue = function(){
			return continuousPlayConfigValue;
		}
		
		this.getContinuousPlayOverride = function(){
			//console.log("LOGO.Player.getContinuousPlayValue("+LOGO.Player.getContinuousPlayValue()+")");
			return LOGO.Player.getContinuousPlayValue();
		}
		
	//PLAYER
		this.onPlayerLoaded = function(controller){
			//REPORTING
			player = LOGO.Player.controller.player;
			player.addEventListener('STATE_CHANGE','MTVNTimerStateCheck');
			player.addEventListener('METADATA','LOGO.Player.onMetaData');
			
			//MEDIA ENDED EVENT
			if(LOGO.Player.instance == "downelink"){
				LOGO.Player.controller.player.addEventListener("MEDIA_ENDED","LOGO.Player.dlPlayNextVideo");
			}
		}
		
		this.onMetaData = function( metadata ){
			LOGO.Player.metadata = metadata;
		}
		
		this.dlPlayNextVideo = function( metadata ){
			var isAd = String(LOGO.Player.metadata.isAd);
			try{
				if(isAd == "false"){
					playNextVideo();
				}
			}
			catch(err){}
					
		}
		
		this.addPlayer = function(){
			LOGO.Player.init();
			
			//ExtendedUriEdit (ONLY TEST ON QA FOR PRIME SUPPORT)
			if(LOGO.Player.playerMediaHost.indexOf("-d.mtvi") != -1){
				LOGO.Player.playerMediaHost = LOGO.Player.playerMediaHost.replace("-d.mtvi","-q.mtvi");
			}
			
			//LOGO.Player.videoUri = LOGO.Player.videoUri.replace("logotv","logoonline");
			
			if(LOGO.Player.videoUri.indexOf("downelinkdb") == -1){
				if(LOGO.Player.videoUri.indexOf("downelink.com") != -1){
					LOGO.Player.instance = "downelink";
					//LOGO.Player.videoUri = LOGO.Player.videoUri.replace("downelink.com","logotv.com");
				}
			} else {
				LOGO.Player.instance = "downelink";
			}
			
			//SET SID BASED ON INSTANCE - also add MEDIA ENDED EVENT
			if(LOGO.Player.instance == "downelink"){
				LOGO.Player.sid = "logo_downelink";
			}
			
			if(LOGO.Player.id != null){
				LOGO.Player.cp += "id%3D"+LOGO.Player.id+"%26";
			}
			
			if(LOGO.Player.vid != null){
				LOGO.Player.cp += "vid%3D"+LOGO.Player.vid+"%26";
			}
			
			LOGO.Player.cp += "instance%3D"+LOGO.Player.instance;
			
			LOGO.Player.embedString = LOGO.Player.playerMediaHost+''+LOGO.Player.videoUri+'/'+LOGO.Player.cp;
			
			var flashVersion = "10.0.12.36";
			var embeddedPlayer = new SWFObject(LOGO.Player.embedString,'embeddedPlayer', '100%', '100%', flashVersion, '#cccccc');
				embeddedPlayer.addVariable('sid', LOGO.Player.sid);
				embeddedPlayer.addVariable('autoPlay', LOGO.Player.autoPlay);
				embeddedPlayer.addParam("allowFullScreen",true);
				embeddedPlayer.addParam("name",embeddedPlayer);
				embeddedPlayer.addParam("id",embeddedPlayer);
				embeddedPlayer.addParam("enableJavascript",true);
				embeddedPlayer.addParam("wmode","transparent");
				embeddedPlayer.addParam("allowScriptAccess","always");
				embeddedPlayer.addParam("swliveconnect",true);
				embeddedPlayer.useExpressInstall('http://www.logoonline.com/player/expressInstall/adobeExpressInstall.swf');
				embeddedPlayer.write(LOGO.Player.playerTarget);
		}	
}
var onPlayerLoaded = LOGO.Player.onPlayerLoaded;
