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 yahoo_setAccessibilityPixelAltText() {
	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 yahoo_goTo( url ) {
	window.location.href = url;
}

function yahoo_roofBarClick( tableCellRef, url ) {
	yahoo_roofBar( tableCellRef, 0 );
	yahoo_goTo( url );
}

function yahoo_navBar( tableCellRef, hoverFlag, navStyle ) {
	if ( hoverFlag ) {
		switch ( navStyle ) {
			case 1:
				tableCellRef.style.backgroundColor = '#9D159D';
				break;
			default:
//				tableCellRef.style.backgroundColor = '#ccc';
				if ( document.getElementsByTagName ) {
					tableCellRef.getElementsByTagName( 'a' )[0].style.color = '#c00';
				}
		}
	} else {
		switch ( navStyle ) {
			case 1:
				tableCellRef.style.backgroundColor = '#6F0F6F';
				break;
			default:
//				tableCellRef.style.backgroundColor = '#ddd';
				if ( document.getElementsByTagName ) {
					tableCellRef.getElementsByTagName( 'a' )[0].style.color = '#000';
				}
		}
	}
}

function yahoo_navBarClick( tableCellRef, navStyle, url ) {
	yahoo_navBar( tableCellRef, 0, navStyle );
	yahoo_goTo( url );
}



// this function is used to redirect the search form if necessary
function validate(theFormValidate) { return yahoo_validateSearchForm( theFormValidate );}


//this is for the dropdowns on the pages like TRAVEL


function napVector (vectorChoice) {
	   location.href = document.nap.vector.options[document.nap.vector.selectedIndex].value;
	   }
function ipVector (vectorChoice) {
	   location.href = document.ip.vector.options[document.ip.vector.selectedIndex].value;
	   }


function yahoo_setOptionsFromArray( selectOptions, array ) {
//	selectOptions = options reference -	document.forms['{formname}'].{selectname}.options
//								   or -	document.{formname}.{selectname}.options
//	array = Array - { 'text', 'url', 'text', 'url', ... }
// javascript:if( new Option() ) { alert( "true" ) } else { alert( "false" ) }
//	Mozilla: true
//	IE5/Mac: true
//	NN4/Mac: true
	var length = selectOptions.length;
	if ( new Option() ) {
		length = 2;								//	start at the top
		for ( var i = 0; i < array.length; i+=2 ) {
			selectOptions[length++] = new Option( array[i], array[i+1], false );
		}
	} else if ( document.createElement( "OPTION" ) ) {
		if ( selectOptions.length > 1 ) {
			for ( var i = 2; i < selectOptions.length; i++ ) {
				selectOptions.remove( 2 );		//	strip off options because we add them later
			}
		}
		for ( var i = 0; i < array.length; i+=2 ) {
			var newOption = document.createElement( "OPTION" );
			newOption.text = array[i];
			newOption.value = array[i+1];
			selectOptions.add( newOption );
		}
	}
}


//this is for the edition cookie popup, Jamie Randell author

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;
}

