// JavaScript Document

String.prototype.trim = function() {
a = this.replace(/^\s+/, '');
return a.replace(/\s+$/, '');
}

function checkForm(){
var outcome=true;
	if(document.getElementById('mailinglist_name').value.trim() =="" || document.getElementById('mailinglist_name').value == "Name here"){
		alert('You didn\'t enter your name!');
		outcome = false;
		return outcome;	
	}
	if(!validateEmail(document.getElementById('email_address').value) || document.getElementById('email_address').value.trim() ==""){
		alert('You didn\'t enter an email address or the email address appears incorrect!');
		outcome = false;
		return outcome;	
	}
	if(!document.getElementById('privacy_policy').checked){
		alert('You didn\'t check the privacy policy box');
		outcome = false;
		return outcome;	
	}
	if(outcome){
		return outcome;	
		}
}

function validateEmail ( theEmail ) {
 //emailpat = /^([a-zA-Z0-9])+([\.a-zA-Z0-9_-.])*@([a-zA-Z0-9_-.])+(\.[a-zA-Z0-9_-]+)+$/;
var emailpat = "^[\\w-_\.]*[\\w-_\.]\@[\\w]\.+[\\w]+[\\w]$";
var emailpat = new RegExp(emailpat);

 if( !emailpat.test( theEmail ) ) {
  return false;
 }
 return true;
}

function thePopUp(thePage,thename){
window.open(thePage,thename,"menubar=0,resizable=1,width=350,height=250,left=0,top=0")
	}
