<!--
var alphachars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";

function isAlphanumeric(s, valid_chars) {
	var allValid = true;
	var ch = '';
	for (i = 0;  i < s.length;  i++) {
		ch = s.charAt(i);
		for (j = 0;  j < valid_chars.length;  j++)
			if (ch == valid_chars.charAt(j))
				break;
			if (j == valid_chars.length) {
				allValid = false;
			break;
		}
	}
	if (s.match("--")){
		allValid = false;
	}
	return allValid;
}

function isValidEmail(s){
	var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	if (filter.test(s)){
		return true;
	} else {
		return false;
	}
/*	
	if the above regex works, this commented code can be deleted - agoodman	
	// there must be >= 1 character before @, so we start looking at 
	// character position 1 (i.e. second character)
	var i = 1;
	var sLength = s.length;

	// look for @
	while ((i < sLength) && (s.charAt(i) != "@")) {
		i++
	}
	if((i >= sLength) || (s.charAt(i) != "@"))
		return false;
	else
		i += 2;

	// look for .
	while ((i < sLength) && (s.charAt(i) != ".")) {
		i++
	}
	// there must be at least one character after the .
	if ((i >= sLength - 1) || (s.charAt(i) != "."))
		return false;
	else
		return true;
*/
}

function validateEmail(form, msg){
	if(form.emailaddress.value == '' || !isValidEmail(form.emailaddress.value)) {
		alert(msg);
		form.emailaddress.focus();
		form.emailaddress.select();
		return false;
	}
	return true;
}
function validateCity(form,msg,msg2){
	if (form.city.value == ""){
		alert(msg);//"You must provide your city of residence to proceed"
		form.city.focus();
		return false;
	}
	if(!isAlphanumeric(form.city.value, alphachars + '- #\.\'')) {
		alert(msg2);//"Invalid character in city of residence"
		form.city.focus();
		form.city.select();
		return false;    
	}
	return true;
}
//-->

