// JavaScript Document
// very basic for now...
function isValidEmail(field)
{
with (field)
{
apos=value.indexOf("@");
dotpos=value.lastIndexOf(".");
if (apos<1||dotpos-apos<2) 
  {return false;}
else {return true;}
}
}

function validate() {
	errorMsg = '';
	// required fields
	
	if (document.regForm.participant_name.value=='') {
		errorMsg += 'Participant name\n';
	}
	if (document.regForm.address.value=='') {
		errorMsg += 'Address\n';
	}
	if (document.regForm.country.options[0].selected) {
		errorMsg += 'Country\n';
	}
	if (document.regForm.city_zipcode.value=='') {
		errorMsg += 'City, Zip Code\n';
	}
	if (document.regForm.phone.value=='') {
		errorMsg += 'Phone\n';
	}
	if (document.regForm.email.value=='') {
		errorMsg += 'Email address\n';
	} else if (!isValidEmail(document.regForm.email.value)) {
		errorMsg += 'Your email address is invalid.\n';
	}
	
	// registration category	
	ICOK=false;
	for (ic=0;ic<7;ic++) {
		if (document.regForm.registrationCategory[ic].checked) 
			ICOK=true;
	}
	if (!ICOK) {
		errorMsg += 'Registration category\n';
	}

	if (errorMsg!=''){
		outMsg = 'These fields need to be filled or require your attention:\n\n';
		outMsg += errorMsg;
		alert(outMsg);
		return false;
	}
	return true;
}

