/*-----------------------------------------------------------------------
Created by: Kd
Created date: 26-Sep-06
File description: Member Form
Special instructions-notes:Java script Validation
Tables used:None
Stored procedures:None
Triggers used:None
-----------------------------------------------------------------------*/

function Validate(theForm)
{
	var errMesg = "";
	var displayMesg = "";
	
	

	//Validate the login name
	
	//Check for password
/*	if ( theForm.password.value.length < 6 || theForm.password.value.length > 12)
		{
		errMesg += "Password must be 6-12 characters.\n";
		}	
		*/
/*
if (theForm.confirmpwd)
	{	
	if ( theForm.password.value != theForm.confirmpwd.value )
		{
		errMesg += "Your Password do not match. Please retype and try again.\n" ;
		}
}
	*/
	
	
 	var Q = ""; // this block determines lifespan of Q
	{
	
	/* 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 (isWhitespace(theForm.password.value))
		{
			Q += "  Password\n";
		}	
	
	if (theForm.confirmpwd)
	{	
	if (isWhitespace(theForm.confirmpwd.value))
		{
			Q += "  Confirm Password\n";
		}	
	
}
*/
			
	if (isWhitespace(theForm.first_name.value))
		{
			Q += "  First Name\n";
		}
else if(!isCharsInBag(theForm.first_name.value, "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ' "))
		{
		errMesg += "First Name contains Invalid Characters\n";
		}
	if (isWhitespace(theForm.last_name.value))
		{
			Q += "  Last Name\n";
		}
else if(!isCharsInBag(theForm.last_name.value, "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ' "))
		{
		errMesg += "Last Name contains Invalid Characters\n";
		}

	

if (isWhitespace(theForm.phone.value))
		{
			Q += "  Phone\n";
		}			
	else if(!isCharsInBag(theForm.phone.value, "0123456789- "))
		{
		errMesg += "Phone Number contains Invalid Characters\n";
		}

	if(theForm.fax.value!="" && !isCharsInBag(theForm.fax.value, "0123456789- "))
		{
		errMesg += "Fax contains Invalid Characters\n";
		}	


	
		

	if (isWhitespace(theForm.address.value))
		{
			Q += "  Address\n";
		}		
		
	if(theForm.address.value!="" && theForm.address.value.length>500)
		{
			errMesg += "Address should not be greater than 500 characters\n";
		}

	if (isWhitespace(theForm.city.value))
		{
			Q += "  City\n";
		}			
	if (theForm.state.value=="0")
		{
			Q += "  State\n";
		}

	if (isWhitespace(theForm.zip_code.value))
		{
			Q += "  Zip Code\n";
		}	

	if (theForm.country.value=="" || theForm.country.value==0)
		{
			Q += "  Country\n";
		}	
		
		
		

if (theForm.chkterm)
{		
	if (theForm.chkterm.checked==false)	
		{
			Q += "  Terms and Conditions\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;
			}	
	}
}

