function ValidateEmailFaxNumberGroup ( strEmailBoxID, strFaxNumBoxID )
{
	var cEmailBox = document.getElementById(strEmailBoxID);
	var cFaxNumBox = document.getElementById(strFaxNumBoxID);

	var cEmailRegExp = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
	// var cFaxNumRegExp = /(^\([1-9]\d{2}\)\s?|^[1-9]\d{2}-)\d{3}\-\d{4}$/;
	
	var cFaxNumRegExp = /^\D*\d{3}\D*\d{3}\D*\d{4}$/;

	var fIsValid = true;
	var fIsEmailPresent = true;
	var fIsFaxNumPresent = true;
	var fIsEmailValid = true;
	var fIsFaxNumValid = true;
	
	var stripFaxNumber;	
	var FaxNumber;
	
	// -------------------------------------------------------
	// This is only valid if the following conditions exist:
	//    At least one must be filled.
	//    All that are filled must be valid.
	//

	fIsEmailPresent = cEmailBox.value.replace(/\s/g, "") != "";
	fIsEmailValid = cEmailRegExp.test(cEmailBox.value);

	
	// fIsFaxNumPresent = cFaxNumBox.value.replace(/\s/g, "") != "";
	// fIsFaxNumValid = cFaxNumRegExp.test(cFaxNumBox.value);

	FaxNumber = cFaxNumBox.value;
	
	fIsFaxNumPresent = FaxNumber.replace(/\s/g, "") != "";
	
	// replace any special characters entered in the phone number
	stripFaxNumber = FaxNumber.replace(/[\(\)\.\-\ ]/g, '');
			
	if (stripFaxNumber.length != 10)
		fIsFaxNumValid = false;
	else fIsFaxNumValid = cFaxNumRegExp.test(cFaxNumBox.value);
	
	if ( fIsEmailPresent && !fIsEmailValid )
	{
		cEmailBox.focus();
		fIsValid = false;
	};

	if ( fIsFaxNumPresent && !fIsFaxNumValid )
	{
		cFaxNumBox.focus();
		fIsValid = false;
	};

	if ( !fIsEmailPresent && !fIsFaxNumPresent )
	{
		cEmailBox.focus();
		fIsValid = false;
	};

	return fIsValid;
};

function ValidateEmailTextBox (strTextBoxID, fIsRequired)
{
	var cTextBox = document.getElementById(strTextBoxID);
	var cEmailRegExp = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
	var fIsValid = true;

	if ((fIsRequired) && (!ValidateTextBox(strTextBoxID)))
	{
		cTextBox.value = cTextBox.value.replace(/\s/g, "")
		cTextBox.focus();
		fIsValid = false;
	}
	else if ((cTextBox.value.replace(/\s/g, "") != "") && (!cEmailRegExp.test(cTextBox.value)))
	{
		cTextBox.focus();
		fIsValid = false;
	}
	
	return (fIsValid);
}

function ValidateTextBox (strTextBoxID)
{
	var cTextBox = document.getElementById(strTextBoxID);
	var fIsValid = true;
	
	if (cTextBox.value.replace(/\s/g, "") == "")
	{
		cTextBox.value = cTextBox.value.replace(/\s/g, "")
		cTextBox.focus();
		fIsValid = false;
	}
	
	return (fIsValid);
}

function ValidateHiddenTextBox (strTextBoxID)
{
	var cTextBox = document.getElementById(strTextBoxID);
	var fIsValid = true;
	
	if (cTextBox.value.replace(/\s/g, "") == "")
	{
		cTextBox.value = cTextBox.value.replace(/\s/g, "")
		fIsValid = false;
	}
	
	return (fIsValid);
}

function ValidateDropDownList (strTextBoxID)
{
	var cDropDownList = document.getElementById(strTextBoxID);
	var fIsValid = true;
	
	if (cDropDownList.options[cDropDownList.selectedIndex].value.replace(/\s/g, "") == "")
	{
		cDropDownList.focus();
		fIsValid = false;
	}
	
	return (fIsValid);
}

