//requires mootools

function checktripform(theForm){

if (theForm.firstname.value==""){
alert("Please enter your first name.");
theForm.firstname.focus();
return false;
}
if (theForm.lastname.value==""){
alert("Please enter your last name.");
theForm.lastname.focus();
return false;
}

var x = theForm.email.value;
var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
if (filter.test(x) !=true){
alert("Please enter a valid email address.");
theForm.email.focus();
return false;
}

if (theForm.phone.value==""){
alert("Please enter your telephone number.");
theForm.phone.focus();
return false;
}

var fullname = theForm.firstname.value+" "+theForm.lastname.value;

var message = "Name: "+fullname+"\n";
message+="Email address: "+theForm.email.value+"\n";
message+="Phone number: "+theForm.phone.value+"\n";
message+="Preferred arrival date: "+theForm.booking_arrival_month.value+"."+theForm.booking_arrival_day.value+"."+theForm.booking_arrival_year.value+"\n";
message+="Preferred departure date: "+theForm.booking_departure_month.value+"."+theForm.booking_departure_day.value+"."+theForm.booking_departure_year.value+"\n";
message+="Comments: "+theForm.comments.value+"\n\n";

//ajax call (needs mootools)
var test = new Ajax('ishopstudio.com/factory/ajax.php', {postBody: 
    	Object.toQueryString({
    	trigger: 'booktrip',
	name: fullname,
	email_from: theForm.email.value,
	message: message
   }),
    	onComplete: function(request){request.responseText;}, evalScripts: true, method: 'post' }).request();

theForm.firstname.value="";
theForm.lastname.value="";
theForm.email.value="";
theForm.phone.value="";
theForm.comments.value="";

return false;	
}


