function inheritAll() {
	for (var i = 1; i < arguments.length; i++) {
		for (x in arguments[i].prototype) {
			arguments[0].prototype[x] = arguments[i].prototype[x];
		}
	}
}

function myPlaylistVideo(videoId,videoTab){
        this.id = videoId;
        this.tab = videoTab;
}

function CNNPlaylistManager() {
	if (CNNPlaylistManager.caller != CNNPlaylistManager.getInstance) {
		if((navigator.userAgent.indexOf('Safari')==-1) && (navigator.userAgent.indexOf('Opera')==-1)) {
			throw new Error("There is no public constructor for CNNPlaylistManager.");
		}
	}
	this.jsonurls = null;
	this.controller = null;
	this.tab = 'notab';
	this.t1PageType = 'Unknown T1 Page';
	this.singleUrl = null;
	this.noIEStorage = false;
	this.noCookies = false;
	this.forceSensitive = false;
	this.dataObject = null;
	this.cnnIsIntl = (location.hostname.indexOf('edition.') > -1) ? true : false; 
	this.cnnIsArabic = (location.hostname.indexOf('arabic.') > -1) ? true : false; 
	this.moscarray = null;
	this.startVideo = null;
	this.playerName = null;
	this.doNotResetSynchOnPreroll = false;
	this.skipStartSlateButLoadSynch = false;
	this.sensitiveSynchDisplaying = false;
	this.playlists = new Array();
	this.activePlaylist = null;
	this.splashActive = false;
	this.isSmall = false;
	this.playStartSlate = true;
	this.playlistType = '';
	this.mosPreloaded = false;
	this.runNextUpSlate = false;
	this.vidString = 'BVP';
	this.vidContext = 'BVP';
	this.raceCondition = false;
	this.nextUpSlate = null;
	this.endSlate = null;
	this.raceVideos = 0;
	this.raceFunction = null;
	this.endSlate = false;
	this.playingFirstVideo = true;
	this.mosSlateActive = true;
	this.slateSize = '576x324';
	this.onlyCallMeOnce = false;
	this.isVideoError = false;
	this.loadFirstVideo = null;
	this.switchToMyList = false;
	this.errorObject = null;
	this.playlist = function(jsonList,pointer,tabList) {
		this.jsonList = jsonList;
		this.tabList = new Array();
		if(tabList){
			this.tabList = tabList;
		}
		this.pointer = pointer;
		this.playlistJsonObjs = null;
		this.activeJson = function() { return this.jsonList[this.pointer]; }
	}
	this.testCookies = function() {
		document.cookie = 'CNNTestCookie=yes; path=/';
		if (document.cookie.length > 0) {
			if (document.cookie.indexOf('CNNTestCookie') < 0) {
				this.noCookies = true;
			}
		} else { this.noCookies = true; }
	}
	this.advanceTo = function(playlistName,val) {
		if (this.noCookies == false) {
			if (this.splashActive) {
				this.splashActive = false;
				document.getElementById('cnnVPFlashLargeContainer').style.backgroundImage = '';
				document.getElementById('cnnVPFlashLargeContainer').innerHTML = '';
			}
			if (this.activePlaylist != playlistName) {
				if (this.activePlaylist != null && this.activePlaylist != '') {
					this.unHighlight();
				}
				this.activePlaylist = playlistName;
				this.playlists[this.activePlaylist].pointer = val;
				if (this.onlyCallMeOnce == false) {
					this.onlyCallMeOnce = true;
					CNNPlayer.getActivePlayer().setPlayerContext(this.vidContext);
					CNNPlayer.getActivePlayer().createPlayListContext(this.vidString);
				}
				CNNPlayer.getInstance('','advanceTo1').loadContent(this.playlists[this.activePlaylist].jsonList,this.playlists[this.activePlaylist].activeJson());
			} else {
				this.playlists[this.activePlaylist].pointer = val;
				CNNPlayer.getInstance('','advanceTo2').setCurrentPlayListPosition(this.playlists[this.activePlaylist].activeJson());			
			}
			this.highlight();
			this.mosPreloaded = true;
		}
	}
	this.setPlaylist = function(playlistName,callBackFunc) {
		pt = this.playlists[playlistName];
		this.getPlayer().serializerFactory = xmp.baseplayer.MetaFileLoaderFactory.getInstance().create('videoContentMeta');
		pt.playlistJsonObjs = this.getPlayer().serializerFactory.setIds(pt.jsonList, (new xmp.util.Callback('contentItemCB', CNNPlayer.playlistContentItemCB, null)));	
		this.getPlayer().serializerFactory.setAllLoadedCallback(new xmp.util.Callback('allContentItemsCB', callBackFunc, null));
		this.getPlayer().serializerFactory.load();
	}
	this.getPlayer = function() {
		return CNNPlayer.getInstance('','getPlayer');
	}
	this.unHighlight = function() {
		if (this.activePlaylist != 'saplaylist') {
			ppp = this.playlists[this.activePlaylist];
			if (this.activePlaylist == 'bvpplaylist')
				classpre = 'nextup_';
			else
				classpre = 'myup_';
			unactiveClassname = 'box_item';
			
			for (var i = 0; i < ppp.playlistJsonObjs.length; i++) {
				document.getElementById(classpre+i).className = unactiveClassname;
				if (classpre == 'myup_') {
					document.getElementById('myupgraydiv_'+i).innerHTML = '<a href="javascript:CNNPlaylistManager.getInstance().MYPMRemove('+i+');"><img name="myupgray_'+i+'" id="myupgray_'+i+'" src="/video/bvp/images/close_btn.gif" width="12" height="12" alt="" border="0"></a>';
				}
			}
		}
	}
	this.highlight = function() {
		if (this.activePlaylist != 'saplaylist') {
			ppp = this.playlists[this.activePlaylist];
			if (this.activePlaylist == 'bvpplaylist')
				classpre = 'nextup_';
			else
				classpre = 'myup_';
			activeClassname = 'box_item_play';
			
			this.unHighlight();
			document.getElementById(classpre+ppp.pointer).className=activeClassname;
				if (classpre == 'myup_') {
					document.getElementById('myupgraydiv_'+ppp.pointer).innerHTML = '&nbsp;';
				}
		}
	}
	this.emailLink = function(pl) {
		this.emailThis(this.dataObject);
	}
	this.emailCurrent = function(pl) {
		this.emailThis(this.dataObject);
	}
	this.emailVideo = function() {
		this.emailThis(this.dataObject);
	}
	this.emailThis = function(obj) {
		clickTitle = this.dataObject.headline;
		clickURL = ((window.location.href.split("/"))[2])+'/video/?/'+this.dataObject.id.slice(1,this.dataObject.id.length);
		commonLoc="&fb=Y&url="+escape(getClickURL())+"&title="+escape(getClickTitle())+"&random="+Math.random()+"&partnerID="+partnerID+"&expire="+escape(getClickExpire());
		ET();
	}
	this.errorMessageGenerator = function() {
		if (this.errorObject == null) {
			return "Unspecified Fatal Error";
		}
		if (this.errorObject.innerError._code == xmp.XmpErrorCodes.FATAL_PLATFORM) {
			this.errorObject = null;
			var str = 'The web browser you are using to view this video is not supported.  Please use one of the supported browsers:';
			if (navigator.userAgent.indexOf('Windows') > -1) {
				str += '<br><b>Windows</b><br><a href="http://www.microsoft.com/windows/products/winfamily/ie/default.mspx" target="_blank">Microsoft Internet Explorer 6 and above</a><br>';
				str += '<a href="http://en.www.mozilla.com/en/firefox/" target="_blank">Firefox 1.5 and above</a>';
			}
			if (navigator.userAgent.indexOf('Mac') > -1) {
				str += '<br><b>Macintosh</b><br><a href="http://www.apple.com/support/downloads/safariupdate201.html" target="_blank">Safari 2.0.4 and above</a><br>';
				str += '<a href="http://en.www.mozilla.com/en/firefox/" target="_blank">Firefox 1.5 and above</a>';
			}
			return str;
		}
		if (this.errorObject.innerError._code == xmp.XmpErrorCodes.FATAL_PLUGIN) {
			str = ('A plugin required to play your video could not be located.<br><br>Please ensure the <a href="'+this.errorObject.innerError.plugIn.downloadUrl+'" target="_blank">'+this.errorObject.innerError.plugIn.displayName+'</a> is installed properly.');
			this.errorObject = null;
			return str;
			// plugin error
		}
		if (this.errorObject.innerError._code == xmp.XmpErrorCodes.FATAL_PLUGIN_INIT) {
			this.errorObject = null;
			return ('The video timed out attempting to play.<br><br>Please ensure that you do not have any Flash Blocking plugins active.');
		}
		if (this.errorObject.innerError._code >= xmp.XmpErrorCodes.CRITICAL_UNSPECIFIED_AJAX_ERROR && this.errorObject.innerError._code <= xmp.XmpErrorCodes.CRITICAL_PLAYER_CONNECTION) {
			this.errorObject = null;
			return ('The video system was not able to establish connectivity due to a Proxy/Firewall or network connectivity.');
		}
	}
	this.errorSlate = function() {
		if (this.activePlaylist == 'bvpplaylist' || this.activePlaylist == 'myARplaylist' || this.activePlaylist == 'mosplaylist') {
			var str = '<div style="font-family:arial, sans-serif; color:#838383; font-size:11px; width: 100%; height: 100%; background-color: #f4f4f4;"><div style="padding: 138px 0px 0px 0px; text-align: center; width: 100%;"><font style="font-size: 22px;">'+this.errorMessageGenerator()+'</div></div>';
		} else {
			var str = '<div style="font-family:arial, sans-serif; color:#838383; font-size:11px; width: 100%; height: 100%; background-color: #f4f4f4;"><div style="padding: 5px 0px 0px 0px; text-align: center; width: 100%;">'+this.errorMessageGenerator()+'</div></div>';
		}
		document.getElementById('cnnVPFlashLargeContainer').innerHTML = str;
	}
	this.flashDetection = function() {
		if (
				((window.navigator.platform.toLowerCase()).indexOf('mac') > -1 &&
				new CNN_FlashDetect().detectVersion(9)) ||
				((window.navigator.platform.toLowerCase()).indexOf('mac') < 0 &&
				new CNN_FlashDetect().detectVersion(8))) {
			return true;
		} else {
			return false;
		}
	}
}

