//pre-load images
var testImg = new Image();
testImg.src = 'news_images/news_image173.png';
var listImg = new Image();
listImg.src = 'news_images/news_image172.png';
var treeImg = new Image();
treeImg.src = 'news_images/news_image171.png';
var formImg = new Image();
formImg.src = 'news_images/news_image170.png';
var autoImg = new Image();
autoImg.src = 'news_images/news_image169.png';

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 + '">';
	str += '<img border="0" src="' + this.img.src + '"></a><br>';
	str += this.copy + '<br>';
        str +=  '<a href="' + this.link + '">' + this.follow + '</a>';
	return str;
}

var newsArray = new Array();

newsArray[0] = new makeNews("The Salmonbellies mourn the loss of Bill Gartside, long-time supporter and past President (1973-75) who passed away late last month. He will be missed by all who knew him.",'','',testImg).write();

newsArray[1] = new makeNews("On Behalf of the entire New Westminster Sr Salmonbellies Lacrosse Organization, Our Executive, Board of Directors, Players, Coaches, Managers, Support Staff, Volunteers, Sponsors and our fans...",'http://www.salmonbellies.com/news_20111224.htm','Full Story',listImg).write();

newsArray[2] = new makeNews("The league schedule has been confirmed and we're bringing it to you first, Bellies fans. Just over five months to go until the home opener!",'http://www.salmonbellies.com/news_20111223.htm','Full Story',treeImg).write();

newsArray[3] = new makeNews("At the recent WLA AGM, the decision was made to allow territorial affiliation for each of the teams in the league.",'http://www.salmonbellies.com/news_20111221.htm','Full Story',formImg).write();

newsArray[4] = new makeNews("At the end of the 2011 season, the Salmonbellied took the time to honour Dr. Rardi Van Heest by awarding her the Bill Armstrong trophy for outstanding contribution to the Salmonbellies Lacrosse Club.",'http://www.salmonbellies.com/news_20111120.htm','Full Story',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()',7000);
}
function pauseNews() {
	if (timerID != null) {
		clearTimeout(timerID);
		timerID = null;
	}
}

function playNews() {
	if (timerID == null) {
		timerID = setTimeout('rotateNews()', 5000);
	}
}

