//holds an instance of XMLHTTPRequest
var xmlHttp = createXmlHttpRequestObject();


	
	
//creates ab XMLHTTPREQUEST instance
function createXmlHttpRequestObject()
{
	//will store the reference to the XMLHttpRequest object
	var xmlHttp;
	//this should work for all browsers except IE6 and older
	try
	{
		//try to create XMLHttpRequest object
		xmlHttp = new XMLHttpRequest();
	}
	catch(e)
	{
		//assume IE6 or older
		var XmlHttpVersions = new Array("MSXML2.XMLHTTP.6.0","MSXML2.XMLHTTP.5.0","MSXML2.XMLHTTP.4.0","MSXML2.XMLHTTP.3.0","MSXML2.XMLHTTP","Microsoft.XMLHTTP");
		//try every prog id until one works
		for (var i=0; i<XmlHttpVersions.length && !xmlHttp; i++)
		{
			try
			{
				//try to create XMLHttpRequest object
				xmlHttp = new ActiveXObject(XmlHttpVersions[i]);
			}
			catch(e) {}
		}
	}
	//return the created object or display an error message
	if (!xmlHttp)
		alert("Error with your Internet Explorer browser (creating the XMLHttpRequest object). To access the list of SIMoN Network Partners please switch to a different browser.");
	else
		return xmlHttp;
}




//called to read a file from the server
function processInst()
{
	//only continue if xmlHttp is not void
	if (xmlHttp)
	{
		//try to connect to the server
		try
		{
			
			// get vars from the input form
			var inst = document.getElementById('inst').value;
			
			//assemble the query string to pass to biblio_action.php
			var queryString = "?inst=" + inst + "&invest=&full=";
			//initiate server
			xmlHttp.open("GET", "network_partners_action.php" + queryString, true);
			xmlHttp.onreadystatechange = handleRequestStateChange;
			xmlHttp.send(null);
	
		}
		//display the error in case of failure
		catch(e)
		{
			alert("Cannot connect to server:\n" + e.toString());
		}
	}
}


//called to read a file from the server
function processInvest()
{
	//only continue if xmlHttp is not void
	if (xmlHttp)
	{
		//try to connect to the server
		try
		{
			
			// get vars from the input form
			var invest = document.getElementById('invest').value;
			
			//assemble the query string to pass to biblio_action.php
			var queryString = "?invest=" + invest + "&full=&inst=";
			//initiate server
			xmlHttp.open("GET", "network_partners_action.php" + queryString, true);
			xmlHttp.onreadystatechange = handleRequestStateChange;
			xmlHttp.send(null);
	
		}
		//display the error in case of failure
		catch(e)
		{
			alert("Cannot connect to server:\n" + e.toString());
		}
	}
}


//called to read a file from the server
function processFull()
{
	//only continue if xmlHttp is not void
	if (xmlHttp)
	{
		//try to connect to the server
		try
		{
			
			//assemble the query string to pass to biblio_action.php
			var queryString = "?full=yes&inst=&invest=";
			//initiate server
			xmlHttp.open("GET", "network_partners_action.php" + queryString, true);
			xmlHttp.onreadystatechange = handleRequestStateChange;
			xmlHttp.send(null);
	
		}
		//display the error in case of failure
		catch(e)
		{
			alert("Cannot connect to server:\n" + e.toString());
		}
	}
}




//function that handles the HTTP response
function handleRequestStateChange()
{
	// display the status of the request
	if (xmlHttp.readyState == 4)
	{
		//continue only if HTTP status is "OK"
		if (xmlHttp.status == 200)
		{
			try
			{
				//read the message from the server
				handleServerResponse();
			}
			catch(e)
			{
				//display error message
				alert("Error reading the response: " + e.toString());
			}
		}
		else
		{
			//display status messgae
			alert("There was a problem retrieving the data:\n" + xmlHttp.statusText);
		}
	}
}


//function to handle server response
function handleServerResponse()
{
	//get the DIV from the results page
	var resultsDisplay = document.getElementById('myDivElement');
	resultsDisplay.innerHTML = xmlHttp.responseText;
}

	
	

	
	
	
	
	