//pre-load images
var imgSavings = new Image();
imgSavings.src = '../../images/asITCalculatorBox.png';
var imgInformer = new Image();
imgInformer.src = '../../images/asBlogBox_fp.png';

function makeNews(theText,theLink,theImage,theAltText){
	this.copy = theText;
	this.link = theLink;
	this.img = theImage;
	this.alt = theAltText;
	this.write = writeNews;
}

function writeNews(){
	var str = '';
	str += '<p><strong>' + this.copy + '</strong></p>';
	str += '<a href="' + this.link + '"><img style="margin: 12px 0 0 16px;" src="' + this.img.src + '" height="75" width="150" alt="' + this.alt + '" border="0" /></a>';
	return str;
}

var newsArray = new Array();
newsArray[0] = new makeNews('How much will you save by using TCS Vision?','../../savings-calculator.php',imgSavings,'Huge IT Cost Savings').write();

newsArray[1] = new makeNews("Blogs, whitepapers, and more to keep you in the IT loop",'blog.html',imgInformer,'Stay Informed by Reading Our News').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()',8000);
}
function pauseNews() {
	if (timerID != null) {
		clearTimeout(timerID);
		timerID = null;
	}
}

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