function CreateXMLHttp () {

	if (typeof XMLHttpRequest != "undefined")
		return new XMLHttpRequest();
	else {
		if (window.ActiveXObject) {
			var Versions = ["MSXML2.XMLHttp.5.0","MSXML2.XMLHttp.4.0","MSXML2.XmlHttp.3.0","MSXML2.XMLHttp","Microsoft.XMLHttp"];
			for (var i = 0;i<Versions.length;i++) {
				try {
					var XmlHttp = new ActiveXObject(Versions[i]);
					return XmlHttp;
				} catch (oError) {}
			}
		}
	}
	
	throw new Error ("Zmien przegladarke!");

}

function AddComment (type,id) {

	var XMLHTTP = CreateXMLHttp ();
	XMLHTTP.open("POST","ajax/addcomment",true);
	XMLHTTP.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
	XMLHTTP.onreadystatechange = function () {
		if (XMLHTTP.readyState == 4 && XMLHTTP.status == 200) {
			document.getElementById('responseforcomment').style.display = "block";
			document.getElementById('responseforcomment').innerHTML = XMLHTTP.responseText;
		}
	}
	
	XMLHTTP.send('type='+type+'&id='+id+'&nick='+encodeURIComponent(document.getElementById('nick_comment').value)+'&email='+encodeURIComponent(document.getElementById('email_comment').value)+'&www='+encodeURIComponent(document.getElementById('www_comment').value)+'&body='+encodeURIComponent(document.getElementById('body_comment').value));
}

function SendEmail() {
	
	var XMLHTTP = CreateXMLHttp ();
	XMLHTTP.open("POST","ajax/sendemail",true);
	XMLHTTP.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
	XMLHTTP.onreadystatechange = function () {
		if (XMLHTTP.readyState == 4 && XMLHTTP.status == 200) {
			document.getElementById('responseforemail').style.display = "block";
			document.getElementById('responseforemail').innerHTML = XMLHTTP.responseText;
		}
	}
	
	XMLHTTP.send('name='+encodeURIComponent(document.getElementById('nick_form').value)+'&email='+encodeURIComponent(document.getElementById('email_form').value)+'&text='+encodeURIComponent(document.getElementById('body_form').value));
}

function Newsletter () {
	
	var XMLHTTP = CreateXMLHttp ();
	XMLHTTP.open("POST","ajax/newsletter",true);
	XMLHTTP.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
	XMLHTTP.onreadystatechange = function () {
		if (XMLHTTP.readyState == 4 && XMLHTTP.status == 200) {
			document.getElementById('responsefornewsletter').style.display = "block";
			document.getElementById('responsefornewsletter').innerHTML = XMLHTTP.responseText;
		}
	}
	
	XMLHTTP.send('email='+encodeURIComponent(document.getElementById('email_form2').value));
}