// JavaScript Document

function validate(form)
{
	var firstname=trim(form.firstname.value);
	var email=trim(form.email.value);
	var phone=form.phone.value
	var firstnameRegex = /^[a-zA-Z]+(([\'\,\.\- ][a-zA-Z ])?[a-zA-Z]*)*$/; 
	var lastnameRegex = /^[a-zA-Z]+(([\'\,\.\- ][a-zA-Z ])?[a-zA-Z]*)*$/;
	var companynameRegex = /^[a-zA-Z]+(([\'\,\.\- ][a-zA-Z ])?[a-zA-Z]*)*$/;
	var phoneRegex = /^\D?(\d{3})\D?\D?(\d{3})\D?(\d{4})$/;
	var emailRegex = /^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/;
	var zipRegx= /^\d{5}([\-]\d{4})?$/;

	
	
	if(firstname == "") 
	{
		inlineMsg('firstname','Please Enter  Name.',3);
		return false;
	}
	
	if(firstname.length < 2 )
	{
		inlineMsg('firstname','Name Should be 2-50 characters Only.',3);
		document.quotefrm.firstname.focus();
		return false;
	}
   
	if(firstname.length >50)
	{
		inlineMsg('firstname','Name Should be 2-50 characters Only.',3);
		document.quotefrm.firstname.focus();
		return false;
	}
  
	if(!firstname.match(firstnameRegex)) 
	{
		inlineMsg('firstname','Please Enter Alphabets Only.',3);
		document.quotefrm.firstname.focus();
		return false;
	} 
	if(email == "") 
	{
		inlineMsg('email','Please Enter Email.',3);
		document.quotefrm.email.focus();
		return false;
	}
	
	if(!email.match(emailRegex)) 
	{
		inlineMsg('email','Please Enter valid Email. ',3);
		document.quotefrm.email.focus();
		return false;
	} 
		
	if((phone == "") || (phone == "___-___-____"))
	{
		inlineMsg('phone','Please Enter Phone No.',3);
		document.quotefrm.phone.focus();
		return false;
	}
	
	if(phone.indexOf('___')!=-1){
		inlineMsg('phone','Please Enter Valid Phone No.',3);
		document.quotefrm.phone.focus();
		return false;
	}
	
	if(!phone.match(phoneRegex)){
		inlineMsg('phone','Please Enter Valid Phone No.',3);
		document.quotefrm.phone.focus();
		return false;
	}
	
	//	if(conditions == "") 
//	{
//		inlineMsg('conditions','Please Enter Special Conditions.',3);
//		return false;
//	}
	
	return true;	
}

