// ================For Member Signup=======================

function validate_signup(theForm)
{
		
       if (theForm.fname.value == "")
				{
					theForm.fname.style.background = '#FFFFB3'; 
					alert ("Please enter your first name");
					theForm.fname.focus();
					return false;
				}			
		if (!/^[a-z\s]+$/i.test(theForm.fname.value)) 
				{
					 theForm.fname.style.background = '#FFFFB3'; 
					 alert('Please do not enter any numbers in this field.');
					 theForm.fname.focus();
					 return false;
				}		
		
   if (theForm.lname.value == "")
				{
					theForm.lname.style.background = '#FFFFB3'; 
					alert ("Please enter your last name");
					theForm.lname.focus();
					return false;
				}
	
	if (!/^[a-z\s]+$/i.test(theForm.lname.value)) 
				{
					 theForm.lname.style.background = '#FFFFB3'; 
					 alert('Please do not enter any numbers in this field.');
					 theForm.lname.focus();
					 return false;
				}
				
	 if (theForm.address.value == "")
				{
					theForm.address.style.background = '#FFFFB3'; 
					alert ("Please enter your street address");
					theForm.address.focus();
					return false;
				}
		
//------------------
	if(theForm.city.value=='' && theForm.state.value=='' && theForm.zipcode.value=='')
	{
		theForm.city.style.background = '#FFFFB3'; 
		alert ("Please enter your city name");
		theForm.city.focus();
		return false;
	}
	if(theForm.city.value=='' && theForm.state.value !='' && theForm.zipcode.value !='')
	{
		theForm.city.style.background = '#FFFFB3'; 
		alert ("Please enter your city name");
		theForm.city.focus();
		return false;
	}
	if(theForm.city.value=='' && theForm.state.value !='' && theForm.zipcode.value =='')
	{
		theForm.city.style.background = '#FFFFB3'; 
		alert ("Please enter your city name");
		theForm.city.focus();
		return false;
	}
	if(theForm.city.value !='' && theForm.state.value=='' && theForm.zipcode.value=='')
	{
		theForm.state.style.background = '#FFFFB3'; 
		alert ("Please select your state");
		theForm.state.focus();
		return false;
	}
//------------

	if (theForm.chkziperr.value !='1')
				{
					theForm.zipcode.style.background = '#FFFFB3'; 
					alert ("Your zip code and town/State do not match, please try again.");
					theForm.zipcode.focus();
					return false;
				}
				
	if (theForm.phone1.value == "" || theForm.phone1.value.length < 3 )
				{
					theForm.phone1.style.background = '#FFFFB3'; 
					alert ("Please enter correct phone number");
					theForm.phone1.focus();
					return false;
				}
	
		if (isNaN(theForm.phone1.value)) {
			theForm.phone1.style.background = '#FFFFB3'; 
			alert("Phone number must be 10 digits");
			theForm.phone1.focus();
			return false;
		}
	
	
	if (theForm.phone2.value == "" || theForm.phone2.value.length < 3)
				{
					theForm.phone2.style.background = '#FFFFB3'; 
					alert ("Please enter correct phone number");
					theForm.phone2.focus();
					return false;
				}
	if (isNaN(theForm.phone2.value)) {
			theForm.phone2.style.background = '#FFFFB3'; 
			alert("Phone number must be 10 digits");
			theForm.phone2.focus();
			return false;
		}				
				
	if (theForm.phone3.value == "" || theForm.phone3.value.length < 4)
				{
					theForm.phone3.style.background = '#FFFFB3'; 
					alert ("Please enter correct phone number");
					theForm.phone3.focus();
					return false;
				}	
	
	if (isNaN(theForm.phone3.value)) {
			theForm.phone3.style.background = '#FFFFB3'; 
			alert("Phone number must be 10 digits");
			theForm.phone1.focus();
			return false;
		}
								
	
	var emailRegEx = /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i;
	if (theForm.email.value == "")
				{
					theForm.email.style.background = '#FFFFB3'; 
					alert ("Please enter your email address");
					theForm.email.focus();
					return false;
				}
				
	else if(theForm.email.value.search(emailRegEx) == -1)
		{
					theForm.email.style.background = '#FFFFB3';  
					alert ("Please enter a valid email address");
					theForm.email.focus();
					return false;
		}

	else if (theForm.chkerr.value == "<font color='red'>&nbsp;Email Address has already been used. Please select another</font>")
				{
					theForm.email.style.background = '#FFFFB3'; 
					alert ("Email Address has already been used. Please select another");
					theForm.email.focus();
					return false;
				}
				
 theForm.submit();	
}