function ValidatePhoneTextBox (strTextBoxID, fIsRequired)
{
	var cTextBox = document.getElementById(strTextBoxID);
	var cRegExp = /(^\([1-9]\d{2}\)\s?|^[1-9]\d{2}-)\d{3}\-\d{4}$/;
	var fIsValid = true;
	
	if ((fIsRequired) && (!ValidateTextBox(strTextBoxID)))
	{
		cTextBox.value = cTextBox.value.replace(/\s/g, "")
		cTextBox.focus();
		fIsValid = false;
	}
	else if ((cTextBox.value.replace(/\s/g, "") != "") && (!cRegExp.test(cTextBox.value)))
	{
		cTextBox.focus();
		fIsValid = false;
	}
	
	return (fIsValid);
}

function ValidateDateTextBox(strTextBoxID, fIsRequired)
{
	var cTextBox = document.getElementById(strTextBoxID);
	var cRegExp = /^(?:(?:(?:0?[13578]|1[02])(\/|-)31)|(?:(?:0?[1,3-9]|1[0-2])(\/|-)(?:29|30)))(\/|-)(?:[1-9]\d\d\d|\d[1-9]\d\d|\d\d[1-9]\d|\d\d\d[1-9])$|^(?:(?:0?[1-9]|1[0-2])(\/|-)(?:0?[1-9]|1\d|2[0-8]))(\/|-)(?:[1-9]\d\d\d|\d[1-9]\d\d|\d\d[1-9]\d|\d\d\d[1-9])$|^(0?2(\/|-)29)(\/|-)(?:(?:0[48]00|[13579][26]00|[2468][048]00)|(?:\d\d)?(?:0[48]|[2468][048]|[13579][26]))$/;
	var fIsValid = true;
	
	if ((fIsRequired) && (!ValidateTextBox(strTextBoxID)))
	{
		cTextBox.value = cTextBox.value.replace(/\s/g, "")
		cTextBox.focus();
		fIsValid = false;
	}
	
	else if ((cTextBox.value.replace(/\s/g, "") != "") && (!cRegExp.test(cTextBox.value)))
	{
		cTextBox.focus();
		fIsValid = false;
	}
	
	return (fIsValid);
}

function ValidateTimeTextBox(strTextBoxID, fIsRequired)
{
	var cTextBox = document.getElementById(strTextBoxID);
	var cRegExp = /^((([0]?[1-9])|([1]\d)):([0-5]\d)\s?(([ap])\.?m\.?)?)$|^((([01]{0,1}\d)|([2]{1}[0-3]{1})):([0-5]\d)\s?)$/i;
	var fIsValid = true;
	
	if ((fIsRequired) && (!ValidateTextBox(strTextBoxID)))
	{
		cTextBox.value = cTextBox.value.replace(/\s/g, "")
		cTextBox.focus();
		fIsValid = false;
	}
	
	else if ((cTextBox.value.replace(/\s/g, "") != "") && (!cRegExp.test(cTextBox.value)))
	{
		cTextBox.focus();
		fIsValid = false;
	}
	
	return (fIsValid);
}

/*
function TestTimeValidation()
{
	var cRegExp = /^((([0]?[1-9])|([1]\d)):([0-5]\d)\s?(([ap])\.?m\.?)?)$|^((([01]{0,1}\d)|([2]{1}[0-3]{1})):([0-5]\d)\s?)$/i;
	var astrTestsToPass = new Array('11:00', '11:00', '13:00', '15:45', '1:35 am', '5:45 p.M.', '12:59', '00:00', '05:15', '05:12 a.m.');
	var astrTestsToFail = new Array('', '25:00', '25', 'asdf', '25:23:54 a.m.', '-12:00', '12:00 jf', '#12:00', ':00', '12:60', '12:4', '24:00', '00:00 am');
	
	var astrPassedResults = new Array();
	var astrFailedResults = new Array();
	
	var strMessage = "";
	
	for (var i=0; i<astrTestsToPass.length; i++)
	{
		if (!cRegExp.test(astrTestsToPass[i]))
		{
			astrPassedResults.push(astrTestsToPass[i]);
		}
	}
	
	for (var i=0; i<astrTestsToFail.length; i++)
	{
		if (cRegExp.test(astrTestsToFail[i]))
		{
			astrFailedResults.push(astrTestsToFail[i]);
		}
	}
	
	if (astrPassedResults.length > 0)
	{
		strMessage += "\r\Failed: " + astrPassedResults.join(", ")
	}
	
	if (astrFailedResults.length > 0)
	{
		strMessage += "\r\nPassed: " + astrFailedResults.join(", ")
	}
	
	if (strMessage != "")
	{
		alert("Expression broken!" + strMessage);
	}
}

TestTimeValidation();
*/
