/**************** IMAGE SLIDE HOLDER ****************/
document.writeln('<table width="100%" cellspacing="0" cellpadding="0"><tr><td id="featured"><!--START IMAGE SLIDES--><div><a id="featureNewsImageLink" href="http://www.nrao.edu/nraoRSS.xml"><img src="http://www.nrao.edu/images_news/other/megamaser.jpg" alt="NRAO News" name="featureNewsImage" width="526" height="112" id="featureNewsImage" style="border:1px solid #798691; border-bottom:none;" /></a><div id="controller" style="width:526px;"> <a href="http://www.nrao.edu/nraoRSS.xml"><img src="http://www.nrao.edu/images/logos/rssnewsfeed2.gif" alt="RSS News Feed" width="91" height="20" border="0" style="margin:2px 0px 0px 2px;" /></a> <a href="http://twitter.com/TheNRAO"><img src="http://www.nrao.edu/images/logos/twitter2.gif" alt="Twitter" width="91" height="20" border="0" style="margin:2px 0px 0px 2px;" /></a> <a href="http://www.facebook.com/pages/Charlottesville-VA/National-Radio-Astronomy-Observatory-NRAO/22534272968#!/pages/Charlottesville-VA/National-Radio-Astronomy-Observatory-NRAO/22534272968" target="_blank"><img src="http://www.nrao.edu/images/logos/facebook2.gif" alt="Facebook" width="91" height="20" border="0" style="margin:2px 0px 0px 2px;" /></a> <a href="http://www.youtube.com/user/NRAOEPO"><img src="http://www.nrao.edu/images/logos/youtube2.gif" alt="YouTube" width="91" height="20" border="0" style="margin:2px 10px 0px 2px;" /></a>');
document.writeln('<a id="prev" href="#" onclick="clearTimeout(t2); chgNewsImg(-1); pause(this);"></a>');
document.writeln('<a id="pp" class="pause" href="#" onclick="pause(this);"></a>');
document.writeln('<a id="next" href="#" onclick="clearTimeout(t2); chgNewsImg(1); pause(this);"></a>');
document.writeln('<div id="locator"># of #</div></div></div><!--END IMAGE SLIDES--></td></tr><tr><td>');



/**************** NEWS ITEMS ****************/
/*************************
news[NUMBER] = [
	"TITLE",
	"DATE",
	"INTRO",
	"LINK",
	"IMAGE",
	"science, epo, or both"];
*************************/
var news = [];
news[0] = [
	"Heaviest Pulsar Found by Most Accurate Means",
	20101027,
	"Using a trick of General Relativity and the most accurate pulsar timing equipment on Earth, radio astronomers have weighed a two solar mass pulsar. What does this record-breaking pulsar tell us about the nature of collapsed stars?",
	"http://www.nrao.edu/pr/2010/bigns/",
	"http://www.nrao.edu/images/2SolarMassPulsarbanner.jpg",
	"both"];
news[1] = [
	"Surprise: Dwarf Galaxy Harbors Supermassive Black Hole",
	20110110,
	"Which came first, the galaxy or the supermassive black hole? This latest research from the VLA seems to nail down the answer to this very old question.",
	"http://www.nrao.edu/pr/2011/bhdwarf/",
	"http://www.nrao.edu/images/NRAO_News_DwarfSMBH.jpg",
	"both"];
news[2] = [
	"Early Science with the Expanded VLA",
	20110524,
	"The VLA celebrated its 30th birthday with a suite of upgrades that have greatly expanded its capabilities. Enjoy a taste of the new science that has come from this new tool for astronomy.",
	"http://www.nrao.edu/pr/2011/evlaearly/",
	"http://www.nrao.edu/images/EVLAEarlyBANNER.jpg",
	"both"];
news[3] = [
	"First Images from ALMA",
	20111003,
	"NRAO releases the first visualizations of ALMA test data to reveal once-invisible details of star-formation in the Antennae Galaxies.",
	"http://www.nrao.edu/pr/2011/almafirstpics/",
	"http://www.nrao.edu/images/ALMAFirstPicsBanner.jpg",
	"both"];
news[4] = [
	"VLBA Helps Produce First Complete Description of a Black Hole",
	20111117,
	"For the first time, astronomers have produced a complete description of a black hole, a concentration of mass so dense that not even light can escape its powerful gravitational pull. Their precise measurements have allowed them to reconstruct the history of the object from its birth some six million years ago.",
	"http://www.nrao.edu/pr/2011/cygx1/",
	"http://www.nrao.edu/images/CygX1Banner.jpg",
	"both"];
