//
// NBC Universal Embedded Video Player Javascript Source
//
//DEBUG flag. remove to suppress firebug output.

this.DEBUG = true;

var vp_debugOutputType='';
function debugOutput(debugMessage,debugType)
{
	if (vp_debugOutputType == 'alert')
	{	alert(debugMessage);	}
	if (vp_debugOutputType == 'firebug')
	{	
		switch (debugType)
		{
			case "log":
				console.log(debugMessage);
				break;
			case "info":
				console.info(debugMessage);
				break;
			case "warn":
				console.warn(debugMessage);
				break;
			case "error":
				console.error(debugMessage);
				break;
			default:
				console.log(debugMessage);
		}
	}
}

//helper for defining classes courtesy Douglas Crockford
Function.prototype.method = function(name, func)
{
	this.prototype[name] = func;
	return this;
};

//disable debugger if FireBug is not installed
if ( typeof console != "object" || !this.DEBUG ) { var n = function(){}; console = {warn: n, error: n, info: n, log: n} };

if (typeof EmbeddedPlayerUtil == "undefined")
EmbeddedPlayerUtil = 
{
	getElementPosition: function(e) {
		var obj = (typeof(e) == "string") ? document.getElementById(e) : e;
		var curleft = curtop = 0;
		if (obj.offsetParent) { // NBC bug: "Microsoft JScript runtime error: Object required" (see prototype.js offsetParent function) 
			curleft = obj.offsetLeft
			curtop = obj.offsetTop
			while (obj = obj.offsetParent) {
				curleft += obj.offsetLeft
				curtop += obj.offsetTop
			}
		}
		return { x:curleft, y:curtop };
	}
}

