function Headline(fileArray){
	
this.headlineList = fileArray;	
this.currentFile = this.headlineList[0];
this.currentIndex = 0;
this.numberOfFiles = this.headlineList.length;
this.rotate = rotate;
this.buildButtons =buildButtons;
this.displayHeadlines =displayHeadlines;
this.displayNext = displayNext;
}



function rotate(){
	
	//build buttons for all the headlines including the pause button
	//this.buildButtons();
	this.displayHeadlines();
		return true;
}


function displayHeadlines(){

	var myObject = this;

	var tempFile = this.headlineList[this.currentIndex];
	var display = function () {myObject.displayNext(tempFile); myObject.displayHeadlines();};
	window.setTimeout(display,15000);
	this.currentIndex = (this.currentIndex+1) % this.numberOfFiles;
	//this.displayHeadlines();
return true;
}


function displayNext(showFile){

	//check for jpg
	//if image file then just show it within an image tag inside of headline div

	//check for html file
	//if html then use get obj request to get the page and display inside of headline div
	//at first we will only use html files

	//check for xml file
	//use our stylesheet to render html and add to headline div

	//check for IE browser
	var xmlhttp = false;

	try{
		xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
	} catch (e){
		//use older active x object
		try{
			xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
		} catch (E){
			//non IE Browser yeah!
			xmlhttp = new XMLHttpRequest();
		}
	}


	xmlhttp.open("GET",showFile);
	xmlhttp.onreadystatechange = function(){
		if (xmlhttp.readyState ==4 && xmlhttp.status ==200){
				
				document.getElementById('headline').innerHTML = xmlhttp.responseText;
		}
	}

	xmlhttp.send(null);
		
}



function moveForward(){
//move forward one slide

}

function moveBackward(){
//move backwards one slide

}


function showSlide(mySlide){
//take number mySlide and

}


function buildButtons(){


	//next step is to add listeners to all the buttons and a transparent background


		var buttonHTML = "<ul class=\'buttons\'><li class=\'button\'><<</li>";
	
	for (var i=0;i<this.headlineList.length;i++){
		var temp = "<li class=\'button\'>" + (i+1) + "</li>";
		buttonHTML = buttonHTML + temp;
	}
	
	var generatedButtons = buttonHTML + "<li class=\'button\'>>></li></ul>";


	document.getElementById("buttonArea").innerHTML = generatedButtons;
	return true;


}


