<!-- File Operations -->
<!-- Functions for loading text from a file. -->

var emptySpace = "";

//gets a file from a particular URL
function getFile(pURL) {
	if (window.ActiveXObject) {//IE       		
      xmlhttp=new ActiveXObject('Microsoft.XMLHTTP'); 
      if (xmlhttp) {
         xmlhttp.onreadystatechange=postFileReady;
         xmlhttp.open('GET', pURL, true);
         xmlhttp.send();
      }
	}
	
   else if (window.XMLHttpRequest) { // code for Mozilla, Safari, etc 
      xmlhttp=new XMLHttpRequest();
      xmlhttp.onreadystatechange=postFileReady;
      xmlhttp.open("GET", pURL, true);
      xmlhttp.send(null);
   } 
}

// adds empty space to the bottom of the scrollable text so that the scroller only stops once all of 
// the text has disappeared off the top of the scroller (the viewableHeight is used to calculate how 
// much empty space should be used)
function createEmptySpace() {
	emptySpace = "";
	for (i=0; i<scroller.viewableHeight; i+=20)
	{
		emptySpace = emptySpace + "<br>";
	}
}

// function to handle asynchronous call
function postFileReady() {
	if (xmlhttp.readyState==4) { 
 		createEmptySpace();
		document.getElementById('innerScroller').innerHTML=xmlhttp.responseText+emptySpace;
		if (xmlhttp.status==200) { 
			document.getElementById('innerScroller').innerHTML=xmlhttp.responseText+emptySpace;
		}
   }
}
