// JavaScript Document
// Cross-browser function to load the XML film list file
// Call with file name to be loaded
var xmlFilm;
function loadFList(url)
{
xmlFilm=null;
if (window.XMLHttpRequest){
	xmlFilm = new XMLHttpRequest();
}
else if (window.ActiveXObject){
	xmlFilm = new ActiveXObject("Microsoft.XMLHTTP");
}
if (xmlFilm!=null){
	xmlFilm.onreadystatechange = processReqChange;
    xmlFilm.open("GET", url, true); // async request
    xmlFilm.send(null);
    }
else {
	alert("Sorry, but your browser does not support XMLHttp");
	}
}
// listener function, triggered when request completes
function processReqChange()
{
if (xmlFilm.readyState == 4)
	{// 4 = "loaded"
    if (xmlFilm.status == 200)
		{// 200 = "OK"
		key = "";
		showFilmList(xmlFilm, key);
    	}
	else 
		{
        alert('There was a problem retrieving the XML data: status=' + xmlFilm.statusText);
        }
    }
}
// Cross-browser function to load the XML film maker list file
// Call with file name to be loaded
var xmlFM;
function loadFMList(url)
{
xmlFM=null;
if (window.XMLHttpRequest){
	xmlFM = new XMLHttpRequest();
}
else if (window.ActiveXObject){
	xmlFM = new ActiveXObject("Microsoft.XMLHTTP");
}
if (xmlFM!=null){
	xmlFM.onreadystatechange = processReqChange2;
    xmlFM.open("GET", url, true); // async request
    xmlFM.send(null);
    }
else {
	alert("Sorry, but your browser does not support XMLHttp");
	}
}
// listener function, triggered when request completes
function processReqChange2()
{
if (xmlFM.readyState == 4)
	{// 4 = "loaded"
    if (xmlFM.status == 200)
		{// 200 = "OK"
		// do nothing
    	}
	else 
		{
        alert('There was a problem retrieving the XML data: status=' + xmlFM.statusText);
        }
    }
}
// Cross-browser function to load a text (or HTML) file
// Call with file name to be loaded
var xhr = null; // global for film synopsis file object
function makeRequest(url) {
if (window.XMLHttpRequest) {
	xhr = new XMLHttpRequest();
}
else if (window.ActiveXObject) {
	xhr = new ActiveXObject("Microsoft.XMLHTTP");
}
if (xhr!=null) {
		xhr.onreadystatechange = function(){showContents(xhr)};
		xhr.open("GET", url, true); // async request
		xhr.send(null);
	}
else {
	alert("Cannot read the synopsis");
	}
}
// listener function, triggered when request completes
// displays the contents of the requested file
function showContents(xhr) {
	var outMsg = "";
	if (xhr.readyState == 4) {
		switch (xhr.status) {
		case 200:
//		testtxt = testtxt+xhr.readyState+'-'+xhr.status+'-'+xhr.statusText+'<br/>';
			outMsg = xhr.responseText;
			break;
		case 404:
			outMsg = "<i>No further details available at present<i>";
			break;
		default:
			outMsg = "<p>Cannot access the information requested at this time</p>";
			break;
		}
		d5.innerHTML = outMsg;
	}
	return;
}
