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 rsubmitIt(form) {
	if (!validEmail(form.emailaddr.value)) {
		alert("Invalid email address")
		form.emailaddr.focus()
		form.emailaddr.select()
		return false
	}
	return true

}
function popsubmitIt(form) {
	if (form.elements[0].checked != true) {
		alert("Please Select a Newsletter for your Subscription");
		form.elements[0].click();
		return false;
	}
	if (!validEmail(form.subscriber.value)) {
		alert("Invalid email address")
		form.subscriber.focus()
		form.subscriber.select()
		return false
	}	
	return true
}

function processSubscriber(form) {

	if (validEmail(form.emailaddr.value)) {
		http	= createRequestObject();
		email	= form.emailaddr.value;
		where	= '/cgi-bin/subscriptions.pl';
		parms	= '?checksubscriber='+email;
		target	= 'processSubscriberCheck';
		submitRequestTEST(where,parms,target);
	} else {
		msg	= 'Please enter a valid email address';
		alert(msg);
		return false;
	}
	return false;
}

function processSubscriberCheck(email) {

	var date = new Date();
	date.setYear(date.getYear()+1902);
	var expires = "; expires="+date.toGMTString();

	if (validEmail(email)) {
		//alert('already subscribed');
		//document.cookie = "useremail="+ email + ";path=/; domain=.healingtaousa.com"+expires;
		document.cookie = "useremail="+ email + ";path=/; "+expires;
		document.location.reload();
	} else if (email == 0) {
		//alert('not subscribed');
		document.subscribefrm.submit();
	}
}

