function sendHelp ( formElem ) {
  if(!formElem.getElement("input[name=url]")) {
    var url = document.createElement('input');
    url.name = 'url';
    url.type = 'hidden';
    url.value = window.location.href;
    formElem.appendChild(url);
  }
	var name = formElem.getElement("input[name=name]");
	var mail = formElem.getElement("input[name=email]");
	var dotaz = formElem.getElement("textarea");
	var td = formElem.getElement("td[colspan=2]");
	var back = td.get("html");
	var req = new Request({url: "/sendhelp.php", method: "post",
		onRequest: function() {
			td.set("html", "<img src=\"/highslide/graphics/loader.white.gif\" alt=\"Načítám\" />");
		},
		onSuccess: function() {
			alert("Váš dotaz byl úspěšně odeslán.");
			name.set("value", "");
			mail.set("value", "");
			dotaz.set("value", "");
		},
		onFailure: function(xhr) {
			if (xhr.status == 400) {
				alert("Vyplňte prosím všechna pole");
			} else if (xhr.status == 403) {
				alert("Musíte vyčkat 1 minutu před odesláním dalšího emailu.");
			} else if (xhr.status == 500) {
				alert("Váš dotaz se z technických důvodů nepodařilo odeslat.\nZkuste to prosím za chvíli znovu nebo využijte přímých kontaktů.");
			} else {
				alert("Nastala chyba při odesílání.");
			}
		},
		onComplete: function() {
			td.set("html", back);
		}
	});
	req.send(formElem);
	return false;
}

function sendDop ( formElem ) {
	var name = formElem.getElement("input[name=name]");
	var mail = formElem.getElement("input[name=email]");
	var rname = formElem.getElement("input[name=rname]");
	var rmail = formElem.getElement("input[name=remail]");
	var td = formElem.getElement("td[colspan=2]");
	var back = td.get("html");
	var req = new Request({url: "/senddop.php", method: "post",
		onRequest: function() {
			td.set("html", "<img src=\"/highslide/graphics/loader.white.gif\" alt=\"Načítám\" />");
		},
		onSuccess: function() {
			alert("Váše doporučení bylo úspěšně odesláno.");
			name.set("value", "");
			mail.set("value", "");
			rname.set("value", "");
			rmail.set("value", "");
		},
		onFailure: function(xhr) {
			if (xhr.status == 400) {
				alert("Vyplňte prosím všechna pole.");
			} else if (xhr.status == 403) {
				alert("Musíte vyčkat 1 minutu před odesláním dalšího emailu.");
			} else if (xhr.status == 500) {
				alert("Váše doporučení se z technických důvodů nepodařilo odeslat.\nZkuste to prosím za chvíli znovu.");
			} else {
				alert("Nastala chyba při odesílání.");
			}
		},
		onComplete: function() {
			td.set("html", back);
		}
	});
	req.send(formElem);
	return false;
}
