function validateform() {
      with (document.nwsletterform) {
 	var chk_service;
	var chk_status;
	if (email.value == "" || email.value == "your email") {
		alert("please enter your email"); 
		return false;
	}
	if(!checkMail(email, "Email", true)) {
				return false;
			}	
	if (!chk_email(email)) {
			email.focus();
			email.select();
			return false;
	}
	if (zipcode.value.length == 0 ) {
		alert("Please enter Zip Code");
		zipcode.focus();
		zipcode.select();
		return false;
	}
	if (zipcode.value.length <= 3 || zipcode.value.length > 12) {
		alert("Please enter a valid zip code.")
		zipcode.focus();
		zipcode.select();
  		return false;
	
	}
	var bad_zip_chars = ".`/ (){}|<>/,&+=*'%?!~#^:;";
	if (!chk_badchar(zipcode.value, bad_zip_chars)) {
  		alert("Please remove all special characters from zip code.")
		zipcode.focus();
		zipcode.select();
  		return false;
 	}	
	if (service_code.selectedIndex <= 0 ) {
		alert("Please select Service");
		return false;
	}
	if (status_code.selectedIndex <= 0 ) {
		alert("Please select your Status");
		return false;
	}
	for(var i = 0; i < elements.length; i++) {
  			if(elements[i].name == "rb_agree" && elements[i].checked == false) {
				alert("We're sorry: in order to submit the form , you must review and agree to the Military.com Service Agreement");
				return false;
			}
		}		
	document.nwsletterform.formsource.value = GetCookie("SRCT");
	return true;		
 }
}

function checkMail(thisField, emailLabel, required)
{
   var result = true;
   var x = thisField.value.toLowerCase();
   var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9])+$/;
   
   var invalidEmails = new Array ("unknown@unknown.com","none@none.com","noemail@aol.com", "noemail@yahoo.com", "noemail@hotmail.com", "noemail@netzero.com", "noemail@juno.com", "noemail@netscape.com", "noemail@prodegy.net", "noemail@msn.net");
   var isEmpty = false ;
   if(x == "" || x == null) { isEmpty = true; }
   
   if(required && isEmpty)
   {
	alert('Please enter a value for the "' + emailLabel + '" field.');
	thisField.focus();
	result = false;
   }

   if(result && !isEmpty && !filter.test(x))
   {
	alert('Please enter a valid ' + emailLabel + ' value.');
	thisField.focus();
	result = false;
   }
   
   for(i=0; i<invalidEmails.length; i++)
   {
	if(result && invalidEmails[i] == x)
   	{
		alert('Please enter a valid ' + emailLabel + ' value.');
		thisField.focus();
		result = false;
   	}
   }
   
   return result;
}


function chk_email(obj) {
 var bad_email_chars = "`/ (){}|<>/,&+=*'%?!~#^:;";
 // check if user type in the email
 /* if (obj.value=="your email") {
  alert("Please type in your email address.")
  return false;
 } */
 // check for spl characters that are invalid
 if (!chk_badchar(obj.value, bad_email_chars)) {
  alert("Please remove all special characters from email address.")
  return false;
 }
 
 // Check for an @ sign
 var at_sign = obj.value.indexOf("@");
 if (at_sign < 0) {
  var msg = "Oops!  You forgot an '@' sign in your e-mail address.  Please enter an address such as ";
  msg = msg + obj.value + "@Military.com";
  alert(msg);
  return false;
 }
 // Check for a domain
 var dot = obj.value.substring(at_sign, obj.value.length + 1).indexOf(".");
 if (dot < 0) {
  var msg = "Oops, you forgot a '.' following the @ sign in your e-mail address.  Please enter an address such as ";
  msg = msg + obj.value + ".com";
  alert(msg);
  return false;
 }
 return true;
}

function chk_badchar(word, badchars) {
 var found = -1; // bad char not found 
 for (var i = 0; i < badchars.length; i++) {
  	found = word.indexOf(badchars.charAt(i));
  	if (found > -1) {
   		break;  // exit from for loop
  	}
 }
 if (found > -1) 
 	 return false;
 else 
 	 return true;
}
	