// http://www.webcheatsheet.com/javascript/form_validation.php

function isEmpty(fld)
{
	if (fld.value.length == 0) {
		return true;
	}
	return false;
}

function trim(s)
{
	return s.replace(/^\s+|\s+$/, '');
}

function validEmail(fld)
{
	var tfld = trim(fld.value);                        // value of field with whitespace trimmed off
	var emailFilter = /^[^@]+@[^@.]+\.[^@]*\w\w$/ ;
	var illegalChars= /[\(\)\<\>\,\;\:\\\"\[\]]/ ;
   
	if (!emailFilter.test(tfld)) {              //test email for illegal characters
		return false;
	} else if (fld.value.match(illegalChars)) {
		return false;
	}
	return true;
}

function validPhone(fld)
{
	var error = "";
	var stripped = fld.value.replace(/[\(\)\.\-\ ]/g, '');    
	
	if (fld.value == "") {
		return false;
	} else if (isNaN(parseInt(stripped))) {
		return false;
	} else if (!(stripped.length == 10)) {
		return false;
	}
	return true;
}
