addLoadEvent(contact);

function contact()
{
//test for the elements
if (document.getElementById('contactpageform') && document.getElementById('message')) 
	{
	var send = document.getElementById('contactpageform');
	send.onsubmit = check_fields;
	}
}

// what to do when submitting
function check_fields()
{
var mess = document.getElementById('message').value;
//test there is a message and it's not ridiculously short
if (!mess || mess == '' || mess.length < 10)
	{
	alert('Your message is too short, please elabourate');
	return false;
	}
else
	{
	if (document.getElementById('name'))	//test for element
		{
		var nam = document.getElementById('name').value;
		if (!nam || nam == '')
			{
			var prompt_nam = prompt("You don't seem to have entered a name.\nEither enter your name, or click 'Cancel' to send your message as anonymous.");
			if (prompt_nam)
				{
				document.getElementById('name').value = prompt_nam;
				}
			}
		}

	if (document.getElementById('email'))	//test for element
		{
		var email = document.getElementById('email').value;
		if (!email || email == '')
			{
			var prompt_email = prompt("You don't seem to have entered an email address. This means you will not be able to receive a reply.\nEither enter your email, or click 'Cancel' to send your message without option of reply.");
			if (prompt_email)
				{
				document.getElementById('email').value = prompt_email;
				}
			}
		}

	//send the form
	document.getElementById('contactpageform').submit();
	}	
}