CNNPlaylistManager.__instance__ = null; 

CNNPlaylistManager.getInstance = function (playerName) {
	if (this.__instance__ == null) {
		inheritAll(CNNPlaylistManager,BVPPlaylistManager,MYPlaylistManager,SAPlaylistManager);
		this.__instance__ = new CNNPlaylistManager();
		this.__instance__.playerName = playerName;
		currentPlayer = playerName;
	}
	return this.__instance__;
}
CNNPlaylistManager.isBootStrapped = null;
CNNPlaylistManager.endOfVideoContent = function(advancePointerButNotContent) {
	if (CNNPlaylistManager.getInstance().switchToMyList == false) {
		CNNPlaylistManager.getInstance().switchToMyList = false;
		ppp = CNNPlaylistManager.getInstance().playlists[CNNPlaylistManager.getInstance().activePlaylist];
		if (ppp.playlistJsonObjs.length - 1 != ppp.pointer) {
			ppp.pointer++;
			CNNPlaylistManager.getInstance().highlight();
			CNNPlaylistManager.getInstance().runNextUpSlate = true;
		}
		CNNPlayer.getInstance('','endOfVideoContent').advance();
	} else {
		CNNPlaylistManager.getInstance().switchToMyList = false;
		load_Play_List('navMyPlay_List');
		CNNPlaylistManager.getInstance().advanceTo('myARplaylist',0);
	}
}
CNNPlaylistManager.findImageSize = function(imageSizeArray, id) {
	for (var i = 0; i < imageSizeArray.length; i++) {
		if (imageSizeArray[i].id == id) {
			return imageSizeArray[i].resource;
		}
	}
	return ("http://i.cdn.turner.com/cnn/.element/img/2.0/global/misc/"+id+".no.photo.gif");
}
CNNPlaylistManager.providedResponse = function(pObj) {
	var rstr = '';
	try {
		for (var i = 0; i < pObj.length; i++) {
			if (pObj[i].url != null && pObj[i].url != '')
				rstr += '<a href="'+pObj[i].url+'" target="_blank">'+pObj[i].source+'</a>';
			else
				rstr += pObj[i].source;
			if (i < pObj[i].length - 1)
				rstr += ', ';
		}
	} catch(err) {}
	return rstr;
}