if (typeof EmbeddedPlayerManager == "undefined")
EmbeddedPlayerManager = function()
{
	function Constructor()
	{
		//public instance vars
		this.BASE_LOCATION = "";
		this.COMPANION_REFERRER = "";
		this.METADATA_THUMB_URL = "";
		
		this.players;
		this.companionReference; // SG: reference of companion used for collapse, set from PHP/IFrame companion renderer script
		this.lastPlayer;
		this.fullscreenPlayer = null;
	
		//require swfobject
		if (!deconcept || !deconcept.SWFObject)
		{
			debugOutput("Couldn't initialize EmbeddedPlayerManager. SWFObject unavailable");
			return null;
		}

		debugOutput("making shared instance of embeddedPlayerManager. this message should only appear once","info");
		this.players = new Array();
		
		this.initOnResize();
		this.initOnScroll();
		
	}
	
	//public methods
	with(Constructor)
	{
		//embed a new player (or return it if it already exists)
		//players are stored by the div id of where they are embedded
		
		method("embedPlayer", function( targetDivID, companionContainerID, deepLinkIDOrPath, width, height, configLocation, videoControls, autoStartOnEmbed, initialVolume, exitFullscreenOnVideoComplete, embVal, overrideRandom, overrideKeyword1, overrideKeyword2, overrideKeyword3, overrideClipID)
		{
			//TEMP HARDCODED 100 configID for transition from 2.x to 3.x
			var ConfigID = 10000;
switch (configLocation) {
case "config.xml": ConfigID=10000; break;
case "xml/config/config.xml": ConfigID=10001; break;
case "xml/config/config_1_1.xml": ConfigID=10002; break;
case "xml/config/config_3_300.xml": ConfigID=10003; break;
case "xml/config/config_ah_1_1.xml": ConfigID=11000; break;
case "xml/config/config_ah_3_300.xml": ConfigID=11001; break;
case "xml/config/config_ah_3_600.xml": ConfigID=11002; break;
case "xml/config/config_nbcumarketplace_1_1.xml": ConfigID=12000; break;
case "xml/config/config_nbcumarketplace_3_300.xml": ConfigID=12001; break;
case "xml/config/config_bbc_1_1.xml": ConfigID=13000; break;
case "xml/config/config_bbc_3_300.xml": ConfigID=13001; break;
case "xml/config/config_bravo_1_1.xml": ConfigID=13002; break;
case "xml/config/config_bravo_3_300.xml": ConfigID=13003; break;
case "xml/config/config_outzonetv_1_1.xml": ConfigID=13004; break;
case "xml/config/config_outzonetv_3_300.xml": ConfigID=13005; break;
case "xml/config/config_trio_1_1.xml": ConfigID=13006; break;
case "xml/config/config_trio_3_300.xml": ConfigID=13007; break;
case "xml/config/config_dotcomedy_1_1.xml": ConfigID=14000; break;
case "xml/config/config_dotcomedy_3_300.xml": ConfigID=14001; break;
case "xml/config/config_lunchbreak_1_1.xml": ConfigID=14002; break;
case "xml/config/config_lunchbreak_20_3600.xml": ConfigID=14003; break;
case "xml/config/config_lunchbreak_3_300.xml": ConfigID=14004; break;
case "xml/config/config_spitinos_1_1.xml": ConfigID=14005; break;
case "xml/config/config_spitinos_3_300.xml": ConfigID=14006; break;
case "xml/config/config_astrology_1_1.xml": ConfigID=15000; break;
case "xml/config/config_astrology_3_300.xml": ConfigID=15001; break;
case "xml/config/config_drnancy_1_1.xml": ConfigID=15002; break;
case "xml/config/config_drnancy_3_300.xml": ConfigID=15003; break;
case "xml/config/config_gurl_1_1.xml": ConfigID=15004; break;
case "xml/config/config_gurl_3_300.xml": ConfigID=15005; break;
case "xml/config/config_healthology_1_1.xml": ConfigID=15006; break;
case "xml/config/config_healthology_3_300.xml": ConfigID=15007; break;
case "xml/config/config_ivillage_1_1.xml": ConfigID=15008; break;
case "xml/config/config_ivillage_3_300.xml": ConfigID=15009; break;
case "xml/config/config_meganshow_1_1.xml": ConfigID=15010; break;
case "xml/config/config_meganshow_3_300.xml": ConfigID=15011; break;
case "xml/config/config_totalhealth_1_1.xml": ConfigID=15012; break;
case "xml/config/config_totalhealth_3_300.xml": ConfigID=15013; break;
case "xml/config/config_chillertv_1_1.xml": ConfigID=16000; break;
case "xml/config/config_chillertv_3_300.xml": ConfigID=16001; break;
case "xml/config/config_horrorfest_1_1.xml": ConfigID=16002; break;
case "xml/config/config_horrorfest_3_300.xml": ConfigID=16003; break;
case "xml/config/config_nbc_1_1.xml": ConfigID=16004; break;
case "xml/config/config_nbc_3_300.xml": ConfigID=16005; break;
case "xml/config/config_nbcrewind_1_1.xml": ConfigID=17000; break;
case "xml/config/config_nbcrewind_3_300.xml": ConfigID=17001; break;
case "xml/config/config_nbcrewind_test.xml": ConfigID=17002; break;
case "xml/config/config_nbcrewinddaytime_1_1.xml": ConfigID=17003; break;
case "xml/config/config_nbcrewinddaytime_3_300.xml": ConfigID=17004; break;
case "xml/config/config_icue_1_1.xml": ConfigID=18000; break;
case "xml/config/config_icue_3_300.xml": ConfigID=18001; break;
case "xml/config/config_nass_1_1.xml": ConfigID=18002; break;
case "xml/config/config_nass_3_300.xml": ConfigID=18003; break;
case "xml/config/config_scifi_1_1.xml": ConfigID=19000; break;
case "xml/config/config_scifi_3_300.xml": ConfigID=19001; break;
case "xml/config/config_scificlassics_1_1.xml": ConfigID=19002; break;
case "xml/config/config_scificlassics_3_300.xml": ConfigID=19003; break;
case "xml/config/config_dew_1_1.xml": ConfigID=20000; break;
case "xml/config/config_dew_3_300.xml": ConfigID=20001; break;
case "xml/config/config_dogshowusa_1_1.xml": ConfigID=20002; break;
case "xml/config/config_dogshowusa_3_300.xml": ConfigID=20003; break;
case "xml/config/config_nbcsports_1_1.xml": ConfigID=20004; break;
case "xml/config/config_nbcsports_3_300.xml": ConfigID=20005; break;
case "xml/config/config_nbcsportsfullepisode_1_1.xml": ConfigID=20006; break;
case "xml/config/config_nbcsportsfullepisode_3_300.xml": ConfigID=20007; break;
case "xml/config/config_nbcsportssi_1_1.xml": ConfigID=20008; break;
case "xml/config/config_nbcsportssi_3_300.xml": ConfigID=20009; break;
case "xml/config/config_rotoworld_1_1.xml": ConfigID=20010; break;
case "xml/config/config_rotoworld_3_300.xml": ConfigID=20011; break;
case "xml/config/config_rydercup_1_1.xml": ConfigID=20012; break;
case "xml/config/config_rydercup_3_300.xml": ConfigID=20013; break;
case "xml/config/config_blinddate_1_1.xml": ConfigID=21000; break;
case "xml/config/config_blinddate_3_300.xml": ConfigID=21001; break;
case "xml/config/config_chrismatthews_1_1.xml": ConfigID=21002; break;
case "xml/config/config_chrismatthews_3_300.xml": ConfigID=21003; break;
case "xml/config/config_jerryspringertv_1_1.xml": ConfigID=21004; break;
case "xml/config/config_jerryspringertv_3_300.xml": ConfigID=21005; break;
case "xml/config/config_mauryshow_1_1.xml": ConfigID=21006; break;
case "xml/config/config_mauryshow_3_300.xml": ConfigID=21007; break;
case "xml/config/config_digphilly_1_1.xml": ConfigID=22000; break;
case "xml/config/config_digphilly_3_300.xml": ConfigID=22001; break;
case "xml/config/config_ivillagelive_1_1.xml": ConfigID=22002; break;
case "xml/config/config_ivillagelive_3_300.xml": ConfigID=22003; break;
case "xml/config/config_knbc_1_1.xml": ConfigID=22004; break;
case "xml/config/config_knbc_3_300.xml": ConfigID=22005; break;
case "xml/config/config_knsd_1_1.xml": ConfigID=22006; break;
case "xml/config/config_knsd_3_300.xml": ConfigID=22007; break;
case "xml/config/config_kntv_1_1.xml": ConfigID=22008; break;
case "xml/config/config_kntv_3_300.xml": ConfigID=22009; break;
case "xml/config/config_kxas_1_1.xml": ConfigID=22010; break;
case "xml/config/config_kxas_3_300.xml": ConfigID=22011; break;
case "xml/config/config_tvsd_1_1.xml": ConfigID=22012; break;
case "xml/config/config_tvsd_3_300.xml": ConfigID=22013; break;
case "xml/config/config_wcau_1_1.xml": ConfigID=22014; break;
case "xml/config/config_wcau_3_300.xml": ConfigID=22015; break;
case "xml/config/config_wmaq_1_1.xml": ConfigID=22016; break;
case "xml/config/config_wmaq_3_300.xml": ConfigID=22017; break;
case "xml/config/config_wnbc_1_1.xml": ConfigID=22018; break;
case "xml/config/config_wnbc_3_300.xml": ConfigID=22019; break;
case "xml/config/config_wnbckids_1_1.xml": ConfigID=22020; break;
case "xml/config/config_wnbckids_3_300.xml": ConfigID=22021; break;
case "xml/config/config_wrc_1_1.xml": ConfigID=22022; break;
case "xml/config/config_wrc_3_300.xml": ConfigID=22023; break;
case "xml/config/config_wtvj_1_1.xml": ConfigID=22024; break;
case "xml/config/config_wtvj_3_300.xml": ConfigID=22025; break;
case "xml/config/config_wvit_1_1.xml": ConfigID=22026; break;
case "xml/config/config_wvit_3_300.xml": ConfigID=22027; break;
case "xml/config/config_usa_1_1.xml": ConfigID=23000; break;
case "xml/config/config_usa_3_300.xml": ConfigID=23001; break;
case "xml/config/config_usafullepisode_1_1.xml": ConfigID=23002; break;
case "xml/config/config_usafullepisode_3_300.xml": ConfigID=23003; break;
default: ConfigID=10000; break;
}

	
console.log("ConfigID:" +ConfigID+"configLocation:" +configLocation);

			//TEMP HARDCODED config.xml for transition from 2.x to 3.x
			configLocation = "config.xml";
			//TEMP HARDCODED controls/skin5.swf for transition from 2.x to 3.x until skins are finished
			//videoControls= "controls/skin5.swf";
			this.embedPlayer3( targetDivID, companionContainerID, deepLinkIDOrPath, width, height, configLocation, videoControls, autoStartOnEmbed, initialVolume, exitFullscreenOnVideoComplete, embVal, overrideRandom, overrideKeyword1, overrideKeyword2, overrideKeyword3, overrideClipID,ConfigID);
		});
		method("embedPlayer3", function( targetDivID, companionContainerID, deepLinkIDOrPath, width, height, configLocation, videoControls, autoStartOnEmbed, initialVolume, exitFullscreenOnVideoComplete, embVal, overrideRandom, overrideKeyword1, overrideKeyword2, overrideKeyword3, overrideClipID,configID )
		{
			
			//SET ENABLE FULLSCREEN BY DEFAULT
			enableFullscreen = true;
			
			//if this has already been embedded, return it
			if (this.players[targetDivID]) return this.players[targetDivID];
			
			//ensure the target is available
			if (!document.getElementById(targetDivID))
		
			//defaults
			var deepLinkID = "";
			var deepLinkPath = "";
			var playerWidth = 384;
			var playerHeight = 316;
			var theconfigID = 100;
			
			if (deepLinkIDOrPath)
			{
				if (typeof deepLinkIDOrPath == "string" && deepLinkIDOrPath.indexOf("/") != -1)
				{
					deepLinkPath = deepLinkIDOrPath;
				} else {
					deepLinkID = deepLinkIDOrPath;
				}
			}
			
			if (typeof width == "number" && typeof height == "number")
			{
				playerWidth = width;
				playerHeight = height;
			}
			if (typeof configID == "number") theconfigID = configID;

			this.lastPlayer = new EmbeddedPlayer(this, targetDivID, companionContainerID, deepLinkID, deepLinkPath, playerWidth, playerHeight, configLocation, videoControls, autoStartOnEmbed, initialVolume, enableFullscreen, exitFullscreenOnVideoComplete, embVal, overrideRandom, overrideKeyword1, overrideKeyword2, overrideKeyword3, overrideClipID,theconfigID );
			this.players[targetDivID] = this.lastPlayer;
			this.lastPlayer.currentClip.dlid = deepLinkID;	//ADDED 01-05-2007: ADAM GREENBAUM
			return this.lastPlayer;
		});
		
		
		// SG: public setter of companion reference
		method( "setCompanion", function( companion )
		{
			this.companionReference = companion;
		});		
		// SG: public setter of companion reference
		method( "testRef", function( guy )
		{
			alert("you are connected"+ guy);
		});
		
		// SG: public getter of companion reference
		method( "getCompanionReference", function()
		{
			return this.companionReference;
		});
		
		
		method("getPlayer", function(playerID)
		{
			try {
				//getPlayer() returns the last one used (not guaranteed to be singleton)
				if ( typeof playerID == "undefined" ) {
					return this.lastPlayer;
				}
				this.lastPlayer = this.players[playerID];
				return this.lastPlayer;
			} catch( e ) {
				// error message goes here...
			}
		});
		
		doItToAll_array =["pause","play","mute","volumeUp", "volumeDown","rewind", "fastForward"];
		
		for(i in doItToAll_array) {
			my_str = 'method("'+ doItToAll_array[i]+'All", function()';
			my_str +='{';
			my_str +=	'try {';
			my_str +=		'for ( var i in this.players ) {';
			my_str +=			'if (this.players[i].id) {';
			my_str +=				'this.players[i].'+doItToAll_array[i]+'();';
			my_str +=			'}';
			my_str +=		'}';
			my_str +=	'} catch( e ) {';
			my_str +=	'debugOutput("ePM.'+doItToAll_array[i]+'All(): "+e.message);';
			my_str +=	'}'	;
			my_str +='});';
			
			eval(my_str);
		}
					
		
		method( "setBaseLocation", function(baseLocationValue)
		{
			this.BASE_LOCATION = baseLocationValue;
		});
		
		method( "setCompanionRenderer", function(companionRendererValue)
		{
			this.COMPANION_RENDERER = companionRendererValue;
		});
		
		method( "setMetadataThumbURL", function(metadataThumbURLValue)
		{
			this.METADATA_THUMB_URL = metadataThumbURLValue;
		});
		
		method("setActivePlayer", function(playerID) {
		/*
		ADDED 01-15-2007, Adam Greenbaum
		Set current player / lastPlayer
		*/
			try {
				if (this.isValidPlayer(playerID) == true)
				{	this.lastPlayer = this.players[playerID];	}
				else
				{	this.lastPlayer = this.lastPlayer;	}
			} catch( e ) {
				debugOutput("ePM.setActivePlayer(): "+e.message);
				// error message goes here...
			}
		});
		
		method("isValidPlayer", function(playerID) {
		/*
		ADDED 01-15-2007, Adam Greenbaum
		Validate if playerID is valid
		*/
			try {
				//VALIDATE PLAYLIST
				var isValidPlayer = false;
				for (var i in this.players)
				{
					if (i == playerID)
					{	isValidPlayer = true;}
				}
				return isValidPlayer;
			} catch( e ) {
				debugOutput("ePM.isValidPlayer(): "+e.message);
				// error message goes here...
			}
		});
		
		method("setActiveFullscreen", function(aPlayer)
		{
			this.fullscreenPlayer = aPlayer;
		});
		
		//takes the full screen player out of full screen
		method("unFullscreen", function()
		{
			this.fullscreenPlayer.fullscreen( false );
		});
		
		method("updatePositions", function()
		{
			for (var i in this.players) {
				var currentPlayer = this.players[i];
				if (currentPlayer.id) {
					var placeholderPos = EmbeddedPlayerUtil.getElementPosition("placeholder_"+ currentPlayer.id);
					currentPlayer.container.style.left = placeholderPos.x + "px";
					currentPlayer.container.style.top = placeholderPos.y + "px";
					
					if ( navigator.userAgent.toLowerCase().indexOf( "msie" ) > -1 ) { // position correction for IE
						currentPlayer.container.style.left = parseInt( currentPlayer.container.style.left ) + 1 + "px";
						currentPlayer.container.style.top = parseInt( currentPlayer.container.style.top ) + 1 + "px";
					}
					
				}
			}
		});
		
		method("initOnResize", function()
		{
			var _self = this;
			if (typeof(window.onresize) != 'function') {
				window.onresize = function() {
					_self.updatePositions();
				}
			} else {
				if (!this.oldResize) {
					this.oldResize = window.onresize;
				}
				window.onresize = function() {
					_self.oldResize();
					_self.updatePositions();
				}
			}
		});
		
		method("resetOnResize", function() {
			if (this.oldResize) {
				window.onresize = this.oldResize;
			} else {
				window.onresize = null;
			}
			this.initOnResize();
		});
		
		//ADDED 03-02-2007
		method("initOnScroll", function()
		{
			var _self = this;
			if (typeof(window.onscroll) != 'function') {
				window.onscroll = function() {
					_self.updatePositions();
				}
			} else {
				if (!this.oldScroll) {
					this.oldScroll = window.onscroll;
				}
				window.onscroll = function() {
					_self.oldScroll();
					_self.updatePositions();
				}
			}
		});
		
		//ADDED 03-02-2007
		method("resetOnScroll", function() {
			if (this.oldScroll) {
				window.onscroll = this.oldScroll;
			} else {
				window.onscroll = null;
			}
			this.initOnScroll();
		});
	}
	return new Constructor();
};



//embPlayerOBJect begin

