//pre-load images
var mclellanImg = new Image();
mclellanImg.src = '/academics/physics/profiles/images/mclellan-4624-110x110.jpg';
var gottbrechtImg = new Image();
gottbrechtImg.src = '/academics/physics/profiles/images/GottbrechtSteamboat-110x110.jpg';
var davidImg = new Image();
davidImg.src = '/academics/physics/profiles/images/danny_5310-110x110.jpg';
var pamImg = new Image();
pamImg.src = '/academics/physics/profiles/images/dany_and_pam-110x110.jpg';
var goetzImg = new Image();
goetzImg.src = '/academics/physics/profiles/images/katelyn_5318-110x110.jpg';
var owenImg = new Image();
owenImg.src = '/academics/physics/profiles/images/jack_5325-110x110.jpg';
var rosileImg = new Image();
rosileImg.src = '/academics/physics/profiles/images/Rosile_and_Nelli_165x110.jpg';
var biobotzImg = new Image();
biobotzImg.src = '/academics/physics/profiles/images/biobotz_class-110x110.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("Undergraduate Claire McLellan is investigating organic (plastic) electronic devices based on...",'http://www.wfu.edu/physics/profiles/profiles.html#profile1','Read More',mclellanImg).write();

newsArray[1] = new makeNews("Matthew Gottbrecht, a former undergraduate student, researched protein structure and protein active site analysis...",'http://www.wfu.edu/physics/profiles/profiles.html#profile2','Read More',gottbrechtImg).write();

newsArray[2] = new makeNews("Daniel David uses state-of-the-art computer software and laboratory techniques...",'http://www.wfu.edu/physics/profiles/profiles.html#profile3','Read More',davidImg).write();

newsArray[3] = new makeNews("Pamela Wang studied how the protein hemoglobin binds to the small molecule nitrite...",'http://www.wfu.edu/physics/profiles/profiles.html#profile4','Read More',pamImg).write();

newsArray[4] = new makeNews("Katelyn Goetz is performing research on single crystal of novel organic semiconductors...",'http://www.wfu.edu/physics/profiles/profiles.html#profile5','Read More',goetzImg).write();

newsArray[5] = new makeNews("Jack Owen works on development of low-cost, high performance organic thin-film transistors...",'http://www.wfu.edu/physics/profiles/profiles.html#profile6','Read More',owenImg).write();

newsArray[6] = new makeNews("Recent graduates Patrick Nelli and David Rosile worked together to develop a new aptamer discovery method...",'http://www.wfu.edu/physics/profiles/profiles.html#profile7','Read More',rosileImg).write();

newsArray[7] = new makeNews("Professor Jed Macosko is a major proponent of entrepreneurship in the sciences...",'http://www.wfu.edu/physics/profiles/profiles.html#profile8','Read More',biobotzImg).write();


var nIndex = Math.floor(Math.random() * newsArray.length);
var timerID = null;
function rotateNews(){
	var len = newsArray.length;
	if(nIndex >= len)
		nIndex = 0;
	document.getElementById('stories').innerHTML = newsArray[nIndex];
	nIndex++;
	timerID = setTimeout('rotateNews()',9000);
}
function pauseNews() {
	if (timerID != null) {
		clearTimeout(timerID);
		timerID = null;
	}
}

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