function SAPlaylistManager() {}
SAPlaylistManager.prototype.SAConfiguration = null;
SAPlaylistManager.prototype.SALoadVideo = function(configuration) {
	if (this.flashDetection()) {
		this.SAConfiguration = configuration;
		this.jsonurls = this.SAConfiguration.videoArray;
		this.vidContext = this.SAConfiguration.vidContext;
		this.vidString = this.SAConfiguration.vidString;
		this.slateSize = this.SAConfiguration.slateSize[0]+"x"+this.SAConfiguration.slateSize[1];
		CNNPlaylistManager.isBootStrapped = SAIsBootStrapped;
		CNNPlayer.create();
	} else {
		setTimeout("CNNPlaylistManager.getInstance().SANoFlashTimer()",1000);		
	}
}
SAPlaylistManager.prototype.SABootStrapCallback = function(success) {
	if (success) {
		this.playlists['saplaylist'] = new this.playlist(this.jsonurls,this.SAConfiguration.startPoint);
		this.setPlaylist('saplaylist',SAPlaylistUICallback);
	} else {
		if (this.errorObject != null) {
			this.SAConfiguration.bootErrorHandler(this.errorObject._code);
		} else {
			this.SAConfiguration.bootErrorHandler("General Error");
		}
	}
}
SAPlaylistManager.prototype.SAWriteSplash = function() {
	this.playlistType = 'sa';
	this.playStartSlate = true;
	this.dataObject = this.playlists['saplaylist'].playlistJsonObjs[this.SAConfiguration.startPoint].getDataObject();
	CNNPlaylistManager.getInstance().advanceTo('saplaylist',this.SAConfiguration.startPoint);
}
SAPlaylistManager.prototype.SANoFlashTimer = function() {
	this.SAConfiguration.bootErrorHandler('No Flash');
}

