// JavaScript Document
//============================ Function to check the username ===============================
	function checkuser(str) {
				document.getElementById("chkuser").style.visibility="visible";
				document.getElementById("chkuser").innerHTML='&nbsp;Wait....'
				var emailRegEx = /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i;			
				if(str.search(emailRegEx) == -1)
				{
					$('chkuser').innerHTML='<font color="red">&nbsp;Invalid Email Address</font>';
					return false;
				}
				new Ajax.Request("checkuser.php", 
					{ 
					method: 'post', 
					postBody: 'q='+ str,					
					onComplete: showResponsecu 
					});
				}
function showResponsecu(req){
	
				$('chkuser').innerHTML= req.responseText;
				$('chkerr').value= req.responseText;
			}
//============================================================================================


//===================================For Adding More Lawyers Text Boxes ======================
function add2(str)
{
	
	
	var older=str-1;
	//document.getElementById('add2').style.visibility="visible";
	document.getElementById('add'+str).className="visi";
	document.getElementById('add'+older+older).className="unvisible";
	//document.getElementById('add'+str+str).className="visi";
	
}
//==============================================================================================

//===================================for connect page ==========================================

function checkPA(str)
{	
	alert(str);
	if(str=='BKM')
		document.getElementById('hasattorny').style.display='';	
	//|| str=='INJ' || str=='CRI' || str=='DIV' || str=='DUI')

}		
	
//==============================================================================================

//============================ Function to check the email for forget password =================
function forgotpass()
	{
				var emailaddress=document.getElementById("emailaddress").value;
				var emailRegEx = /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i;
				if(emailaddress=="")
					{
						document.getElementById("err").innerHTML='Please enter your email address';
						document.getElementById("emailaddress").style.background='#FFFFB3'; 
						document.getElementById("emailaddress").focus();
						return false;
					}
					else if(emailaddress.search(emailRegEx) == -1)
					{
						document.getElementById("err").innerHTML='Please enter valid emaill address';
						document.getElementById("emailaddress").style.background='#FFFFB3'; 
						document.getElementById("emailaddress").focus();
						return false;
					}
				else
				{
					document.getElementById("chkem").style.visibility="visible";
					document.getElementById("chkem").innerHTML='<img src="images/loading.gif" height="32" width="32" alt="Processing..." />';
					new Ajax.Request("forgotpassword.php", 
						{ 
						method: 'post', 
						postBody: 'q='+ emailaddress,					
						onComplete: showResponsecemail 
						});
					}
	}
	
function showResponsecemail(req)
	{
		$('chkem').innerHTML= req.responseText;
		$('chkem').value= req.responseText;		
	}
//============================================================================================
//=============To check whether enter pressed or not ========================================
function noenter(e) 
{
	//getEvent=event.keyCode;
	//aler("i m in");
	
	/*if(window.event)
		keyPressed = window.event.keyCode;	// IE
	else
		keyPressed = e.which;	 // Firefox*/

	getEvent=(window.event) ? event.keyCode : e.keyCode;
    if (getEvent == "13") 
	{
 		//alert("Enter Pressed");
		mysearchfun();
    	return false;
    } 
	else 
	{
    	return true;
    }
}
//===========================================================================================

//=============To validate the ZIp , City, State ============================================

function ValidateZipCityState(ZipCode,CityName,StateName)
{
				$('chkzip').innerHTML='<img src="images/loading.gif" height="22" width="22" alt="Searching..." /> Searching...</div>';
				document.getElementById("chkzip").style.display="";

				new Ajax.Request("checkZipCityState.php", 
					{ 
					method: 'post', 
					postBody: 'q='+ ZipCode + "&r=" + CityName + "&s=" + StateName,					
					onComplete: showResponsezcs 
					});
				}
function showResponsezcs(req){
				var msg
				if(req.responseText=='1')
					 msg="<font color='green'>&nbsp;Result found!</font>";
				else
					 msg="<font color='red'>&nbsp;Result not found!</font>";
					 
				$('chkzip').innerHTML= msg;
				$('chkziperr').value= req.responseText;
}
//===========================================================================================


//=============To check the length of zip code ========================================
function countit(fieldName, str)
{
   if(fieldName=='zip')
   {
	   //ZipCode Portion 
	    var cityName=document.getElementById('city').value;
		var States=document.getElementById('state').value;
		
		if (str.length > "0")
		{
		   ValidateZipCityState(str,cityName,States);
		   return false;
		} 
		else 
		{
			ValidateZipCityState(str,cityName,States);
			return true;
		}
   }
   
   if(fieldName=='city')
   {
		   var States=document.getElementById('state').value;
		   var ZipCode=document.getElementById('zipcode').value;
		   ValidateZipCityState(ZipCode,str,States);
		   return false;	  
   }
   
   if(fieldName=='states')
   {
	   //State Portion 
	   if(document.getElementById('city').value !='')
	   {
		   var cityName=document.getElementById('city').value;
		   var ZipCode=document.getElementById('zipcode').value;
		   ValidateZipCityState(ZipCode,cityName,str);
		   return false;
	   }
	   
   }
   
   
}
//===========================================================================================
