// JavaScript Document
	function Validatecontactcase(){
	var retVal =  true; 

	if ((document.frm.name1.value==null)||(document.frm.name1.value=="")){
		alert("Enter valid name");
		document.frm.name1.focus();
		retVal =  false;
		return false;
	}else if (isProper(document.frm.name1.value) == false) {
        alert("Enter valid name");
        document.frm.name1.focus();
		retVal =  false;
        return false;
    }

	myRegExp = new RegExp("[^a-z,\\s]", "i"); 
	if(myRegExp.test(document.frm.name1.value)) {
		alert("Enter valid name");
		document.frm.name1.focus();
		retVal = false;
		return false;
	}


	if ((document.frm.email.value==null)||(document.frm.email.value=="")){
		alert("Enter valid E-Mail");
		document.frm.email.focus();
		retVal =  false;
		return false;
	}
	if (echeck(document.frm.email.value)==false){
		document.frm.email.focus();
		retVal =  false;
		return false; 
	} 


	var phone =  checkPhoneBlanks(checkPhone(document.frm.phone.value));
	if(phone.length!=10) {
		alert('Enter valid phone');
		document.frm.phone.value="___-___-____";
		document.frm.phone.focus();
		retVal =  false;
		return false; 
	}

	/*Optional phone number*/
	var mobilephone =  checkPhoneBlanks(checkPhone(document.frm.mobilephone.value));
	if(mobilephone !="") {
		if(mobilephone.length!=10) {
			alert('Enter valid mobilephone');
			document.frm.mobilephone.value="___-___-____";
			document.frm.mobilephone.focus();
			retVal =  false;
			return false; 
		}
	}
	if(deleteBlanks(document.frm.needs.value)=="") {
		alert('Tell us about your case');
		document.frm.needs.value="";
		document.frm.needs.focus();
		retVal =  false;
		return false;
	}

	if (document.frm.attorney_client_relationship.checked!=true){
		alert("Select Disclaimers");
		document.frm.attorney_client_relationship.focus();
		retVal =  false;
		return false; 
	}

	document.frm.action="contactcase_action.php";
	document.frm.submit();

	//alert('End of the function');
	}
	/********************************************************************************/
	function Validatequickcontact() {

	var retVal =  true; 

	if ((document.quickcontact.name2.value==null)||(document.quickcontact.name2.value=="")){
		alert("Enter valid name");
		document.quickcontact.name2.focus();
		retVal =  false;
		return false;
	}else if (isProper(document.quickcontact.name2.value) == false) {
        alert("Enter valid name");
        document.quickcontact.name2.focus();
		retVal =  false;
        return false;
    }

	myRegExp = new RegExp("[^a-z,\\s]", "i"); 
	if(myRegExp.test(document.quickcontact.name2.value)) {
		alert("Enter valid name");
		document.quickcontact.name2.focus();
		retVal = false;
		return false;
	}


	var phone = document.quickcontact.telephone1.value;
	var phone2 = document.quickcontact.telephone2.value;
	var phone3 = document.quickcontact.telephone3.value;
	if((phone =='' ) || (phone2=='') || (phone3=='')) {
			alert('Enter valid phone number');
			document.quickcontact.telephone1.focus();
			retVal =  false;
			return false;
	}


	if((phone.length > 0) || (phone2.length > 0) || (phone3.length > 0)) {
		if((phone.length > 1 && phone.length < 3 )){
			alert('Enter valid phone number');
			document.quickcontact.telephone1.focus();
			retVal =  false;
			return false;
		}
		if((phone2.length > 1 && phone2.length < 3 ) || (phone2.length == 0)){
			alert('Enter valid phone number');
			document.quickcontact.telephone2.focus();
			retVal =  false;
			return false;
		}
		if((phone3.length > 1 && phone3.length < 4 ) || (phone3.length == 0)){
			alert('Enter valid phone number');
			document.quickcontact.telephone3.focus();
			retVal =  false;
			return false;
		}
		if((phone.length < 3) || (phone2.length < 3) || (phone3.length < 4)){
			alert('Enter valid phone number');
			document.quickcontact.telephone1.focus();
			retVal =  false;
			return false;
		}
		if ((isNaN(parseInt(phone)))){
			alert('Enter valid phone number');
			document.quickcontact.telephone1.focus();
			retVal =  false;
			return false;
		}
		if ((isNaN(parseInt(phone2)))){
			alert('Enter valid phone number');
			document.quickcontact.telephone2.focus();
			retVal =  false;
			return false;
		}
		if ((isNaN(parseInt(phone3)))){
			alert('Enter valid phone number');
			document.quickcontact.telephone3.focus();
			retVal =  false;
			return false;
		}
	}

	if ((document.quickcontact.email.value==null)||(document.quickcontact.email.value=="")){
		alert("Enter valid E-Mail");
		document.quickcontact.email.focus();
		retVal =  false;
		return false;
	}
	if (echeck(document.quickcontact.email.value)==false){
		document.quickcontact.email.focus();
		retVal =  false;
		return false; 
	} 
	if(document.quickcontact.searchengine.value=="" || document.quickcontact.searchengine.value==null || document.quickcontact.searchengine.value==1) {
			alert('Select Search engine');
			document.quickcontact.searchengine.focus();
			retVal =  false;
			return false;
	}
	if(document.quickcontact.hear.value=="" || document.quickcontact.hear.value==null || document.quickcontact.hear.value==1) {
			alert('Select How did you hear about us');
			document.quickcontact.hear.focus();
			retVal =  false;
			return false;
	}
	if(deleteBlanks(document.quickcontact.needs.value)=="") {
		alert('Tell us about your case');
		document.quickcontact.needs.focus();
		retVal =  false;
		return false;
	}

	return retVal;
	}

	/************************************* Debt Negotiation Form Validation *******************************************/

	function Validatedebt(){

		var retVal =  true; 

		if ((document.exA.name1.value==null)||(document.exA.name1.value=="")){
			alert("Enter valid name");
			document.exA.name1.focus();
			retVal =  false;
			return false;
		}else if (isProper(document.exA.name1.value) == false) {
			alert("Enter valid name");
			document.exA.name1.focus();
			retVal =  false;
			return false;
		}
		/*Name should be only the characters*/
		myRegExp = new RegExp("[^a-z,\\s]", "i"); 
		if(myRegExp.test(document.exA.name1.value)) {
			alert("Enter valid name");
			document.exA.name1.focus();
			retVal = false;
			return false;
		}
	
	/*telephone1*/
	var phone = document.exA.telephone1.value;
	var phone2 = document.exA.telephone2.value;
	var phone3 = document.exA.telephone3.value;
	if((phone =='' ) || (phone2=='') || (phone3=='')) {
			alert('Enter valid phone number');
			document.exA.telephone1.focus();
			retVal =  false;
			return false;
	}


	if((phone.length > 0) || (phone2.length > 0) || (phone3.length > 0)) {
		if((phone.length > 1 && phone.length < 3 )){
			alert('Enter valid phone number');
			document.exA.telephone1.focus();
			retVal =  false;
			return false;
		}
		if((phone2.length > 1 && phone2.length < 3 ) || (phone2.length == 0)){
			alert('Enter valid phone number');
			document.exA.telephone2.focus();
			retVal =  false;
			return false;
		}
		if((phone3.length > 1 && phone3.length < 4 ) || (phone3.length == 0)){
			alert('Enter valid phone number');
			document.exA.telephone3.focus();
			retVal =  false;
			return false;
		}
		if((phone.length < 3) || (phone2.length < 3) || (phone3.length < 4)){
			alert('Enter valid phone number');
			document.exA.telephone1.focus();
			retVal =  false;
			return false;
		}
		if ((isNaN(parseInt(phone)))){
			alert('Enter valid phone number');
			document.exA.telephone1.focus();
			retVal =  false;
			return false;
		}
		if ((isNaN(parseInt(phone2)))){
			alert('Enter valid phone number');
			document.exA.telephone2.focus();
			retVal =  false;
			return false;
		}
		if ((isNaN(parseInt(phone3)))){
			alert('Enter valid phone number');
			document.exA.telephone3.focus();
			retVal =  false;
			return false;
		}
	}



	var workphone1 = document.exA.workphone1.value;
	var workphone2 = document.exA.workphone2.value;
	var workphone3 = document.exA.workphone3.value;
	if (workphone1 !="" || workphone2 !="" || workphone3!="")
	{

		if((workphone1 =='' ) || (workphone2=='') || (workphone3=='')) {
				alert('Enter valid workphone number');
				document.exA.workphone1.focus();
				retVal =  false;
				return false;
		}


		if((workphone1.length > 0) || (workphone2.length > 0) || (workphone3.length > 0)) {
			if((workphone1.length > 1 && workphone1.length < 3 )){
				alert('Enter valid workphone number');
				document.exA.workphone1.focus();
				retVal =  false;
				return false;
			}
			if((workphone2.length > 1 && workphone2.length < 3 ) || (workphone2.length == 0)){
				alert('Enter valid workphone number');
				document.exA.telephone2.focus();
				retVal =  false;
				return false;
			}
			if((workphone3.length > 1 && workphone3.length < 4 ) || (workphone3.length == 0)){
				alert('Enter valid workphone number');
				document.exA.workphone3.focus();
				retVal =  false;
				return false;
			}
			if((workphone1.length < 3) || (workphone2.length < 3) || (workphone3.length < 4)){
				alert('Enter valid workphone number');
				document.exA.workphone1.focus();
				retVal =  false;
				return false;
			}
			if ((isNaN(parseInt(workphone1)))){
				alert('Enter valid workphone number');
				document.exA.workphone1.focus();
				retVal =  false;
				return false;
			}
			if ((isNaN(parseInt(workphone2)))){
				alert('Enter valid workphone number');
				document.exA.workphone2.focus();
				retVal =  false;
				return false;
			}
			if ((isNaN(parseInt(workphone3)))){
				alert('Enter valid workphone number');
				document.exA.workphone3.focus();
				retVal =  false;
				return false;
			}
		}
	}

	var mobilephone1 = document.exA.mobilephone1.value;
	var mobilephone2 = document.exA.mobilephone2.value;
	var mobilephone3 = document.exA.mobilephone3.value;

	if (mobilephone1 !="" || mobilephone2 !="" || mobilephone3!="")
	{

		if((mobilephone1 =='' ) || (mobilephone2=='') || (mobilephone3=='')) {
				alert('Enter valid mobilephone number');
				document.exA.mobilephone1.focus();
				retVal =  false;
				return false;
		}


		if((mobilephone1.length > 0) || (mobilephone2.length > 0) || (mobilephone3.length > 0)) {
			if((mobilephone1.length > 1 && mobilephone1.length < 3 )){
				alert('Enter valid mobilephone number');
				document.exA.mobilephone1.focus();
				retVal =  false;
				return false;
			}
			if((mobilephone2.length > 1 && mobilephone2.length < 3 ) || (mobilephone2.length == 0)){
				alert('Enter valid mobilephone number');
				document.exA.telephone2.focus();
				retVal =  false;
				return false;
			}
			if((mobilephone3.length > 1 && mobilephone3.length < 4 ) || (mobilephone3.length == 0)){
				alert('Enter valid mobilephone number');
				document.exA.mobilephone3.focus();
				retVal =  false;
				return false;
			}
			if((mobilephone1.length < 3) || (mobilephone2.length < 3) || (mobilephone3.length < 4)){
				alert('Enter valid mobilephone number');
				document.exA.mobilephone1.focus();
				retVal =  false;
				return false;
			}
			if ((isNaN(parseInt(mobilephone1)))){
				alert('Enter valid mobilephone number');
				document.exA.mobilephone1.focus();
				retVal =  false;
				return false;
			}
			if ((isNaN(parseInt(mobilephone2)))){
				alert('Enter valid mobilephone number');
				document.exA.mobilephone2.focus();
				retVal =  false;
				return false;
			}
			if ((isNaN(parseInt(mobilephone3)))){
				alert('Enter valid mobilephone number');
				document.exA.mobilephone3.focus();
				retVal =  false;
				return false;
			}
		}
	}

	if (document.exA.contact_greeting.value!="" && !checkurl(document.exA.contact_greeting.value))
	{
		alert("Enter valid I would like to be addressed");
		document.exA.contact_greeting.focus();
		retVal =  false;
		return false;
	}

	if ((document.exA.email.value==null)||(document.exA.email.value=="")){
		alert("Enter valid E-Mail");
		document.exA.email.focus();
		retVal =  false;
		return false;
	}
	if (echeck(document.exA.email.value)==false){
		document.exA.email.focus();
		retVal =  false;
		return false; 
	} 

	if (document.exA.contact_address.value!="" && !checkurl(document.exA.contact_address.value))
	{
		alert("Enter valid address");
		document.exA.contact_address.focus();
		retVal =  false;
		return false;
	}
	if (document.exA.contact_address1.value!="" && !checkurl(document.exA.contact_address1.value))
	{
		alert("Enter valid address");
		document.exA.contact_address1.focus();
		retVal =  false;
		return false;
	}
	if (document.exA.contact_city.value!="" && !checkurl(document.exA.contact_city.value))
	{
		alert("Enter valid city");
		document.exA.contact_city.focus();
		retVal =  false;
		return false;
	}
	if (document.exA.contact_state.value!="" && !checkurl(document.exA.contact_state.value))
	{
		alert("Enter valid state");
		document.exA.contact_state.focus();
		retVal =  false;
		return false;
	}

	/*Zip code */
	myRegExp = new RegExp("[^0-9,\\s]", "i"); 
	if(myRegExp.test(document.exA.contact_zip.value) || ((document.exA.contact_zip.value.length>0) && (document.exA.contact_zip.value.length<5))) {
		alert("Enter valid zip");
		document.exA.contact_zip.focus();
		retVal = false;
		return false;
	}
	
	if ((document.exA.needs.value==null)||(document.exA.needs.value=="")){
		alert("Enter What is your goal");
		document.exA.needs.focus();
		retVal =  false;
		return false;
	}

	return retVal;	
	} /*Function ends*/

	/************************************* Common Functions *******************************************/
	function isProper(string) {
	
	   if (!string) return false;
	   var iChars = "*|,\":<>[]{}`\;()@&$#%1234567890";
	
	   for (var i = 0; i < string.length; i++) {
		  if (iChars.indexOf(string.charAt(i)) != -1)
			 return false;
	   }
	   return true;
	} 

	function deleteBlanks(entry)
	{
		var len = entry.length ;
		var foundBlank = 1;
		while(foundBlank == 1 && len > 0) 
		{
			var indx = entry.indexOf(" ");
			if(indx == -1) 
				foundBlank = 0 ;
			else
				entry = entry.substring(0,indx) + entry.substring(indx+1,len);
			len = entry.length;
		}
		return entry;
	}

	var bugchars = '!#$^&*()+|}{[]?><~%:;/,=`"\'';
	function CharsInBag(s)
	{   var i;
	var lchar="";
		// Search through string's characters one by one.
		// If character is not in bag.
		for (i = 0; i < s.length; i++)
		{   
			// Check that current character isn't whitespace.
			var c = s.charAt(i);
			if(i>0)lchar=s.charAt(i-1)
			if (bugchars.indexOf(c) != -1 || (lchar=="." && c==".")) return false;
		}
		return true;
	}
	
	function isInteger(s)
	{   var i;
		for (i = 0; i < s.length; i++)
		{   
			// Check that current character is not a number.
			var c = s.charAt(i);
			if ((c >= "0") && (c <= "9") && (c != ".")) return false;
		}
		// All characters are numbers.
		return true;
	}
	function echeck(str) {
		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		var lastdot=str.lastIndexOf(dot)
		var lastval = parseInt(lstr) - parseInt(lastdot);

		if (lastval >5){
		   alert("Invalid E-Mail")
		   return false;
		}
		if (lastval <3){
		   alert("Invalid E-Mail")
		   return false;
		}

		if (str.indexOf(at)==-1){
		   alert("Invalid E-Mail")
		   return false
		}
		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Invalid E-Mail")
		   return false
		}
		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr || str.substring(lastdot+1)==""){
		    alert("Invalid E-Mail")
		    return false
		}
		 
		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("Invalid E-Mail")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("Invalid E-Mail")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("Invalid E-Mail")
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    alert("Invalid E-Mail")
		    return false
		 }
		if(CharsInBag(str)==false){
		    alert("Invalid E-Mail")
		    return false
		 }
	   /*var arrEmail=str.split("@")
		 var ldot=arrEmail[1].indexOf(".")
		 if(isInteger(arrEmail[1].substring(ldot+1))==false){
		    alert("Invalid E-mail ID2")
		    return false
		 }*/
 		 return true					
	}
	function ismaxlength(obj){
		/*var mlength=obj.getAttribute? parseInt(obj.getAttribute("maxlength")) : ""*/
		var mlength=250; 
		if (obj.getAttribute && obj.value.length>mlength)
		obj.value=obj.value.substring(0,mlength)
	}

	function checkPhone(entry)
	{
		var len = entry.length ;
		var foundBlank = 1;
		while(foundBlank == 1 && len > 0) 
		{
			var indx = entry.indexOf("-");
			if(indx == -1) 
				foundBlank = 0 ;
			else
				entry = entry.substring(0,indx) + entry.substring(indx+1,len);
			len = entry.length;
		}
		return entry;
	}

	function checkPhoneBlanks(entry)
	{
		var len = entry.length ;
		var foundBlank = 1;
		while(foundBlank == 1 && len > 0) 
		{
			var indx = entry.indexOf("_");
			if(indx == -1) 
				foundBlank = 0 ;
			else
				entry = entry.substring(0,indx) + entry.substring(indx+1,len);
			len = entry.length;
		}
		return entry;
	}

	function numbersonly(e, decimal) {
		var key;
		var keychar;
	  
		 if (window.event) {
			key = window.event.keyCode;
		  }
		  else if (e) {
			 key = e.which;
		  }
		  else {
			 return true;
		  }
		  
		  keychar = String.fromCharCode(key);
	  
		  if ((key==null) || (key==0) || (key==8) ||  (key==9) || (key==13) || (key==27) ) {
			 return true;
		  }
		  else if ((("0123456789").indexOf(keychar) > -1)) {
			 return true;
		  }
		  else if (decimal && (keychar == ".")) { 
			return true;
		  }
		  else
			 return false;
	}

	function trim_text(str)
	{
		str = str.replace(/^\s+|\s+$/g, '');
		return str;
	}
