/****************************************************/
/******** ValidateCustomerServiceForm.js ************/
/****************************************************/
/* File contains functions used to validate forms   */
/****************************************************/
/* Created By: Justin R. Schwimmer                  */
/****************************************************/

//Validating ValidateCustomerServiceForm
function ValidateCustomerServiceForm() 
{
	var ErrMsg = "";
	var ErrCnt = 0;
	
	//First Name check: No blanks, or numbers
	if (IsEmpty(document.frmName.fname.value)) 
	{
		ErrMsg += "  => Your Name is a required field.\n";
		ErrCnt += 1;			
	} 
	else if (ContainsChars(document.frmName.fname.value)) 
	{
		ErrMsg += "  => Your Name can only contain letters.";
		ErrCnt += 1;
	}
	
	//Last Name check: No blanks, or numbers
	//if (IsEmpty(document.frmName.shopname.value)) 
	//{
		//ErrMsg += "  => Your Shop Name is a required field.\n";
		//ErrCnt += 1;	
	//} 
	//else if (ContainsChars(document.frmName.shopname.value)) 
	//{
		//ErrMsg += "  => Your Shop Name can only contain letters.\n";
		//ErrCnt += 1;	
	//}
	
	//Street Address check: letters, blanks, numbers, and hypens allowed
	if (IsStreetAddress(document.frmName.address.value)) 
	{
		ErrMsg += "  => Address field can only contain numbers, letters, and hypens.\n";
		ErrCnt += 1;		
	} 
	
	//City check: letters, blanks, and hypens allowed
	if (ContainsChars(document.frmName.city.value)) 
	{
		ErrMsg += "  => City field can only contain letters, blanks, and hypens.\n";
		ErrCnt += 1;			
	} 

	//State check: letters, blanks, and hypens allowed
	if (ContainsChars(document.frmName.state.value)) 
	{
		ErrMsg += "  => State field can only contain letters, blanks, and hypens.\n";
		ErrCnt += 1;			
	}
 	
 	//Zip check: numbers, and hypens allowed
 	if (IsStreetAddress(document.frmName.zip.value)) 
	{
		ErrMsg += "  => Zip code field can only contain numbers, and hypens.\n";
		ErrCnt += 1;		
	} 

	//Phone check: numbers, parenthesis, and hypens allowed
	if (IsPhone(document.frmName.phone.value)) 
	{
		ErrMsg += "  => Phone field can only contain numbers, parenthesis,and hypens.\n";
		ErrCnt += 1;		
	} 

	//Email check: letters, numbers, hypens, periods, "at" sign
	if (IsEmpty(document.frmName.email.value)) 
	{
		ErrMsg += "  => Email address is a required field.\n";
		ErrCnt += 1;			
	} 
	else if (IsEmail(document.frmName.email.value)) 
	{
		ErrMsg += "  => Email field not valid. (ex. name@domain.com).\n";
		ErrCnt += 1;			
	} 
	
	//Questions/Comments must not be blank
	if (IsEmpty(document.frmName.txtComments.value)) 
	{
		ErrMsg += "  => Questions/Comments is a required field.\n";
		ErrCnt += 1;			
	} 
	
	if (ErrCnt != 0)
	{
		ErrMsg = ErrCnt + ((ErrCnt == 1)? " Error has" : " Errors have") + " occurred, please see below for details. \n\n" + ErrMsg;
		alert(ErrMsg);
		return false;	
	}
}


