function validateRadio(check) {
    for (i=0; i<check.length; i++) {
        if (check[i].checked) {
            return true;
        }
    }
    return false;
}
function validateText(text) {
    if(text == "") {
        return false
    }	
    return true
}
function validateLength(login, maxNum, minNum) {
    //alert("leng =" + login.length)
    if(login.length > maxNum) {
        return false
    }	
    if(login.length < minNum) {
        return false
    }	
    return true	
}
function validateEmail(text) {
    var str = text; // email string
    var reg1 = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/; // valid
    if (reg1.test(str)) {
        return true
    }	
            
    return false
}

function isNum(passedVal) {
    return ((passedVal.match(/^\d+$/))? true:false);
}

function RequiredMissing(f,n)
{
	if (window.document.signup.elements[f].value == "")
	{
		alert(n + " is a required field");
		return(true);
	}
	else
		return(false);
}

// Open the firm email window
function open_firm_email_form(email_form_query)
{
	thewindow = window.open('https://www.americanbar.com/firmemail.asp?'+email_form_query,'Email_Window','width=480,height=740,directories=no,location=no,menubar=no,scrollbars=no,status=yes,toolbar=no,resizable=yes');
}


function windowopen()  
{
thewindow = window.open('popup.html','myWindow','width=480,height=500,directories=no,location=no,menubar=no,scrollbars=yes,status=yes,toolbar=no,resizable=yes');
thewindow.focus();
}
	

// Javascript for search page
function CheckValid(){
  with (document.fSrch){
    if ((cvalueFirmName.value.length ==0) && 
	   (cvalueCity.value.length ==0) && 
	   (sbyState.options[document.fSrch.sbyState.selectedIndex].value.length ==0) &&
	   (sbyCountry.options[document.fSrch.sbyCountry.selectedIndex].value.length ==0)) {
      alert('Please Enter a value to Search');
      cvalueFirmName.focus();
      return false;
    }
    
    if ((iPageSize.value.length == 0) || (iPageSize.value < 0) || isNaN(iPageSize.value)) 
    {
      alert('Please Enter a Numeric Value greater than 0 in Result Size field');
      iPageSize.focus();
      return false;
    }

    action = 'http://www.americanbar.com/index.asp?pg=1&bRealTable='+
             rTable[0].checked
  }
  return true;
}

function checkEnterKey(e){
    e = (e)? e:((window.event)?window.event:"");
    
    if(e.keyCode==13)document.fSrch.submit();
    else return true;
}

function setTable() {
  //if (document.fSrch.rTable[0].checked == true)
     cTableName = "tblLawFirm"
  //else
     //cTableName = "tblTmpLawFirm"
}

function getResults() {
	var qs;
	var pageName;
	var cTableName;
	var popUp;
	var iPage;

   	cTableName = "tblLawFirm"
	pageName = "SearchResults.asp";
	var page = document.pageNum.pageVal.value;
	qs = "?pg="+ page + "&bRealTable=true&iPageSize=20&sbyFirmName=" 
		+ escape(document.fSrch.sbyFirmName.options[document.fSrch.sbyFirmName.selectedIndex].value) + "&cvalueFirmName=" 
        + escape(document.fSrch.cvalueFirmName.value) + "&sbyCity=" + escape(document.fSrch.sbyCity.options[document.fSrch.sbyCity.selectedIndex].value) + "&cvalueCity=" 
        + escape(document.fSrch.cvalueCity.value) + "&sbyState=" + escape(document.fSrch.sbyState.options[document.fSrch.sbyState.selectedIndex].value) + "&sbyCountry=" 
        + escape(document.fSrch.sbyCountry.options[document.fSrch.sbyCountry.selectedIndex].value);

    document.fSrch.action = pageName + qs;	
	document.fSrch.submit();
}
// Legal Description JavaScripts
function LDCheckValid()
{
  with (document.fSrchInLegalDesc){
    if ((iPageSize.value.length == 0) || (iPageSize.value < 0) || isNaN(iPageSize.value)) 
        {
            alert('Please Enter a Numeric Value greater than 0 in Result Size field');
            iPageSize.focus();
            return false;
        } else {
            return true;
        }
    }
}

function ldnextpg(ipage){
  with (document.fSrchInLegalDesc){
    action = 'http://www.americanbar.com/index.asp?pg=' +ipage;
    
    ldgetResults();
    submit();

  }
}

function ldgetResults() {
	var qs;
	var pageName;
	var cTableName;
	var popUp;
	var iPage;

	pageName = "SearchInLegalDescResults.asp";
	var ldpage = document.pageNum.pageVal.value;
	qs = "?pg="+ ldpage + "&iPageSize=20" + "&cvalueLegalDesc=" 
	  + document.fSrchInLegalDesc.cvalueLegalDesc.value;

	document.fSrchInLegalDesc.action=pageName + qs;
	document.fSrchInLegalDesc.submit();
}
function validateDate(text) {
	var str = text; // email string
	var reg1 = /^[0-9]{1,2}\/[0-9]{2}$/; // valid
	if (reg1.test(str)) {
		return true
	}	
	return false	
}

function validateCardNum(text) {
	var str = text; // email string
	var reg1 = /^[0-9]+$/; // valid
	if (reg1.test(str)) {
		return true
	}	
	return false	
}

function OpenCertDetails()
{
	thewindow = window.open('https://www.thawte.com/cgi/server/certdetails.exe?code=USFORS29-2', 'anew', config='height=400,width=450,toolbar=no,menubar=no,scrollbars=yes,resizable=no,location=no,directories=no,status=yes');
}
 
