﻿//LOAD IMAGE NAMES HERE
var story1Img = new Image();
story1Img.src = 'stories/story1.jpg';
var story2Img = new Image();
story2Img.src = 'stories/story2.jpg';
var story3Img = new Image();
story3Img.src = 'stories/story3.jpg';
var story4Img = new Image();
story4Img.src = 'stories/story4.jpg';
var story5Img = new Image();
story5Img.src = 'stories/story5.jpg';


//---------------- DO NOT MODIFY------

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><br>';
	str += this.copy + ' ';
        str +=  '<a href="' + this.link + '">' + this.follow + '</a>';
	return str;
}



// THIS IS WHERE YOU ADD HEADLINES - NEED TO MATCH IMAGE NAMES LISTED ABOVE


var newsArray = new Array();
newsArray[0] = new makeNews("JWHL launches 'Hockey For Haiti' clothing drive to help Haitian Earthquake Victims.",'url','To get your team involved, contact us!',story1Img).write();

newsArray[1] = new makeNews("2010 Challenge Cup!",'http://www.jwhl.org/challenge-cup.html','More Info',story2Img).write();

newsArray[2] = new makeNews("Eight JWHL players named to US U18 Team",'http://www.usahockey.com/Template_Usahockey.aspx?NAV=TU_02_07_02&id=266498','Link to USA Hockey Website',story3Img).write();

newsArray[3] = new makeNews("NAHA Red wins 2009 JWHL Challenge Cup - RED Division Championship!",'http://www.jwhl.org','More Info',story5Img).write();

//newsArray[4] = new makeNews("NAHA Red wins 2009 JWHL Challenge Cup - RED Division Championship!",'http://www.jwhl.org','More Info',story5Img).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);
	}
}
