/*-----------------------------------------------------------------------
Created by: CS
Created date: 19 Jan 2007
File description: Contact Us
Special instructions-notes:Java script Validation
Tables used:None
Stored procedures:None
Triggers used:None
-----------------------------------------------------------------------*/

function Validate(theForm)
{
	var errMesg = "";
	var displayMesg = "";
	
 	var Q = ""; 
	{
		if ((isWhitespace(theForm.businessname.value)) || (theForm.businessname.value == 'Please enter your Name'))
		{
			Q += " Name\n";
		}
		
		if ((isWhitespace(theForm.add01.value)) || (theForm.add01.value == 'Address line 1'))
		{
			Q += " Address\n";
		}
		if(theForm.add01.value!="" && theForm.add01.value.length>500)
		{
			errMesg += "Please limit your address to less than 500 alpha-numeric characters\n";
		}
		
		if ((isWhitespace(theForm.phone.value)) || (theForm.phone.value == 'Please enter your Phone Number'))
		{
			Q += " Phone\n";
		}else if(!isCharsInBag(theForm.phone.value, "0123456789- "))
		{
			errMesg += "The phone # you entered is invalid. Please re-enter.\n";
		}		

		if ((isWhitespace(theForm.email.value)) || (theForm.email.value == 'Please enter your E-mail address'))
		{
			Q += " Email Address\n";
		}else if(echeck(theForm.email.value))
		{
		   errMesg += "Please check and re-enter the email address information as the data provided has been determined to be invalid.\n";
		}else if(!isCharsInBag( theForm.email.value, "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789@._-"))
		{
			errMesg += "Please check and re-enter the email address information as the data provided has been determined to be invalid.\n";
		}

		if (theForm.suggestion.selectedIndex == 0)
		{
			Q += " Nature of Comment/Suggestion\n";
		}
		
		if ((isWhitespace(theForm.comment.value)) || (theForm.comment.value == 'Please enter your Comment'))
		{
			Q += " Comment\n";
		}
		if(theForm.comment.value!="" && theForm.comment.value.length>500)
		{
			errMesg += "Please limit your comments to less than 500 alpha-numeric characters\n";
		}			

		if ( Q.length > 0 )
		{
			displayMesg = "You have not provided the required information that will help us respond to your concern(s). Please pay close attention to mandatory information indicated by the asterisk (*).";
		}
		if ( errMesg.length > 0 )
		{
			displayMesg = "You have not provided the required information that will help us respond to your concern(s). Please pay close attention to mandatory information indicated by the asterisk (*).";
		}
	} 
	
	if (errMesg == "" && displayMesg == "")
	{
		return true;
	}
	else
	{
		if(displayMesg!="")
		{
			alert(displayMesg);
			return false;			
		}else
		{
			alert(displayMesg);
			return false;
		}	
	}
}
