function trim(text){
	text = text.replace(/^\s+/, "");
	text = text.replace(/\s+$/, "");
	text = text.replace(/\s+/g, " ");
	return text;
}

function checkFeedbackForm(){		
	
	if (trim($("#contact-name").val()).length < 2 || trim($("#contact-name").val()) == "Type Your Full Name"){
		alert("Please enter your full name.");
		$("#contact-name").val(trim($("#contact-name").val()));
		$("#contact-name").focus();
		return false;
	}
	
	if (!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(trim($("#contact-email").val()))) || trim($("#contact-email").val()) == "name@domain.com"){
		alert("Please enter a valid email address.");
		$("#contact-email").val(trim($("#contact-email").val()));
		$("#contact-email").focus();
		return false;
	}
	
	if (trim($("#contact-comment").val()).length < 2 || trim($("#contact-comment").val()) == "Type your comments here"){
		alert("Please enter your comment.");
		$("#contact-comment").val(trim($("#contact-comment").val()));
		$("#contact-comment").focus();
		return false;
	}
	
	return true;
}

function checkBookingForm(){		
	
	if (trim($("#book-name").val()).length < 2 || trim($("#book-name").val()) == "Full Name"){
		alert("Please enter your full name.");
		$("#book-name").val(trim($("#book-name").val()));
		$("#book-name").focus();
		return false;
	}
	
	if (trim($("#book-number").val()).length < 2 || trim($("#book-number").val()) == "+27 (0)12 345 6789"){
		alert("Please enter a contact number.");
		$("#book-number").val(trim($("#book-number").val()));
		$("#book-number").focus();
		return false;
	}
	
	if (!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(trim($("#book-email").val()))) || trim($("#book-email").val()) == "name@domain.com"){
		alert("Please enter a valid email address.");
		$("#book-email").val(trim($("#book-email").val()));
		$("#book-email").focus();
		return false;
	}
	
	return true;
}

function checkSubscribeForm(){		
	
	if (trim($("#special-name").val()).length < 2 || trim($("#special-name").val()) == "Full Name"){
		alert("Please enter your full name.");
		$("#special-name").val(trim($("#special-name").val()));
		$("#special-name").focus();
		return false;
	}
	
	if (!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(trim($("#special-email").val()))) || trim($("#special-email").val()) == "name@domain.com"){
		alert("Please enter a valid email address.");
		$("#special-email").val(trim($("#special-email").val()));
		$("#special-email").focus();
		return false;
	}
	
	return true;
}

function checkSTFForm(){		
	
	if (!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(trim($("#recip").val())))){
		alert("Please enter a valid email address.");
		$("#recip").val(trim($("#recip").val()));
		$("#recip").focus();
		return false;
	}
	
	if (!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(trim($("#frome").val())))){
		alert("Please enter a valid email address.");
		$("#frome").val(trim($("#frome").val()));
		$("#frome").focus();
		return false;
	}
	
	return true;
}
