// JavaScript Document
function validName(name) { if (name == ""){return false;}return true; }
function validEmail(email) { invalidChars = " + / ? ; : , () {} [] \ & % !"; if (email == ""){return false;}
	for (i=0; i < invalidChars.length; i++) { badChar = invalidChars.charAt(i); if(email.indexOf(badChar,0) != -1) {return false} }	atPos = email.indexOf("@", 1);
	if(atPos == -1) {return false;}	if(email.indexOf("@",atPos+1) != -1) {return false}	periodPos = email.indexOf(".", atPos); if(periodPos == -1) {return false;} if (periodPos+3 > email.length){return false;} return true; }
function validateEAlertForm(formId) { var form = document.getElementById(formId); 	
	if(!validEmail(form.Email.value)) { form.Email.focus(); alert(correctEmailText()); return;}
	if(!validEmail(form.Email2.value)) { form.Email2.focus(); alert(correctEmailText()); return;}
	if(form.Email.value != form.Email2.value) { form.Email.focus(); alert('Email and confirmation email do not match.'); return;}
	if(!validName(form.Industry.value)) { form.Industry.focus(); alert('Please select an industry.'); return;}	
	if(!validName(form.PostalCode.value) || form.PostalCode.value.length<5 || isNaN(form.PostalCode.value)) 
			{ form.PostalCode.focus(); alert('Please provide a valid zipcode.'); return;}
	if(!oneSelected('categories',1)) {alert('Please select one or more subscription categories.'); return; }
	form.submit(); }
function correctEmailText() { var text = "Sorry, the email you've entered is invalid.\n\n A valid email consists of the following: \n\n 1) Must not be blank.\n\n 2) Must not have the following invalid charactors \n\n        spaces + / ? ; : , () {} [] \ & % ! \n\n 3) Must have one @ charactor \n\n 4) atleast one .(period) after the @ charactor \n"; return text;}
function oneSelected(selectGroupName,minimum) { var inputs = document.getElementsByName(selectGroupName); for (var i = 0;i<inputs.length;i=i+1) { if(inputs[i].checked) return true; } return false; }