if (typeof EmbeddedPlayer == "undefined")
EmbeddedPlayer = function(manager, targetDivID, companionContainerID, deepLinkID, deepLinkPath, playerWidth, playerHeight, configLocation, videoControls, autoStartOnEmbed, initialVolume, enableFullscreen, exitFullscreenOnVideoComplete, embVal, overrideRandom, overrideKeyword1, overrideKeyword2, overrideKeyword3, overrideClipID,configID )
{
	function Constructor()
	{
		//public vars
		this.manager = manager;
		this.id = targetDivID;
		this.onMetadata;
		this.onClearMetadata;
		this.companion;				//the instance of the Companion class we're using
		this.swf;						//the swf <object> or <embed> tag
		this.container;				//the div holding the swf
		this.companionDiv		//ADDED 01-09-2007 [ADAM GREENBAUM]: Div for Companion
		//this.companioniframe;	//iframe that shows companion ad	COMMENTED OUT 01-09-2007
		this.width = playerWidth;
		this.height = playerHeight;
		this.isFullscreen = false;	//tracks if we're fullscreen
		this.isFullscreenEnabled = (enableFullscreen == true); //default to false
		//this.isPlayingAd2 = this.isPlayingAd();
		this.playingAdType;			//ADDED 01-09-2007: For Ad Types
		this.placeholder;
		this.oldWin;
		this.lastScrollPos;
		this.divIDList = new Array();		//added 11-29-2006: Adam Greenbaum - For JS Fullscreen
		this.cssPropertyList1;				//added 11-29-2006: Adam Greenbaum - For JS Fullscreen
		this.cssPropertyList2;				//added 11-29-2006: Adam Greenbaum - For JS Fullscreen
		//this.playlistCurrentDLID = 0;		//ADDED 01-05-2007 [ADAM GREENBAUM]: For Playlists
		//this.playlistCurrentPosition = -1;	//ADDED 01-05-2007 [ADAM GREENBAUM]: For Playlists
		//this.playlistSeedDLID = null;		//ADDED 01-05-2007 [ADAM GREENBAUM]: For Playlists
		//this.playlist = new Array();		//ADDED 01-05-2007 [ADAM GREENBAUM]: For Playlists
		this.currentClip = new Object();	//ADDED 01-12-2007 [ADAM GREENBAUM]: For storing current clip info
		this.currentClip.dlid = 0;
		this.metadataContainers = new MetadataContainer(this);	//ADDED 01-09-2007 [ADAM GREENBAUM]: For onMetadata elements
		this.metadata = new Object();		//ADDED 01-10-2007 [ADAM GREENBAUM]: For onMetadata clipObject
		this.playlists = new Array();		//ADDED 01-11-2007 [ADAM GREENBAUM]: For new Object playlists
		this.lastPlaylist;					//ADDED 01-11-2007 [ADAM GREENBAUM]: For new Object playlists
		this.activePlaylist;				//ADDED 01-11-2007 [ADAM GREENBAUM]: For new Object playlists
		this.runOnFullscreenStartFunction;		//ADDED 01-12-2007 [ADAM GREENBAUM]: For RunOnFullscreenStart function
		this.runOnFullscreenEndFunction;		//ADDED 01-12-2007 [ADAM GREENBAUM]: For RunOnFullscreenEnd function
		this.runOnBeginFunction;			//RENAMED 01-16-2007 [ADAM GREENBAUM] - runOnPlay (start of ad)
		this.runOnClipStartFunction;		//RENAMED 01-16-2007 [ADAM GREENBAUM] - runOnStart (start of clip)
		this.runOnClipSwitchedFunction;		//RENAMED 01-16-2007 [ADAM GREENBAUM] - runOnSwitched (start of ad)
		this.runOnClipCompletedFunction;	//RENAMED 01-16-2007 [ADAM GREENBAUM] - runOnPlay (start of ad)
		this.runOnClosedFunction;			//ADDED 01-12-2007 [ADAM GREENBAUM]: For RunOnClosed function
		this.runOnEndFunction;				//ADDED 01-16-2007 [ADAM GREENBAUM] - runOnEnd (end of content / postroll)
		this.allowPlaylistAdvance = true;	//ADDED 02-01-2007 [ADAM GREENBAUm - For allowing playlist to continue]

		//ONCLEARMETADATA - After clip finishes / postroll finishes
		this.onClearMetadata = function()
		{
			this.executeRunOnEnd();
			if (this.allowPlaylistAdvance == true)
			{	//if (document.getElementById( "debugAds" )) document.getElementById("debugAds").innerHTML = "<br>onclearmetadata+playlistadvance" + document.getElementById("debugAds").innerHTML;
				this.activePlaylist.playNext();}
			//this.activePlaylist.playNext();
		}
		
		
		
		this.companionDiv = document.getElementById( companionContainerID );
		
		//create swfobject. we will set things like width and height later depending on if we're doing fullscreen or not. 
		var swfid = "player_" + targetDivID;
		var swfobject = new deconcept.SWFObject(embeddedPlayerManager.BASE_LOCATION + "embedded.swf", swfid, null, null, "8", "#000000", true);
		swfobject.addParam("allowScriptAccess", "always");
		//swfobject.addParam("wmode","transparent"); //MOB
		swfobject.addParam("allowFullScreen", "true");
		if (deepLinkID) swfobject.addVariable("deepLinkID", deepLinkID);
		if (deepLinkPath) swfobject.addVariable("deepLinkPath", deepLinkPath);
		if (videoControls) swfobject.addVariable("overridevideoControls", videoControls);
		if ( exitFullscreenOnVideoComplete != undefined ) swfobject.addVariable("overrideexitFullscreenOnVideoComplete", exitFullscreenOnVideoComplete);
		if ( overrideKeyword1 ) swfobject.addVariable( "overrideKeyword1", overrideKeyword1 ); 	//ADDED FOR VERSION 2.0 - 1-10-2007
		if ( overrideKeyword2 ) swfobject.addVariable( "overrideKeyword2", overrideKeyword2 );	//ADDED FOR VERSION 2.0 - 1-10-2007
		if ( overrideKeyword3 ) swfobject.addVariable( "overrideKeyword3", overrideKeyword3 );	//ADDED FOR VERSION 2.0 - 1-10-2007
		if ( overrideClipID ) swfobject.addVariable( "overrideClipID", overrideClipID );		//CHANGED FOR VERSION 2.0, FROM overrideVideoID to overrideClipID
		if ( overrideRandom ) swfobject.addVariable( "overrideRandom", overrideRandom );	//ADDED FOR VERSION 2.0 - 1-10-2007
		if ( embVal ) swfobject.addVariable( "overrideembVal", embVal ); 
		if ( configLocation ) swfobject.addVariable( "passAlong_configFile", configLocation );
		if ( autoStartOnEmbed) swfobject.addVariable( "overrideautoStart", autoStartOnEmbed );
		if ( autoStartOnEmbed===false) swfobject.addVariable( "overrideautoStart", autoStartOnEmbed );
		if ( initialVolume ) swfobject.addVariable( "overridevolume", initialVolume );	//ADDED FOR VERSION 2.0 - 1-10-2007		
		//if ( overrideNetworkID ) swfobject.addVariable( "overrideNetworkID", overrideNetworkID );	//OLD - Version 1.2 - 1-10-2007
		if ( embeddedPlayerManager.BASE_LOCATION ) swfobject.addVariable( "passAlong_baseLocation", embeddedPlayerManager.BASE_LOCATION );
		swfobject.addVariable("playerID", targetDivID);
		//swfobject.addVariable("autoStart", autoStart);	//USING ONE ABOVE
		swfobject.addVariable( "passAlong_configID", configID);
		if ( this.isFullscreenEnabled )
		{
			//fullscreen approach: you can't change position of a div with flash without
			//having the movie restart, so we actually create 2 new divs.
			//
			//the PLACEHOLDER goes into the flow at the target point and reserves space for
			//the player in its normal state.
			//
			//the CONTAINER is added at the end of the body and is absolutely positioned.
			//The swf will be embedded inside the CONTAINER, and the container will be placed
			//over top of the placeholder.
			//
			//The swf is embedded inside the container at 100%x100%, allowing the container
			//div's size to control the effective size of the player. The container div
			//is created at the normal size of the player.
			//
			//When fullscreen is triggered, the CONTAINER is set to fill the entire screen.
			
			//create new container to hold actual player
			this.container = document.createElement("div");
			var containerID = "container_" + this.id;
			this.container.id = containerID;
			this.container.className = "fullscreenPlayer";
			document.body.appendChild(this.container);
			with (this.container.style)
			{
				position = "absolute";  
				width = playerWidth + "px";
				height = playerHeight + "px";
				margin = "0";
				padding = "0";
				backgroundColor = "#000";
				border = "none";
			}
			
			//create placeholder to save space in the layout for the real swf to be put on top of
			this.placeholder = document.createElement("div");
			this.placeholder.id = "placeholder_" + this.id;
			document.getElementById(targetDivID).appendChild(this.placeholder);
			with (this.placeholder.style)
			{
				width = playerWidth + "px";
				height = playerHeight + "px";
				margin = "0";
				padding = "0";
				border = "none";
			}
			
			//move container to be on top of placeholder
			var placeholderPos = EmbeddedPlayerUtil.getElementPosition("placeholder_"+ this.id);

			this.container.style.left = placeholderPos.x + "px";
			this.container.style.top = placeholderPos.y + "px";
			
			if ( navigator.userAgent.toLowerCase().indexOf( "msie" ) > -1 ) { // position correction for IE
				this.container.style.left = parseInt( this.container.style.left ) + 1 + "px";
				this.container.style.top = parseInt( this.container.style.top ) + 1 + "px";
			}
			
			swfobject.setAttribute("width", "100%");
			swfobject.setAttribute("height", "100%");
			swfobject.write(containerID);
		} else {
			swfobject.setAttribute("width", playerWidth);
			swfobject.setAttribute("height", playerHeight);
			swfobject.write(targetDivID);
		}
		
		this.swf = document.getElementById(swfid);
	}
	
	//public methods
	with(Constructor)
	{
		method("_onFullscreen", function( newFullscreenState )
		{
			if ( typeof newFullscreenState != "boolean" ) return;
			if ( !this.isFullscreenEnabled ) { debugOutput("Fullscreen not enabled for this player.","warn"); return; }
			// if (newFullscreenState == this.isFullscreen) return;
			
			this.isFullscreen = newFullscreenState;
			if ( this.isFullscreen )
			{
				this.setOldWindowParameters();
				
				//this.manager.setActiveFullscreen( this );
				//var _self = this;
				window.onresize = function() {
					// _self.goFullScreen();
				}
				//CALL FULLSCREEN_START FUNCTION
				this.executeRunOnFullscreenStart();
				//HIDE PAGE ELEMENTS - ALL BROWSERS
				//ADDED 11-29-2006
				this.onEnterFullScreenCSS();
				this.goFullScreenJS();	//CHANGED 01-2007 FOR NEW FUNCTON NAME

			} 
			else { // restore normal mode
				var c = this.container;
				with (c.style)
				{
					top = left = right = bottom = "";
				}

				this.placeholder.style.width = this.width + "px";
				this.placeholder.style.height = this.height + "px";
				
				var placeholderPos = EmbeddedPlayerUtil.getElementPosition("placeholder_"+ this.id);
				c.style.width = this.width + "px";
				c.style.height = this.height + "px";
				c.style.left = placeholderPos.x + "px";
				c.style.top = placeholderPos.y + "px";
				
				// if not Firefox
				if (navigator.userAgent.toLowerCase().indexOf("firefox") == -1)
				{
					if (document.documentElement) { // IE strict mode
						document.documentElement.style.overflow = "";
						
						if ( navigator.userAgent.toLowerCase().indexOf( "safari" ) > -1 ) { // Safari
							document.body.style.overflow = "visible";
						}
						
					} else { // IE quirks mode
						document.body.style.overflow = "";
					}
				}
				window.onscroll = function(){};
				
				this.manager.resetOnResize();
				
				// alert( "width: " + this.oldWin.w + " height: " + this.oldWin.h + " x: " + this.oldWin.l + " y: " + this.oldWin.t  );
				
				if ( !document.all ) {
					top.window.resizeTo( this.oldWin.w, this.oldWin.h ); // resize browser window to old size
					top.window.moveTo( this.oldWin.l, this.oldWin.t ); // move browser window to old opsition
					window.scrollTo( 0, this.lastScrollPos );
				} else { // IE
					//top.window.resizeTo( 800, 600 ); // resize browser window to 800x600
					//top.window.moveTo( this.oldWin.l, this.oldWin.t ); // move browser window to old opsition
					//window.scrollTo( 0, this.lastScrollPos );
					top.window.resizeTo( this.oldWin.w, this.oldWin.h ); // resize browser window to old size
					top.window.moveTo( this.oldWin.l, this.oldWin.t ); // move browser window to old opsition
					window.scrollTo( 0, this.lastScrollPos );
				}
				//CALL FULLSCREEN_END FUNCTION
				this.executeRunOnFullscreenEnd();
				
				//HIDE PAGE ELEMENTS - ALL BROWSERS
				//ADDED 11-29-2006
				this.onExitFullScreenCSS();
			}
		});
		
		
		method("setFullscreenElementIDs", function(elementList) {
		/*
		ADDED 11-29-2006, Adam Greenbaum
		Fix for wmode=transparent / wmode=opaque issue in firefox
		For all browsers
		NOTE: Create array of elements to hide/work with.
		*/
			//this.divIDList = new Array();
			this.divIDList = elementList.split(",");
		});


		method("onEnterFullScreenCSS", function() {
		/*
		ADDED 11-29-2006, Adam Greenbaum
		Fix for wmode=transparent / wmode=opaque issue in firefox
		For all browsers
		*/

			//if (navigator.userAgent.toLowerCase().indexOf("firefox") > -1)
			//{
				this.cssPropertyList1 = new Array();
				this.cssPropertyList2 = new Array();
				var cssPropertyList1_container = "";
				var cssPropertyList2_container = "";
				for (var i = 0; i < this.divIDList.length; i++)
				{
					try
					{
						if (cssPropertyList1_container != "" )	{cssPropertyList1_container = cssPropertyList1_container + ",";}
						if (cssPropertyList2_container != "" )	{cssPropertyList2_container = cssPropertyList2_container + ",";}
						cssPropertyList1_container = cssPropertyList1_container + this.getStyle(this.divIDList[i].toString(),"overflow");
						cssPropertyList2_container = cssPropertyList2_container + this.getStyle(this.divIDList[i].toString(),"visibility");
						debugOutput("ENTER-BEFORE:"+ i +"|"+ this.divIDList[i].toString() +"|"+ this.getStyle(this.divIDList[i].toString(),"overflow") +"|"+ this.getStyle(this.divIDList[i].toString(),"visibility"),"info");
						document.getElementById(this.divIDList[i].toString()).style.overflow = "hidden";
						document.getElementById(this.divIDList[i].toString()).style.visibility = "hidden";
						debugOutput("ENTER-AFTER:"+ i +"|"+ this.divIDList[i].toString() +"|"+ this.getStyle(this.divIDList[i].toString(),"overflow") +"|"+ this.getStyle(this.divIDList[i].toString(),"visibility"),"info");
					}
					catch( e )
					{	debugOutput("ePM.getPlayer().onEnterFullScreenCSS: "+e.message);	}
				}
				this.cssPropertyList1 = cssPropertyList1_container.split(",");
				this.cssPropertyList2 = cssPropertyList2_container.split(",");
			//}
		});


		method("onExitFullScreenCSS", function() {
		/*
		ADDED 11-29-2006, Adam Greenbaum
		Fix for wmode=transparent / wmode=opaque issue in firefox
		For all browsers
		*/

			//if (navigator.userAgent.toLowerCase().indexOf("firefox") > -1)
			//{
				for (var i = 0; i < this.divIDList.length; i++)
				{
					try
					{
						debugOutput("EXIT-BEFORE:"+ i +"|"+ this.divIDList[i].toString() +"|"+ this.getStyle(this.divIDList[i].toString(),"overflow") +"|"+ this.getStyle(this.divIDList[i].toString(),"visibility"),"info");
						document.getElementById(this.divIDList[i].toString()).style.overflow = this.cssPropertyList1[i].toString();
						document.getElementById(this.divIDList[i].toString()).style.visibility = this.cssPropertyList2[i].toString();
						debugOutput("EXIT-AFTER:"+ i +"|"+ this.divIDList[i].toString() +"|"+ this.getStyle(this.divIDList[i].toString(),"overflow") +"|"+ this.getStyle(this.divIDList[i].toString(),"visibility"),"info");
						//console.info(this.divIDList[i].toString());
					}
					catch( e )
					{	debugOutput("ePM.getPlayer.onExitFullScreenCSS: "+e.message);	}
				//}
			}
		});
		
		method( "getStyle", function( el,styleProp )
		{
		/*
		Get Style helper for CSS detection
		*/
			var x = document.getElementById(el);
			if (x.currentStyle)
				var y = x.currentStyle[styleProp];
			else if (window.getComputedStyle)
				var y = document.defaultView.getComputedStyle(x,null).getPropertyValue(styleProp);
			return y;		
		});
		
		method("goFullScreenJS", function() {	//CHANGED 01-2007 - FUNCTION NAME CHANGED FROM goFullScreen to goFullScreenJS
			
			//////////////////////////////////////////////////
			// SG: resize browser window to fullscreen	
			//////////////////////////////////////////////////
			top.window.moveTo( 0, 0 );

			if ( document.all ) { 
				top.window.resizeTo( screen.availWidth, screen.availHeight ); 
			} else if ( document.layers || document.getElementById ) { 
   				if ( top.window.outerHeight < screen.availHeight || top.window.outerWidth < screen.availWidth ) { 
					top.window.outerHeight = top.screen.availHeight; 
       				top.window.outerWidth = top.screen.availWidth; 
				} 	
			}
	
			if ( navigator.userAgent.toLowerCase().indexOf( "mac" ) > -1 && navigator.userAgent.toLowerCase().indexOf( "netscape" ) > -1 ) {
				top.window.moveTo( 0, 0 );
			}
	
			if ( navigator.userAgent.toLowerCase().indexOf( "safari" ) > -1 ) {
				top.window.resizeTo( screen.availWidth, screen.availHeight );
			}
			//////////////////////////////////////////////////
			//////////////////////////////////////////////////

			var scrollPos = this.setContainer();
			window.onscroll = function(){ window.scrollTo( 0, scrollPos ); };
			window.onscroll();
			
			var _self = this;
			window.onresize = function() {
				_self.setContainer();		
			}
			
		});
		
		
		method( "setContainer", function()
		{
			
			//this is the great way to remove the browser's scrollbars
			//unfortunately in mozilla it forces the swf to reload = no seamless experience
			
			var c = this.container;
			var scrollPos = 0;
			if ( navigator.userAgent.toLowerCase().indexOf("firefox") == -1 ) {
				if ( document.documentElement && document.documentElement.scrollTop ) {
					document.documentElement.style.overflow = "hidden";
					scrollPos = document.documentElement.scrollTop;
				} else if ( document.body.scrollTop ) {
					if (navigator.userAgent.toLowerCase().indexOf("safari") > -1) {
						document.body.style.overflow = "visible";
					}
					else {	document.body.style.overflow = "hidden"; }
					scrollPos = document.body.scrollTop;
				}
				// save scrollpos for later. // only once
				if ( this.lastScrollPos == null ) { this.lastScrollPos = scrollPos; }
			} else {
				// save scrollpos for later // only once
				if ( this.lastScrollPos == null ) { this.lastScrollPos = window.pageYOffset; }
			}
				
			var ch = 0;
			var cw = 0;
			if ( typeof( window.innerWidth ) == 'number' ) {
				ch = window.innerHeight;
				cw = window.innerWidth;
			} else if ( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
				ch = document.documentElement.clientHeight;
				cw = document.documentElement.clientWidth;
			} else if ( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
				ch = document.body.clientHeight;
				cw = document.body.clientWidth;
			}
			with ( c.style ) {
				if ( document.all && !window.opera ) {
					height = ch +"px";
					width = cw +"px";
				} else {
					height = "100%";
					width = "100%";
				}
				left = "0px";
				right = "0px";
				bottom = "0px";
				top = scrollPos + "px";
			}
			
			return scrollPos;

		});
		
		
		// store parameters of old window
		method( "setOldWindowParameters", function()
		{
			
			this.oldWin = new Object(); // save size & location of original window
			this.oldWin.l = top.window.screenX || top.window.screenLeft - 4;
			this.oldWin.t = top.window.screenY || top.window.screenTop - 104;
				
			// Calculating IE outer height/width
			if ( document.all ) {
				//var offW = document.body.offsetWidth;
				//var offH = document.body.offsetHeight;
				//top.window.resizeTo( 800, 600 );
				//var diffW = document.body.offsetWidth - offW;
				//var diffH = document.body.offsetHeight - offH;
				//this.oldWin.w = 800 - diffW + 51;
				//this.oldWin.h = 600 - diffH + 139;	
				this.oldWin.w = document.documentElement.clientWidth + 30;
				this.oldWin.h = document.documentElement.clientHeight + 135;
			} else {
				this.oldWin.h = top.window.outerHeight;
				this.oldWin.w = top.window.outerWidth;
			} 
				
			this.lastScrollPos = null; // reset last scroll position

		});
		
		
		method( "onPlayVideo", function( clipObject )
		{

			var wasPlayingAd = this.isPlayingAd();
			//this.isPlayingAd = clipObject.isAd;
			this.playingAdType = clipObject.adType;
			
			if ( wasPlayingAd && !this.isPlayingAd() ) {
				this.companion = embeddedPlayerManager.getCompanionReference(); //get the companion object
				if ( this.companion != "" && this.companion != null ) { // object = swf, nonobject (empty string) = image
					// this.companion.collapse();
				}
			}
		
		});


		// SG: Call from Flash -> load companion ad
		method( "companionCall", function( evt)
		//method( "onLoadCompanion", function( evt )
		{
			//GET ALL VALUES FROM EVENTS OBJECT
			var companionURL = this.validateCompanionParam(evt["companionObject"]["companionURL"]);
			var companionClickURL = this.validateCompanionParam(evt["companionObject"]["companionClickURL"]);
			var companionType = this.validateCompanionParam(evt["companionObject"]["companionType"]);
			var JScompanionCallString = this.validateCompanionParam(evt["companionObject"]["JScompanionCallString"]);
				//test
			//		DEBUG FOR COMPANION
			
			//var test1 =this.validateCompanionParam(ad["JScompanionCallString"]);
			tempStrMOB = "This is HERE FOR TESTING ONLY REMOVE alert FOR Poduction\n";
			tempStrMOB += "JScompanionCallString="+JScompanionCallString;
			tempStrMOB += "companionClickURL:"+companionClickURL+" companionURL:"+companionURL+" companionType:"+companionType+" \n";

			//document.getElementById("debugEvent").innerHTML = tempStrMOB;  // for testing only 
			debugOutput("tempStrMOB" + tempStrMOB);
			
			if (companionClickURL != "" && companionURL != "")	//STANDARD COMPANION
			{	this.writeCompanion(companionType,companionURL,companionClickURL)}
			else	//300x250
			{	this.write300x250(JScompanionCallString)}
			
		
		});
		
		//FUNCTION: Render Companion Ad
		method( "writeCompanion", function(companionType,companionURL,companionClickURL)
		{
			var divid = this.companionDiv.id.toString();
			companionURL = companionURL.replace("[timestamp]",Math.round(1000000000000*Math.random()));
			companionClickURL = companionClickURL.replace("[timestamp]",Math.round(1000000000000*Math.random()));
			switch(companionType)
			{
				case "swf":
					var adswfid = "companionSWF_" + divid;
					var swfobject = new deconcept.SWFObject( "http://video.nbcuni.com/embed/player_1-2/companion.swf", adswfid, "300", "250", "8", "#000000" );
					swfobject.addParam( "wmode", "transparent" );
					swfobject.addParam( "allowScriptAccess", "always" );
					swfobject.addVariable( "sourceURL", escape( companionURL ) );
					swfobject.addVariable( "linkURL", escape( companionClickURL ) );
					swfobject.write( divid );
					var swf = document.getElementById( adswfid );
					if (typeof EmbeddedPlayerManager != "undefined")	{embeddedPlayerManager.setCompanion( swf );}
					break;
				case "image":
					document.getElementById( divid ).innerHTML = "<a href='" + companionClickURL + "' target='_blank'><img src=\'" + companionURL + "\' border=\'0\' /></a>"; // simple href
					if (typeof EmbeddedPlayerManager != "undefined")	{embeddedPlayerManager.setCompanion( null );}
					break;
				case "iframe":
					document.getElementById( divid ).innerHTML = "<iframe src='" + companionURL + "' frameborder=\'0\' width=\'300\' height=\'250\' scrolling=\'no\' allowtransparency=\'true\' /></iframe>"; 
					if (typeof EmbeddedPlayerManager != "undefined")	{embeddedPlayerManager.setCompanion( null );}
					break;
				case "js":
					document.getElementById( divid ).innerHTML = "<iframe id='companionAdiFrame' scrolling=\'no\' frameborder=\'0\' width=\'300\' height=\'250\' allowtransparency=\'true\' src='"+embeddedPlayerManager.COMPANION_RENDERER+"?companionType=js&companion="+escape(companionURL)+"' /></iframe>"; 
					if (typeof EmbeddedPlayerManager != "undefined")	{embeddedPlayerManager.setCompanion( null );}
					break;
				default:
					document.getElementById( divid ).innerHTML = "<a href='" + companionClickURL + "' target='_blank'><img src=\'" + companionURL + "\' border=\'0\' /></a>"; // simple href
					if (typeof EmbeddedPlayerManager != "undefined")	{embeddedPlayerManager.setCompanion( null );}
			}
		});
		
		//FUNCTION: Render 300x250
		method( "write300x250", function(JScompanionCallString)
		{
			var divid = this.companionDiv.id.toString();
			document.getElementById( divid ).innerHTML = "<iframe id='companionAdiFrame' frameborder=\'0\' scrolling=\'no\' width=\'300\' height=\'250\' src='"+
			embeddedPlayerManager.COMPANION_RENDERER+"?companionType=300x250&JScom="+escape(JScompanionCallString)+"' /></iframe>"; 
			if (typeof EmbeddedPlayerManager != "undefined")	{embeddedPlayerManager.setCompanion( null );}
		});
		
		//FUNCTION: ValidateParam
		method( "validateCompanionParam", function(param)
		{
			if (typeof param == "undefined" || param == "null" || param == "undefined" || param == null || param == undefined)
			{	return "";}
			else
			{	return param;}
		});
		
		
		//PUBLIC METHODS
		
		method( "browserWindowBeforeUnload", function()
		{
			try {
				//if ( this.isPlayingAd() ) { return; }
				this.swf.onBrowserWindowBeforeUnload(); // tell flash about onbeforeunload
			} catch( e ) {
				debugOutput("ePM.getPlayer().browserWindowBeforeUnload(): "+e.message);
				// error message goes here...
			}
		});

		//alternate to providing your own data callback: provide container
		//elements and we will create a callback function that writes into these.
		//pass in either html elements or IDs
		//you define your own callback manually by using myPlayer.onMetadata = function(){custom actions;}
		
		method("setMetadataContainers", function(nameContainer, subtitleContainer, descriptionContainer, scheduleContainer)
		{
			this.metadataContainers.setTitle(nameContainer);
			this.metadataContainers.setSubtitle(subtitleContainer);
			this.metadataContainers.setShortDescription(descriptionContainer);
			this.metadataContainers.setAirtime(scheduleContainer);
			this.metadataContainers.setContainers();
			
		});
		
		// SG: resize player on demand by calling embeddedPlayerManager.getPlayer().resizePlayer( width, height )
		method("resizePlayer", function( newWidth, newHeight )
		{
			try {
				this.width = newWidth;
				this.height = newHeight;
				
				var c = this.container;
				with ( c.style ) { top = left = right = bottom = ""; }

				this.placeholder.style.width = this.width + "px";
				this.placeholder.style.height = this.height + "px";
				
				var placeholderPos = EmbeddedPlayerUtil.getElementPosition("placeholder_"+ this.id);
				c.style.width = this.width + "px";
				c.style.height = this.height + "px";
				c.style.left = placeholderPos.x + "px";
				c.style.top = placeholderPos.y + "px";
				
				if ( navigator.userAgent.toLowerCase().indexOf( "msie" ) > -1 ) { // position correction for IE
					c.style.left = parseInt( c.style.left ) + 1 + "px";
					c.style.top = parseInt( c.style.top ) + 1 + "px";
				}
				
			} catch( e ) {
				debugOutput("ePM.getPlayer().resizePlayer(): "+e.message);
				// error message goes here...
			}
		});
		
		method("hidePlayer", function(backgroundColor,backgroundImage,backgroundRepeat,backgroundPosition) {
		/*
		ADDED 01-05-2007, Adam Greenbaum
		Hide Player - for DHTML Rollovers
		*/
			try {
				if (typeof backgroundColor == "undefined" ) {backgroundColor = "black"; }	//SET DEFAULT FOR COLOR
				if (typeof backgroundImage != "undefined")	//IF USING AN IMAGE
				{
					//SET DEFAULTS
					if (typeof backgroundRepeat == "undefined") {backgroundRepeat = "repeat"; }
					if (typeof backgroundPosition == "undefined") {backgroundPosition = "center"; }
					//SET IMAGE PROPERTIES
					document.getElementById("placeholder_"+this.id.toString()).style.backgroundImage = "url("+backgroundImage+")";	//SET BACKGROUND IMAGE VALUE
					document.getElementById("placeholder_"+this.id.toString()).style.backgroundRepeat = backgroundRepeat;	//SET BACKGROUND REPEAT
					document.getElementById("placeholder_"+this.id.toString()).style.backgroundPosition = backgroundPosition;	//SET BACKGROUND POSITION VALUE
				}
				else	//IF JUST BACKGROUND COLOR
				{
					document.getElementById("placeholder_"+this.id.toString()).style.backgroundImage = "";
					document.getElementById("placeholder_"+this.id.toString()).style.backgroundRepeat = "";
					document.getElementById("placeholder_"+this.id.toString()).style.backgroundPosition = "";
				}
				//SET BACKGROUND COLOR
				document.getElementById("placeholder_"+this.id.toString()).style.backgroundColor = backgroundColor;	//SET BACKGROUND COLOR
				//HIDE DIV
				//document.getElementById("container_"+this.id.toString()).style.visibility = "hidden";	//REMOVED 03-02-07 to solve audio drop out
				document.getElementById("container_"+this.id.toString()).style.width = "1px";	//ADDED 03-02-07 to solve audio drop out
				document.getElementById("container_"+this.id.toString()).style.height = "1px";	//ADDED 03-02-07 to solve audio drop out
			} catch( e ) {
				debugOutput("ePM.getPlayer().hidePlayer(): "+e.message);
				//alert(e);// error message goes here...
			}
		});
		
		method("unHidePlayer", function() {
		/*
		ADDED 01-05-2007, Adam Greenbaum
		Un-Hide Player - for DHTML Rollovers
		*/
		try {
			document.getElementById("placeholder_"+this.id.toString()).style.backgroundColor = "#000000";
			document.getElementById("placeholder_"+this.id.toString()).style.backgroundImage = "";
			document.getElementById("placeholder_"+this.id.toString()).style.backgroundRepeat = "";
			document.getElementById("placeholder_"+this.id.toString()).style.backgroundPosition = "";
			//document.getElementById("container_"+this.id).style.visibility = "visible";				//REMOVED 03-02-07 to solve audio drop out
			document.getElementById("container_"+this.id.toString()).style.width = this.width + "px";	//ADDED 03-02-07 to solve audio drop out
			document.getElementById("container_"+this.id.toString()).style.height = this.height + "px";	//ADDED 03-02-07 to solve audio drop out
		}
		catch ( e ) {
			debugOutput("ePM.getPlayer().unHidePlayer: "+e.message);
		}
		});
		
		method( "goFullscreen", function()
		{
			try {
				this.swf.goFullscreen();
				alert("goFull");
			} catch( e ) {
				debugOutput("ePM.getPlayer().goFullscreen(): "+e.message);
				// error message goes here...
			}
		});
		
		// SG: tell Flash to toggle fullscreen. Should be used for public fullscreen call instead of goFullScreen
		method( "toggleFullscreen", function()
		{
			try {
				this.swf.toggleFullscreen();
				alert("goFulltoggle");
			} catch( e ) {
				// error message goes here...
			}
		});
		
		method("setRunOnBegin", function(functionCall) {
		/*
		ADDED 01-11-2007, Adam Greenbaum
		Set function to run on play (once the clip/preroll starts)
		*/
			this.runOnBeginFunction = functionCall;
		});
		
		method("executeRunOnBegin", function() {
		/*
		ADDED 01-11-2007, Adam Greenbaum
		Execute special runOnPlay function
		*/
			try
			{	eval(this.runOnBeginFunction);	}
			catch(e)
			{
				debugOutput("ePM.getPlayer().executeRunOnBegin(): "+e.message);
			}
		});
		
		method("setRunOnClipStart", function(functionCall) {
		/*
		ADDED 01-12-2007, Adam Greenbaum
		Set function to run on clip start (after preroll)
		*/
			this.runOnClipStartFunction = functionCall;
		});
		
		method("start", function() {
		/*
		ADDED 01-12-2007, Adam Greenbaum
		Execute special runOnClipStart function (starts when clip starts)
		*/
			try
			{	eval(this.runOnClipStartFunction);	}
			catch(e)
			{
				debugOutput("ePM.getPlayer().executeRunOnClipStart(): "+e.message);
			}
		});
		method("setRunOnClipSwitched", function(functionCall) {
		/*
		ADDED 01-12-2007, Adam Greenbaum
		Set function to run on clip switch (after click playVideo(dlid))
		*/
			this.runOnClipSwitchedFunction = functionCall;
		});
		
		method("switched", function() {
		/*
		ADDED 01-12-2007, Adam Greenbaum
		Execute special runOnClipSwitched function
		*/
			try
			{	eval(this.runOnClipSwitchedFunction);	}
			catch(e)
			{
				debugOutput("ePM.getPlayer().executeRunOnClipSwitched(): "+e.message);
			}
		});
		
		method("setRunOnClipCompleted", function(functionCall) {
		/*
		ADDED 01-12-2007, Adam Greenbaum
		Set function to run on clip completes 
		*/
			this.runOnClipCompletedFunction = functionCall;
		});
		
		method("end", function() {
		/*
		ADDED 01-12-2007, Adam Greenbaum
		Execute special runOnClipCompleted function
		*/
			try
			{	eval(this.runOnClipCompletedFunction);	}
			catch(e)
			{
				debugOutput("ePM.getPlayer().executeRunOnCompleted(): "+e.message);
			}
		});
		
		method("setRunOnClosed", function(functionCall) {
		/*
		ADDED 01-12-2007, Adam Greenbaum
		Set function to run on window is refreshed/closed 
		*/
			this.runOnClosedFunction = functionCall;
		});
		
		method("executeRunOnClosed", function() {
		/*
		ADDED 01-12-2007, Adam Greenbaum
		Execute special runOnClosed function
		*/
			try
			{	eval(this.runOnClosedFunction);	}
			catch(e)
			{
				debugOutput("ePM.getPlayer().executeRunOnClosed(): "+e.message);
			}
		});
		
		method("setRunOnEnd", function(functionCall) {
		/*
		ADDED 01-12-2007, Adam Greenbaum
		Set function to run on clip end (clip complete/postroll end)
		*/
			this.runOnEndFunction = functionCall;
		});
		
		method("executeRunOnEnd", function() {
		/*
		ADDED 01-12-2007, Adam Greenbaum
		Execute special runOnPlayEnd function
		*/
			try
			{	eval(this.runOnEndFunction);	}
			catch(e)
			{
				debugOutput("ePM.getPlayer().executeRunOnEnd(): "+e.message);
			}
		});
		
		method("setRunOnFullscreenStart", function(functionCall) {
		/*
		ADDED 01-12-2007, Adam Greenbaum
		Set function to run on fullscreen start up
		*/
			this.runOnFullscreenStartFunction = functionCall;
		});
		
		method("executeRunOnFullscreenStart", function() {
		/*
		ADDED 01-12-2007, Adam Greenbaum
		Execute special runOnFullscreenStart function
		*/
			try
			{	eval(this.runOnFullscreenStartFunction);	}
			catch(e)
			{
				debugOutput("ePM.getPlayer().executeRunOnFullscreenStart(): "+e.message);
			}
		});
		
		method("setRunOnFullscreenEnd", function(functionCall) {
		/*
		ADDED 01-12-2007, Adam Greenbaum
		Set function to run on fullscreen end
		*/
			this.runOnFullscreenEndFunction = functionCall;
		});
		
		method("executeRunOnFullscreenEnd", function() {
		/*
		ADDED 01-12-2007, Adam Greenbaum
		Execute special runOnFullscreenEnd function
		*/
			try
			{	eval(this.runOnFullscreenEndFunction);	}
			catch(e)
			{
				debugOutput("ePM.getPlayer().executeRunOnFullscreenEnd(): "+e.message);
			}
		});
		
		method("createPlaylist", function(clipList, playlistID, setActive, delayFirstClip, delayBetweenClips) {
		/*
		ADDED 01-11-2007, Adam Greenbaum
		Create playlist
		*/
			if ( typeof playlistID == "undefined" )	{	playlistID = "default";}
			if ( typeof setActive == "undefined" )	{	setActive = true;}
			if ( typeof delayFirstClip == "undefined" )	{	delayFirstClip = 0;}
			if ( typeof delayBetweenClips == "undefined" )	{	delayBetweenClips = 0;}
			this.lastPlaylist = new Playlist(this, playlistID, clipList, this.currentClip.dlid, delayFirstClip, delayBetweenClips);
			this.playlists[playlistID] = this.lastPlaylist;
			if (setActive == true)
			{	this.activePlaylist = this.lastPlaylist;}
			return this.lastPlaylist;
		});

		method("playNextClipInPlaylist", function() {
		/*
		ADDED 01-09-2007, Adam Greenbaum
		Play next clip in active playlist
		*/
			try {
				if (this.activePlaylist == null || this.isValidPlaylistID(this.activePlaylist.playlistID) == false)
				{	this.activePlaylist = this.lastPlaylist;	}
				//else{alert("currentplaylist:"+this.activePlaylist.playlistID);alert("currentplaylist:"+this.activePlaylist.playlist.join(","));}
				this.getPlaylist(this.activePlaylist.playlistID).playNext();
			} catch( e ) {
				debugOutput("ePM.getPlayer().playNextClipInPlaylist(): "+e.message);
				// error message goes here...
			}
		});
		
		method("setActivePlaylist", function(playlistID) {
		/*
		ADDED 01-09-2007, Adam Greenbaum
		Set current playlist ID
		*/
			try {
				if (this.isValidPlaylistID(playlistID) == true)
				{	this.activePlaylist = this.playlists[playlistID];	}
				else
				{	this.activePlaylist = this.lastPlaylist;	}
			} catch( e ) {
				debugOutput("ePM.getPlayer().setActivePlaylist(): "+e.message);
				// error message goes here...
			}
		});
		
		method("isValidPlaylistID", function(playlistID) {
		/*
		ADDED 01-15-2007, Adam Greenbaum
		Validate if playlist is valid
		*/
			try {
				//VALIDATE PLAYLIST
				var isValidPlaylistID = false;
				for (var i in this.playlists)
				{
					if (i == playlistID)
					{	isValidPlaylistID = true;}
				}
				return isValidPlaylistID;
			} catch( e ) {
				debugOutput("ePM.getPlayer().isValidPlaylistID(): "+e.message);
				// error message goes here...
			}
		});

		method("getPlaylist", function(playlistID)
		{
			try {
				//getPlayer() returns the last one used (not guaranteed to be singleton)
				if ( typeof playlistID == "undefined" ) {
					return this.lastPlaylist;
				}
				this.lastPlaylist = this.playlists[playlistID];
				return this.lastPlaylist;
			} catch( e ) {
				debugOutput("ePM.getPlayer().getPlaylist(): "+e.message);
				// error message goes here...
			}
		});
		method("initDone", function() 
		{
			//alert("initDone_MOBddd");
			pf_array = this.swf.publicFunction({'func':'getPFs'} );
	        //	alert(pf_array);
			for(i in pf_array) {
		        // alert(pf_array[i]);
				//if (typeof(pf_array[i])=="string") {
				methodName = pf_array[i];
				//methodName = "set"+ifirstChar+i.substring(1);
				my_str = 'method("'+methodName+'", function(inputParam) { ';
				my_str += 	'try {';
				my_str += 		"return this.swf.publicFunction({'func':'"+methodName+"', 'param':inputParam} ); ";
				my_str += 	'} catch( e ) {';
				my_str += 	'debugOutput("ePM.getPlayer().' + methodName+': "+e.message);';
				my_str +=	'}';
				my_str += '});';
				eval(my_str);
			}
			method( "setAdOverride", function(item,value) // obj should be 
				{
					try{
						this.swf.publicFunction({'func':'setAdOverride', 'param':{'overrideName':item, 'overrideValue':value}});
					}
					catch(e){}
			});
			
			method("playVideo", function( pathID, fromPlaylist, playlistID )
			{
				try {
					if (this.isPlayingAd() == false)
					{
					//document.getElementById("debugAds").innerHTML = "<br>playvideo:" + pathID+" fromPlaylist:"+fromPlaylist + document.getElementById("debugAds").innerHTML;
					this.currentClip.dlid = pathID;
					//if (fromPlaylist == null || fromPlaylist == "" || typeof fromPlaylist == "undefined")
					//{	this.playlistCurrentPosition = -1;	}
					if (fromPlaylist == null || fromPlaylist == "" || typeof fromPlaylist == "undefined" || typeof fromPlaylist == undefined)
					{	
						this.inAutoplay = false;	//ADDED3-26-2007: Adam Greenbaum - For playlist delays
						for ( var i in this.playlists) {
							if (this.playlists[i].playlistID)
							{
								//this.playlists[i].seed(pathID);
								//alert("nextclip:"+this.playlists[i].nextClip.dlid + " " +this.playlists[i].nextClip.position);
								this.playlists[i].currentPosition = this.playlists[i].getPosition(pathID);
								this.playlists[i].currentDLID = pathID;
								this.playlists[i].nextClip = this.playlists[i].getNext();
								//this.playlists[i].nextClip = this.playlists[i].getNext();			//UPDATE NEXT CLIP INFORMATION
								//alert("nextclip2:"+this.playlists[i].nextClip.dlid + " " +this.playlists[i].nextClip.position);
							}
						}
					}
					else
					{	this.playlists[playlistID].nextClip = this.playlists[playlistID].getNext();	}
					//alert(this.activePlaylist.nextClip.dlid);
						this.swf.publicFunction({'func':'playVideo', 'param':pathID} );
					// flash is not going to play video is ad is currently playing. no need to js check
					//this.swf.playVideoByPathID( pathID, overrideKeyword, overrideVideoID, embVal, overrideNetworkID );	//OLD - Version 1.2 - 1-10-2007
				}
			} catch( e ) {
				debugOutput("ePM.getPlayer().playVideo(): "+e.message);
				// error message goes here...
			}
		});
			
			method("playVideoByPathID", function( pathID )
			{
				this.playVideo(pathID)
			});
			method("getCurrentTime", function( pathID )
			{
				return	this.getCurrentTimeStart(pathID);
			});
			this.isPlayingAd2 = this.isPlayingAd();

		});
		
	}
	
	return new Constructor();
};