//=========================Signup2==============================
function validate_singup2(theForm)
{
		if (theForm.experience.checked == false)
				{
					theForm.experience.style.background = '#FFFFB3'; 
					alert ("Please select your experience range");
					theForm.experience.focus();
					return false;
				}
		
       if (theForm.uname.value == "")
				{
					theForm.uname.style.background = '#FFFFB3'; 
					alert ("Please enter username");
					theForm.uname.focus();
					return false;
				}
		
		if (theForm.email.value != theForm.uname.value)
				{
					theForm.uname.style.background = '#FFFFB3'; 
					alert ("Ops!!! Email Address already exists");
					theForm.uname.value = theForm.email.value;
					theForm.uname.focus();
					return false;
				}
				
	
   if (theForm.pass.value == "")
				{
					theForm.pass.style.background = '#FFFFB3'; 
					alert ("Please enter password");
					theForm.pass.focus();
					return false;
				}
	if (theForm.pass.value.length < 6)
				{
					theForm.pass.style.background = '#FFFFB3'; 
					alert ("Password must be six characters long");
					theForm.pass.focus();
					return false;
				}
				
				
	if (theForm.pass2.value == "")
				{
					theForm.pass2.style.background = '#FFFFB3'; 
					alert ("Please enter confirm password");
					theForm.pass2.focus();
					return false;
				}
				
	if (theForm.pass.value != theForm.pass2.value)
				{
					theForm.pass.style.background = '#FFFFB3'; 
					alert ("Both passwords do not matach");
					theForm.pass2.value='';
					theForm.pass2.focus();
					return false;
				}
				
		if(theForm.spam.value=="")		
		{
					theForm.spam.style.background = '#FFFFB3'; 
					alert ("Please enter security code");
					theForm.spam.focus();
					return false;
		}
	    if(isNotValidCharacters(theForm.spam, 'Entered Text is not Valid'))
		{return false;}
	
theForm.submit();
}

//==========================Law Firm Member signup======================================
function validatelfignup(theForm)
{
		
       if (theForm.lawfirmname.value == "")
				{
					theForm.lawfirmname.style.background = '#FFFFB3'; 
					alert ("Please enter law firm name");
					theForm.lawfirmname.focus();
					return false;
				}			
			
	if (theForm.phone1.value == "" || theForm.phone1.value.length < 3 )
				{
					theForm.phone1.style.background = '#FFFFB3'; 
					alert ("Please enter correct phone number");
					theForm.phone1.focus();
					return false;
				}
	
		if (isNaN(theForm.phone1.value)) {
			theForm.phone1.style.background = '#FFFFB3'; 
			alert("Phone number must be 10 digits");
			theForm.phone1.focus();
			return false;
		}
	
	
	if (theForm.phone2.value == "" || theForm.phone2.value.length < 3)
				{
					theForm.phone2.style.background = '#FFFFB3'; 
					alert ("Please enter correct phone number");
					theForm.phone2.focus();
					return false;
				}
	if (isNaN(theForm.phone2.value)) {
			theForm.phone2.style.background = '#FFFFB3'; 
			alert("Phone number must be 10 digits");
			theForm.phone2.focus();
			return false;
		}				
				
	if (theForm.phone3.value == "" || theForm.phone3.value.length < 4)
				{
					theForm.phone3.style.background = '#FFFFB3'; 
					alert ("Please enter correct phone number");
					theForm.phone3.focus();
					return false;
				}	
	
	if (isNaN(theForm.phone3.value)) {
			theForm.phone3.style.background = '#FFFFB3'; 
			alert("Phone number must be 10 digits");
			theForm.phone1.focus();
			return false;
		}
	
	var emailRegEx = /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i;
	if (theForm.email.value == "")
				{
					theForm.email.style.background = '#FFFFB3'; 
					alert ("Please enter your email address");
					theForm.email.focus();
					return false;
				}
				
	else if(theForm.email.value.search(emailRegEx) == -1)
		{
					theForm.email.style.background = '#FFFFB3';  
					alert ("Please enter a valid email address");
					theForm.email.focus();
					return false;
		}
		
	else if (theForm.chkerr.value == "<font color='red'>&nbsp;Email Address has already been used. Please select another</font>")
				{
					theForm.email.style.background = '#FFFFB3'; 
					alert ("Email Address has already been used. Please select another");
					theForm.email.focus();
					return false;
				}
				
	//------------------
	if(theForm.city.value=='' && theForm.state.value=='' && theForm.zipcode.value=='')
	{
		theForm.city.style.background = '#FFFFB3'; 
		alert ("Please enter your city name");
		theForm.city.focus();
		return false;
	}
	if(theForm.city.value=='' && theForm.state.value !='' && theForm.zipcode.value !='')
	{
		theForm.city.style.background = '#FFFFB3'; 
		alert ("Please enter your city name");
		theForm.city.focus();
		return false;
	}
	if(theForm.city.value=='' && theForm.state.value !='' && theForm.zipcode.value =='')
	{
		theForm.city.style.background = '#FFFFB3'; 
		alert ("Please enter your city name");
		theForm.city.focus();
		return false;
	}
	if(theForm.city.value !='' && theForm.state.value=='' && theForm.zipcode.value=='')
	{
		theForm.state.style.background = '#FFFFB3'; 
		alert ("Please select your state");
		theForm.state.focus();
		return false;
	}
//------------
 theForm.submit();		
}

