validate = function() {
	var fm = document.search_form;
	if (fm.lo_age[fm.lo_age.selectedIndex].value > fm.hi_age[fm.hi_age.selectedIndex].value) {
		alert("The age ranges are invalid.");
		fm.hi_age.focus();
		return false;
	}
	
	if (fm.loc.checked) {
		var obj = $('adv_opts');
		if (fm.cid && fm.cid.value == "") {
			alert("Select a country.");
			if (obj) obj.style.display =  "inline";
			fm.cid.focus();
			return false;
		}
		
		if (fm.sid && fm.sid.value == "") {
			alert("Select a state/province.");
			if (obj) obj.style.display =  "inline";
			fm.sid.focus();
			return false;
		}
	}
		
	var pb = $('prgbar_search');
	if (pb) {
		pb.style.visibility = 'visible';
	}
	
	fm.dos.value=1;
	fm.tr.value='';
	fm.page.value='';

	return true;
};

chkProfile = function(val) {
	var fm = document.form2;
	
	if (fm.username.value != "")
		viewProfile(fm.username.value);

	return false;
};

toggleAdvancedSearch = function() {
	obj = $('adv_opts');
	if (obj) {
		if (obj.style.display == "none") {
			obj.style.display =  "inline";
			val = 'inline';
		}
		else {
			obj.style.display = "none";
			val = 'none';
		}
		setCookie('bpwadv_opts', val, expiration);
	}	
};

doLocation = function(chk) {
	var fm = document.search_form;
	if (fm) {
		if (!chk) {
			if (!fm.loc.checked && fm.ccid)
				fm.ccid.selectedIndex = -1;
		}
		else {
			fm.loc.checked = 1;
		}
	}
};

setCountry = function(_id) {
	var fm = document.search_form;
	if (fm) {
		fm.cid.value = _id;
		if (fm.sid) fm.sid.selectedIndex = -1;
		if (fm.ccid) fm.ccid.selectedIndex = -1;
		showProgress();
	}
};

setState = function(_id) {
	var fm = document.search_form;
	if (fm) {
		fm.sid.value = _id;
		if (fm.ccid) fm.ccid.selectedIndex = -1;
		showProgress();
	}
};

setCity = function(_id) {
	var fm = document.search_form;
	if (fm) {
		fm.ccid.value = _id;
		//showProgress();
	}
};

function do_progress() {
	showProgress();
}

showProgress = function () {
	var fm = document.search_form;
	var pb = $('prgbar');

	if (fm.dos) fm.dos.value = '';
	if (fm.tr) fm.tr.value = '';
	if (fm.loc && !fm.loc.checked) fm.loc.checked = 1;
	if (pb) {
		pb.style.visibility = 'visible';
	}

	fm.submit();
};
