function checkLogon(form) {
	if (form.llogon.value.length<5) {
		alert("Please enter the Logon you wish to use to access your Readings.\nThe minimum length is 4 characters.\nYou will be advised if the Logon is already in use.");
		form.llogon.focus();
		form.llogon.select();
		return false;
	}
	if (form.lpasswd.value.length < 5) {
		alert("Please enter the password to be used with this Logon.\nThe minimum length is 4 characters");
		form.lpasswd.focus();
		form.lpasswd.select();
		return false;
	}
	return true;
}

function checkEmail(form) {
	if (!validEmail(form.email.value)) {
		alert("Please enter a valid working email address.\nA validation email will be sent to this address.\nYou will be required to respond from this email address\nbefore your I Ching Reading account will be accessible.");
		form.email.focus();
		form.email.select();
		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 checkRegi(form) {
	if (form.lname.value.length<1) {
		alert("Please enter the name you wish us to use in correspondance and printouts.\nYou may use a single initial if you wish.\nThe default is your logon name.");
		form.lname.focus();
		form.lname.select();
		return false;
	}
	if (form.lpob.value.length < 4) {
		alert("Please enter your Place of Birth.\nThe minimum length is 4 characters.");
		form.lpob.focus();
		form.lpob.select();
		return false;
	}
	if (!validEmail(form.lemail.value)) {
		alert("Please enter a valid working email address.\nA validation email will be sent to this address.\nYou will be required to respond from this email address\nbefore your I Ching Reading account will be accessible.");
		form.lemail.focus();
		form.lemail.select();
		return false;
	}
	if (form.lyob.value < 1850 || form.lyob.value > 2050) {
		alert("Please enter a valid year of birth\nbetween 1850 and 2050 inclusive.");
		form.lyob.focus();
		form.lyob.select();
		return false;
	}
	if (form.ldob.value < 1 || form.ldob.value > 31) {
		alert("Please enter a valid day of birth\nbetween 1 and 31 inclusive.");
		form.ldob.focus();
		form.ldob.select();
		return false;
	}
	if (form.lhob.value < 0 || form.lhob.value > 23 || form.lhob.value == '') {
		alert("Please enter a valid hour of birth\nbetween 0 and 23 inclusive.");
		form.lhob.focus();
		form.lhob.select();
		return false;
	}
	if (form.lminob.value < 0 || form.lminob.value > 59 || form.lminob.value == '') {
		alert("Please enter a valid minute of birth\nbetween 0 and 59 inclusive.\nIf the minute is unknown, please use 30.");
		form.lminob.focus();
		form.lminob.select();
		return false;
	}
	if (form.llongob.value < 0 || form.llongob.value > 180 || form.llongob.value == '') {
		alert("Please enter a valid longitude of birth\nbetween 0 and 180 inclusive.\n");
		form.llongob.focus();
		form.llongob.select();
		return false;
	}
	if (form.tzob.value < 0 || form.tzob.value > 12 || form.tzob.value =='') {
		alert("Please enter a valid time zone of birth between 0 and 12 inclusive.\nPlease do not use + or -. Energy Master will determine the appropriate sign\nfrom the Longitude direction, E(+) or W(-) so please be careful to that one correct!");
		form.tzob.focus();
		form.tzob.select();
		return false;
	}
	return true;
}
function showProfile(id) {
	item = document.getElementById(id);
	if (item.style.display == 'none'){
		item.style.display	= '';
	} else {
		item.style.display	= "none";
	}
}

function updateProfile() {
	edress = document.rbdload.edress.value;
	aid = document.rbdload.aid.value;
	script = 'http://www.energy-master.com/cgi-bin/i_ch.pl';
	parms	= '?aid='+aid+'&edress='+edress;
	sndReq(script,parms);
}