function BVPPlaylistManager() {}
BVPPlaylistManager.prototype.BVPMNumVidsInList = 12;
BVPPlaylistManager.prototype.BVPMVideoSelected = function(videoId,section) {
	var taboolaSel = false;
	if (section == 'taboola') {
		taboolaSel = true;
		section = 'top_stories';
	}
	if (this.noCookies == false) {
		this.switchToMyList = false;
		load_Play_List('navNext_Up');
		if (this.splashActive) {
			this.splashActive = false;
			document.getElementById('cnnVPFlashLargeContainer').style.backgroundImage = '';
			document.getElementById('cnnVPFlashLargeContainer').innerHTML = '';
		}
		CNNPlaylistManager.getInstance().activePlaylist = null;
		tempArray = new Array();
		var l = cnnSectionData[section].length;
		for (var i = 0; i < l; i++) {
			if (cnnSectionData[section][i] == videoId) {
				tempArray = this.BVPMGeneratePlaylistFromStart(i,section);
				break;
			}
		}
		if (taboolaSel == true && tempArray.length == 0) {
			tempArray = this.BVPMGeneratePlaylistFromStart(1,section);
			tempArray.pop();
			tempArray.splice(0,1,videoId);
		}
		this.playlists['bvpplaylist'] = new this.playlist(tempArray,0);
		this.setPlaylist('bvpplaylist',BVPPlaylistUICallback);
	}
}
BVPPlaylistManager.prototype.BVPMGeneratePlaylistFromStart = function(startPointer,section) {
	listSize = this.BVPMNumVidsInList;
	if (listSize > cnnSectionData[section].length) { listSize = cnnSectionData[section].length; }
	tempList = new Array();
	tempList[tempList.length] = cnnSectionData[section][startPointer++];
	while (tempList.length < listSize) {
		if (startPointer == cnnSectionData[section].length) { startPointer = 0; }
		tempList[tempList.length] = cnnSectionData[section][startPointer++];
	}
	if (this.loadFirstVideo != null) {
		this.playStartSlate = false;
		var foundIt = -1;
		for (var i = 0;i < tempList.length; i++) {
			if (tempList[i] == this.loadFirstVideo) {
				foundIt = i;
			}
		}
		if (foundIt < 0) {
			tempList.pop();
		} else {
			tempList.splice(foundIt,1);
		}
		tempList.unshift(this.loadFirstVideo);
		this.loadFirstVideo = null;
	}
	this.tab = currSectionNav;
	return tempList;
}
BVPPlaylistManager.prototype.BVPMLoadSingleVideo = function(jsonURL) {
	this.playStartSlate = false;
	this.skipStartSlateButLoadSynch = true;
	this.playlists['bvpplaylist'] = new this.playlist(new Array(jsonURL),0);
	this.setPlaylist('bvpplaylist',BVPPlaylistUICallbackFromStart);
}
BVPPlaylistManager.prototype.BVPMWritePlaylistUI = function() {
	tempStr = '';
	playList = this.playlists['bvpplaylist'].playlistJsonObjs;
	if (playList != null) {
		for (var i = 0; i < playList.length; i++) {
			tempStr += '<div class="box_item" id="nextup_' + i + '"><a href="#" onclick="CNNPlaylistManager.getInstance().advanceTo(\'bvpplaylist\','+i+'); return false;"><img src="' + CNNPlaylistManager.findImageSize(playList[i].getDataObject().images,"44x25");
			tempStr += '" width="45';
			tempStr += '" height="25';
			tempStr += '" border="0" alt="" /></a><a href="#" onclick="CNNPlaylistManager.getInstance().advanceTo(\'bvpplaylist\','+i+'); return false;">' + playList[i].getDataObject().headline;
			tempStr += '</a> <span class="duration">' + CNNPlayer.secondsIntoMinutes(playList[i].getDataObject().trt);
			tempStr += '</span></div>'
		}
		WTPO_writeToLayer(tempStr, "Play_Box");
	}
	else {
		tempStr = '<div id="nextup_0" style="text-align:center;margin-top:40px;color:#949494;"><b>There are no videos in your playlist.<br>Please make your selections below.</b></div>';
		WTPO_writeToLayer(tempStr, "Play_Box");
	}
}
BVPPlaylistManager.prototype.BVPMGetSplashPlaylist = function(sec) {
	this.playlists['bvpplaylist'] = new this.playlist(this.BVPMGeneratePlaylistFromStart(((sec == 'top_stories') ? 1 : 0),sec),0);
	this.setPlaylist('bvpplaylist',BVPPlaylistUICallbackFromStart);
}
BVPPlaylistManager.prototype.BVPMWriteSplash = function() {
	this.playlistType = 'bvp';
	if (this.noCookies == false) {
		CNNPlaylistManager.getInstance().advanceTo('bvpplaylist',0);
		this.BVPMWriteContent(this.playlists['bvpplaylist'].playlistJsonObjs[0].getDataObject());
		if (this.playlists['bvpplaylist'].playlistJsonObjs[0].getDataObject().providedBy != null) {
			document.getElementById('providedByL').innerHTML = '<b>&#1575;&#1604;&#1605;&#1589;&#1583;&#1585;: '+CNNPlaylistManager.providedResponse(this.playlists['bvpplaylist'].playlistJsonObjs[0].getDataObject().providedBy)+'</b>';
			document.getElementById('providedByS').innerHTML = '<b>&#1575;&#1604;&#1605;&#1589;&#1583;&#1585;: '+CNNPlaylistManager.providedResponse(this.playlists['bvpplaylist'].playlistJsonObjs[0].getDataObject().providedBy)+'</b>';
		}
		else {
			document.getElementById('providedByL').innerHTML = ''; 
			document.getElementById('providedByS').innerHTML = ''; 
		}
		if (this.playlists['bvpplaylist'].playlistJsonObjs[0].getDataObject().dateCreated != null) {
			document.getElementById('addedOnL').innerHTML = '<b>&#1571;&#1590;&#1610;&#1601; &#1601;&#1610;</b> '+this.playlists['bvpplaylist'].playlistJsonObjs[0].getDataObject().dateCreated;
			document.getElementById('addedOnS').innerHTML = '<b>&#1571;&#1590;&#1610;&#1601; &#1601;&#1610;</b> '+this.playlists['bvpplaylist'].playlistJsonObjs[0].getDataObject().dateCreated;
		}
		else {
			document.getElementById('addedOnL').innerHTML = ''; 
			document.getElementById('addedOnS').innerHTML = ''; 
		}
	} else {
		document.getElementById('cnnVPFlashLargeContainer').innerHTML = "<div class=\"cnnVideoMessageContainer\"><div class=\"cnnVideoMessage\"><p class=\"cnnTopGraf\"><b>COOKIES DISABLED</b><br><br>Please enable cookies to view CNN videos.<\/div><\/div>";
	}
}
BVPPlaylistManager.prototype.BVPMStartFromSplash = function() {
	this.splashActive = false;
	document.getElementById('cnnVPFlashLargeContainer').style.backgroundImage = '';
	document.getElementById('cnnVPFlashLargeContainer').innerHTML = '';
	CNNPlaylistManager.getInstance().BVPMVideoSelected(cnnSectionData['top_stories'][0],'top_stories');
}
BVPPlaylistManager.prototype.BVPMWriteContent = function(obj) {
	this.dataObject = obj;
	callControllerMethod('setEmailEnabled',true);
	if (obj != null) {
		str = '<div class="bvp_deschead"><b>'+((obj.headline != null) ? obj.headline : '')+'</b> <span class="bvp_desctrt">'+((obj.trt != null) ? CNNPlayer.secondsIntoMinutes(obj.trt) : '')+'</span></div>';
		str += '<div class="bvp_desctext">'+((obj.description != null) ? obj.description : '');
		str += '<div class="bvp_desclinks">'
		if (obj.relateds != null) {
			for (var i = 0; i < obj.relateds.length; i++) {
				str += '<b>&#8226;</b> <a href="'+obj.relateds[i].url+'">'+obj.relateds[i].headline+'</a><br>';
			}
		}
		str += '</div>';
		str += '</div>';
		document.getElementById('contentL').innerHTML = str;
		document.getElementById('contentS').innerHTML = str;
	} else {
		document.getElementById('contentL').innerHTML = '';
		document.getElementById('contentS').innerHTML = '';
	}
}

