
function validateForm ()
{
	for (var i=0; i< document.forms.frmComments.length; i++)
	{
		frmElement = document.forms.frmComments[i];
		frmElement.onchange = changeToBlack;  // register event handler
		
		if (frmElement.name == "Email")
		{
			if (frmElement.value == '') return// user did not fill in Email box
				
			var reg = /.+@.*\..+/;  //match emali address
			var formattedCorrectly = reg.test(frmElement.value);
			if (! formattedCorrectly)
			{
				answer = confirm('The email address is not correct.  Do you want to send your comments anyway?');
				if (answer)
				{
					// sending with bad email address, so change it to something that will work
					frmElement.value = 'Comments@mahindraUSA.com'
				}
				else
				{
					frmElement.focus();
					frmElement.select();
					frmElement.style.color = 'red';
					return false;
				}
			}
		}
	}
}

function changeToBlack()
{
	this.style.color = 'black';
}