//embeddedPlayer Object paste embPlayerObject.js here
//document.write('<script type="text/javascript" src="http://video-test.nbcuni.com/embed/js_3-x/embPlayerObject.js"></script>');
//
//embPlayerOBJect END





//playerBuildObject.js here
//document.write('<script type="text/javascript" src="http://video-test.nbcuni.com/embed/js_3-x/playerBuildObject.js"></script>');

if(typeof reconcept == "undefined") var reconcept = new Object();
reconcept.playerBuildObject = function() {
    this.attributes = new Object();
	this.attributes.targetDivID= this.attributescompanionContainerID= null;
	this.attributes.deepLinkIDOrPath=  this.attributes.videoControls=null;
	this.attributes.width= this.attributes.height= this.attributes.configLocation= null;
	this.attributes.autoStartOnEmbed= this.attributes.initialVolume= null;
	this.attributes.exitFullscreenOnVideoComplete= this.attributes.embVal= null;
	this.attributes.overrideRandom= this.attributes.overrideKeyword1= null;
	this.attributes.overrideKeyword2= this.attributes.overrideKeyword3= null;
	this.attributes.overrideClipID = this.attributes.configID =null;
}
reconcept.playerBuildObject.prototype = {
	setAttribute: function(name, value){
		this.attributes[name] = value;
	},
	write: function(){
		myStr = "";
		for(i in this.attributes) {
			myStr += i+": "+ this.attributes[i];
		}
		//alert(myStr);
				embeddedPlayerManager.embedPlayer3(	
				    this.attributes.targetDivID,
				    this.attributes.companionContainerID,
			        this.attributes.deepLinkIDOrPath,
                	this.attributes.width, 
                	this.attributes.height, 
                	this.attributes.configLocation, 
                	this.attributes.videoControls,
                	this.attributes.autoStartOnEmbed, 
            	    this.attributes.initialVolume,
            	    this.attributes.exitFullscreenOnVideoComplete, 
                	this.attributes.embVal,
        	        this.attributes.overrideRandom, 
                	this.attributes.overrideKeyword1,
                	this.attributes.overrideKeyword2,
                    this.attributes.overrideKeyword3, 
                	this.attributes.overrideClipID,
					this.attributes.configID
	 			);
		//embeddedPlayerManager.testRef("builder");
	}
}
var playerBuildObject = reconcept.playerBuildObject;

