var agt		= navigator.userAgent.toLowerCase();
var versInt	= parseInt(navigator.appVersion);
var is_aol	= (agt.indexOf("aol") != -1);
var cnnDomainArray = location.hostname.split( '.' );
var EditionDomain = ( cnnDomainArray.length > 1 ) ? '.' + cnnDomainArray[cnnDomainArray.length-2] + '.' + cnnDomainArray[cnnDomainArray.length-1] : '';
var newWin = null;

function popWin(url,WinName) {
	var widthString  = ",width=" + 800;	
	var heightString = ",height=" +600;
	var args = "toolbar=yes,location=no,directories=no,status=yes,scrollbars=yes,resizable=yes,menubar=no,titlebar=no, dependent=no," + heightString + widthString;
	//window.newWin.close();
		
	if (newWin && !newWin.closed) {
		
		newWin.location = url;
		//return false;
		//if (newWin && newWin.focus) newWin.focus();
	} else {
		newWin = window.open("",WinName,args);
		newWin.moveTo(0, 17);
		//newWin.resizeTo(screen.availWidth, screen.availHeight);
		//newWin.resizeTo(650,	525);
		newWin.location = url;
		//newWin.focus();
	}
} 

function popWinVar(url,WinName, width, height) {
	var widthString  = ",width=" + 400;
	var heightString = ",height=" + 300;
	var args = "toolbar=no,location=no,directories=no,status=no,scrollbars=no,resizable=yes,menubar=no,titlebar=no, dependent=no" + heightString + widthString;
	//window.newWin.close();
		
	if (newWin && !newWin.closed) {
		
		newWin.location = url;
		//return false;
		//if (newWin && newWin.focus) newWin.focus();
	} else {
		newWin = window.open("",WinName,args);
		newWin.moveTo(0, 17);
		//newWin.resizeTo(width,	height);
		//newWin.resizeTo(screen.availWidth, screen.availHeight);
		
		newWin.location = url;
		//newWin.focus();
	}
} 


function closeWin(){
	if (newWin && newWin.close) newWin.close();
}
function goTo( url ) {
	window.location.href = url;
}

function roofBar( tableCellRef, hoverFlag ) {
	if ( hoverFlag ) {
		//tableCellRef.style.backgroundImage = 'url("http://i.cnn.net/cnn/.element/img/1.0/main/roofbar_bg2.gif")';
		if ( document.getElementsByTagName ) {
			tableCellRef.getElementsByTagName( 'a' )[0].style.color = '#c00';
			
		}
	} else {
		//tableCellRef.style.backgroundImage = 'url("http://i.cnn.net/cnn/.element/img/1.0/main/roofbar_bg.gif")';
		if ( document.getElementsByTagName ) {
			tableCellRef.getElementsByTagName( 'a' )[0].style.color = '#333';
		}
	}
}

function roofBarClick( tableCellRef, url ) {
	roofBar( tableCellRef, 0 );
	goTo( url );
}

function navBar( tableCellRef, hoverFlag, navStyle, original ) {
	if ( hoverFlag ) {
		switch (original){
			case 1:
				chgcolor = '#900';
				break;
			case 2: 
				chgcolor = '#DAE3ED';//'#9CF'; //subnav color
				break;
			default:
				chgcolor = '#C00';
		}
		switch ( navStyle ) {
			case 1:
				tableCellRef.style.backgroundColor = chgcolor;
				
				break;
			default:
				if ( document.getElementsByTagName ) {
					tableCellRef.getElementsByTagName( 'a' )[0].style.color = '#c00';
					
				}
		}
	} else {
		switch (original){
			case 1:
				origcolor = '#fff';
				break;
			case 2: 
				origcolor = '#FFF'; //subnav color
				break;
			case 3: 
				origcolor = '#39F'; //subnav color
				break;
			default:
				origcolor = '#fff';
		}
		switch ( navStyle ) {
			case 1:
				tableCellRef.style.backgroundColor = origcolor;
				break;
				
			default:
				if ( document.getElementsByTagName ) {
					tableCellRef.getElementsByTagName( 'a' )[0].style.color = '#000';
				}
		}
	}
}

function navBarClick( tableCellRef, navStyle, url, original, location ) {
	navBar( tableCellRef, 0, navStyle, original);
	switch (location) {
	case 1: 
		window.open(url);
		break;
	case 2:
		popWin(url, 'kb');
		break;
	default:
		goTo( url );
	}
	
}


