function validateForm(form)
{
	if(form.name.value == "" || form.surname.value == "" || form.email.value == "")
		showError();
	else
		//alert(form.name.value+","+form.surname.value+","+form.email.value+","+form.phone.value+","+form.address.value+","+form.nationality.value+","+form.comments.value);
		sendMail(form.name.value,form.surname.value,form.email.value,form.phone.value,form.address.value,form.nationality.value,form.comments.value);
	return false;
}




function sendMail (name,surname,email,phone,address,nationality,comments)
{
		ajax = new Ajax();
		ajax.open ("POST", 'sendMail.php', true);
		ajax.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');

		ajax.onreadystatechange = function ()
		{
			if (ajax.readyState == 4)
			{
				catchResponse(ajax.responseText);
			}
		}
		//alert("name="+name+"&surname=" + surname+"&email=" + email+"&phone=" + phone+"&address=" + address + "&nationality=" + nationality+ "&comments=" + comments);
		ajax.send("name=" + name + "&surname=" + surname+"&email=" + email+"&phone=" + phone+"&address=" + address + "&nationality=" + nationality+ "&comments=" + comments);
}


function catchResponse(message)
{
	if(message == "1" )
	{
		showOk();
	}
	else
	{
		alert("Error sending information. Please Try again.");
	}
}

function showError()
{
	document.getElementById("errorDiv").style.display = "block";
	document.getElementById("errorDiv").style.visibility = "visible";
	document.getElementById("errorDiv").style.position = "absolute";
	document.getElementById("errorDiv").style.left = "160px";
	document.getElementById("errorDiv").style.top = "130px";
	document.getElementById("errorDiv").style.width = "224px";
	document.getElementById("sendButton").style.visibility = "hidden";
	document.getElementById("formInputs").style.visibility = "hidden";
}

function hideError()
{
	document.getElementById("errorDiv").style.display = "none";
	document.getElementById("errorDiv").style.visibility = "hidden";
	document.getElementById("sendButton").style.visibility = "visible";
	document.getElementById("formInputs").style.visibility = "visible";
}


function showOk()
{
		document.getElementById("okDiv").style.visibility = "visible";
		document.getElementById("okDiv").style.display = "block";
		document.getElementById("okDiv").style.position = "absolute";
		document.getElementById("okDiv").style.left = "160px";
		document.getElementById("okDiv").style.top = "130px";
		document.getElementById("okDiv").style.width = "240px";
		document.getElementById("sendButton").style.visibility = "hidden";
		document.getElementById("formInputs").style.visibility = "hidden";
}

function hideOk()
{
	document.getElementById("okDiv").style.visibility = "hidden";
	document.getElementById("okDiv").style.display = "none";
	document.getElementById("sendButton").style.visibility = "visible";
	document.getElementById("formInputs").style.visibility = "visible";
}