//playerBuildObject.js end


	


//METADATA CONTAINERS FOR onMetadata EVENT
//metaDataObject.js here
//document.write('<script type="text/javascript" src="http://video-test.nbcuni.com/embed/js_3-x/metaDataObject.js"></script>');
if (typeof MetadataContainer == "undefined")
MetadataContainer = function(parentPlayer)
{
	function Constructor()
	{
		this.player = parentPlayer;
		this.title = "";
		this.subtitle = "";
		this.shortDescription = "";
		this.airtime = "";
		this.dlid = "";
		this.thumbSmall = "";
		this.thumbSmallImage = "";
		this.thumbLarge = "";
		this.publishDate = "";
		this.thumbLargeImage = "";
		this.folderPath = "";
		this.usOnly = "";
		this.folderid = "";
		this.startDate = "";
		this.endDate = "";
		this.isThirdParty = "";
		this.longDescription = "";
		this.guid = "";
		this.buyURL = "";
		this.buyURLtext = "";
		this.relatedURL = "";
		this.relatedURLtext = "";
		this.copyright = "";
		this.thumbMezznPath = "";
		this.fullPageConfig = "";
		this.streamType = "";
		this.permalink = "";
		this.adPlaylist = "";
		this.showVideoAds = "";
	}
	with (Constructor)
	{	
		template = new Constructor();
		for(i in template) {
			if (typeof(template[i])=="string") {
			ifirstChar = i.substring(0,1).toUpperCase();
			methodName = "set"+ifirstChar+i.substring(1);
			my_str = 'method("'+methodName+'", function(inputParam) { ';
			my_str +='this.'+i+' = inputParam.toString();'
			my_str +='});';
			eval(my_str);
			}
		}
		
		method("setContainers", function() {
			this.player.onMetadata = function(clipObject)
			{
				//EXECUTE RUN ON PLAY FUNCTION
				this.executeRunOnBegin();
				//MAP OBJECT FIELDS
				this.metadata.title				= clipObject.title;
				this.metadata.subtitle			= clipObject.subtitle;
				this.metadata.shortDescription	= clipObject.description;
				this.metadata.airtime			= clipObject.showtime;
				this.metadata.dlid				= clipObject.clipid;
				this.metadata.thumbSmall		= clipObject.thumburl;
				this.metadata.thumbLarge		= clipObject.imageurl;
				this.metadata.thumbSmallImage	= "<img src=\""+embeddedPlayerManager.METADATA_THUMB_URL+"" + this.metadataContainers.replaceCharsforHTML(clipObject.thumburl) + "\" />";
				this.metadata.thumbLargeImage	= "<img src=\""+embeddedPlayerManager.METADATA_THUMB_URL+"" + this.metadataContainers.replaceCharsforHTML(clipObject.imageurl) + "\" />";
				this.metadata.folderPath		= clipObject.folderpath;
				this.metadata.usOnly			= clipObject.geoip;
				this.metadata.folderid			= clipObject.folderid;
				this.metadata.streamURL			= clipObject.streamURL;
				this.metadata.clipOrder			= clipObject.placement;
				this.metadata.startDate			= clipObject.startdate;
				this.metadata.endDate			= clipObject.enddate;
				this.metadata.isThirdParty		= clipObject.thirdpartyclip;
				this.metadata.longDescription	= clipObject.longdescription;
				this.metadata.guid				= clipObject.guid;
				this.metadata.publishDate		= clipObject.publishdate;
				this.metadata.buyURL			= clipObject.buyurl;
				this.metadata.buyURLtext		= clipObject.buyurltext;
				this.metadata.relatedURL		= clipObject.relatedurl;
				this.metadata.relatedURLtext	= clipObject.relatedurltext;
				this.metadata.copyright			= clipObject.copyright;
				this.metadata.thumbMezznPath	= clipObject.mezznimagepath;
				this.metadata.fullPageConfig	= clipObject.fullpageconfigpath;
				this.metadata.streamType		= clipObject.streamtype;
				this.metadata.permalink			= clipObject.permalink;
				this.metadata.adPlaylist		= clipObject.adplaylist;
				this.metadata.showVideoAds		= clipObject.videoads;
				//POPULATE METADATA OBJECT
				this.currentClip = this.metadata;
				//FILL METADATA CONTAINERS
		for(i in this.metadataContainers) {
		//for(i in tempARRAY) {
			if (typeof(this.metadataContainers[i])=="string") {
				if ((this.metadataContainers[i] != null) && (this.metadataContainers[i] != "")) {	
    				document.getElementById(this.metadataContainers[i]).innerHTML = this.metadataContainers.replaceCharsforHTML(this.metadata[i]);	
				}
			}
		}
			}
		});
		
		//FUNCTION: Helper for output
		method("replaceCharsforHTML", function(str_input) {
			var str_return = new String(str_input);
			str_return = str_return.replace("&","&amp;");
			return str_return;
		});
	}
	return new Constructor();
};