function MYPlaylistManager() {}
MYPlaylistManager.prototype.MYPMStorage = null;
MYPlaylistManager.prototype.MYPMLoadFromStorage = function() {
	this.playlistType = 'bvp';
	
	if (document.all) {
		try {
			document.getElementById('dataInstanceTest').load('IEStorageTest');
		} catch(err) {
			this.noIEStorage = true;
		}
	}
	
	this.testCookies();
	try{
	if (this.noIEStorage == false && this.noCookies == false) {
		this.MYPMStorage = StorageManager.getInstance().getStorage();
		this.MYPMStorage.setOnload( MYPlaylistDataIsLoaded );
		this.MYPMStorage.load();
	} else {
		this.playlists['myARplaylist'] = new this.playlist(new Array(),0);
		loadFirstSection(); 
		this.MYPMWritePlaylistUI();
	}
	}catch(e){}
}
MYPlaylistManager.prototype.getCurrentVideoTab = function() {
	return this.playlists['myARplaylist'].tabList[this.playlists['myARplaylist'].pointer];
}
MYPlaylistManager.prototype.MYPMSaveToStorage = function() {
	if (this.MYPMStorage == null) {
		this.MYPMStorage = StorageManager.getInstance().getStorage();
	}
	for (var i = 0; i < this.playlists['myARplaylist'].jsonList.length; i++) {
		if (this.MYPMStorage.contains(this.playlists['myARplaylist'].jsonList[i]) == false) {
			var currentVideo = new myPlaylistVideo(this.playlists['myARplaylist'].jsonList[i],this.playlists['myARplaylist'].tabList[i]);
			storageRet = this.MYPMStorage.put(this.playlists['myARplaylist'].jsonList[i],currentVideo,new Date(new Date().getTime() + 3*24*3600000 ));
		}
	}
	this.MYPMStorage.save();
}
MYPlaylistManager.prototype.MYPMAddToPlaylist = function(val) {
	if (this.MYPMStorage.contains(val) == false && this.playlists['myARplaylist'].jsonList.length < 15) {
		this.playlists['myARplaylist'].jsonList.push(val);
		this.playlists['myARplaylist'].tabList.push(currSectionNav);
		if (CNNPlaylistManager.getInstance().activePlaylist == 'myARplaylist') {
			CNNPlayer.getInstance('','MYPMAddToPlaylist').appendToPlayList(val);
		} else { 
			this.switchToMyList = true; 
		}
		o = 0;
		this.setPlaylist('myARplaylist',MYPlaylistUICallbackFromAppend);
		try{
		this.MYPMSaveToStorage();
		}catch(e){}
		makePlaylistAdderUnclickable(val);		
		load_Play_List('navMyPlay_List');
	}
}
MYPlaylistManager.prototype.MYPMDataLoadedCB = function() {
	tempJsonArray = new Array();
	tempTabArray = new Array();
	for (var i = 0; i < this.MYPMStorage.allKeys.length; i++) {
		if (this.MYPMStorage.allKeys[i].indexOf('.json') > -1) {
			var thisObj = this.MYPMStorage.dataObjects[this.MYPMStorage.allKeys[i]];
			tempJsonArray[tempJsonArray.length] = thisObj.id;
			tempTabArray[tempTabArray.length] = thisObj.tab;
		}
	}
	this.playlists['myARplaylist'] = new this.playlist(tempJsonArray,0,tempTabArray);
	this.setPlaylist('myARplaylist',MYPlaylistUICallback);
}
MYPlaylistManager.prototype.MYPMRemove = function(it) {
	pl = this.playlists['myARplaylist'];
	toRemove = '';
	if (pl.pointer != it || CNNPlaylistManager.getInstance().activePlaylist != 'myARplaylist') {
		tempArray = pl.jsonList;
		tempJsonList = new Array();
		tempTabList = new Array();
		for (i = 0; i < pl.jsonList.length; i++) {
			if (i != it) {
				tempJsonList.push(pl.jsonList[i]);
				tempTabList.push(pl.tabList[i]);
			}
			else {
				toRemove = pl.jsonList[i];
				tabToRemove = pl.tabList[i];
			}
		}
		this.playlists['myARplaylist'].jsonList = tempJsonList;
		this.playlists['myARplaylist'].tabList = tempTabList;
		if (CNNPlaylistManager.getInstance().activePlaylist == 'myARplaylist') {
			CNNPlayer.getInstance('','MYPMRemove').removeFromPlayList(toRemove);
		}
		this.setPlaylist('myARplaylist',MYPlaylistUICallbackFromAppend);
		this.MYPMStorage.remove(toRemove);
		try{
		this.MYPMSaveToStorage();
		}catch(e){}
		makePlaylistAdderClickable(toRemove);
	}
}
MYPlaylistManager.prototype.MYPMWritePlaylistUI = function() {
	tempStr = '';
	playList = this.playlists['myARplaylist'].playlistJsonObjs;
	if (playList != null && playList.length > 0) {
		for (var i = 0; i < playList.length; i++) {
			tempStr += '<div class="box_item" id="myup_' + i + '"><div id="myupgraydiv_'+i+'" style="float:right;margin-top:5px;"><a href="javascript:CNNPlaylistManager.getInstance().MYPMRemove('+i+');">';
			tempStr += '<img name="myupgray_'+i+'" id="myupgray_'+i+'" src="/video/bvp/images/close_btn.gif" width="12" height="12" alt="" border="0"></a></div>';
			tempStr += '<a href="#" onclick="CNNPlaylistManager.getInstance().advanceTo(\'myARplaylist\','+i+'); return false;"><img src="' + CNNPlaylistManager.findImageSize(playList[i].getDataObject().images,"44x25") + '" width="45" height="25" border="0" alt="" /></a>';
			tempStr += '<a href="#" onclick="CNNPlaylistManager.getInstance().advanceTo(\'myARplaylist\','+i+'); return false;">' + playList[i].getDataObject().headline + '</a> <span class="duration">' + CNNPlayer.secondsIntoMinutes(playList[i].getDataObject().trt) + '</span></div>';
		}
		WTPO_writeToLayer(tempStr, "My_Play_Box");
		WTPO_writeToLayer('<a href="javascript:load_Play_List(\'navMyPlay_List\');"><div>&nbsp;&nbsp;&#1602;&#1575;&#1574;&#1605;&#1577; &#1575;&#1604;&#1593;&#1585;&#1590;<span style="color:#949494;"> '+playList.length+' </span></div></a>&nbsp;', 'myPlaylistQuantity');
	}
	else {
		if (this.noIEStorage == true) {
			tempStr = '<div id="myup_0" style="text-align:center;margin-top:40px;color:#949494;"><b>IE Persistent storage is disabled.<br>Please enable to use the "My Playlist" feature.</b></div>';
		}
		else if (this.noCookies == true) {
			tempStr = '<div id="myup_0" style="text-align:center;margin-top:40px;color:#949494;"><b>Persistent storage is turned off<br>due to cookies being disabled.<br>Please enable to use the "My Playlist" feature.</b></div>';
		} else {
			tempStr = '<div id="myup_0" style="text-align:center;margin-top:40px;color:#949494;"><b>&#1604;&#1575; &#1610;&#1608;&#1580;&#1583; &#1571;&#1610; &#1601;&#1610;&#1583;&#1610;&#1608; &#1601;&#1610; &#1602;&#1575;&#1574;&#1605;&#1577; &#1575;&#1604;&#1593;&#1585;&#1590;.<br>&#1610;&#1585;&#1580;&#1609; &#1575;&#1604;&#1575;&#1582;&#1578;&#1610;&#1575;&#1585; &#1605;&#1606; &#1575;&#1604;&#1602;&#1575;&#1574;&#1605;&#1577; &#1571;&#1583;&#1606;&#1575;&#1607;</b></div>';
		}
		WTPO_writeToLayer(tempStr, "My_Play_Box");
		WTPO_writeToLayer('<a href="javascript:load_Play_List(\'navMyPlay_List\');"><div>&nbsp;&nbsp;&nbsp;&#1602;&#1575;&#1574;&#1605;&#1577; &#1575;&#1604;&#1593;&#1585;&#1590;<span style="color:#949494;"> 0 </span></div></a>&nbsp;', 'myPlaylistQuantity');
	}
	if (CNNPlaylistManager.getInstance().activePlaylist == 'myARplaylist') {
		this.highlight();
	}
}


