function validateAll() {
	try {
		var frm = document.getElementById("form");
		var e = document.getElementById("error");
		var msg = "";
	
		// get basic search terms
		var namesearch = "", country = "", state = "", province = "", city = "";
		if (frm.namesearch)
			namesearch = getValue(frm.namesearch);
		if (frm.country)
			country = frm.country.options[frm.country.selectedIndex].value;
		if (frm.state)
			state = frm.state.options[frm.state.selectedIndex].value;
		if (frm.province)
			province = frm.province.options[frm.province.selectedIndex].value;
		if (frm.city)
			city = trim(frm.city.value);
	
		// get advanced search terms
		var aop = "", language = "", school = "", bar = "";
		if (frm.aop)
			aop = getValue(frm.aop);
		if (frm.language)
			language = getValue(frm.language);
		if (frm.school)
			school = getValue(frm.school);
		if (frm.bar)
			bar = getValue(frm.bar);
			
function getCheckedValue(radioObj) {
	if(!radioObj)
		return "";
	var radioLength = radioObj.length;
	if(radioLength == undefined)
		if(radioObj.checked)
			return radioObj.value;
		else
			return "";
	for(var i = 0; i < radioLength; i++) {
		if(radioObj[i].checked) {
			return radioObj[i].value;
		}
	}
	return "";
}

termtype = getCheckedValue(frm.termtype);

if (termtype == "") {
	msg += "Please Specify To Search By Lawyer, Law Firm, Or Both<br />";
}
		
		// check Country-State-Province requirement
		var stateLabel = "State";
		if (country == "Canada") stateLabel = "Province";
		if ((country == "United-States") || (country == "Canada")) {
			if ((country == "Canada") && (province == "")) {
				msg += "Please Specify Province";
			}			
			else if (namesearch + aop + city + state + province + language + school + bar == "") {
				msg += 'Please specify one or more of the following:';
				msg += '<br />- Lawyer or Firm Name<br />- Area of Practice<br />- City<br />- ' + stateLabel + 
				 '<br />- Language<br />- Law School<br />- Licensed to Practice in';
			}
		}
		else {
			if (namesearch + aop + city + language + school + bar == "") {
				msg += 'Please specify one or more of the following:';
				msg += '<br />- Lawyer or Firm Name<br />- Area of Practice<br />- City' +
				 '<br />- Language<br />- Law School<br />- Licensed to Practice in';
			}
		}
		
		// test wildcards
		var wildcardMsg = "";
		if (!wildcardTest(city))
			wildcardMsg += "<br />- City";
		if (!wildcardTest(namesearch))
			wildcardMsg += "<br />- Lawyer or Firm Name";
		if (!wildcardTest(aop))
			wildcardMsg += "<br />- Area of Practice";
		if (!wildcardTest(language))
			wildcardMsg += "<br />- Language";
		if (!wildcardTest(school))
			wildcardMsg += "<br />- Law School";
		if (!wildcardTest(bar))
			wildcardMsg += "<br />- Licensed to Practice in";
		// include wildcard message
		if (wildcardMsg != "") {
			msg += '<br />Please specify at least two characters when using a wildcard search for the following:' + wildcardMsg;
		}
			
		// If errors detected
		if (msg != "") {
			//alert(msg);
			e.innerHTML = "<p>" + msg + "</p>";
			return false;
		}
	
		updateFormActionStatic(frm);
		location.href = frm.action;
		return false;		
	}
	catch(er) {
		//alert('Your search request could not be performed.\nAn error occurred validating your search criteria.');
		e.innerHTML = "<p>Your search request could not be performed.\nAn error occurred validating your search criteria.</p>";
		return false;
	}
}

function initInputs() {
	// set the initial value for search form inputs
	var frm = document.getElementById("form");
	if (city != "")
		frm.city.value = city;
	if (name != "")
		frm.namesearch.value = name;
	if (aop != "")
		frm.aop.value = aop;
	if (language != "")
		frm.language.value = language;
	if (school != "")
		frm.school.value = school;
	if (bar != "")
		frm.bar.value = bar;
	
	// default radio group
	if (termtype != "")
		setRadioValue(frm.termtype, termtype);
		
	// default select-one for Country
    if (country != "")
    	setSelectOneByValue(frm.country, country);
    // with Country set, show appropriate input: states, provinces or neither
    checkCountry();
    
    // default select-one for State/Province
    if (state != "") {
    	if (country == "Canada")
	    	setSelectOneValue(frm.province, state);
	    else
	    	setSelectOneValue(frm.state, state);
    }
    
    // add helper text to empty text input fields
    addHelperText(); 
}
