//pre-load images
var newImg = new Image();
newImg.src = 'news/news_images/news_image33.jpg';
var testImg = new Image();
testImg.src = 'news/news_images/news_image32.jpg';
var listImg = new Image();
listImg.src = 'news/news_images/news_image31.jpg';
var treeImg = new Image();
treeImg.src = 'news/news_images/news_image30.jpg';
var formImg = new Image();
formImg.src = 'news/news_images/news_image29.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 + '">';
	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("Recent New Westminster Junior Salmonbellies grads played a very prominent role in the recent World Field Lacrosse Championships in Manchester England.",'http://www.jrbellies.com/news_20100727.htm','Full Story',newImg).write();

newsArray[1] = new makeNews("When it comes to Jr. Bellies player Tyler Digby the term 'big' covers both his imposing size and the opportunity he has earned to play NCAA Division 1 football and lacrosse.",'http://www.jrbellies.com/news_20100724.htm','Full Story',testImg).write();

newsArray[2] = new makeNews("The Jr. Bellies will start their quest for the cup with a first round date versus the Victoria Junior Shamrocks. Click for the playoff schedule.",'http://www.jrbellies.com/schedule.htm','Full Story',listImg).write();

newsArray[3] = new makeNews("Although Bellies' captain Jarrett Toll had hoped that the Western Hockey League chapter in his life would have a few more pages and include playing in the Memorial Cup, a Game 5 loss to the Calgary Hitmen in the WHL final brought Jarrett's five year junior hockey career to an end.",'http://www.jrbellies.com/news_20100612.htm','Full Story',treeImg).write();

newsArray[4] = new makeNews("The extremely prestigious awards just keep on coming for recent Jr. Bellies players now combining education and lacrosse at NCAA Division 1 schools.",'http://www.jrbellies.com/news_20100608.htm','Full Story',formImg).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()', 2000);
	}
}