MYPlaylistDataIsLoaded = function() { CNNPlaylistManager.getInstance().MYPMDataLoadedCB(); }
MYPlaylistUICallback = function() { loadFirstSection(); CNNPlaylistManager.getInstance().MYPMWritePlaylistUI(); }
MYPlaylistUICallbackFromAppend = function() { CNNPlaylistManager.getInstance().MYPMWritePlaylistUI(); }
BVPPlaylistUICallback = function() { CNNPlaylistManager.getInstance().BVPMWritePlaylistUI(); CNNPlaylistManager.getInstance().advanceTo('bvpplaylist',0);}
BVPPlaylistUICallbackFromStart = function() { CNNPlaylistManager.getInstance().BVPMWritePlaylistUI(); CNNPlaylistManager.getInstance().BVPMWriteSplash()}
SAPlaylistUICallback = function() { CNNPlaylistManager.getInstance().SAWriteSplash()}


SAIsBootStrapped = function(success) {
	CNNPlaylistManager.getInstance().SABootStrapCallback(success);
}

function flipBVPImage(imgName,srcName,onOff,ad) {
	if (ieVersion() == 0 || ieVersion() >= 7) {
		document.images[imgName+'Img'].src = '/video/bvp/images/'+srcName+'_'+onOff+'.png';
	}
	else {
		if (ad == null) ad = '';
		document.getElementById(imgName+'_button'+ad).runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='/video/bvp/images/"+srcName+"_"+onOff+".png')";
	}
}