//metaDataObject.js end


//PLAYLIST OBJECT begin
//embeddedPlayer Object paste metaDataObject.js here
//document.write('<script type="text/javascript" src="http://video-test.nbcuni.com/embed/js_3-x/playListObject.js"></script>');

if (typeof Playlist == "undefined")
Playlist = function(parentPlayer, playlistID, clipList, currentDLID, delayFirstClip, delayBetweenClips)
{
	function Constructor()
	{
		this.player = parentPlayer;
		this.playlistID = playlistID;
		this.currentDLID = currentDLID;	
		this.currentPosition = -1;		
		this.seedDLID = null;			
		this.playlist = new Array();
		this.nextClip = new Object();
		this.delayFirstClip = delayFirstClip;
		this.delayBetweenClips = delayBetweenClips;
		this.delayCounter = 0;
		this.delayToggle = false;

		//CREATE PLAYLIST
		this.playlist = clipList.split(",");
		this.nextClip = this.getNext();
	}
	with (Constructor)
	{
		method("seed", function(dlid) {
		/*
		ADDED 01-11-2007, Adam Greenbaum
		Seed Playlist
		*/
			this.seedDLID = dlid;
			this.nextClip = this.getNext();
		});
		
		method("add", function(dlid) {
		/*
		ADDED 01-11-2007, Adam Greenbaum
		Add to end of playlist
		*/
			try {
				this.playlist.push(dlid);
				this.nextClip = this.getNext();	//UPDATE INFORMATION ON NEXT CLIP
			} catch( e ) {
				debugOutput("ePM.getPlayer().getPlaylist().add(): "+e.message);
				// error message goes here...
			}
		});
		
		method("remove", function(positionIndex) {
		/*
		ADDED 01-11-2007, Adam Greenbaum
		Delete from playlist
		*/
			try {
				this.playlist.splice(positionIndex,1);
				this.nextClip = this.getNext();	//UPDATE INFORMATION ON NEXT CLIP
			} catch( e ) {
				debugOutput("ePM.getPlayer().getPlaylist().remove(): "+e.message);
				// error message goes here...
			}
		});
		
		method("clear", function() {
		/*
		ADDED 01-11-2007, Adam Greenbaum
		Clear Playlist
		*/
			try {
				this.playlist = new Array();
				this.currentPosition = -1;
				this.seedDLID = null;
			} catch( e ) {
				debugOutput("ePM.getPlayer().getPlaylist().clear(): "+e.message);
				// error message goes here...
			}
		});
		
		method("move", function(positionIndexStart,positionIndexEnd) {
		/*
		ADDED 01-09-2007, Adam Greenbaum
		Reorder playlist item
		*/
			try {
				positionIndexStart = Number(positionIndexStart);
				positionIndexEnd = Number(positionIndexEnd);
				if (positionIndexEnd > this.playlist.length-1)
				{positionIndexEnd = this.playlist.length;}
				if (positionIndexStart > this.playlist.length-1)
				{positionIndexStart = this.playlist.length-1;}
				var playlistItemValue = this.playlist[positionIndexStart];
				if (positionIndexStart < positionIndexEnd)	//MOVING TOWARDS END OF ARRAY
				{
					this.playlist.splice(positionIndexEnd+1,0,playlistItemValue);
					this.playlist.splice(positionIndexStart,1);
				}
				else if (positionIndexStart > positionIndexEnd) //MOVING TOWARDS BEGINNING OF ARRAY
				{
					this.playlist.splice(positionIndexEnd,0,playlistItemValue);
					this.playlist.splice(positionIndexStart+1,1);
				}
				else{}//DO NOTHING, DID NOT MOVE
				this.nextClip = this.getNext();	//UPDATE INFORMATION ON NEXT CLIP
			} catch( e ) {
				debugOutput("ePM.getPlayer().getPlaylist().move(): "+e.message);
				// error message goes here...
			}
		});
		
		method("playNext", function() {
		/*
		ADDED 01-05-2007, Adam Greenbaum
		Use Playlist, play next clip in playlist (if available)
		*/
			try {
				//alert("in playnext");
				//if (document.getElementById( "debugAds" )) document.getElementById("debugAds").innerHTML = "<br>playnext:" + this.getNext().dlid + document.getElementById("debugAds").innerHTML;
				if (this.nextClip.atEndOfPlaylist == false && this.player.allowPlaylistAdvance == true)	//MORE ITEMS IN PLAYLIST & ALLOWED TO ADVANCE
				{
					if (this.delayToggle == false)
					{
						if (this.player.inAutoplay == true)	//IF NOT IN AUTOPLAY
						{
							this.delayCounter = this.delayBetweenClips;
							//alert("autoplay=true: "+this.delayCounter);
						}
						else	//IN AUTOPLAY
						{
							this.delayCounter = this.delayFirstClip;
							//alert("firstclip: "+this.delayCounter);
							this.player.inAutoplay = true;
						}
						this.delayToggle = true;
					}
					
					//IF DELAY COUNTER IS NOT AT 0
					if (this.delayCounter > 0)
					{
						this.delayCounter = this.delayCounter-1;
						//alert("delaycounter: "+this.delayCounter);
						//document.getElementById("debugAds").innerHTML = document.getElementById("debugAds").innerHTML + "<br>"+this.delayCounter;
						timeoutID = window.setTimeout("embeddedPlayerManager.getPlayer('"+this.player.id+"').getPlaylist().playNext()", 1000);
					}
					else
					{
						//alert("playing next clip");
						this.delayToggle = false;
						//this.nextClip = this.getNext();		//UPDATE INFORMATION ON NEXT CLIP
						this.currentPosition = this.nextClip.position;	//SET PLAYLIST NEXT CLIP POSITION
						this.currentDLID = this.nextClip.dlid;		//SET PLAYLIST NEXT CLIP DLID
						//alert("INSIDE:"+this.currentPosition+" "+this.nextClip.position+" "+this.currentDLID);
						//alert(this.nextClip.dlid);
						this.player.playVideo(this.nextClip.dlid,1,this.playlistID);				//PLAY NEXT CLIP
					}
				}
				//else {alert("playNext:at end");} //DO NOTHING, END OF PLAYLIST
			} catch( e ) {
				debugOutput("ePM.getPlayer().getPlaylist().playNext(): "+e.message);
				// error message goes here...
			}
		});
		
		method("getPosition", function(dlid) {
			var arrayIndexPosition = -1;
			for (var x=0; x<=this.playlist.length-1; x++)	
			{	
				if (dlid.toString() === this.playlist[x].toString())
				{
					arrayIndexPosition = x;
				}
			}
			return arrayIndexPosition;
		});
		
		
		method("getNext", function() {
		/*
		ADDED 01-05-2007, Adam Greenbaum
		Get info on next clip
		*/
			if (this.playlist.length > 0)	//DATA EXISTS IN PLAYLIST
			{
				//alert("if: data exists in playlist");
				var nextClipDLID = 0;
				var nextClipPosition = -1;
				var atEndOfPlaylist = true;
				if (this.seedDLID != null)	//THERE IS A PLAYLIST SEED
				{
					//alert("if: seed is not null");
					if (this.seedDLID.toString() == "0") //SPECIAL CASE, 0 LOADS FIRST CLIP IN PLAYLIST
					{
						//alert("if: seed is 0");
						nextClipDLID = this.playlist[0];	//SET NEXT CLIP DLID TO FIRST DLID
						nextClipPosition = 0;				//SET NEXT CLIP POSITION TO 0
					}
					else
					{
						//alert("else: seed is not 0");
						nextClipDLID = this.seedDLID;	//SET NEXT CLIP DLID TO SEED DLID
						nextClipPosition = this.getPosition(nextClipDLID);			//SET NEXT CLIP POSITION
					}
					atEndOfPlaylist = false;			//NOT A THE END OF THE PLAYLIST
					this.seedDLID = null;				//CLEAR SEED DLID
				}
				else	//THERE IS NO PLAYLIST SEED, USE CURRENT DLID/LAST KNOWN POSITION
				{
					//alert("else: seed is null");
					for (var x=0; x<=this.playlist.length-1; x++)	//LOOP THROUGH ARRAY TO FIND MATCHING DLID OR MATCHING POSITION
					{	// IF PLAYLIST CURRENT DLID = STORED CURRENT DLID && (STORED CURRENT POSITION = -1/NOT CHANGED || CURRENT POSITION = STORED CURRENT POSITION)
						if (this.playlist[x].toString() == this.currentDLID && (this.currentPosition == -1 || x == this.currentPosition))
						{
							if (x+1 == this.playlist.length) {}
							else
							{
								nextClipDLID = this.playlist[x+1];	//SET NEXT CLIP - DLID
								nextClipPosition = x+1;			//SET NEXT CLIP POSITION
								x = this.playlist.length-1;		//SET LOOP COUNTER TO END
								atEndOfPlaylist = false;		//NOT A THE END OF THE PLAYLIST
							}
						}
						else {}
					}
				}
				if (atEndOfPlaylist == false)	//IF STILL ELEMENTS IN THE PLAYLIST
				{	
					this.nextClip.atEndOfPlaylist = false;
					this.nextClip.position = nextClipPosition;
					this.nextClip.dlid = nextClipDLID;
					//if (document.getElementById( "debugAds" )) document.getElementById("debugAds").innerHTML = "<br>nextcliposition:" + this.nextClip.position + "<br>nextclipdlid:" + this.nextClip.dlid + document.getElementById("debugAds").innerHTML;
					//alert("MORE:"+this.nextClip.position+this.nextClip.dlid+" "+this.currentDLID+this.currentPosition);
					return this.nextClip;
				}
				else
				{
					this.nextClip.atEndOfPlaylist = true;
					this.nextClip.position = -1;
					this.nextClip.dlid = 0;
					//alert("DONE:"+this.nextClip.position+this.nextClip.dlid+" "+this.currentDLID+this.currentPosition);
					return this.nextClip;
				}
			}
		});
	}
	
	return new Constructor();
};


