// Phone Number Formatter

function mask(f){ 
f.maxLength = 14;
tel='('; 
var val =f.value.split(''); 
for(var i=0;i<val.length;i++){ 
if(i==2){val[i]=val[i]+') '} 
if(i==5){val[i]=val[i]+'-'} 
tel=tel+val[i] 
} 
    if (tel != '('){
f.value=tel; 
    }
    else {
    f.value = "";
    }
} 
function unMask(f){
 f.value = f.value.replace("(","");
 f.value = f.value.replace("-","");
 f.value = f.value.replace(")","");
 f.value = f.value.replace(" ","");
}
function noAlpha(obj){
	reg = /[^0-9]/g;
	obj.value =  obj.value.replace(reg,"");
 }


// Validiator 

function validateForm() {
  var vbCRLF = String.fromCharCode(13,10);
  var incomplete = 0, notqualified = 0, msg = "";
  
  
  var financingChecked = false;
    for (var x = 0; x < document.emailForm.Financing.length; x ++) {
        if (document.emailForm.Financing[x].checked) {
         financingChecked = true;
        }
    }
  
  var hasAttorneyChecked = false;
    for (var x = 0; x < document.emailForm.RepresentedByAttorney.length; x ++) {
        if (document.emailForm.RepresentedByAttorney[x].checked) {
         hasAttorneyChecked = true;
        }
    }
      
  if (document.emailForm.FirstName.value == "") {
    incomplete = 1;
    msg = " - First Name" + vbCRLF;
  }
  if (document.emailForm.LastName.value == "") {
    incomplete = 1;
    msg += " - Last Name" + vbCRLF;
  }
  if ((document.emailForm.ZIPCode.value == "") || isNaN(document.emailForm.ZIPCode.value)) {
    incomplete = 1;
    msg += " - ZIP Code" + vbCRLF;
  }  
  if ((document.emailForm.HomePhone.value == "") || (document.emailForm.HomePhone.value.length<14)) {
    incomplete = 1;
    msg += " - Home Phone" + vbCRLF;
  }
  if (document.emailForm.Email.value == "" || document.emailForm.Email.value.indexOf("@")==-1 || document.emailForm.Email.value.indexOf(".")==-1 ) {
    incomplete = 1;
    msg += " - Email Address" + vbCRLF;
  }
  if(!financingChecked) {
    incomplete = 1;
    msg += " - Financing Method" + vbCRLF;
  }
  if (document.emailForm.HowSoon.value.length == 0){
    incomplete = 1;
    msg += " - How soon are you looking for an attorney" + vbCRLF;
  }
  if(!hasAttorneyChecked) {
    incomplete = 1;
    msg += " - Current Representation" + vbCRLF;
  }
  if (incomplete == 1) {
    alert("Please complete the following fields before proceeding:" + vbCRLF + msg);
  }
  else {
    document.emailForm.submit();
  }
}




<!--
var vbCRLF = String.fromCharCode(13,10);
var localDest = 0;

function navTo(){
	localDest = 1;
}

function landingPageNavTo(url){
	document.location.href = "../includes/recordLandingPageNav.asp?nextPage="+url;
}

var phone_field_length=0;
function TabNext(obj,event,len,next_field) {
	if (event == "down") {
		phone_field_length=obj.value.length;
		}
	else if (event == "up") {
		if (obj.value.length != phone_field_length) {
			phone_field_length=obj.value.length;
			if (phone_field_length == len) {
				next_field.focus();
			}
		}
	}
}

function trim(str){
	re = / /gi;
	newstr=str.replace(re, "");
	return(newstr);
}
function stripPunc(str){

	re = /,/gi;
	newstr = str.replace(re, "");
	re = /'/gi;
	newstr = newstr.replace(re, "");
	return(newstr);
}

function getCookie(name)
{
    var dc = document.cookie;
    var prefix = name + "=";
    var begin = dc.indexOf("; " + prefix);
    if (begin == -1)
    {
        begin = dc.indexOf(prefix);
        if (begin != 0) return null;
    }
    else
    {
        begin += 2;
    }
    var end = document.cookie.indexOf(";", begin);
    if (end == -1)
    {
        end = dc.length;
    }
    return unescape(dc.substring(begin + prefix.length, end));
}

function checkCookie(){
	var formViewed = 0;
	formViewed = getCookie("CaseReviewForm");
	if (formViewed == 0 && localDest == 0){
		openTopTen();
	}
}

function openTopTen(){
	var h1, w1;
	h1 = screen.height;
	h1 = (h1/2) - 141;
	w1 = screen.width;
	w1 = (w1/2) - 178;
	
	window.open("top_ten.htm","","height=282,width=356,left="+w1+",top="+h1+",status=no");

}

function TopTenConfirm(){

	var email = document.getElementById("email").value;
	var h1, w1;
	h1 = screen.height;
	h1 = (h1/2) - 141;
	w1 = screen.width;
	w1 = (w1/2) - 178;
	
	window.open("top_ten_send.asp?email=" + email,"","height=282,width=356,left="+w1+",top="+h1+",status=no");

}

function TopTenConfirmPC(){

	var email = document.getElementById("email").value;
	var h1, w1;
	h1 = screen.height;
	h1 = (h1/2) - 141;
	w1 = screen.width;
	w1 = (w1/2) - 178;
	
	window.open("../top_ten_send.asp?email=" + email,"","height=282,width=356,left="+w1+",top="+h1+",status=no");

}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function verFastForm(){

	var dataMissing = 0,msg = "";
	if (document.form1.name.value == ""){
		dataMissing = 1;
		msg += "- Name" + vbCRLF;
	}
	if (document.form1.email.value == ""){
		dataMissing = 1;
		msg += "- Email" + vbCRLF;
	}
	if (document.form1.area.value == "" || document.form1.pre.value == "" || document.form1.suff.value == ""){
		dataMissing = 1;
		msg += "- Phone Number" + vbCRLF;
	}
	if (dataMissing == 1){
	
		msg = "Please complete the following field(s) before proceeding:" + vbCRLF + msg;
		alert(msg); }
	else{
		document.form1.submit();
	}

}

function popUp(URL) {
window.open(URL, 'popup', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=475,height=400');
}


function doTrafficLogout()
{
	document.location.href = "../TrafficTracker/logout.asp";
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

	window.onload = function() {
    MM_preloadImages('images/b_evaluation_on.gif','images/b_our_firm_on.gif','images/b_bankruptcy_right_on.gif','images/b_what_happens_after_on.gif','images/b_learn_about_7_on.gif','images/b_learn_about_13_on.gif','images/b_state_laws_on.gif');    
	}
	
	window.onunload = function() {
    checkCookie();    
	}	
//-->




