// JavaScript Document
function validate()
{
	var strFieldname=document.form1.txtFirstName.value;
	var strTemp;
	var iFlag=true;
	strTemp = trimAll(strFieldname);
	
	if(strTemp.length <= 0)
	{
		alert('Enter your first name');
		iFlag= false;	
		document.form1.txtFirstName.focus();
		return false;
	}
	strFieldname=''
	
	strFieldname=document.form1.txtLastName.value;
	strTemp = trimAll(strFieldname);
	if(strTemp.length <= 0)
	{
		alert('Enter your last name');
		iFlag= false;	
		document.form1.txtLastName.focus();
		return false;
	}
	strFieldname=''
	iFlag=true;
	
	/*strFieldname=document.form1.txtPhoneNo.value;
	strTemp = trimAll(strFieldname);
	if(strTemp.length <= 0)
	{
		alert('Enter your phone number');
		document.form1.txtPhoneNo.focus();
		iFlag= false;	
		return false;
	}
	else
	{
		iFlag=validateUSPhone(strTemp);
		if (iFlag==false)
		{
			alert('Invalid Phone number');
			document.form1.txtPhoneNo.focus();
			return false;
		}
		
	}*/
	
	strFieldname=''
	strFieldname=document.form1.txtEmailAddress.value;
	strTemp = trimAll(strFieldname);
	if(strTemp.length <= 0)
	{
		alert('Pleae fill email id for future correspondence');
		iFlag= false;	
				document.form1.txtEmailAddress.focus();
		return false;
	}
	else
	{
		iFlag=validateEmail(strTemp);
		if (iFlag==false)
		 {
			 alert('Invalid email id');
			document.form1.txtEmailAddress.focus();
			return false;
		 }
		 
	}
	strFieldname=''	
	iFlag=true;
	
	//chkBradFord chkErinnBatcha chkFrankBatcha

	//txtToEmail
	var checkFlag = false;
	var tomail="";
	if(document.form1.chkBradFord.checked==true)
	{
		checkFlag = true;
		tomail = "brad@batchalaw.com"
	}
	if(document.form1.chkErinnBatcha.checked==true)
	{
		checkFlag = true;
		if(tomail!='')
			tomail = tomail + ",erinn@batchalaw.com"
		else
			tomail = "erinn@batchalaw.com"
	}
	if(document.form1.chkFrankBatcha.checked==true)
	{
		checkFlag = true;
		if(tomail!='')
			tomail = tomail + ",frank@batchalaw.com"
		else
			tomail = "frank@batchalaw.com"
	}
	if(checkFlag == false)
	{		
//		alert("Select to whom you want to send mail.")
		//return false;
		checkFlag = true;
		tomail = "brad@batchalaw.com"

	}
	//tomail=tomail + ',Jeff@newviewpointdesign.com,test@newviewpoint.com';
	document.form1.txtToEmail.value = tomail; 
	
	//alert(document.form1.txtToEmail.value)
	
	strFieldname=''
	
	strFieldname=document.form1.txtSubject.value;
	strTemp = trimAll(strFieldname);
	if(strTemp.length <= 0)
	{
		alert('Enter email subject');
		iFlag= false;	
		document.form1.txtSubject.focus();
		return false;
	}
	
	strFieldname=''
	
	strFieldname=document.form1.txtMsg.value;
	strTemp = trimAll(strFieldname);
	if(strTemp.length <= 0)
	{
		alert('Enter your message.');
		iFlag= false;	
		document.form1.txtMsg.focus();
		return false;
	}
	
	//return false;
	
}
function trimAll( strValue ) 
{
	var objRegExp = /^(\s*)$/;
	if(objRegExp.test(strValue)) 
	{
		strValue = strValue.replace(objRegExp, '');
		if( strValue.length == 0)
			return strValue;
	}
   objRegExp = /^(\s*)([\W\w]*)(\b\s*$)/;
   if(objRegExp.test(strValue)) 
   {
		strValue = strValue.replace(objRegExp, '$2');
	}
	return strValue;
}
function validateUSPhone( strValue ) 
{
	  var objRegExp  = /^\([1-9]\d{2}\)\s?\d{3}\-\d{4}$/;  
	  return objRegExp.test(strValue);
}
function validateEmail( strValue) {

	var objRegExp  = /^[\w\.-]+@[\w-]+\.[\w\.-]+$/;
	  return objRegExp.test(strValue);
}
