function emailCatch(email){	
	if (email.length>4){	
		var ampers=0;
		var dots=0;		
		for (i=0;i<(email.length);i++){
			if (email.substring(i,(i+1))=="@"){
				ampers++;
			}
		}		
		for (i=0;i<(email.length);i++){
			if (email.substring(i,(i+1))=="."){
				dots++;
			}
		}		
	}
	if ((email.length<5)||(ampers!=1)||(dots==0)){
		return true;
	}
}
function submitForm(){
	
	var errors = 0;
	var popup="\nYour form entries are incomplete:\n\n";
	
		
	// check regular text fields
	var txtFields=new Array("first_name","last_name","tel_no");
	for (var i=0; i<txtFields.length; i++){
		if (eval("document.Form1." + txtFields[i] + ".value") == "") {
			eval("document.getElementById('r_" + txtFields[i] + "').style.visibility='visible'");
			errors++;
		}else{
			eval("document.getElementById('r_" + txtFields[i] + "').style.visibility='hidden'");
		}
	}

	// check email field
	if (emailCatch(document.getElementById('email').value)){
		eval("document.getElementById('r_email').style.visibility='visible'");
		errors++;
		popup+="\u00A0\u00A0\u00A0\u00A0\u00A0Please enter a valid email address\n\n";			
	}else{
		eval("document.getElementById('r_email').style.visibility='hidden'");
	}

			
	if (errors > 0){
			popup+="Please complete the fields marked\nwith a red * and then re-submit.\n\n";
			alert(popup);
	}else{
		document.forms.Form1.submit();
	}
}

