function makeNews(c,l){
	this.copy = c;
	this.link = l;
	this.write = writeNews;
}

function writeNews(){
	var str = '';
	str += '<p><a onmouseover="pauseNews()" onmouseout="playNews()" href="' + this.link + '">';
	str += this.copy + '</a></p>';
	return str;
}

var newsArray = new Array();
newsArray[0] = new makeNews("San Mateo, CA &ndash; July 26, 2010<br />Glenborough’s 1525 Wilson Boulevard Building Ranks 3rd at the Midpoint of the EPA’s National Building Competition</em>",'news/2010/07_26_10.html').write();
newsArray[1] = new makeNews("San Mateo, CA &ndash; June 21, 2010<br />Sandra L. Boyle to Speak at the 2010 <em>BOMA International Conference</em>",'news/2010/06_21_10.html').write();
newsArray[2] = new makeNews("San Mateo, CA &ndash; June 16, 2010<br />Glenborough Announces Leasing Activity at Centerstone Plaza",'news/2010/06_16_10.html').write();

var nIndex = 0;
var timerID = null;

function rotateNews(){
	var len = newsArray.length;
	if(nIndex >= len)
		nIndex = 0;
		buttonHighlight();
	document.getElementById('homecontent_news_stories').innerHTML = newsArray[nIndex];
	nIndex++;
	timerID = setTimeout('rotateNews()',3000);
}

function pauseNews() {
	if (timerID != null) {
		clearTimeout(timerID);
		timerID = null;
	}
}

function playNews() {
	if (timerID == null) {
		timerID = setTimeout('rotateNews()', 3000);
	}
}

function jumpNews(article){
	nIndex = article;
	document.getElementById('homecontent_news_stories').innerHTML = newsArray[nIndex];
	buttonHighlight();
}

function buttonHighlight(){
		if(nIndex == 0){
			document.getElementById('homecontent_news_btns').innerHTML = '<a href="#" class="selected" onmousedown="jumpNews(0)"></a><a href="#" onmousedown="jumpNews(1)"></a><a href="#" onmousedown="jumpNews(2)">'
		}
		if(nIndex == 1){
			document.getElementById('homecontent_news_btns').innerHTML = '<a href="#" onmousedown="jumpNews(0)"></a><a href="#" class="selected" onmousedown="jumpNews(1)"></a><a href="#" onmousedown="jumpNews(2)">'
		}
		if(nIndex == 2){
			document.getElementById('homecontent_news_btns').innerHTML = '<a href="#" onmousedown="jumpNews(0)"></a><a href="#" onmousedown="jumpNews(1)"></a><a href="#" class="selected" onmousedown="jumpNews(2)">'
		}
}