

var agt		= navigator.userAgent.toLowerCase();
var versInt	= parseInt(navigator.appVersion);
var is_aol	= (agt.indexOf("aol") != -1);


function CNN_goTo( url ) {
	window.location.href = url;
}

function CNN_roofBar( tableCellRef, hoverFlag ) {
	if ( hoverFlag ) {
		tableCellRef.style.backgroundImage = 'url("http://www.PopMusic.com/IMAGES/roofbar_bg2.gif")';
		if ( document.getElementsByTagName ) {
			tableCellRef.getElementsByTagName( 'a' )[0].style.color = '#c00';
		}
	} else {
		tableCellRef.style.backgroundImage = 'url("http://www.PopMusic.com/IMAGES/roofbar_bg.gif")';
		if ( document.getElementsByTagName ) {
			tableCellRef.getElementsByTagName( 'a' )[0].style.color = '#333';
		}
	}
}

function CNN_roofBarClick( tableCellRef, url ) {
	CNN_roofBar( tableCellRef, 0 );
	CNN_goTo( url );
}

function CNN_navBar( tableCellRef, hoverFlag, navStyle ) {
	if ( hoverFlag ) {
		switch ( navStyle ) {
			case 1:
				tableCellRef.style.backgroundColor = '#69c';
				break;
			default:
				if ( document.getElementsByTagName ) {
					tableCellRef.getElementsByTagName( 'a' )[0].style.color = '#c00';
				}
		}
	} else {
		switch ( navStyle ) {
			case 1:
				tableCellRef.style.backgroundColor = '#3366cc';
				break;
			default:
				if ( document.getElementsByTagName ) {
					tableCellRef.getElementsByTagName( 'a' )[0].style.color = '#000';
				}
		}
	}
}

function CNN_navBarClick( tableCellRef, navStyle, url ) {
	CNN_navBar( tableCellRef, 0, navStyle );
	CNN_goTo( url );
}




// _________________________________________________________________________



// _____________________________________________________________ WebMonkey code
/*
WM_setCookie(), WM_readCookie(), WM_killCookie()
A set of functions that eases the pain of using cookies.

Source: Webmonkey Code Library
(http://www.hotwired.com/webmonkey/javascript/code_library/)

Author: Nadav Savio
*/

// This next little bit of code tests whether the user accepts cookies.
function WM_browserAcceptsCookies() {
	var WM_acceptsCookies = false;
	if ( document.cookie == '' ) {
		document.cookie = 'WM_acceptsCookies=yes'; // Try to set a cookie.
		if ( document.cookie.indexOf( 'WM_acceptsCookies=yes' ) != -1 ) {
			WM_acceptsCookies = true;
		} // If it succeeds, set variable
	} else { // there was already a cookie
		WM_acceptsCookies = true;
	}
	
	return ( WM_acceptsCookies );
}

function WM_setCookie( name, value, hours, path, domain, secure ) {
	if ( WM_browserAcceptsCookies() ) { // Don't waste your time if the browser doesn't accept cookies.
		var numHours = 0;
		var not_NN2 = ( navigator && navigator.appName
					&& (navigator.appName == 'Netscape')
					&& navigator.appVersion
					&& (parseInt(navigator.appVersion) == 2) ) ? false : true;

		if ( hours && not_NN2 ) { // NN2 cannot handle Dates, so skip this part
			if ( (typeof(hours) == 'string') && Date.parse(hours) ) { // already a Date string
				numHours = hours;
			} else if ( typeof(hours) == 'number' ) { // calculate Date from number of hours
				numHours = ( new Date((new Date()).getTime() + hours*3600000) ).toGMTString();
			}
		}
		
		document.cookie = name + '=' + escape(value) + ((numHours)?(';expires=' + numHours):'') + ((path)?';path=' + path:'') + ((domain)?';domain=' + domain:'') + ((secure && (secure == true))?'; secure':''); // Set the cookie, adding any parameters that were specified.
	}
} // WM_setCookie

function WM_readCookie( name ) {
	if ( document.cookie == '' ) { // there's no cookie, so go no further
	    return false;
	} else { // there is a cookie
	    var firstChar, lastChar;
		var theBigCookie = document.cookie;
		firstChar = theBigCookie.indexOf(name);	// find the start of 'name'
		var NN2Hack = firstChar + name.length;
		if ( (firstChar != -1) && (theBigCookie.charAt(NN2Hack) == '=') ) { // if you found the cookie
			firstChar += name.length + 1; // skip 'name' and '='
			lastChar = theBigCookie.indexOf(';', firstChar); // Find the end of the value string (i.e. the next ';').
			if (lastChar == -1) lastChar = theBigCookie.length;
			return unescape( theBigCookie.substring(firstChar, lastChar) );
		} else { // If there was no cookie of that name, return false.
			return false;
		}
	}	
} // WM_readCookie

function WM_killCookie( name, path, domain ) {
	var theValue = WM_readCookie( name ); // We need the value to kill the cookie
	if ( theValue ) {
		document.cookie = name + '=' + theValue + '; expires=Fri, 13-Apr-1970 00:00:00 GMT' + ((path)?';path=' + path:'') + ((domain)?';domain=' + domain:''); // set an already-expired cookie
	}
} // WM_killCookie


