/**
* A set of functions to check the data that was entered into a webform
*/

/**
* Checks the data that has been entered into a form
*
* @param	form	The data that the submitted form contains
* @returns	Boolean value representing if the form is ready to be submitted or not
*/
function checkFaq(form)
{
	// Blank error message
	var error = "";
	
	// Check email
	if( ! form.email.value)
	{
		error += "Please enter your email address\n";
	} else {
		if( ! isValidEmail(form.email.value))
		{
			error += "Please enter in a valid email address\n";
		}
	}
	
	// Check question
	if( ! form.question.value)
	{
		error += "Please enter a question\n";
	}
	
	// See if there are any errors
	if(error)
	{
		// Error, send errors and don't send form
		alert(error);
		return false;
	} else {
		// No errors, send form
		return true;
	}
	
}

/**
* Checks against a regular expression if there is a valid email entered
*
* @param	email		The email to be checked
* @returns	Boolean value representing if the email is valid or not
*/
function isValidEmail(email)
{
	// Setup Regular Expression
	var reg_exp = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/
	// Return the expression checked against the email
	return reg_exp.test(email);
}