// --------------------------------------
// HomeFinder.js start
// --------------------------------------

function CheckForNull (src, errMsg)
{
	//assumes 'src' is an object or a string
	var str;
	var bSetFocus;
	
	if (typeof(src) == "object") {
		str = src.value;
		bSetFocus = true;
	} else {
		str = src;
		bSetFocus = false;
	}
	
	if (str.length == 0) {
		alert(errMsg);
		if (bSetFocus) {
			src.focus();
		}			
		return false;
	}	

	return true;
}

function GenIsValidEmail(strEmail, strFldName)
{
	// validate email address
	
	//var re = /^\w+@\w+(\.\w+)+$/;
	var re = /^[A-Za-z0-9_.\-]+@[A-Za-z0-9_\-]+(\.[A-Za-z0-9_\-]+)+$/;
	
	if (strEmail.length <= 0)
	{
		if (strFldName.length <= 0)
			alert('The Email address cannot be blank.');
		else
			alert(strFldName + ' cannot be blank.');
		return false;
	}
		
	if (!re.test(strEmail))
	//if (!((strEmail.indexOf("@") != -1) && (strEmail.indexOf(".") != -1)))
	{
		if (strFldName.length <= 0)
			alert('The Email address you specified is not valid.');
		else
			alert(strFldName + ' is not a valid Email address.');
		return false;
	}

	return true;	
}

function IsValidPhone(control, message)
{
	//create regular expression
	var re = /^\([1-9]\d{2}\)\s?\d{3}\-\d{4}$/;
	
	//check for empty text box
	if (control.value.length <= 0)
	{
		return true;
	}	
	
	//test against reg expression
	if (!re.test(control.value))
	{
		alert(message + "  Phone numbers must be in the following format: (614) 123-4567");
		control.focus();
		return false;
	}
	
	//return
	return true;	
}

// --------------------------------------
// HomeFinder.js end
// --------------------------------------
