
// Begin form validation
function validateForm(form)	
{
	if ((document.getElementById) || (document.all)) 
	{
		if (bgColorArray.length > 0) 
		{
			for (var loop=0; loop < bgColorArray.length; loop++) 
			{
				var path = eval("document.frmContact." + bgColorArray[loop] + ".style");
				path.backgroundColor = '#FFFFFF';					
			}
			for (var loop=0; loop < bgColorArray.length; loop++)
			{
				bgColorArray[loop] = "";
			}
		}
	}					
	
	form.firstname.value = Trim(form.firstname.value);	
	form.email.value = Trim(form.email.value);

	var output = "";

	    
													
	if (!validateAlpha(form.firstname.value,1,50)) 
	{
		output += "Name\n";
		setFocus(form.firstname);
		if ((document.getElementById) || (document.all)) 
		{
			bgColorArray[arrayCounter] = "firstname";
			arrayCounter += 1;
		}
	}
							
	
	if (!valEmail(form.email.value)) 
	{
		output += "Email Address\n";
		setFocus(form.email);
		if ((document.getElementById) || (document.all)) 
		{
			bgColorArray[arrayCounter] = "email";
			arrayCounter += 1;
		}
	}		
	

	if (!isUSZip(form.zip.value)) 
	{
		output += "Zip Code\n";
		setFocus(form.zip);
		if ((document.getElementById) || (document.all)) 
		{
			bgColorArray[arrayCounter] = "zip";
			arrayCounter += 1;
		}
	}
	
	if (form.topic.value == 'Compliments or concerns about recent visit') 
	{
		output += "Date of Visit\n";
		setFocus(form.dateofVisit);
		if ((document.getElementById) || (document.all)) 
		{
			bgColorArray[arrayCounter] = "dateofVisit";
			arrayCounter += 1;
		}
	}
	
	/*if (!isValidDate(form.dateofVisit.value))
	{
		output += "Date of Visit\n";
		setFocus(form.dateofVisit);
		if ((document.getElementById) || (document.all)) 
		{
			bgColorArray[arrayCounter] = "dateofVisit";
			arrayCounter += 1;
		}
	}*/

	
	if (output != "")
	{
		alert("The following information was missing or incorrect:\n\n"+output);
		focusItem.focus();
		focusItem = "";
		if ((document.getElementById) || (document.all)) 
		{
			bgColorArray.length = arrayCounter;
			arrayCounter = 0;
			
			//loop through to change background color of incorrect items
			for (var loop=0; loop < bgColorArray.length; loop++) 
			{
				var path = eval("document.frmContact." + bgColorArray[loop] + ".style");
				path.backgroundColor = '#9A0000';					
			}
		}
		return false;
	} 
	else 
	{
		return true;
	}
}	
//  End form validation
