function Headlines() {
	this.headlineItems = [];
	this.curIndex = 0;
	this.timer;
}

Headlines.prototype.addHeadLine = function( title, image, url )  {
	
	return this.headlineItems.push( [ title, image, url ] );
	
}

Headlines.prototype.display = function( index ) {
	
	var titleLink = document.getElementById("headlineTitleText");
	var displayImage = document.getElementById("headlineImage");
	var imageLink = document.getElementById("headlineLink");
	
	if( titleLink != null ) {
		titleLink.innerHTML = this.headlineItems[ index ][0];
		titleLink.setAttribute("href", this.headlineItems[ index ][2] );
	}
	
	if( displayImage != null ) displayImage.src = this.headlineItems[ index ][1];
	
	if( imageLink != null ) imageLink.setAttribute("href", this.headlineItems[ index ][2] );
}

Headlines.prototype.startTimer = function() {
	
	var o = {};
	o.o = this;
	
	this.timer = setInterval(function() {o.o.next(true);}, 4000);
	
}

Headlines.prototype.stopTimer = function() {
	
	if( this.timer != null ) {
		clearInterval( this.timer );
		this.timer = null;
	}
	
}

Headlines.prototype.next = function( internal ) {
	
	if( internal == null ) this.stopTimer();
	
	this.curIndex++;
	if( this.curIndex >= this.headlineItems.length ) this.curIndex = 0;
	this.display( this.curIndex );
		
	return false;
}

Headlines.prototype.prev = function( internal ) {
	
	if( internal == null ) this.stopTimer();
	
	this.curIndex--;
	if( this.curIndex < 0 ) this.curIndex = this.headlineItems.length-1;
	this.display( this.curIndex );
	
	return false;
}