function trim(str)
{
	return str.replace(/^\s+|\s+$/g,'');
}

function isEmpty(formElement, message) {
	formElement.value = trim(formElement.value);
	
	_isEmpty = false;
	if (formElement.value == '') {
		_isEmpty = true;
		alert(message);
		formElement.focus();
	}
	
	return _isEmpty;
}

function checkEmail()
{
	theForm = window.document.mailing;
	if (isEmpty(theForm.email, 'Please Enter Your Email Address')) {
			return;
		} else {
			
				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))){
					alert('Incorrect email address');

				} else {
					window.document.mailing.submit();
			
		}
		}
	
}
