function sendRequest(service, method, url, content) {
	var xmlhttp = (window.XMLHttpRequest ? new XMLHttpRequest : (window.ActiveXObject ? new ActiveXObject("Microsoft.XMLHTTP") : false));
	if(!xmlhttp) alert("Nepodarilo sa nadviazať spojenie so serverom!");
	xmlhttp.open(method, url);
	xmlhttp.onreadystatechange = function() { service(xmlhttp); };
	xmlhttp.setRequestHeader("Cache-Control", "no-cache");
	xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=windows-1250");
	xmlhttp.send(content);
	return false;
}

function progressBar(action) {
	if(action == "show" && document.getElementById("progressBar")) document.getElementById("progressBar").innerHTML = "<img src='"+SITE_ROOT+"images/progress.gif' alt='nahrávam...' />";
	if(action == "hide" && document.getElementById("progressBar")) document.getElementById("progressBar").innerHTML = "";
}

function loadData(xmlhttp) {
	if(xmlhttp.readyState == 4) {
		if(xmlhttp.status == 200) {
			var result = xmlhttp.responseText;
			if(result == "EXIST") {
				document.getElementById("passwordContainer").style.display = "inline";
				showBubleBlue(document.getElementById("passwordContainer"), "E-mail je už zaregistrovaný! Ak poznáš heslo, zadaj ho - v opačnom prípade pokračuj bez hesla - zašleme Ti nové");
			}
			else {
				document.getElementById("passwordContainer").style.display = "none";
				hideBubleBlue();
			}
			progressBar("hide");
		}
		else progressBar("show");
	}
	else progressBar("show");
}

function emptyFc() {
	progressBar("hide");
}

function checkEmail(obj) {
	var email = obj.value;
	sendRequest(loadData, "GET", SITE_ROOT+"ajax_checkemail.php?email="+email, "");
}
