var num_files = 4;
var file_path = "text/";
var file_name = "testimonial";
var file_ext = ".html"
var target_ID = "contentMargin";

function randomNumber(lower, upper) {
	var rand_number = Math.floor((upper-(lower-1))*Math.random()) + lower;
	return rand_number;
}

function getFile(pURL) {
   if (window.XMLHttpRequest) { // code for Mozilla, Safari, etc 
      xmlhttp=new XMLHttpRequest();
      xmlhttp.onreadystatechange=postFileReady;
      xmlhttp.open("GET", pURL, true);
      xmlhttp.send(null);
   } else if (window.ActiveXObject) { //IE 
      xmlhttp=new ActiveXObject('Microsoft.XMLHTTP'); 
      if (xmlhttp) {
         xmlhttp.onreadystatechange=postFileReady;
         xmlhttp.open('GET', pURL, true);
         xmlhttp.send();
      }
   }
}

// function to handle asynchronous call
function postFileReady() {
   if (xmlhttp.readyState==4) { 
      if (xmlhttp.status==200) { 
         document.getElementById('contentMargin').innerHTML=xmlhttp.responseText;
      }
   }
}

function randomText() {
	var file_number = randomNumber(1, num_files);
	var file_url = file_path + file_name + file_number + file_ext;
	var text = getFile(file_url);
	document.getElementById(target_ID).innerHTML=text;
} 


window.onload = randomText;