//===============Lawfirm signup2 =========================
function validate_lawfirmsignup2(theForm)
{
 	
	 if (theForm.uname.value == "")
				{
					theForm.uname.style.background = '#FFFFB3'; 
					alert ("Please enter username");
					theForm.uname.focus();
					return false;
				}
		
	if (theForm.email.value != theForm.uname.value)
				{
					theForm.uname.style.background = '#FFFFB3'; 
					alert ("Ops!!! Email Address already exists");
					theForm.uname.value = theForm.email.value;
					theForm.uname.focus();
					return false;
				}
				
 	if (theForm.pass.value == "")
				{
					theForm.pass.style.background = '#FFFFB3'; 
					alert ("Please enter password");
					theForm.pass.focus();
					return false;
				}
	if (theForm.pass.value.length < 6)
				{
					theForm.pass.style.background = '#FFFFB3'; 
					alert ("Password must be six characters long");
					theForm.pass.focus();
					return false;
				}
				
				
	if (theForm.pass2.value == "")
				{
					theForm.pass2.style.background = '#FFFFB3'; 
					alert ("Please enter confirm password");
					theForm.pass2.focus();
					return false;
				}
				
	if (theForm.pass.value != theForm.pass2.value)
				{
					theForm.pass.style.background = '#FFFFB3'; 
					alert ("Both passwords do not matach");
					theForm.pass2.value='';
					theForm.pass2.focus();
					return false;
				}
				
		if(theForm.spam.value=="")		
		{
					theForm.spam.style.background = '#FFFFB3'; 
					alert ("Please enter security code");
					theForm.spam.focus();
					return false;
		}
	    if(isNotValidCharacters(theForm.spam, 'Entered Text is not Valid'))
		{return false;}
	
theForm.submit();
}


//=========================Admin SignIn==============================
function validate_admin(theForm)
{
		
       if (theForm.username.value == "")
				{
					theForm.username.style.background = '#FFFFB3'; 
					alert ("Please enter username");
					theForm.username.focus();
					return false;
				}			
			
   if (theForm.pass.value == "")
				{
					theForm.pass.style.background = '#FFFFB3'; 
					alert ("Please enter password");
					theForm.pass.focus();
					return false;
				}
				
}

// ================For Changing Admin Password=======================

