function XMLHttp() {
	try{
		this.pyynto = new XMLHttpRequest();
	}
	catch(e){
		try{
			this.pyynto = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch(e){
			try{
				this.pyynto = new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch(E){
				this.pyynto = false;
			}
		} 
	}
}
XMLHttp.prototype.laheta = function(url,data,kontti,loading) {
	//alert(loading);
	var viesti = "<img src='/kuvat/loading.gif'>";
	var dataesc = "";
	var self = this;
	pyynto = this.pyynto;
	this.kontti = kontti;
	if(this.kontti != 'eval'){
		this.sisalto = document.getElementById(this.kontti);
		if(!loading )
			this.sisalto.innerHTML = viesti;
	}
	if(data != null){
		for(n = 0;n < data.length;n++){
			dataesc += data[n][0] + "=" + escape(data[n][1]) + "&";
		}	
		dataesc = dataesc.replace(/&$/g,"");
	}
	
	pyynto.onreadystatechange = function () {self.vastaus();};
	pyynto.open("POST", url, true);
	pyynto.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); 
	pyynto.send(dataesc);
};
XMLHttp.prototype.vastaus = function() {
	var virheviesti = "Virhe...";
	pyynto = this.pyynto;
	if (pyynto.readyState == 4) {
		if (pyynto.status == 200) {
			output = pyynto.responseText;
			if(this.kontti != 'eval'){
				var sis = output.split("-||eval||-");
				this.sisalto.innerHTML = sis[0];
				eval(sis[1]);
			}
			else{
				eval(output);
			}
		}
		//else
			//alert(virheviesti + pyynto.status);
	}
};
