var showSearchUi=[];
function getSearchBarUi(showSearchBar,index){
if(showSearchBar==true){
return "<div id='searchUi"+index+"' style='display:block;'><input id='searchInput"+index+"' onclick='javascript:toggleUiVisible('"+index+"')' placeholder='🔎 Search' style='background-color:lightgray;outline:none;padding: 15px;width:100%;margin:5px;border:0px;-moz-border-radius:10px;-webkit-border-radius:10px;border-radius:10px;font:20px Calibri;' onkeyup='javascript:filter('"+index+"')'><div id='recordList"+index+"' style='background-color:lightgray;width:100%;margin:5px;-moz-border-radius:10px;-webkit-border-radius:10px;border-radius:10px;'></div></div>";}
else{return '';}
}
function toggleUiVisible(index){
if(showSearchUi[index]==undefined){
showSearchUi[index]=true;}
if(showSearchUi[index]==true){
document.getElementById('recordList'+index).innerHTML=recordToSearch[index];
showSearchUi[index]=false;
document.getElementById('recordList'+index).style.display='block';}else{
showSearchUi[index]=true;
document.getElementById('recordList'+index).style.display='none';}
}
var recordItem=[];
var recordToSearch=[];
function setRecordToSearch(records,index){
recordToSearch[index]='';
for(var i=0;i<records.length;i++){
recordItem[index]=records[i].split('^*^');
recordToSearch[index]=recordToSearch[index]+"<div class='onSearchHover' style='cursor:pointer;padding:15px 12px;font:20px Calibri;' onclick='javascript:{document.getElementById('searchInput"+index+"').value='"+recordItem[index][0].trim()+"'; toggleUiVisible("+index+");}' >"+recordItem[index][0].trim()+"</div>";
}
//toggleUiVisible(index);
}
var searchText=[];
var list=[];
function filter(index){
searchText[index]=document.getElementById('searchInput'+index).value.toLowerCase();
list[index]=(document.getElementById('recordList'+index)).getElementsByTagName('div');
for(var i=0;i<list[index].length;i++){
if((list[index][i].innerHTML.toLowerCase()).indexOf(searchText[index])>-1){
list[index][i].style.display='';
}
else{
list[index][i].style.display='none';}
}
}