function validate_changepass(theForm)
{
		
       if (theForm.oldpass.value == "")
				{
					theForm.oldpass.style.background = '#FFFFB3'; 
					alert ("Please Provide Old Password");
					theForm.oldpass.focus();
					return false;
				}			
		

if (theForm.newpass.value == "")
				{
					theForm.newpass.style.background = '#FFFFB3'; 
					alert ("Please Provide New Password");
					theForm.newpass.focus();
					return false;
				}	
				
	
	if (theForm.retyppass.value == "")
				{
					theForm.retyppass.style.background = '#FFFFB3'; 
					alert ("Please Retype New Password");
					theForm.retyppass.focus();
					return false;
				}
				
		
	if (theForm.retyppass.value != theForm.newpass.value)
				{
					theForm.retyppass.style.background = '#FFFFB3'; 
					alert ("Your Passwords Do Not Match");
					theForm.retyppass.value="";
					theForm.retyppass.focus();
					return false;
				}
 
 return true;		
}

//==========================Search Box======================================
function validate_search(theForm)
{
		
       if (theForm.typo.value == "" || theForm.typo.value == "Enter a search term, city, state, or zip code")
				{
					alert ("Please provide search parameters");
					theForm.typo.focus();
					return false;
				}		
return true;
}


function validate_loginform(theForm)
{
		
       if (theForm.uname.value == "")
				{
					theForm.uname.style.background = '#FFFFB3'; 
					alert ("Please enter username");
					theForm.uname.focus();
					return false;
				}	
				
		 if (theForm.pwd.value == "")
				{
					theForm.pwd.style.background = '#FFFFB3'; 
					alert ("Please enter username");
					theForm.pwd.focus();
					return false;
				}	
				
return true;
}



function validate_membersupport(theForm)
{
		
       if (theForm.fullname.value == "")
				{
					theForm.fullname.style.background = '#FFFFB3'; 
					alert ("Please enter your full name");
					theForm.fullname.focus();
					return false;
				}
				
		if (!/^[a-z\s]+$/i.test(theForm.fullname.value)) 
				{
					 theForm.fullname.style.background = '#FFFFB3';
					 alert('Please do not enter any numbers in this field.');
					 theForm.fullname.focus();
					 return false;
				}		
				
		/* if (theForm.interest.value == "")
				{
					theForm.interest.style.background = '#FFFFB3'; 
					alert ("Please select your interest");
					theForm.interest.focus();
					return false;
				}	*/
		if (theForm.phone1.value == "" || theForm.phone1.value.length < 3 )
				{
					theForm.phone1.style.background = '#FFFFB3'; 
					alert ("Please enter correct phone number");
					theForm.phone1.focus();
					return false;
				}
	
		if (isNaN(theForm.phone1.value)) {
			theForm.phone1.style.background = '#FFFFB3'; 
			alert("Phone number must be 10 digits");
			theForm.phone1.focus();
			return false;
		}
	
	
	if (theForm.phone2.value == "" || theForm.phone2.value.length < 3)
				{
					theForm.phone2.style.background = '#FFFFB3'; 
					alert ("Please enter correct phone number");
					theForm.phone2.focus();
					return false;
				}
	if (isNaN(theForm.phone2.value)) {
			theForm.phone2.style.background = '#FFFFB3'; 
			alert("Phone number must be 10 digits");
			theForm.phone2.focus();
			return false;
		}				
				
	if (theForm.phone3.value == "" || theForm.phone3.value.length < 4)
				{
					theForm.phone3.style.background = '#FFFFB3'; 
					alert ("Please enter correct phone number");
					theForm.phone3.focus();
					return false;
				}	
	
	if (isNaN(theForm.phone3.value)) {
			theForm.phone3.style.background = '#FFFFB3'; 
			alert("Phone number must be 10 digits");
			theForm.phone1.focus();
			return false;
		}				
	
	var emailRegEx = /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i;
	if (theForm.email.value == "")
				{
					theForm.email.style.background = '#FFFFB3'; 
					alert ("Please enter your email address");
					theForm.email.focus();
					return false;
				}
				
	else if(theForm.email.value.search(emailRegEx) == -1)
		{
					theForm.email.style.background = '#FFFFB3';  
					alert ("Please enter a valid email address");
					theForm.email.focus();
					return false;
		}
		
	if (theForm.comments.value == "")
				{
					theForm.comments.style.background = '#FFFFB3'; 
					alert ("Please enter your comments");
					theForm.comments.focus();
					return false;
				}	
	
	 if(isNotValidCharacters(theForm.spam, 'Entered Text is not Valid'))
		{return false;}
		
		
return true;
}