function makeOn() { flipBVPImage('play','play','on'); }
function makeOff() { flipBVPImage('play','play','off'); }
function emailOn() { flipBVPImage('email','email','on'); }
function emailOff() { flipBVPImage('email','email','off'); }
function moveOn1() { flipBVPImage('replay','rply','on'); } 
function moveOut1() { flipBVPImage('replay','rply','off'); }

function ieVersion() {
	var ua = window.navigator.userAgent;
  var msie = ua.indexOf ( "MSIE " );
  if ( msie > 0 )      // If Internet Explorer, return version number
  	return parseInt (ua.substring (msie+5, ua.indexOf (".", msie )));
  else                 // If another browser, return 0
    return 0;
}

CNNPlaylistManager.prototype.videoWasLinked = function(){
        var locHref = '' + location.href;
        if(locHref.indexOf('/video/#/')>-1){
                var videoUrl = locHref.slice(locHref.indexOf('/#/')+2)+".json";
                var thisVideo = this.playlists[this.activePlaylist].activeJson();
                return videoUrl==thisVideo;
        }else if(locHref.indexOf('/video/?/')>-1){
		var videoUrl = locHref.slice(locHref.indexOf('/?/')+2)+".json";
		var thisVideo = this.playlists[this.activePlaylist].activeJson();
		return videoUrl==thisVideo;
	}else{
                return false;
        }
}