function openCNNWindow (url,name,widgets) 
{
	popupWin = window.open (url,name,widgets);
}

function openCNNAudio()
{
	openCNNWindow('http://cnn.com/video/popup/audio_sections/top.stories.exclude.html','620x460','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=620,height=460');
}

function openCNNAlerts()
{
	openCNNWindow('http://cnn.com/interactive/us/0109/terror.email/frameset.exclude.html','620x430','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=620,height=430');
}

// this is for opening pop-up windows
function openWindow (earl,name,widgets) 
{
        host = location.hostname;
        if (host.indexOf('customnews') != -1) 
        {
                var url = 'http://customnews.cnn.com' + earl;
        }
        else
        {
                var url = earl;
        }
        popupWin = window.open (url,name,widgets);
        popupWin.opener.top.name="opener";
        popupWin.focus();
}

function openWindowFloc (earl,name,widgets, floc) 
{
        var docDomain = window.location.hostname;
        var docPath = window.location.pathname;
        host = location.hostname;
        if (host.indexOf('customnews') != -1) 
        {
                var url = 'http://customnews.cnn.com' + earl;
        }
        else
        {
                var url = "http://channels.netscape.com/ns/wrap/linker.jsp?floc=" + floc + "&ref=" + earl;
        }
        popupWin = window.open (url,name,widgets);
        popupWin.opener.top.name="opener";
        popupWin.focus();
}

function LaunchVideo(url,format) {
     fullurl = 'http://www.cnn.com/video/code/sniff.exclude.html?' + url + "\;" + format;
     window.open(fullurl,'1x1TestWin','toolbar=no,menubar=no,location=no,scrollbars=no,resizable=no,width=1,height=1');
}
// used to open popup windows from the dateline
function CNN_openMap( location )
{
	var datelineWin = window.open( location, '620x430', "height=430,width=620,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no" );
	datelineWin.focus();
}
// this is for opening pop-up windows
function CNN_openPopup( url, name, widgets, openerUrl )
{
	var host = location.hostname;
        var url2 = "http://www.cnn.com" + url;
	url = url2;
	var popupWin = window.open( url, name, widgets );
	
	if ( openerUrl )
	{
		popupWin.opener.location = openerUrl;
	}

	popupWin.opener.top.name = "opener";
	popupWin.focus();
}

// this is for opening pop-up windows
function CNN_openPopupFloc( url, name, widgets, floc )
{
	var docDomain = window.location.hostname;
	var docPath = window.location.pathname;
	var host = location.hostname;
        	var url2 = "http://channels.netscape.com/ns/wrap/linker.jsp?floc=" + floc + "&ref=" + "http://www.cnn.com" + url;
	url = url2;
	var popupWin = window.open( url, name, widgets );
	popupWin.opener.top.name = "opener";
	popupWin.focus();

}

function med_vod_old(mycategory,mylocation){
	var popup_location = 'http://www.cnn.com/video/popup/main.html';
	if(mycategory && mylocation){
		popup_location = 'http://www.cnn.com/video/popup/main.html?'+mycategory+'?'+mylocation;
	}else if(mycategory){
		popup_location = 'http://www.cnn.com/video/popup/main.html?'+mycategory;
	}
	
	openWindow(popup_location,'620x460','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=620,height=460');
}

function med_vod_281102(vidlocation){
	openWindow(vidlocation,'620x460','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=620,height=460');
}


function med_vod(vidlocation) {
        var url2 = "http://www.cnn.com" + vidlocation;
	vidlocation = url2;
	var ua = window.navigator.userAgent;
	if ((ua.indexOf("R1") > 0) && (vidlocation.indexOf("med.exclude.html") > 0)) {
		var url = vidlocation.replace("med.exclude.html","r1.smi");
		location.href = url;
	} else {
		openWindow(vidlocation,'620x460','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=620,height=460');
	}
}
 

//////////////// Radio
var hasPlayer="";
var ppoLink="";
function getNSRadioCookie(aName, aDocument) {
	if (!aDocument) aDocument = document;
	var myValue = null;
	// Locate the cookie value
	var myCookie;
	var cookieAsString = aDocument.cookie;
	var expression = new RegExp(aName + '=[^;]+');
	while (expression.test(cookieAsString)) {
	    myCookie = cookieAsString.match(expression);
	    cookieAsString = cookieAsString.replace(expression, "");
	}
	// Extract the cookie value
	if (myCookie) {
	    var cookieValue = myCookie[0].match(/=(.*)/);
	    if (cookieValue && (cookieValue.length > 1)) {
	        myValue = cookieValue[1];
	    }
	}
	return myValue;
}
function setRadioLink(stationID, strFlocCode){
	hasPlayer = getNSRadioCookie("hasRadioPlus");
	if ( hasPlayer == 'true'){
		ppoLink="<div class=listA>&#149; <a href=javascript:launchRadioPPO('"+stationID+"','"+strFlocCode+"');>AP Radio News</a></div>";
	}
	return ppoLink;
}
function launchRadioPPO(stationID, strFlocCode) {
	var docDomain = window.location.hostname;
	var docPath = window.location.pathname;
	var pos = 0;
	var numof = -1;
	var i = -1;
	var twopos = -1;
	while (pos != -1) {
		pos = docPath.indexOf("/", i + 1);
		numof += 1;
		if (numof == 1) {
			twopos = pos;
		}
		i = pos;
	}
	if (numof > 1) {
		docPath = docPath.substring(0, twopos);
		if (docDomain.indexOf("member") > -1) {
			docPath = "";
		}
	} else {
		docPath = "";	
	}
	if ((docDomain.indexOf(".netscape.com") > -1) && (docDomain.indexOf("channels") == -1)) {
		docPath = "";
	}
	var trackradioURL = "http://" + docDomain + docPath + "/wrap/linker.jsp?floc=" + strFlocCode + "&ref=";
	//alert(trackradioURL);
	var radioURL = "http://channels.netscape.com/ns/music/radio/launch.jsp?s="+stationID;
	escape(radioURL);
	//alert(radioURL);
	document.location = trackradioURL + radioURL;
}
///////////// END RADIO



