//pre-load images

function makeNews(c,l){
	this.copy = c;
	this.link = l;
	this.write = writeNews;
}

function writeNews(){
	var str = '<a href="' + this.link + '">' + this.copy + '</a>';
	return str;
}

var newsArray = new Array();
newsArray[0] = new makeNews("Pool opens March 15, 2012",
                            'pool.php').write();
newsArray[1] = new makeNews("Sharks Win Champs Meet 2011!!!!",
                            'swimteam.php?index=news').write();
newsArray[2] = new makeNews("Send us your feedback.",
                            'about.php?index=feedback').write();
newsArray[3] = new makeNews("Meet results are online!",
                            'swimteam.php?index=hist_results').write();
newsArray[4] = new makeNews("See Historical Photos of the Club!",
                            'about.php?index=history').write();
newsArray[5] = new makeNews("Read newspaper articles about the Club!",
                            'about.php?index=clubnews').write();
newsArray[6] = new makeNews("Swim Meet pictures are online!",
                            'swimteam.php?index=team_photos').write();
newsArray[7] = new makeNews("Sharks 2012 Calendar has been posted!",
                            'swimteam.php?index=team_cal').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()',6000);
}
function pauseNews() {
	if (timerID != null) {
		clearTimeout(timerID);
		timerID = null;
	}
}

function playNews() {
	if (timerID == null) {
		timerID = setTimeout('rotateNews()', 1000);
	}
}

