";
function getSearchTypes() {
const theSelectedOptions = $("input[name='searchType']:checked");
let theArray = [];
if (theSelectedOptions.length > 0) {
for (let i = 0; i < theSelectedOptions.length; ++i) {
theArray.push(parseInt($(theSelectedOptions[i]).val()));
}
}
return theArray
}
//clear out the search form instead of resetting to default
function uncheck() {
var uncheck = document.getElementsByTagName('input');
for (var i = 0; i < uncheck.length; i++) {
if (uncheck[i].type == 'checkbox') {
uncheck[i].checked = false;
}
else if (uncheck[i].type == "text") {
uncheck[i].value = "";
}
}
var elements = document.getElementsByTagName('select');
for (var i = 0; i < elements.length; i++) {
elements[i].value = "";
}
}
function checkall() {
var checkall = document.getElementsByTagName('input');
for (var i = 0; i < checkall.length; i++) {
if (checkall[i].type == 'checkbox') {
checkall[i].checked = true;
}
else if (checkall[i].type == "text") {
checkall[i].value = "";
}
}
var elements = document.getElementsByTagName('select');
for (var i = 0; i < elements.length; i++) {
elements[i].value = "";
}
}
function submitSearch() {
var url = $("#atlassearchform").attr("action");
var searchPhrase = $("#kw_keyword").val().trim();
var searchTypesArray = getSearchTypes();
var scopeType = parseInt($("input[name='kw_scope']:checked").val());
var scopeValue = null;
if (scopeType == 2) {
scopeValue = $("input[name='kw_scope_county']").val();
} else if (scopeType == 3) {
scopeValue = $("input[name='kw_scope_city']").val();
}
submitSearchRequest(url, searchPhrase, searchTypesArray, scopeType, scopeValue);
}
$("#kw_clear").on("click", uncheck);
$("#kw_checkall").on("click", checkall);
$(document).on(SearchEvents.LOADING, function () {
$("#atlassearchresults").empty().append(searchingDiv);
});
$(document).on(SearchEvents.RECEIVED, function (_, results) {
$("#atlassearchresults").empty().append(results);
setDetailsOverlay();
});
$(document).on(SearchEvents.FAILED, function () {
$("#atlassearchresults").empty().append(
"An error has occurred during the search. " +
"Please try again. " +
"If the issue persists, please contact atlas@thc.texas.gov with details about your search."
);
});
$(document).ready(function () {
$("#atlassearchform").submit(function (e) {
e.preventDefault();
closeAtlasSystemMessage();
eval($("#atlasSearchTabs div.ui-tabs-panel[aria-hidden='false'] input[type='submit']").attr("onclick"));
submitSearch();
return false;
});
$("#trinomial_reset").click(function () {
$('#txt_trinomial_sitenum').val('');
$('#trinomial_sitenum').attr('value', '');
});
// Check sub-level filters if top level filter is selected
$("#ck_markers").change(function () {
if (this.checked) {
$("#ck_rthl").prop('checked', true);
}
if (!this.checked) {
$("#ck_rthl").prop('checked', false);
}
});
$("#ck_nrprops").change(function() {
if (this.checked) {
$("#ck_nhl").prop('checked', true);
}
if (!this.checked) {
$("#ck_nhl").prop('checked', false);
}
});
$("#ck_cemetery").change(function () {
if (this.checked) {
$("#ck_htc").prop('checked', true);
}
if (!this.checked) {
$("#ck_htc").prop('checked', false);
}
});
$("#ck_asf").change(function () {
if (this.checked) {
$("#ck_er").prop('checked', true);
}
if (!this.checked) {
$("#ck_er").prop('checked', false);
}
});
});