/*-----------------------------------------------------------------------
Created by: KD
Created date: 06-nov-2006
File description: Contactus Form
Special instructions-notes:Java script Validation
Tables used:None
Stored procedures:None
Triggers used:None
-----------------------------------------------------------------------*/

function Validate(theForm)
{
	var errMesg = "";
	var displayMesg = "";
	
	
 	var Q = ""; // this block determines lifespan of Q
	{
	
	if (theForm.department.value =='0')
		{
			Q += " Department\n";
		}
			
	if (isWhitespace(theForm.name.value))
		{
			Q += " Name\n";
		}
else if(!isCharsInBag(theForm.name.value, "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ' "))
		{
		errMesg += " Name contains Invalid Characters\n";
		}


/*
if (isWhitespace(theForm.company.value))
		{
			Q += " Company Name\n";
		}

*/


if (isWhitespace(theForm.phone.value))
		{
			Q += " Phone\n";
		}			
	else if(!isCharsInBag(theForm.phone.value, "0123456789- "))
		{
		errMesg += "Phone Number contains Invalid Characters\n";
		}
		
		


	if (isWhitespace(theForm.email.value))
		{
			Q += " Email Address\n";
		}	
		
		else if(echeck(theForm.email.value))
			{
			   errMesg += "Invalid Email Address\n";
			}	
		else if(!isCharsInBag( theForm.email.value, "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789@._-"))
			{
				errMesg += " Email Address contains Invalid Characters\n";
			}

		if(theForm.comment.value!="" && theForm.comment.value.length>500)
		{
			errMesg += "Comment should not be greater than 500 characters\n";
		}

  



	if ( Q.length > 0 )
		{
		displayMesg = "Please provide Valid values for\n" + Q ;
		}	
	} 
	
	if (errMesg == "" && displayMesg == "")
	{
		return true;
	}
	else
	{
		if(displayMesg!="")
			{
				alert(displayMesg);
				return false;			
			}
			else
			{
				alert(errMesg);
				return false;
			}	
	}
}

