//pre-load images
var carlisleImg = new Image();
carlisleImg.src = '/academics/physics/profiles/images/Carlisle004-110x110.jpg';
var gottbrechtImg = new Image();
gottbrechtImg.src = '/academics/physics/profiles/images/GottbrechtSteamboat-110x110.jpg';
var klyapImg = new Image();
klyapImg.src = '/academics/physics/profiles/images/carlson_klyap2-110x110.jpg';
var wallImg = new Image();
wallImg.src = '/academics/physics/profiles/images/wall_williams-110x110.jpg';
var pamImg = new Image();
pamImg.src = '/academics/physics/profiles/images/dany_and_pam-110x110.jpg';
var camImg = new Image();
camImg.src = '/academics/physics/profiles/images/cam-110x110.jpg';
var sparksImg = new Image();
sparksImg.src = '/academics/physics/profiles/images/Sparks_86x110.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("Graduate student Christine Carlisle is studying the mechanical properties of fibrin fibers, which are...",'http://www.wfu.edu/physics/profiles/profiles.html#profile1','Read More',carlisleImg).write();

newsArray[1] = new makeNews("Matthew Gottbrecht, a senior physics major, is doing research on protein structure and protein active site analysis...",'http://www.wfu.edu/physics/profiles/profiles.html#profile2','Read More',gottbrechtImg).write();

newsArray[2] = new makeNews("Undergraduate Sarah Klyap is searching for self-consistent wormhole solutions to...",'http://www.wfu.edu/physics/profiles/profiles.html#profile3','Read More',klyapImg).write();

newsArray[3] = new makeNews("Andrew Wall is working in the ultrafast laser laboratory of...",'http://www.wfu.edu/physics/profiles/profiles.html#profile4','Read More',wallImg).write();

newsArray[5] = new makeNews("Undergraduate Pamela Wang and Professor Daniel Kim-Shapiro are studying how the protein hemoglobin binds to the small molecule nitrite...",'http://www.wfu.edu/physics/profiles/profiles.html#profile5','Read More',pamImg).write();

newsArray[6] = new makeNews("Cam Mateus is an undergraduate student, working in the Computational Biophysics research group...",'http://www.wfu.edu/physics/profiles/profiles.html#profile6','Read More',camImg).write();

newsArray[7] = new makeNews("Eric Sparks is a former undergraduate student who studied the mechanical properties of fibrin fibers...",'http://www.wfu.edu/physics/profiles/profiles.html#profile7','Read More',sparksImg).write();

newsArray[8] = new makeNews("Undergraduate students Patrick Nelli and David Rosile are working together to develop a new aptamer discovery method...",'http://www.wfu.edu/physics/profiles/profiles.html#profile8','Read More',rosileImg).write();

newsArray[4] = new makeNews("Professor Jed Macosko is a major proponent of entrepreneurship in the sciences...",'http://www.wfu.edu/physics/profiles/profiles.html#profile9','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);
	}
}
