function LV_getRealOneStatusCNN() {	// returns ('undetermined'|'installed'|'notinstalled'|'using')
	var RealOneInst = "undetermined";

	if ( canDetectPlugins() ) {
		if ( detectRealOne() ) {
			RealOneInst = "installed";
			if ( agt.indexOf( "(r1 " ) != -1 ) {
				RealOneInst = "using";
			}
		} else {
			RealOneInst = "notinstalled";
		}
	}

	return RealOneInst;
}

function LV_getVideoUrlCNN( videoUrlPath, format, realOneStatus ) {
	var fullUrl;
	var preferredEdition = "www";
	var selectedEdition = WM_readCookie( "SelectedEdition" );
	var premiumUrlPrefix = "http://premium.cnn.com/pr/video";
	var premiumEdition = "premium.cnn.com";
	
	if ( selectedEdition ) {
		preferredEdition = selectedEdition;
	}
	
	if ( preferredEdition == "asia" || preferredEdition == "europe" ) {
		preferredEdition = "edition";
	}
	
	if ( preferredEdition != "www" ) {
		premiumEdition = "premium." + preferredEdition + ".cnn.com";
		premiumUrlPrefix = "http://" + premiumEdition + "/pr/video";
	}
	
	switch( realOneStatus ) {
		case "using":
			fullUrl = premiumUrlPrefix + "/meta" + videoUrlPath + "r1.smil"; 
			break;
		case "installed":
			fullUrl = premiumUrlPrefix + "/meta" + videoUrlPath + "np.smil"; 
			break;
		case "notinstalled":
		default:
			fullUrl = premiumUrlPrefix + videoUrlPath + "exclude.html";
			if ( format == "public" ) {
				fullUrl = "http://premium.cnn.com/video" + videoUrlPath + "exclude.html";
			}
			break;
	}
	
	return ( fullUrl );
}

function LaunchCNNVideo( videoPath, videoFormat ) {
	var VIDEO_POPUP_WIDTH = 620;
	var VIDEO_POPUP_HEIGHT = 480;
	var realOneStatus = LV_getRealOneStatusCNN();
	var videoUrl;

	if ( realOneStatus != "using" ) {	// if you're not using RealOne..
		if ( is_aol ) {	// if you're using AOL, you're getting the popup
			realOneStatus = "notinstalled";
		} else {	// let's check your cookie
			var playerPref = WM_readCookie( "player" );
			if ( playerPref ) {
				switch ( playerPref.toUpperCase() ) {
					case "REALONE":
					case "REAL":	// if your preference is Real, but it's not installed..
						if ( realOneStatus != "installed" ) {
							realOneStatus = "notinstalled";	// ..you'll get the popup
						}
						break;
					case "WINDOWS MEDIA":
					case "QUICKTIME":
					default:
						realOneStatus = "notinstalled";	// popup window
						break;
				}
			}
		}
	}
		
	videoUrl = LV_getVideoUrlCNN( videoPath, videoFormat, realOneStatus );
	
	if ( videoUrl.indexOf( ".exclude.html" ) > 0 ) {
		CNN_openPopup( videoUrl, '' + VIDEO_POPUP_WIDTH + 'x' + VIDEO_POPUP_HEIGHT, 'width=' + VIDEO_POPUP_WIDTH + ',height=' + VIDEO_POPUP_HEIGHT + ',scrollbars=no,resizable=no' );
	} else {
		top.location.href = videoUrl;
	} 
}


function med_vod( vidlocation ) {
	if ( ( agt.indexOf( "r1" ) != -1 ) && ( vidlocation.indexOf( "med.exclude.html" ) != -1 ) ) {
		var url = vidlocation.replace( "med.exclude.html", "r1.smi" );
		location.href = url;
	} else {
		CNN_openPopup( vidlocation, '620x460', 'width=620,height=460' );
	}
}

function CNN_openPopup( url, name, widgets, openerUrl )
{
	var host = location.hostname;
	var popupWin = window.open( url, name, widgets );
	
	if ( popupWin && popupWin.opener ) {
		if ( openerUrl )
		{
			popupWin.opener.location = openerUrl;
			popupWin.focus();
		}
		popupWin.opener.top.name = "opener";
	}
}