function getRequestBody(_form){
	var aParams = new Array();
	
	for(var i=0; i<_form.elements.length; i++){
		var sParam = encodeURIComponent(_form.elements[i].name);
		sParam += "=";
		if(_form.elements[i].name == "pass"){
			sParam += hex_md5(_form.elements[i].value);
		} else {
			sParam += encodeURIComponent(_form.elements[i].value);
		}
		aParams.push(sParam);
	}
	return aParams.join("&");
}

//form id="fChPass" name="fChPass" onsubmit="checkPass('fChPass', 'chpass.php'); return false;" method="post">

function sendRequest(_form, _action){
	var oForm;
	var sBody = "";
	if(_form != null){
		oForm = document.forms[_form];
		sBody = getRequestBody(oForm);
	}
	
	var oXmlHttp = zXmlHttp.createRequest();
	oXmlHttp.open("post", _action, true);
	oXmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	
	oXmlHttp.onreadystatechange = function(){
		if(oXmlHttp.readyState == 4){
			if(oXmlHttp.status == 200){
				if(oXmlHttp.responseText == "mailsend"){
					alert("Съобщението беше успешно изпратено!");
				} else if(oXmlHttp.responseText == "learnsend"){
					alert("Заявката е изпратена!\nСкоро ще се свържем с вас.");
				} else if(oXmlHttp.responseText == "error"){
					alert("Няма връзка с базата данни!");
				} else if(oXmlHttp.responseText == "fill"){
					alert("Моля попълнете всички полета!");
				} else {
					alert(oXmlHttp.responseText);
				}
			} else {
				alert("Error: "+oXmlHttp.statusText);
			}
		}
	}
	oXmlHttp.send(sBody);
}
