
function check_email_format(fld, email_address, field_name)
{
	var ind = email_address.indexOf("@",0);
	if ( (ind == -1) || (ind == 0) ) {
		alert("You entered an invalid e-mail address in the 'e-mail' field.");
		fld.select();
		return -1;
	}
	var ind1 = email_address.indexOf(".",ind);
	if (ind1 == -1) {
		alert("You entered an invalid e-mail address in the 'e-mail' field.");
		fld.select();
		return -1;
	}
	if (ind1 + 1 == email_address.length) {
		alert("You entered an invalid e-mail address in the 'e-mail' field.");
		fld.select();
		return -1;
	}
	return 0;
}

function check_vals(arr)
{
	var theForm = document.mainForm
	var obj;
	var st="";
	for (i=0;i<arr.length;i++) {
		obj=eval("theForm."+arr[i]);
		if (arr[i].indexOf("email")!=-1) {
			bol=check_email_format(obj,obj.value,arr[i]);
			if (bol==-1) {
				st+=arr[i] + ",   ";
			}
		} else {
			if (obj.type.indexOf("select") !=-1) {
				if (obj.selectedIndex == 0) {
					st+=arr[i] + ",   ";
				}
			} else { 
				if (obj.value=="" || obj.value==null) {
					st+=arr[i] + ",   ";
				}
			}
		}
	}
	if (st != "") {
		st1 = "The following fields must be filled correctly in order to submit the form:\n" + st + "\nPlease fill them.";
		alert (st1);
		return;
	}
	theForm.submit();
}

