// JavaScript Document

//Check if email is valid, submit the form if it is, give an alert if it isn't, then reset the form to 'email address'
function checkSubscribe() {

var x = document.subscribe.hold.value;

var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
document.subscribe.email.value = document.subscribe.hold.value;
if (filter.test(x)) {
document.subscribe.hold.value = 'email address';
openTarget(this, 'width=450,height=400,resizable=1,scrollbars=1', 'popup');

return true;
}else{
alert ("You must enter a valid email address.");
document.subscribe.hold.value = 'email address';
return false;
}

}

//submit the form if the user presses the Enter key
function checkKeyPress() {

if (window.event && window.event.keyCode == 13){
document.subscribe.submit();
} else {
return true;
}

}

//create the popup window target
function openTarget (form, features, windowName) {
  if (!windowName)
    windowName = 'formTarget' + (new Date().getTime());
  form.target = windowName;
  open ('', windowName, features);
}