<script language="JavaScript">
<!--
var LOC = 0;
var TITLE = 1;
var KEYWORDS = 2;
var DESCRIPTION = 3;
var database = new Array();
function addEntry(_l,_t,_k,_d) {
var _next = database.length?database.length:0;
database[_next] = new Array();
database[_next][LOC]=_l;
database[_next][TITLE]=_t;
database[_next][KEYWORDS]=_k;
database[_next][DESCRIPTION]=_d;
}
addEntry("your_1_page.htm","Your First Page Title", "keywords for first file go here separated by spaces", "First page description here!");
addEntry("your_2_page.htm","Your Second Page Title","keywords for second file go here separated by spaces","Second page description here!");
addEntry("your_3_page.htm","Your Third Page Title", "keywords for third file go here separated by spaces", "Third page description here!");
addEntry("your_4_page.htm","Your Fourth Page Title","keywords for Fourth file go here separated by spaces","Fourth page description here!");

var menu = new Array();
function addMenu(_i) {
//alert(_i);
var _next = menu.length?menu.length:0;
menu[_next] = new Array();
menu[_next][LOC]=database[_i][LOC];
menu[_next][TITLE]=database[_i][TITLE];
menu[_next][KEYWORDS]=database[_i][KEYWORDS];
menu[_next][DESCRIPTION]=database[_i][DESCRIPTION];
}
// this function takes these arguments
// 1> pattern to search for - deliminated by spaces.
// 2> true for OR
// 3> true for AND
// 4> true for EXACT
// return value is the index found or -1 if none found
function findThis(_searchfor,_or,_and,_exact) {
var S = _searchfor.split(" ");
for(var i=0;i<database.length;i++) {
if(_or) {
for (var j=0;j<S.length;j++) {
if (database[i][KEYWORDS].indexOf(S[j]) != -1) {
addMenu(i);
}
}
} else if(_and) {
// AND
var count=0;
for (var j=0;j<S.length;j++) {
if (database[i][KEYWORDS].indexOf(S[j]) != -1) {
count++;
}
}
//alert(count+"\n"+S.length);
if (count==S.length) {
addMenu (i);
}
} else if (_exact) {
//alert("["+_searchfor+"]\n["+database[i][DESCRIPTION]+"]")
if (database[i][KEYWORDS].indexOf(_searchfor) != -1) {
addMenu(i);
}
}
}
return (-1);
}


// this function ENTRY
// is called when the new search is requested.
function entry() {
if ((document.entryform.keyword.value.length < 4) || (document.entryform.keyword.value == " ")) {
alert('Inserisci una parola di almento quattro lettere\n');
return false;
}
and_search = (document.entryform.and_or.selectedIndex == 0?"and":"or");
if (document.entryform.and_or.selectedIndex == 2)
and_search = "exact";
location.href = location.pathname + "?"+ escape(document.entryform.keyword.value) + (and_search != "or"?"&"+and_search:"");
return false;
}

var string="";
var and_search="";
function parseParms() {
var _l1 = document.location.toString().split("?");
var _l2 = "";
var _l3 = "";
if (_l1.length>=1)
_l2 = _l1[1];
if (_l2 && _l2.length>0) {
if (_l2.indexOf("&") != -1) {
_l3 = _l2.split("&")[1];
_l2 = _l2.split("&")[0];
}
}
string = unescape(_l2 || "");
and_search= unescape(_l3 || "or");
}
parseParms();
if (string && string != "") findThis(string,and_search=="or",and_search=="and" ,and_search=="exact");

var _a = '';
_a += '<form name="entryform" onSubmit="return entry()">';
_a += '<center>
';
_a += '<input type="text" size=20 name="keyword" value="'+string+'"> ';
_a += '<input type="button" value="Cerca" onClick="entry()">[img]../vuoto.gif[/img]';
_a += '<select name="and_or" size=1>';
_a += '<option'+(and_search=="and"?" selected":"")+' selected>Trova tutte le parole';
_a += '<option'+(and_search=="or"?" selected":"")+'>Trova almeno una delle parole';
_a += '<option'+(and_search=="exact"?" selected":"")+'>Trova tutte le parole nell\'ordine';
_a += '</select></center>';
_a += '</form>
';
document.write(_a);
if (location.search.length > 1)
document.write('<font face=Arial size=2>Risultati della ricerca:</font>
<hr>
\n');

for (n=0; n<menu.length; n++) {
var _a = '';
_a += '<font face=Arial size=2 color=#FF6600>'+menu[n][TITLE]+'</font>
<font face=Arial size=2>';
_a += menu[n][DESCRIPTION]+'
</font>

';
document.write(_a);
}
if ((menu.length == 0) && (location.search.length > 1))
document.write('Per "'+string+'" non è stato trovato alcun risultato!\n');
// -->

</script>