function validate_connect(theForm)
{
		
       if (theForm.fname.value == "")
				{
					theForm.fname.style.background = '#FFFFB3'; 
					alert ("Please enter your first name");
					theForm.fname.focus();
					return false;
				}	
		if (!/^[a-z\s]+$/i.test(theForm.fname.value)) 
				{
					 theForm.fname.style.background = '#FFFFB3';
					 alert('Please do not enter any numbers in this field.');
					 theForm.fname.focus();
					 return false;
				}	
			
		 if (theForm.lname.value == "")
				{
					theForm.lname.style.background = '#FFFFB3'; 
					alert ("Please enter your last name");
					theForm.lname.focus();
					return false;
				}	
		
		if (!/^[a-z\s]+$/i.test(theForm.lname.value)) 
				{
					 alert('Please do not enter any numbers in this field.');
					 theForm.lname.focus();
					 return false;
				}
					
		if (theForm.zip.value == "")
				{
					
					theForm.zip.style.background = '#FFFFB3'; 
					alert ("Please enter zip code");
					theForm.zip.focus();
					return false;
				}
				
		if (isNaN(theForm.zip.value)) {
			theForm.zip.style.background = '#FFFFB3'; 
			alert("Zipcode must be 5 digits");
			theForm.zip.focus();
			return false;
		}				
		
	
	if (theForm.zip.value.length !=5)
				{
					theForm.zip.style.background = '#FFFFB3'; 
					alert ("Zipcode must be 5 digits");
					theForm.zip.focus();
					return false;
				}				
				
		if (theForm.phone1.value == "" || theForm.phone1.value.length < 3 )
				{
					theForm.phone1.style.background = '#FFFFB3'; 
					alert ("Please enter correct phone number");
					theForm.phone1.focus();
					return false;
				}
	
		if (isNaN(theForm.phone1.value)) {
			theForm.phone1.style.background = '#FFFFB3'; 
			alert("Phone number must be 10 digits");
			theForm.phone1.focus();
			return false;
		}
	
	
	if (theForm.phone2.value == "" || theForm.phone2.value.length < 3)
				{
					theForm.phone2.style.background = '#FFFFB3'; 
					alert ("Please enter correct phone number");
					theForm.phone2.focus();
					return false;
				}
	if (isNaN(theForm.phone2.value)) {
			theForm.phone2.style.background = '#FFFFB3'; 
			alert("Phone number must be 10 digits");
			theForm.phone2.focus();
			return false;
		}				
				
	if (theForm.phone3.value == "" || theForm.phone3.value.length < 4)
				{
					theForm.phone3.style.background = '#FFFFB3'; 
					alert ("Please enter correct phone number");
					theForm.phone3.focus();
					return false;
				}	
	
	if (isNaN(theForm.phone3.value)) {
			theForm.phone3.style.background = '#FFFFB3'; 
			alert("Phone number must be 10 digits");
			theForm.phone1.focus();
			return false;
		}				
	
	var emailRegEx = /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i;
	if (theForm.email.value == "")
				{
					theForm.email.style.background = '#FFFFB3'; 
					alert ("Please enter your email address");
					theForm.email.focus();
					return false;
				}
				
	else if(theForm.email.value.search(emailRegEx) == -1)
		{
					theForm.email.style.background = '#FFFFB3';  
					alert ("Please enter a valid email address");
					theForm.email.focus();
					return false;
		}
		
	if (theForm.parea.value == "")
				{
					theForm.parea.style.background = '#FFFFB3'; 
					alert ("Please select lawyer type");
					theForm.parea.focus();
					return false;
				}	
	
	/* if(isNotValidCharacters(theForm.spam, 'Entered Text is not Valid'))
		{return false;}*/
		
	theForm.submit();	
return true;
}
//=============================================================================================



