// JavaScript Document

// klasa kamAjax
function KamAjax() {
	this.debugMode = false;
	this.vars;
	this.getPlainText = getPlainText;
}

function createXMLHttpRequest() {
		try { return new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) {}
		try { return new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) {}
		try { return new XMLHttpRequest(); } catch (e) {}
		alert("Brak obslugi XMLHttpRequest!");
		return null;
}


function getPlainText(url, callbackFunction) {
	var xhReq = createXMLHttpRequest();
	if (xhReq != null) {
		// false - wywolanie synchroniczne, true - asynchroniczne
		xhReq.open("GET", url, true);
		xhReq.onreadystatechange = function() {
			if (xhReq.readyState == 4 && xhReq.status == 200) {
				callbackFunction(xhReq);
			}
			
		};
		xhReq.send(null);
	} else {
		if (debugMode) alert("Can't create XMLHttpReequest object");
	}
}
