// Preload loading image
var loadingImg = new Image();
loadingImg.src = "./img/Loading.gif";

// Globale variabelen voor mail
var ext = '@parabots.nl"';
var lnk = '<a href="ma' + 'ilto:';

//// AJAX code

// Code van http://www.w3schools.com/ajax/ajax_browsers.asp
function getXMLHtppRequestObject() {
		var xmlHttp;
		try
    {
				// Firefox, Opera 8.0+, Safari
				xmlHttp=new XMLHttpRequest();
    }
		catch (e)
    {
				// Internet Explorer
				try
				{
						xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
				}
				catch (e)
				{
						try
						{
								xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
						}
						catch (e)
						{
								alert("Your browser does not support AJAX!");
								return false;
						}
				}
    }
		return xmlHttp;
}

function fillContent(file) {
 var contentDiv = document.getElementById('contentDiv');

 //contentDiv.innerHTML = file;

	var xmlHttp = getXMLHtppRequestObject();

	xmlHttp.onreadystatechange = function() {
		if(xmlHttp.readyState == 0) {
       contentDiv.innerHTML = "The request is not initialized";
		}
		if(xmlHttp.readyState == 1) {
       // Laat plaatje zien terwijl de data wordt opgehaald
       // (is vantevoren al geladen, zodat dit (hopelijk) snel gaat)
			contentDiv.innerHTML =	"<p>&nbsp;<p><img src='./img/Loading.gif'>";
		}
		if( xmlHttp.readyState == 2) {
			contentDiv.innerHTML = "The request has been sent";
		}
		if( xmlHttp.readyState == 3) {
			contentDiv.innerHTML = "The request is in process";
		}
		if(xmlHttp.readyState == 4)	{
			contentDiv.innerHTML = xmlHttp.responseText;
		}
	}

	//alert("Getting: http://pb2/default/MarketSentiment/fillConsole.cgi?sCategory=" + category + "&sSortBy=" + sortBy);
	xmlHttp.open("GET", file, true);
	
  // Die null is ook echt essentieel voor Firefox, die anders blijft hangen...
	xmlHttp.send(null);
}

//// End AJAX code
