/* Ajax */
var xmlHttp = false;
/*@cc_on @*/
/*@if (@_jscript_version >= 5)
	try {
		xmlHttp = new ActiveXObject('Msxml2.XMLHTTP');
	} catch (e) {
		try {
			xmlHttp = new ActiveXObject('Microsoft.XMLHTTP');
		} catch (e2) {
			xmlHttp = false;
		}
	}
@end @*/
if (!xmlHttp && typeof XMLHttpRequest != 'undefined') {
	if (window.XMLHttpRequest) { // Mozilla, Safari, ...
		xmlHttp = new XMLHttpRequest();
	} else if (window.ActiveXObject) { // IE
		xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
	}
}

function get() {
	var login = document.getElementById('login');
	var pass = document.getElementById('pass');
	var pismo = document.getElementById('pismo');
	var ok = true;
	
	if (! ok) {
		document.getElementById('span').innerHTML = '<span class="red">Не все поля заполнены!</span>';
	} else {
		var poststr = 'login=' + encodeURI(login.value) + '&pass=' + encodeURI(pass.value) + '&pismo=' + encodeURI(pismo.value);
		callServer('putacomment.php', poststr);
	}
	return;
}

function callServer(url, poststr) {
	document.getElementById('span').innerHTML = '<span class="green">Передача данных&hellip;</span>';
	xmlHttp.open('POST', url, true);		
	xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	xmlHttp.setRequestHeader('Content-length', poststr.length);
	xmlHttp.setRequestHeader('Connection', 'close');
	xmlHttp.send(poststr);
	xmlHttp.onreadystatechange = updatePage;
	return;
}

function updatePage() {
	if (xmlHttp.readyState == 4) {
		var response = xmlHttp.responseText;
		document.getElementById('span').innerHTML = response;
	}
}
