function c(cpid,dayidx,hour) {
	var win=window.open('/calentry.asp?cpid='+cpid+'&d='+dayidx+'&h='+hour,
		'cambridge_prayer_org_calentry',
		'width=400,height=360,title=no');
	win.focus();
}

function pr(form) {
	var action=0;
	if(form) {
		var email=form.email;
		if(email) {
			if(isValidEmailAddress(email.value)) {
				form.action='/action/passwordreminder.asp';
				form.submit();
				return;
			} else {
				window.alert('Please enter a valid email address before asking for your password to be emailed to you.');
				return;
			}
		}
	}
}

function submit_calentry(validateuser) {
	var form=document.forms.calentry;
	if(!form) {
		window.alert('Browser Error');
	} else if(!validateuser) {
		form.submit();
	} else if(form.name.value=='') {
		window.alert('Please enter a name for your booking');
	} else if(form.email.value=='') {
		window.alert('Please enter an email address for your booking');
	} else if(!isValidEmailAddress(form.email.value)) {
		window.alert('Please enter a valid email address for your booking');
	} else {
		form.submit();
	}
}

/********************************************/

function isValidEmailAddress(email) {
	if(email.indexOf('@')==-1) {
		return false;
	}
	if(email.indexOf('.')==-1) {
		return false;
	}
	if(email.indexOf('@')!=email.lastIndexOf('@')) {
		return false;
	}
	if(email.lastIndexOf('.')<email.indexOf('@')) {
		return false;
	}
	if(email.length-email.lastIndexOf('.')<3) {
		return false; //has to have at least 2 chars after the last dot
	}
	return true;
}

function homemov(idn) {
	var img=document.getElementById('home'+idn);
	img.src='/images/pages/home1s'+idn+'.jpg';
}

function homemou(idn) {
	var img=document.getElementById('home'+idn);
	img.src='/images/pages/home1m'+idn+'.jpg';
}