function isValidText(frmElement, fieldName)
{
	myRegExp = new RegExp("[^a-z,\\s]", "i"); 
	if(myRegExp.test(frmElement.value)) {
		alert("Only Alphabets are allowed in " + fieldName);
		frmElement.focus();
		frmElement.select();
		retVal = false;
	}
	else {
		retVal = true;
	}
	return retVal;
}


function checktel(tel,valname)
{
	val1=tel.value;
	if (val1!="")
	{
		for (var i=0;i<val1.length;i++)
		{
			var val = val1.charAt(i);
			if ((val1.length<12 ) || (i!=7 && i!=3 && (val<"0" || val>"9") ) || ( (i==3 || i==7) && val!="-" ))
			{
				alert("Please enter "+ valname + " in the format 999-999-9999");
				tel.focus();
				tel.select();
				return false;
			}
		}
	}
	return true;
}


function checkurl(urlval) {
	var urlval = urlval;
	myRegExp = new RegExp("^[A-Za-z]+://[A-Za-z0-9-_]+\\.[A-Za-z0-9-_%&\?\/.=]+$", "i"); 
	if(myRegExp.test(urlval)) {
		return false;
	} else {
		myRegExp = new RegExp("^[A-Za-z0-9-_]+\\.[A-Za-z0-9-_%&\?\/.=]+$", "i"); 
		if(myRegExp.test(urlval)) {
			return false;
		}
	}
	return true;
}