//
function makeNews(c,l,f){
	this.copy = c;
	this.link = l;
	this.follow = f;
	this.write = writeNews;
}

function writeNews(){
	var str = '';
	str += '<a href="' + this.link + '"></a>';
	str += this.copy + '&nbsp;&nbsp';
        str +=  '<a href="' + this.link + '">' + this.follow + '</a>';
	return str;
}

var newsArray = new Array();

newsArray[0] = new makeNews("18/05/2011 - The Stockton Alliance has selected Cube’s InControl product as their sa...",'News.aspx','Read More').write();

newsArray[1] = new makeNews("12/05/2011 - Cube consulting is pleased to welcome Isaac Regional Council (Isaac RC)...",'News.aspx','Read More').write();

newsArray[2] = new makeNews("22/03/2011 - Cube will be attending the Queensland Safety Show and welcomes the oppo...",'News.aspx','Read More').write();

newsArray[3] = new makeNews("05/02/2011 - Cube completes the Greenhouse Gas and Energy Reporting project for Auto...",'News.aspx','Read More').write();

var nIndex = 0;
var timerID = null;
function rotateNews(){
	var len = newsArray.length;
	if(nIndex >= len)
		nIndex = 0;
		
	var stories = document.getElementById('stories');
	if (stories != null && stories != 'undefined') {
		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);
	}
}

