function sendrequest() {
	cleanedemail = ctrlemail(document.user_form.email.value);
	if(cleanedemail===false) {
		alert('The email address you entered does not seem to be a valid email address!');
		return ;
	}

	document.user_form.email.value = cleanedemail;
	ctrlmsg1 = ctrlmsg();
	if(ctrlmsg1===false) { 
		alert('Please complete your message!');
		return ;
	}


	submitform();
}

function submitform() {
	// copy all fields in hidden form
	document.hidden_form.title.value = document.user_form.title.value;
	document.hidden_form.name.value = document.user_form.name.value;
	document.hidden_form.firstname.value = document.user_form.firstname.value;
	document.hidden_form.address.value = document.user_form.address.value;
	document.hidden_form.postcode.value = document.user_form.postcode.value;
	document.hidden_form.city.value = document.user_form.city.value;
	document.hidden_form.country.value = document.user_form.country.value;
	document.hidden_form.tel.value = document.user_form.tel.value;
	document.hidden_form.email.value = document.user_form.email.value;
	document.hidden_form.msg.value = document.user_form.msg.value;

	document.hidden_form.submit();
}
// controls this is a valid email (if there is one) and returns the cleaned email
function ctrlemail(emailtxt) {
	// removes %20, %0A, \r and \n
	forbid = new Array("%0A","%0a","%20","\r","\n","\R","\N");
	for(i=0;i<forbid.length;i++) {
		pos = emailtxt.indexOf(forbid[i]);
		emailtxt = (pos>=0?emailtxt.substring(0,pos):emailtxt);
	}

	if(emailtxt=="") {
		return '';
	}

	if(emailtxt.search(' ')>=0) {
		return false;
	}
	posarobace = emailtxt.search('@');
	poslastdot = emailtxt.lastIndexOf('.');
	if((poslastdot<0)||(poslastdot<posarobace)||(posarobace<0)) {
		return false;
	}

	return(emailtxt);
}
function ctrlmsg() {
	if((document.user_form.name.value + document.user_form.firstname.value + document.user_form.email.value)=='') {
		return false;
	}
	if((document.user_form.msg.value)=='') {
		return false;
	}
	return true;
}