//PLAYLIST OBJECT end


//register global embedded player manager. please DO NOT create more instances of this!
if (typeof embeddedPlayerManager == "undefined")
{
	embeddedPlayerManager = new EmbeddedPlayerManager();
	
	//setup main event handler, this forwards all the ExternalInterface events on to their intended proxy
	this.onEmbeddedPlayerEvent = function(playerID, methodName, eventObject)
	{
		if (typeof embeddedPlayerManager.getPlayer(playerID) == "object" && typeof embeddedPlayerManager.getPlayer(playerID)[methodName] == "function")
		{
			console.info( "Message", methodName);
			embeddedPlayerManager.getPlayer(playerID)[methodName](eventObject);
		} else {
			console.warn("Event type %s not supported.  m.title= %s m.p.dur = %s", methodName, eventObject.title, eventObject.PlayerState.clipDuration);
		}
	}
	
	//setup simple embed function
	this.videoplayer = function(target, companion, video, options)
	{
		if (typeof options == "undefined") options = {};
		var oldonload = window.onload;
		window.onload = function()
		{
			if (typeof oldonload == "function") oldonload();
			var vp = embeddedPlayerManager.embedPlayer(target, companion, video, options["fullscreen"], options["width"], options["height"], options["controls"], options["exitFullscreenOnVideoComplete"]);
			vp.setMetadataContainers(	options["name"], 
										options["subtitle"], 
										options["description"], 
										options["schedule"], 
										options["catalog"], 
										options["id"], 
										
										options["path"], 
										options["streamName"], 
										options["allowPreroll"], 
										options["usOnly"], 
										options["keywordContainer"], 
										options["suppressTimerContainer"], 
										options["thumbSmallContainer"], 
										options["thumbLargeContainer"]
									);
		}
	}
	
	//helper to add things after existing onload handlers, which omniture adds
	this.doAfterLoad = function(f)
	{
		if (typeof f != "function") return;
		var oldonload = window.onload;
		window.onload = function()
		{
			if (typeof oldonload == "function") oldonload();
			f();
		}
	}
}