news[5] = [
	"VLBA, RXTE Team Up to Pinpoint Black Hole's Outburst",
	20120110,
	"Astronomers have gained an important clue about a ubiquitous cosmic process by pinpointing the exact moment when gigantic bullets of fast-moving material were launched from the region surrounding a black hole.",
	"http://www.nrao.edu/pr/2012/diskjet/",
	"http://www.nrao.edu/images/VLBA_RXTE_Banner3.jpg",
	"both"];
news[6] = [
	"Iconic Telescope Renamed to Honor Founder of Radio Astronomy",
	20120110,
	"The National Radio Astronomy Observatory announced the new name for the Very Large Array (VLA) at the American Astronomical Society meeting in Austin, Texas.",
	"http://www.nrao.edu/pr/2012/jansky/",
	"http://www.nrao.edu/images/VLA_Jansky_Banner.jpg",
	"both"];
news[7] = [
	"ALMA Early Science Result Reveals Starving Galaxies",
	20120111,
	"Astronomers using the partially completed ALMA observatory have found critical evidence for how star-forming galaxies evolve into red and dead elliptical galaxies.",
	"http://www.nrao.edu/pr/2012/almastarvinggalaxies/",
	"http://www.nrao.edu/images/ALMAAAS219Banner.jpg",
	"both"];
var news2 = [];
for (j=0; j<news.length; j++){
	news2[j] = news[news.length-1-j];
}
var featureNewsImage = [];
var featureNewsImageLink = [];
for (i=0; i<news2.length; i++){
	if ((audience == news2[i][5]) || (news2[i][5] == "both")){
		document.writeln('<p id="news' + i + '">');
		document.writeln('<a href="' + news2[i][3] + '">');
		document.writeln('<span class="newsTitle">' + news2[i][0] + '</span> ');
		document.writeln('(' + processDate(news2[i][1]) + ')');
		if (news2[i][2] != "nointro"){document.writeln(': ' + news2[i][2]);}
		document.writeln('</a></p>');
	}
	featureNewsImage[i] = news2[i][4];
	featureNewsImageLink[i] = news2[i][3];
}
/*END NEWS ITEMS SCRIPT*/
var items;
var itemsSCI = 0;
var itemsEPO = 0;
for (i=0; i<news.length; i++){
	if ((news[i][5] == "science")||(news[i][5] == "both")){
		itemsSCI++;
	}
	if ((news[i][5] == "epo")||(news[i][5] == "both")){
		itemsEPO++;
	}
}
var newsItems;
if (audience == "epo"){
	newsItems = itemsEPO;
} else {
	newsItems = itemsSCI;
}
/*if (audience == "science"){
	items = itemsSCI;
	document.writeln('<p>' + items + '</p>');
} else {
	items = itemsEPO;
	document.writeln('<p>' + items + '</p>');
}*/



/**************** IMAGE SLIDE SWAPPER ****************/
var imgNewsNum = 0;   /*(Math.floor(Math.random()*newsItems));*/
var t2;
var rowNum;
function chgNewsImg(direction){	
	rowNum = imgNewsNum;
	document.getElementById('news'+rowNum).className = "";   /*Clear previously highlighted row...*/
	imgNewsNum = imgNewsNum + direction;   /*Add the direction ... -1, 0, or 1 ... to the current image number.*/
	if(imgNewsNum >= newsItems){   /*If it passes the end of the image array, go to the beginning.*/
		imgNewsNum = 0;
	}
	if(imgNewsNum < 0){   /*If it passes the beginning of the image array, go to the end.*/
		imgNewsNum = newsItems - 1;
	}
	document.getElementById('featureNewsImage').setAttribute("src", featureNewsImage[imgNewsNum]);   /*Set the image source...*/
	document.getElementById('featureNewsImageLink').setAttribute("href", featureNewsImageLink[imgNewsNum]);   /*Set the image link...*/
	document.getElementById('news'+imgNewsNum).className = "currentNews";   /*Highlight the cooresponding row...*/
	displayNumber = imgNewsNum + 1;   /*Set the display number to one more than the JavaScript count number...*/
	document.getElementById('locator').innerHTML = displayNumber + " of " + newsItems;   /*...and display "# of #" with previous and next buttons.*/
	t2 = setTimeout ("chgNewsImg(1)", 6000);
}
function pause(btn){
	btn.blur();
	clearTimeout(t2);
	document.getElementById('pp').className = "play";
	document.getElementById('pp').setAttribute("onclick", "play(this);");
}
function play(btn){
	btn.blur();
	document.getElementById('pp').className = "pause";
	document.getElementById('pp').setAttribute("onclick", "pause(this);");
	chgNewsImg(1);
}
if(document.getElementById('featureNewsImage')){   /*If there is a feature image on the page after loading (the home page)...*/
	chgNewsImg(0);   /*Set it to the random number.*/
}
document.writeln('</td></tr></table>');

