//pre-load images
var listImg = new Image();
listImg.src = 'Press/img_10/Beyonce_1a.jpg';
var treeImg = new Image();
treeImg.src = 'Press/img_10/EOS_5000_edit_1a.jpg';
var formImg = new Image();
formImg.src = 'Press/img_10/Haiti Hope and Healing Fund_1a.jpg';
var autoImg = new Image();
autoImg.src = 'Press/img_10/Coney Zamperla_1a.jpg';

function makeNews(c,l,f,i){
	this.copy = c;
	this.link = l;
	this.follow = f;
	this.img = i;
	this.write = writeNews;
}

function writeNews(){
	var str = '';
	str += '<a href="' + this.link + '" class="nr">';
	str += '<img border="0" src="' + this.img.src + '" Hspace="18" Vspace="15" align = center></a>';
	str += this.copy + '<br>';
    str += '<a href="' + this.link + '" class="rn">' + this.follow + '</a>';
	return str;
}

var newsArray = new Array();
newsArray[0] = new makeNews("<br> On Friday, March 5, Brooklyn Borough President Marty Markowitz joined Beyoncé, her mother Tina Knowles, Mayor Michael Bloomberg, New York State Office of Alcoholism and Substance Abuse Services Commissioner Karen Carpenter-Palumbo, elected officials and Phoenix House President and CEO Howard Meitiner for the official opening of the Beyoncé Cosmetology Center at the Phoenix House Career Academy in DUMBO... ",'http://www.brooklyn-usa.org/Press/2010/mar5_FR.htm','More Info',listImg).write();

newsArray[1] = new makeNews("<br> On Thursday, February 18, Brooklyn Borough President Marty Markowitz observed Black History Month with a reception and celebration at Borough Hall... ",'http://www.brooklyn-usa.org/Press/2010/feb19_FR.htm','More Info',treeImg).write();

newsArray[2] = new makeNews("<br> On February 17, Brooklyn Borough President Marty Markowitz and Deputy Borough President Yvonne Graham hosted a press conference at Brooklyn Borough Hall, joining the Brooklyn Community Foundation and United Way of New York City to announce the NYC Haitian Community Hope & Healing Fund... ",'http://www.brooklyn-usa.org/Press/2010/feb17a_FR.htm','More Info',formImg).write();

newsArray[3] = new makeNews("<br> On Tuesday, February 16, Brooklyn Borough President Marty Markowitz joined Mayor Michael Bloomberg, elected officials, the New York City Economic Development Corporation and the New York City Department of City Planning at the New York Aquarium to unveil plans for a new amusement park in Coney Island scheduled to open by Memorial Day... ",'http://www.brooklyn-usa.org/Press/2010/feb16a_FR.htm','More Info',autoImg).write();

var nIndex = 0;
var timerID = null;
function rotateNews(){
	var len = newsArray.length;
	if(nIndex >= len)
		nIndex = 0;
	document.getElementById('stories').innerHTML = newsArray[nIndex];
	nIndex++;
	timerID = setTimeout('rotateNews()',18000);
}
function pauseNews() {
	if (timerID != null) {
		clearTimeout(timerID);
		timerID = null;
	}
}

function playNews() {
	if (timerID == null) {
		timerID = setTimeout('rotateNews()', 10);
	}
}
