//function for checking email validation
function echeck(str) {
	var at="@"
	var dot="."
	var lat=str.indexOf(at)
	var lstr=str.length
	var ldot=str.indexOf(dot)
	if (str.indexOf(at)==-1){
	   return "Please enter a valid E-mail Address.";
	}
	
	if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
	   return "Please enter a valid E-mail Address."
	}
	
	if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		return "Please enter a valid E-mail Address.";	}
	
	 if (str.indexOf(at,(lat+1))!=-1){
		return "Please enter a valid E-mail Address.";	 }
	
	 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		return "Please enter a valid E-mail Address.";	 }
	
	 if (str.indexOf(dot,(lat+2))==-1){
		return "Please enter a valid E-mail Address.";	 }
	
	 if (str.indexOf(" ")!=-1){
		return "Please enter a valid E-mail Address.";	 
	}
	
	 return true;					
}

//Function to check numeric values only
function IsNumeric(strString)
{
	var strValidChars = "0123456789";
	var strChar;
	var blnResult = true;
	if (strString.length == 0) return false;
	//  test strString consists of valid characters listed above
	for (i = 0; i < strString.length && blnResult == true; i++)
	{
		strChar = strString.charAt(i);
		if (strValidChars.indexOf(strChar) == -1)
		{
			blnResult = false;
		}
	}
	return blnResult;
}

//function for validating Become a Member form
function validate_form()
{
	id=document.getElementById('dittdi-dittdi');
	h_id='hid_'+'dittdi-dittdi'; 	
	document.getElementById(h_id).style.display='';
	document.getElementById(h_id).innerHTML='';
	if(id.value=='')
	{
		document.getElementById(h_id).style.display='';
		document.getElementById(h_id).innerHTML='Please enter Email.';
		id.focus();
		return false;
	}
	if(echeck(id.value)!=true)
	{
		document.getElementById(h_id).style.display='';
		document.getElementById(h_id).innerHTML=echeck(id.value);
		id.focus();
		return false;
	}
	
	id=document.getElementById('Zip');
	h_id='hid_'+'Zip';
	document.getElementById(h_id).style.display='';
	document.getElementById(h_id).innerHTML='';
	if(id.value=='')
	{
	
		document.getElementById(h_id).style.display='';
		document.getElementById(h_id).innerHTML='Please enter Zip Code.';
		id.focus();
		return false;
	}
	
	if(IsNumeric(id.value)==false)
	{
		document.getElementById(h_id).style.display='';
		document.getElementById(h_id).innerHTML='Please enter Numeric Value.';
		id.focus();
		return false;
	} 
	else 
	{ 
		document.getElementById(h_id).style.display='none';
	}

        id=document.getElementById('City');
	h_id='hid_'+'City';
	document.getElementById(h_id).style.display='';
	document.getElementById(h_id).innerHTML='';
	if(id.value=='')
	{
	
		document.getElementById(h_id).style.display='';
		document.getElementById(h_id).innerHTML='Please enter your City';
		id.focus();
		return false;
	}
       

         id=document.getElementById('LawFirm');
	h_id='hid_'+'Law';
	document.getElementById(h_id).style.display='';
	document.getElementById(h_id).innerHTML='';
	if(id.value=='')
	{
	
		document.getElementById(h_id).style.display='';
		document.getElementById(h_id).innerHTML='Please enter your Law Firm';
		id.focus();
		return false;
	}

   
        

	
	return true;
}