// ______________________________________________________________________ Apple
// Copyright © 2000 by Apple Computer, Inc., All Rights Reserved.




// _____________________________________________________ Netscape Hat

var NS_HAT_COOKIE_NAME = "nsHat";
var NS_HAT_COOKIE_HOURS = '';
var NS_HAT_COOKIE_PATH = "/";
var NS_HAT_COOKIE_DOMAIN = EditionDomain;

if ( !WM_readCookie( NS_HAT_COOKIE_NAME ) && document.referrer && WM_browserAcceptsCookies() )
{
	var referrerMatchArray = document.referrer.toLowerCase().match( "^[^:]+[:/]+([^@]+@)?([^:/]+)[:/]" );
	if ( referrerMatchArray && referrerMatchArray.length > 2 )
	{
		var referrerHostname = referrerMatchArray[2];
		if ( referrerHostname.match( "channels.netscape.com$" ) || referrerHostname.match( "cnn.netscape.cnn.com$" ) )
		{
			WM_setCookie( NS_HAT_COOKIE_NAME, "netscape", '', NS_HAT_COOKIE_PATH, NS_HAT_COOKIE_DOMAIN, '' );
		}
		else
		{
			WM_setCookie( NS_HAT_COOKIE_NAME, "cnn", '', NS_HAT_COOKIE_PATH, NS_HAT_COOKIE_DOMAIN, '' );
		}
	}
}

function displayHat()
{
	var imageDir = ( arguments.length > 0 ) ? ( '/' + arguments[0] + '/' ) : '/white/';
	var referrerHost = WM_readCookie( NS_HAT_COOKIE_NAME );
	switch ( referrerHost )
	{
		case "netscape":
			document.write( '<a href="http://www.netscape.com/" target="new"><img src="http://i.cnn.net/cnn/.element/img/1.1/nshat' + imageDir + 'ns.logo.gif" width="95" height="27" hspace="0" vspace="0" border="0"><\/a><a href="http://www.netscape.com/" target="new"><img src="http://i.cnn.net/cnn/.element/img/1.1/nshat' + imageDir + 'ns.home.gif" width="53" height="27" hspace="0" vspace="0" border="0"><\/a><a href="http://cnn.netscape.cnn.com/news/default.jsp" target="new"><img src="http://i.cnn.net/cnn/.element/img/1.1/nshat' + imageDir + 'ns.news.gif" width="51" height="27" hspace="0" vspace="0" border="0"><\/a><a href="http://sportsillustrated.netscape.cnn.com/" target="new"><img src="http://i.cnn.net/cnn/.element/img/1.1/nshat' + imageDir + 'ns.sports.gif" width="61" height="27" hspace="0" vspace="0" border="0"><\/a><a href="http://channels.netscape.com/ns/pf/default.jsp" target="new"><img src="http://i.cnn.net/cnn/.element/img/1.1/nshat' + imageDir + 'ns.money.gif" width="63" height="27" hspace="0" vspace="0" border="0"><\/a>' );
			break;
		default:
			document.write( '<a href="http://www.netscape.com/" target="new"><img src="http://i.cnn.net/cnn/.element/img/1.1/nshat' + imageDir + 'ns.logo.standalone.gif" width="91" height="27" hspace="2" vspace="0" border="0"><\/a>' );
			break;
	}
}

//CSI functions
var cnnCSIs = new Array();
function cnnAddCSI(id,source,args)
{
	if(!args) { args='';}
	var newCSI = new Object();
	newCSI.src = source;
	newCSI.id  = id;
	newCSI.args = args;
	cnnCSIs[cnnCSIs.length]=newCSI;
}

function cnnUpdateCSI(html, id)
{
	var htmlContainerObj = document.getElementById( id ) || document.all[ id ];
	if(htmlContainerObj)
	{
		htmlContainerObj.innerHTML = html;
	}
	//force a refresh of the content area
	var htmlContentArea = document.body;
	if(htmlContentArea)
	{
		var previousTopVal = htmlContentArea.style.top || '0px';
		htmlContentArea.style.top = '1px';
		htmlContentArea.style.top = previousTopVal;
	}
}

function cnnHandleCSIs()
{
	if(location.hostname.indexOf('cnn.com')>0) {document.domain='cnn.com';}
	if(location.hostname.indexOf('turner.com')>0) {document.domain='turner.com';}

	if(document.body && document.body.innerHTML)
	{
		var iframeOwner = document.getElementById( 'csiIframe' ) || document.all[ 'csiIframe' ];
		var iframeHtmlSrc = '';

		for(var incCounter=0;incCounter<cnnCSIs.length;incCounter++)
		{
			var src = cnnCSIs[incCounter].src;
			var id = cnnCSIs[incCounter].id;
			var today = new Date();
			var currTime = today.getTime();
			var args = '&time='+currTime;
			if(cnnCSIs[incCounter].args)
			{
				args=args+'&'+cnnCSIs[incCounter].args;
			}
			
			iframeHtmlSrc+='<iframe src="'+src+'?domId='+id+args+'" name="iframe'+id+'" id="iframe'+id+'" width="0" height="0" align="right"></iframe>';
		}
		if(iframeOwner)
		{
			iframeOwner.innerHTML=iframeHtmlSrc;
		}
	}
}
// End CSI functions

// end


