﻿/* ---------------------------- */
/* XMLHTTPRequest Enable 		*/
/* ---------------------------- */
function createObject() {
	var request_type;
	var browser = navigator.appName;
	if(browser == "Microsoft Internet Explorer"){
	request_type = new ActiveXObject("Microsoft.XMLHTTP");
	}else{
		request_type = new XMLHttpRequest();
	}
		return request_type;
}

var http = createObject();
//
function send_form() 
{
	nocache = Math.random();
	inwestycja = encodeURI(document.getElementById('inwestycja').value);
	komentarz = encodeURI(document.getElementById('komentarz').value);
	podpis  = encodeURI(document.getElementById('podpis').value);
	
	http.open("POST", "/lib/send_coment.php");
	http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	
	http.send('inwestycja=' + inwestycja + '&komentarz=' + komentarz + '&podpis=' + podpis + '&los=' + nocache);
	
	http.onreadystatechange=send_formReply;
	
	document.getElementById('inwestycja').value = "";
	document.getElementById('komentarz').value = "";
	document.getElementById('podpis').value = "";
}
function send_form_en() 
{
	nocache = Math.random();
	inwestycja = encodeURI(document.getElementById('inwestycja').value);
	komentarz = encodeURI(document.getElementById('komentarz').value);
	podpis  = encodeURI(document.getElementById('podpis').value);
	
	http.open("POST", "/lib/send_coment_en.php");
	http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	
	http.send('inwestycja=' + inwestycja + '&komentarz=' + komentarz + '&podpis=' + podpis + '&los=' + nocache);
	
	http.onreadystatechange=send_formReply;
	
	document.getElementById('inwestycja').value = "";
	document.getElementById('komentarz').value = "";
	document.getElementById('podpis').value = "";
}

	
	
function send_formReply()
{
	
	if(http.readyState == 4)
	{
		var response = http.responseText;
		e = document.getElementById('opinie_odp');
		if(response!=""){e.innerHTML=response; e.style.display="block";} else {	e.style.display="none";}
	}
}
