var agt = navigator.userAgent.toLowerCase();
var versInt = parseInt(navigator.appVersion);
var is_ie	= ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));
var is_ie3    = (is_ie && (versInt < 4));
var is_ie4    = (is_ie && (versInt == 4) && (agt.indexOf("msie 4")!=-1) );
var is_aol   = (agt.indexOf("aol") != -1);
var is_aol3  = (is_aol && is_ie3);
var is_aol4  = (is_aol && is_ie4);
var is_aol5  = (agt.indexOf("aol 5") != -1);
var is_aol6  = (agt.indexOf("aol 6") != -1);
var is_comp   = (agt.indexOf("compuserve") != -1);
var is_comp2000   = (agt.indexOf("cs") != -1);	 
var is_compie = (is_comp && is_ie);

function setPixelsAltText() {
	if ( document.getElementById ) {
		var thePixelRef = document.getElementById( 'accessibilityPixel' );
		var bnewsTitleRef = document.getElementById( 'cnnBreakingNewsTitle' );
		var bnewsTextRef = document.getElementById( 'cnnBreakingNewsText' );
		if ( thePixelRef && ( bnewsTitleRef && bnewsTextRef ) ) {
			var bnewsTitle = '';
			var bnewsText = '';
			if ( bnewsTitleRef.hasChildNodes && bnewsTitleRef.lastChild.hasChildNodes ) {
				bnewsTitle = bnewsTitleRef.lastChild.firstChild.data;
			}
			if ( bnewsTextRef.hasChildNodes ) {
				bnewsText = bnewsTextRef.firstChild.data;
			}
			if ( bnewsTitle && bnewsText ) {
				thePixelRef.setAttribute( 'alt', bnewsTitle + ': ' + bnewsText + ' ' + thePixelRef.getAttribute( 'alt' ) );
			}
		}
	}
}

function ww_goTo( url ) {
	window.location.href = url;
}

function ww_roofBar( tableCellRef, hoverFlag ) {
	if ( hoverFlag ) {
		tableCellRef.style.backgroundImage = 'url("http://webworksonline.com/css/roofbar_bg2.gif")';
		if ( document.getElementsByTagName ) {
			tableCellRef.getElementsByTagName( 'a' )[0].style.color = '#c00';
		}
	} else {
		tableCellRef.style.backgroundImage = 'url("http://webworksonline.com/css/roofbar_bg.gif")';
		if ( document.getElementsByTagName ) {
			tableCellRef.getElementsByTagName( 'a' )[0].style.color = '#333';
		}
	}
}

function ww_roofBarClick( tableCellRef, url ) {
	ww_roofBar( tableCellRef, 0 );
	ww_goTo( url );
}

function ww_navBar( tableCellRef, hoverFlag, navStyle ) {
	if ( hoverFlag ) {
		switch ( navStyle ) {
			case 1:
//				tableCellRef.style.backgroundColor = '#69c';
				tableCellRef.style.backgroundColor = '#000066';
				break;
			default:
//				tableCellRef.style.backgroundColor = '#ccc';
				if ( document.getElementsByTagName ) {
					tableCellRef.getElementsByTagName( 'a' )[0].style.color = '#c00';
				}
		}
	} else {
		switch ( navStyle ) {
			case 1:
//				tableCellRef.style.backgroundColor = '#036';
				tableCellRef.style.backgroundColor = '#69c';
				break;
			default:
//				tableCellRef.style.backgroundColor = '#ddd';
				if ( document.getElementsByTagName ) {
					tableCellRef.getElementsByTagName( 'a' )[0].style.color = '#000';
				}
		}
	}
}

function ww_navBarClick( tableCellRef, navStyle, url ) {
	ww_navBar( tableCellRef, 0, navStyle );
	ww_goTo( url );
}

// this is for opening pop-up windows
function ww_openPopup( url, name, widgets, openerUrl )
{
	var host = location.hostname;
	var popupWin = window.open( url, name, widgets );
	
	if ( openerUrl )
	{
		popupWin.opener.location = openerUrl;
	}

	if ( !( is_aol6 || is_aol3 || is_aol4 || is_aol5 || is_compie || is_comp2000) )
	{
		popupWin.opener.top.name = "opener";
		popupWin.focus();
	}
}


function getEdMinFromStamp(stamp) {
	var year = stamp.substring(0,4);
	var dotpos = stamp.indexOf(".",5);
	var month = stamp.substring(5,dotpos);
	var dotpos2 = stamp.indexOf(".",dotpos+1);
	var day = stamp.substring(dotpos+1,dotpos2);
	dotpos = stamp.indexOf(".",dotpos2+1);
	var hour = stamp.substring(dotpos2+1,dotpos);
	dotpos2 = stamp.indexOf(".",dotpos+1);
	var minute = stamp.substring(dotpos+1,dotpos2);
	var stampDate = new Date(year, parseInt(month)-1, day, hour, minute, 0);
	var minutes = stampDate.getTime()/60000;
	return minutes;
}

// _________________________________________________________________________
function 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 );
}

