/**
 * send form functions
 */
String.prototype.trim = function() {
	a = this.replace(/^\s+/, '');
	return a.replace(/\s+$/, '');
};

function send() {
	// getting vars from shipping form
	var name = document.getElementById('name');
	var email = document.getElementById('email');
	var comments = document.getElementById('body');
	var to = document.getElementById('to');
	
	var info = document.getElementById('infoSendMail');
	
	if (name.value.trim() != "" && email.value.trim() != "") {
	
		// create ajax object
		var xmlhttp = Ajax();
		
		url = "public/sendmail/sendmail.php";
		
		xmlhttp.open("POST", url, true);
		xmlhttp.onreadystatechange = function() {
			if (xmlhttp.readyState == 4) {
				info.style.display = 'block';
				if (xmlhttp.responseText === "OK") {
					info.innerHTML = "<span style='color: green;'>Consulta enviada correctamente. Nos pondremos en contacto con usted a la mayor brevedad.</span>";
				} else {
					info.innerHTML = "<span style='color: red;'>Ha ocurrido un error al enviar la consulta. Int&eacute;ntelo de nuevo.</span>";
				}
			}
		}
		xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		var str="name=" + encodeURI(name.value.replace("&", "&amp;"))
						+ "&email=" + encodeURI(email.value.replace("&", "&amp;"))
						+ "&comments=" + encodeURI(comments.value.replace("&", "&amp;"))
						+ "&to=" + encodeURI(to.value);
		xmlhttp.send(str);
		return false;
		
	} else {
		alert("Algunos campos no se han rellenado correctamente.");
		return false;
	}
}

function validate() {
}