//###################################################################################################################################################
//#################################################################### SPAM #########################################################################
//###################################################################################################################################################
//=========================SPAM======================================================================================================================
function isNotValidCharacters(Sec,MSG)
{
	
	var Spn = document.getElementById('spn').value;
	
	if(Spn=='1')
	{
		if(! ( Sec.value == "JK904" || Sec.value == "jk904" || Sec.value == "Jk904" || Sec.value == "jK904") ) 
		{
			alert(MSG)
			Sec.value=''
			Sec.focus()
			insertSpam()
			return true 
		}
		else
		{
			return false;
		}
	}
	if(Spn=='2')
	{
		if(! ( Sec.value == "WS506" || Sec.value == "Ws506" || Sec.value == "wS506" || Sec.value == "ws506") ) 
		{
			alert(MSG)
			Sec.value=''
			Sec.focus()
			insertSpam()
			return true 
		}
		else
		{
			return false;
		}
	}
	if(Spn=='3')
	{
		if(! ( Sec.value == "JE496" || Sec.value == "Je496" || Sec.value == "jE496" || Sec.value == "je496") ) 
		{
			alert(MSG)
			Sec.value=''
			Sec.focus()
			insertSpam()
			return true 
		}
		else
		{
			return false;
		}
	}
	if(Spn=='4')
	{
		if(! ( Sec.value == "ER453" || Sec.value == "Er453" || Sec.value == "eR453" || Sec.value == "er453") ) 
		{
			alert(MSG)
			Sec.value=''
			Sec.focus()
			insertSpam()
			return true 
		}
		else
		{
			return false;
		}
	}
	if(Spn=='5')
	{
		if(! ( Sec.value == "CY561" || Sec.value == "Cy561" || Sec.value == "cY561" || Sec.value == "cy561") ) 
		{
			alert(MSG)
			Sec.value=''
			Sec.focus()
			insertSpam()
			return true 
			
		}
		else
		{
			return false;
		}
	}
	if(Spn=='6')
	{
		if(! ( Sec.value == "hi421" || Sec.value == "Hi421" || Sec.value == "hI421" || Sec.value == "HI421") ) 
		{
			alert(MSG)
			Sec.value=''
			Sec.focus()
			insertSpam()
			return true 
		}
		else
		{
			return false;
		}
	}
	if(Spn=='7')
	{
		if(! ( Sec.value == "LP590" || Sec.value == "Lp590" || Sec.value == "lP590" || Sec.value == "lp590") ) 
		{
			alert(MSG)
			Sec.value=''
			Sec.focus()
			insertSpam()
			return true 
		}
		else
		{
			return false;
		}
	}
}


//=================================================For SPam =========================================================================================

function insertSpam()
{
var randomnumber=Math.floor(Math.random()*6)
randomnumber++;

if(randomnumber=='1')
	{
		
		document.getElementById('code').innerHTML='<img src="images/spam1.jpg" border="0"><input type="hidden" value="1" name="spn" id="spn">';
	}
if(randomnumber=='2')
	{
		
		document.getElementById('code').innerHTML='<img src="images/spam2.jpg" border="0"><input type="hidden" value="2" name="spn"  id="spn">';
	}
	if(randomnumber=='3')
	{
		
		document.getElementById('code').innerHTML='<img src="images/spam3.jpg" border="0"><input type="hidden" value="3" name="spn" id="spn">';
	}
	if(randomnumber=='4')
	{
		
		document.getElementById('code').innerHTML='<img src="images/spam4.jpg" border="0"><input type="hidden" value="4" name="spn" id="spn">';
	}
	if(randomnumber=='5')
	{
		
		document.getElementById('code').innerHTML='<img src="images/spam5.jpg" border="0"><input type="hidden" value="5" name="spn" id="spn">';
	}
	if(randomnumber=='6')
	{
		
		document.getElementById('code').innerHTML='<img src="images/spam6.jpg" border="0"><input type="hidden" value="6" name="spn" id="spn">';
	}
	if(randomnumber=='7')
	{
		
		document.getElementById('code').innerHTML='<img src="images/spam7.jpg" border="0"><input type="hidden" value="7" name="spn" id="spn">';
	}
}

//###################################################################################################################################################
//=================================================END SPam =========================================================================================