//PLAYER LOCATION. This is where the swfs embedded.swf and companion.swf are hosted. MUST have a trailing slash
embeddedPlayerManager.BASE_LOCATION = "";
embeddedPlayerManager.COMPANION_RENDERER = "http://video.nbcuni.com/embed/common/companion2.html"; // PHP companion renderer URL
embeddedPlayerManager.METADATA_THUMB_URL = "http://video.nbcuni.com/";		//URL BASE FOR METADATA THUMBNAILS


////////////////////////////////////////////////////////////////////////////
// Overrides swfobject onbeforeunload + preserving its methods
////////////////////////////////////////////////////////////////////////////

if ( typeof window.onbeforeunload == "function" ) {
	var oldBeforeUnload=window.onbeforeunload;
	window.onbeforeunload = function() {
		try {
			oldBeforeUnload();
			executeOnUnload();
		} catch( e ) {
			// error message goes here...
			debugOutput("window.onbeforeunload: "+e.message);
		}			
	};
} else { 
	window.onbeforeunload = function() {
		try {
			executeOnUnload();
		} catch( e ) {
			// error message goes here...
			debugOutput("window.onbeforeunload: "+e.message);
		}	
	}
}

////////////////////////////////////////////////////////////////////////////
// WARNING! Moved some calls from swfobject.js See swfobject for details. 
// Moved methods + calls are commented in swfobject.js
////////////////////////////////////////////////////////////////////////////
function executeOnUnload() {
	__flash_unloadHandler = function(){}; 
	__flash_savedUnloadHandler = function(){};

	if ( typeof window.onunload == "function" ) { //alert("execute if before try");
		var oldOnUnload = window.onunload;
		window.onunload = function() {
			try {
				embeddedPlayerManager.getPlayer().browserWindowBeforeUnload(); // call to Flash
				deconcept.SWFObjectUtil.cleanupSWFs();
				oldOnUnload();
			} catch ( e ) {
				// error message goes here...
				debugOutput("window.onunload: "+e.message);
			} 
		};
	} else { 			//alert("execute else before try");
		try {
			embeddedPlayerManager.getPlayer().browserWindowBeforeUnload(); // call to Flash
			window.onunload = deconcept.SWFObjectUtil.cleanupSWFs; 
		} catch( e ) {
			// error message goes here...
			debugOutput("window.onunload: "+e.message);
		}
	}
}

