﻿/*
   JavaScript for Search bar on each page.
*/

var item = new Array();

/*  Just enter as many additional pages as you want to search, then fill in the additional listings for each page.*/

// "Page Name","path","Page Title","Many,Key,Words","Descriptive Comments"

c=0; item[c]=new Array("index.html","","Home Page","index,main,start,home,front,welcome,founded,purpose,object","Reading Garden Club Home Page");
c++; item[c]=new Array("about.html","","About Us","about,mission,information,executive board, board,committees","Detailed information about the Reading Garden Club mission and committees.");
c++; item[c]=new Array("calendar.html","","Calendar page","meetings,meeting,board meeting,general meeting","Calendar listing of RGC activities and meetings.");
c++; item[c]=new Array("photos.html","","Photos Page","photos,club members","Photos slideshow of RGC members in action.");
c++; item[c]=new Array("newsletter.html","","Newsletter Page","monthly newsletters, newsletters","The monthly newsletters of the Reading GFarden Club.");
c++; item[c]=new Array("contact.html","","Contact Page","contact,email,who,membership,adopt-an-island","How to contact Reading Garden Club for more information.");
c++; item[c]=new Array("hort.html","","Horticulture Page","link,links,horticulture,questions,plants","Horticulture links and places to get answers to your gardening questions.");
c++; item[c]=new Array("awards.html","","Awards Page","awards,GCFM,Garden Club Federation of Massachusetts,Library,Celebration,celebration garden","Gardening Awards won by the Reading Garden Club.");
c++; item[c]=new Array("aai.html","","Adopt-an-Island Page","Adopt-an-Island,adopt,island,Town,sites","Information about the RGC's Adopt-an-Island program in the Town of Reading.");
c++; item[c]=new Array("hospice.html","","Hospice Page","hospice,Sawtelle,Sawtell Hospice House,Janice Hart,Hart,Janice","Information about the gardens at the Sawtelle Hospice house.");
c++; item[c]=new Array("tavern.html","","Parker Tavern Page","parker,tavern,parker tavern,holiday,open house","Information about the gardens at the Parker Tavern in Reading.");


/* page="<html><head><title>Search Results</title></head><body bgcolor='white'><center><table border=0 cellspacing=10 width=50% color=green>"; */
page="<html><head><title>Search Results</title></head><body bgcolor='white'><center><table border=0 cellspacing=10 width=50% color=green>";



function search(frm) {
win = window.open("","","scrollbars");
win.document.write(page);
/* win.moveTo(0,0); */
win.document.write("Search Results - please click on link to go to page."+"<br /><br /><br />");
txt = frm.srchval.value.split(" ");
fnd = new Array(); total=0;
for (i = 0; i < item.length; i++) {
fnd[i] = 0; order = new Array(0, 4, 2, 3);
for (j = 0; j < order.length; j++)
for (k = 0; k < txt.length; k++)
if (item[i][order[j]].toLowerCase().indexOf(txt[k]) > -1 && txt[k] != "")
fnd[i] += (j+1);
}
for (i = 0; i < fnd.length; i++) {
n = 0; w = -1;
for (j = 0;j < fnd.length; j++)
if (fnd[j] > n) { n = fnd[j]; w = j; };
if (w > -1) total += show(w, win, n);
fnd[w] = 0;
}
win.document.write("</table><br />Total found: "+total+"<br /></body></html>");

win.document.close();
}
function show(which,wind,num) {
link = item[which][1] + item[which][0]; 
line = "<tr><td><a href='"+link+"'>"+item[which][2]+"</a> Score: "+num+"<br>";
alert(line);
line += item[which][4] + "<br>"+link+"</td><br /></tr>";
wind.document.write(line);
return 1;
}



