// JavaScript Document
//  From: http://keelypavan.blogspot.com/2006/03/reusing-xmlhttprequest-object-in-ie.html
//  From: MSN search by "ie xmlhttpreques refresh"
//  HTTP Request function

	function getXHR(){
	var newReq = null;
		if(window.XMLHttpRequest) {
			try { newReq = new XMLHttpRequest();}
			catch(e) {newReq = false;}
		}
		else 
			if(window.ActiveXObject) {
				try { newReq = new ActiveXObject("Msxml2.XMLHTTP");}
				catch(e) {
					try {newReq = new ActiveXObject("Microsoft.XMLHTTP");}
					catch(e) {newReq = false;}
				}
			}
		return newReq;
	}// eof function getXHR()
var req = getXHR();

var element;      
	function loadXHR(url,id) {
		element = document.getElementById(id);
		if(req) {
			req.open("GET", url, true);
			req.setRequestHeader('Content-Type', 'text/html charset=iso-8859-15'); 
//			req.contentType="text/html charset=iso-8859-15";
			req.onreadystatechange = processReq;
			req.send(null);
		}
		else {
			alert("XMLHttpRequest Object is not supported here!");
		}
	}// eof function loadXHR(url,id)

	function processReq() {
		if (req.readyState == 4) {
			if (req.status == 200 || req.status == 0) {
				element.innerHTML = req.responseText;
			}
			else { 
				alert("There was an issue retrieving the data:\n" + "Reason: " + req.statusText);}
		}
	}// eof function processReq()


//	Synkrooninen AJAX-lataus
	function loadXHRSync(url,id) {
		element = document.getElementById(id);
		if(req) {
			req.open("GET", url, false);
			req.onreadystatechange = processReq;
			req.send("");
		}
		else{
			alert("XMLHttpRequest Object is not supported here!");
		}
	}// eof function loadXHR(url,id)


