//pre-load images
var frenchImg = new Image();
frenchImg.src = 'http://teach.educ.ubc.ca/graphics/rotating/rotate01.jpg';
var nitepImg = new Image();
nitepImg.src = 'http://teach.educ.ubc.ca/graphics/rotating/rotate02.jpg';
var wktepImg = new Image();
wktepImg.src = 'http://teach.educ.ubc.ca/graphics/rotating/rotate03.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;
        str +=  '<a href="' + this.link + '">' + this.follow + '</a>';
	return str;
}

var newsArray = new Array();
newsArray[0] = new makeNews("<p>Since French is one of Canada's official languages, French language teachers are always in demand in our schools. Learn more about ",'http://teach.educ.ubc.ca/bachelor/french_options.html','our French language options here..',frenchImg).write();

newsArray[1] = new makeNews("<p>Of Aboriginal ancestry? It&rsquo;s all about choice! UBC&rsquo;s Native Indian Teacher Education Program may be exactly what you&rsquo;re looking for. Take the first 3 years of your BEd degree near your home community. ",'http://teach.educ.ubc.ca/bachelor/nitep/index.html','Learn More..',nitepImg).write();

newsArray[2] = new makeNews("<p>If studying and teaching in Rural BC interests you, apply for our West Kootenay Teacher Ed Program. Enjoy taking your BEd elementary or secondary program in the stunning Kootenay region of BC.",'http://teach.educ.ubc.ca/bachelor/wktep/index.html','&nbsp;More Info..',wktepImg).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()',10000);
}
function pauseNews() {
	if (timerID != null) {
		clearTimeout(timerID);
		timerID = null;
	}
}

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