//BUSCADOR DE EL CODIGO
//Autor: Iván Nieto Pérez
//Este script y otros muchos pueden
//descarse on-line de forma gratuita
//en El Código: www.elcodigo.net
//Version 2, 31/07/2000

caracter = new Object(5); 
caracter[0] = 'á';
caracter[1] = 'é';
caracter[2] = 'í';
caracter[3] = 'ó';
caracter[4] = 'ú';

caracter_nuevo = new Object(5);
caracter_nuevo[0] = 'a';
caracter_nuevo[1] = 'e';
caracter_nuevo[2] = 'i';
caracter_nuevo[3] = 'o';
caracter_nuevo[4] = 'u';

//NOTA: LA BASE DE DATOS DE ESTE EJEMPLO HA SIDO REDUCIDA A 10 PAGINAS
//CADA PAGINA ESTA REPRESENTADA POR UNA LINEA CON LA SIGUIENTE ESTRUCTURA
//	,"ruta\/nombre fichero (sin extension);titulo;descripcion;palabras clave separadas por comas"
//
//PUEDES AMPLIAR ESTA BASE DE DATOS AL NUMERO DE PAGINAS QUE DESEES AÑADIENDO
//MÁS LINEAS DETRAS DE LA MARCA "//[INTRODUCE AQUI NUEVAS LINEAS]"
//Significado de los datos:
//	ruta			>>	ruta fisica al fichero
//	nombre fichero		>>	nombre del fichero, sin incluir la extension (que debe ser siempre .html)
//	titulo			>>	titulo que aparecera en la pagina de resultados y describe al fichero
//	descripcion		>>	descripcion del documento que aparecera en la pagina de resultados
//	palabras clave		>>	palabras clave del documento
var BaseDatos = new Array(
//LA PRIMERA LINEA NO LLEVA COMA DELANTE
"mapa/Calafell_pueblo;AIRE, DE L'"
,"mapa/Segur_de_Calafell;ALASKA"
,"mapa/Segur_de_Calafell;ALBANIA"
,"mapa/Calafell_playa;ALCALDE ROMEU, PLAÇA"
,"mapa/Segur_de_Dalt;ALCANAR"
,"mapa/Segur_de_Calafell;ALEMANYA, AVDA."
,"mapa/Masia_de_la_Font;ALFONS MAÑE"
,"mapa/Calafell_Park;ALP"
,"mapa/Bellamar;ALTAFULLA"
,"mapa/Mas_Romeu;AMADEU VIVES"
,"mapa/Segur_de_Calafell;AMERICA, PLAÇA"
,"mapa/Segur_de_Dalt;AMETLLA DE MAR"
,"mapa/Segur_de_Calafell;AMETLLER"
,"mapa/Calafell_pueblo;ANDALUSIA"
,"mapa/Segur_de_Calafell;ANDORRA"
,"mapa/Segur_de_Calafell;ANETO"
,"mapa/Calafell_playa;ANGEL GUIMERA"
,"mapa/Segur_de_Calafell;ANGLATERRA, AVDA."
,"mapa/Segur_de_Calafell;ANTILLES"
,"mapa/Segur_de_Calafell_playa;ANTONI ALMAZOR"
,"mapa/Segur_de_Calafell;ANTONI GAUDI"
,"mapa/Calafell_Park;ARBOÇ"
,"mapa/Segur_de_Dalt;ARC DE BERA"
,"mapa/Segur_de_Calafell;ARGENTINA, AVDA."
,"mapa/Segur_de_Calafell;ATLANTIC"
,"mapa/Segur_de_Calafell;AUSTRIA"
,"mapa/Calafell_Park;BAGA"
,"mapa/Calafell_pueblo;BAGES"
,"mapa/Calafell_pueblo;BAIX PENEDES"
,"mapa/Segur_de_Calafell_playa;BAIXADOR"
,"mapa/Segur_de_Calafell_playa;BAIXADOR, PASSATGE"
,"mapa/Segur_de_Calafell_playa;BAIXADOR, PLAÇA"
,"mapa/Prat_de_Calafell;BARCA"
,"mapa/Segur_de_Calafell;BARCELONA"
,"mapa/Bellamar;BARCELONA, AVDA."
,"mapa/Segur_de_Calafell;BARCELONA, CTRA."
,"mapa/Calafell_Residencial;BARCELONES"
,"mapa/Calafell_pueblo;BARCELONETA"
,"mapa/Segur_de_Calafell;BELGICA"
,"mapa/Calafell_Residencial;BELLAVISTA"
,"mapa/Calafell_Residencial;BERGUEDA"
,"mapa/Segur_de_Calafell_playa;BESOS"
,"mapa/Calafell_pueblo;BISBE CATALÀ"
,"mapa/Las_Villas;BOI"
,"mapa/Segur_de_Calafell;BOLIVIA"
,"mapa/Mas_Mel;BONAVENTURA CARLES ARIBAU"
,"mapa/Segur_de_Calafell;BRASIL"
,"mapa/Bellamar;BRUC"
,"mapa/Segur_de_Calafell;BULGARIA"
,";CADAQUES"
,"mapa/Calafell_Park;CADI, DEL"
,"mapa/Calafell_pueblo;CAIGUTS"
,";CAL PEROTET, AVDA."
,"mapa/Segur_de_Calafell;CAMI ALT"
,"mapa/Segur_de_Calafell;CAN PAPIOL"
,"mapa/Segur_de_Calafell;CANADA"
,";CANIGO"
,"mapa/Segur_de_Calafell;CANO EL, PLAÇA"
,"mapa/Segur_de_Calafell;CANTABRIC"
,";CARLES BARRAL"
,"mapa/Calafell_playa;CARME"
,"mapa/Segur_de_Calafell_playa;CARMEN DESVALLS"
,"mapa/Calafell_playa;CARRERADA D'EN RALET"
,"mapa/Calafell_pueblo;CASTELL, PASSATGE"
,";CASTELLANA"
,"mapa/Segur_de_Calafell;CATALUNYA, AVDA."
,"mapa/Calafell_pueblo;CATALUNYA, PLAÇA"
,";CAU FERRAT"
,"mapa/Calafell_Park;CENTRAL, AVDA."
,"mapa/Segur_de_Calafell;CEP"
,"mapa/Calafell_Residencial;CERDANYA"
,"mapa/Segur_de_Calafell;CIRCUMVAL.LACIO"
,"mapa/Valldemar;CLAVELL"
,"mapa/Calafell_pueblo;CLOS DEL BECO"
,"mapa/Calafell_pueblo;CLOS DEL RECTORET"
,"mapa/Segur_de_Calafell;COLOM, PLAÇA"
,"mapa/Segur_de_Calafell;COLOMBIA"
,"mapa/Segur_de_Calafell;COMPTE GOMEZ ORBANEJA"
,"mapa/Segur_de_Calafell;COMTª CASTILLO DE LA MOTA"
,"mapa/Segur_de_Calafell;CONSELL"
,"mapa/Calafell_pueblo;CONSTITUCIO, PLAÇA"
,"mapa/Calafell_pueblo;COSME MAINE, PLAÇA"
,";COSSETANIA, AV."
,"mapa/Calafell_playa;COSTA DAURADA, RAMBLA"
,"mapa/Segur_de_Calafell;COSTA RICA"
,";COSTES DEL GARRAF"
,"mapa/Segur_de_Calafell;CTE GOMEZ DE ORBANEJA, AV"
,"mapa/Bellamar;CUNIT"
,"mapa/Segur_de_Calafell;CUSPIDE"
,"mapa/Calafell_playa;D'EN RALET, CARRERADA"
,"mapa/Valldemar;DALIA"
,"mapa/Segur_de_Calafell_playa;DAVID DE MAS"
,"mapa/Calafell_pueblo;DE LES ERES, PLAÇA"
,";DELTA DE L'EBRE"
,";DEVESA DE GIRONA"
,"mapa/Segur_de_Calafell;DINAMARCA"
,"mapa/Calafell_playa;DOCTOR DACHS"
,"mapa/Segur_de_Calafell;DOCTOR TRUETA"
,"mapa/Masia_de_la_Font;DOCTOR VANDELLOS"
,"mapa/Calafell_pueblo;DOCTOR VANDELLOS"
,"mapa/Segur_de_Calafell_playa;DUERO"
,"mapa/Bellamar;DUESAIGÜES"
,"mapa/Segur_de_Calafell;EBRE"
,";EDUARD TOLDRA"
,"mapa/Segur_de_Calafell;ELCANO, PLAÇA"
,"mapa/Segur_de_Calafell_playa;EMIGDIO RODRIGUEZ PITA"
,";EMPURIES"
,";ENRIC GRANADOS"
,";ENRIC MORERA"
,"mapa/Segur_de_Calafell;EQUADOR"
,"mapa/Calafell_pueblo;ERES LES, PLAÇA"
,"mapa/Segur_de_Calafell;ERMITA, TRAVESSIA"
,"mapa/Segur_de_Calafell;ESBARZER"
,"mapa/Calafell_pueblo;ESCARNOSA, CAMI"
,"mapa/Calafell_pueblo;ESGLESIA"
,"mapa/Segur_de_Calafell;ESPANYA, AVDA."
,"mapa/Segur_de_Calafell;ESPANYA, PLAÇA"
,"mapa/Bellamar;ESPLUGUES"
,";ESPOT"
,";EST"
,"mapa/Calafell_playa;ESTACIO, CARRETERA"
,"mapa/Calafell_playa;ESTACIO, PLAÇA"
,"mapa/Calafell_playa;ESTANY"
,"mapa/Segur_de_Calafell;ESTATS UNITS"
,"mapa/Segur_de_Calafell;ESTONIA"
,"mapa/Segur_de_Calafell;FARIGOLA"
,"mapa/Segur_de_Calafell;FERRADURA"
,";FERRAN SOR"
,"mapa/Segur_de_Calafell;FERROCARRIL, PASSATGE"
,"mapa/Segur_de_Calafell;FINLANDIA"
,"mapa/Bellamar;FOIX"
,";FORANELL"
,"mapa/Calafell_playa;FRANCESC BONJOCH"
,"mapa/Segur_de_Calafell;FRANÇA, AVDA."
,";FREDERIC MOMPOU"
,";GANDESA"
,"mapa/Prat_de_Calafell;GARBI"
,"mapa/Prat_de_Calafell;GARBI, PASSATGE"
,"mapa/Valldemar;GARDENIA"
,"mapa/Segur_de_Calafell;GARONA"
,";GARRIGUES"
,"mapa/Calafell_Residencial;GARROTXA"
,"mapa/Segur_de_Calafell;GAUDI"
,"mapa/Calafell_pueblo;GENERALITAT, AVDA."
,"mapa/Valldemar;GESSAMI"
,"mapa/Valldemar;GINESTA"
,"mapa/Bellamar;GIRONA"
,";GIRONES"
,"mapa/Calafell_Residencial;GIRONES"
,"mapa/Valldemar;GLADIOL"
,"mapa/Segur_de_Calafell;GRECIA"
,"mapa/Segur_de_Calafell;GREGAL"
,"mapa/Segur_de_Calafell;GUADALQUIVIR"
,"mapa/Segur_de_Calafell;GUAIANES"
,"mapa/Segur_de_Calafell;GUATEMALA"
,"mapa/Segur_de_Calafell;HOLANDA"
,"mapa/Segur_de_Calafell;HONDURES"
,"mapa/Segur_de_Calafell;HONGRIA"
,"mapa/Bellamar;HORTA"
,"mapa/Valldemar;HORTENSIA"
,"mapa/Calafell_playa;IGUALADA"
,"mapa/Segur_de_Calafell;ILLES FILIPINES, AV."
,"mapa/Segur_de_Calafell;IRLANDA"
,";ISAAC ALBENIZ"
,"mapa/Segur_de_Calafell;ISLANDIA"
,"mapa/Segur_de_Calafell;ITALIA, AV."
,"mapa/Segur_de_Calafell;IUGOSLAVIA"
,"mapa/Calafell_playa;JACINT VERDAGUER"
,"mapa/Segur_de_Calafell;JARDI DE LA RABASSA"
,"mapa/Calafell_playa;JAUME JANE"
,"mapa/Calafell_pueblo;JAUME PALLARES"
,";JAUME RAFEL"
,"mapa/Calafell_pueblo;JESUS"
," mapa/Segur_de_Calafell;JOAN MARAGALL"
,"mapa/Calafell_pueblo;JOAN MIRO"
,"mapa/Calafell_pueblo;JOAN NIN I ROMEU"
,";JOAN SALVAT-PAPASSEIT"
,";JOANOT MARTORELL"
,";JOAQUIM DOMENECH CASTEL"
,";JOAQUIN RODRIGO"
,"mapa/Segur_de_Calafell;JORDI GARI"
,"mapa/Calafell_pueblo;JOSEP BARGES I BARBA"
,";JOSEP CARNER"
,";JOSEP ITURBI"
,";JOSEP LLUIS DE LA ROSA"
,";mapa/Segur_de_Calafell JOSEP MARIA JUNCADELLA"
,";JOSEP PLA"
,";JOSEP VICENÇ FOIX"
,";JULI GARRETA"
,"mapa/Segur_de_Calafell;LITUANIA, AVDA."
,"mapa/Segur_de_Calafell;LITUANIA, PASSATGE"
,";LLEBEIG"
,"mapa/Bellamar;LLEIDA, AVDA."
,"mapa/Calafell_Park;LLESSUI"
,"mapa/Masia_de_la_Font;LLEVADORA MARIA VIVES"
,";LLEVANT"
,"mapa/Valldemar;LLIRI"
,"mapa/Segur_de_Calafell;LLOBREGAT"
,";LLORENÇ VILLALONGA"
,"mapa/Segur_playa;LLUIS COMPANYS"
,";LLUIS MILLET"
,"mapa/Segur_playa;LOIRA"
,"mapa/Segur_de_Calafell;LUXEMBURG"
,"mapa/Mas_Romeu;MAESTRO SERRANO"
,"mapa/Calafell_pueblo;MAJOR, CARRER"
,"mapa/Calafell_pueblo;MAJOR, PLAÇA"
,"mapa/Calafell_pueblo;MAJOR, PROLONGACIO"
,"mapa/Calafell_playa;MALLORCA"
,"mapa/Segur_de_Dalt;MALLORCA, PASSATGE"
,"mapa/Lestany;MANUEL BENET ORTIZ"
,"mapa/Mas_Romeu;MANUEL DE FALLA"
,"mapa/Calafell_pueblo;MANUEL SOLER"
,"mapa/Segur_de_Calafell;MANZANARES"
,"mapa/Calafell_pueblo;MAR"
,"mapa/Segur_de_Dalt;MARCA HISPANICA, AVDA."
,"mapa/Segur_de_Dalt;MARCA HISPANICA, PTGE."
," mapa/Calafell_pueblo;MARE DE DEU DE LA COVA"
,"mapa/Masia_de_la_Font;MARESME"
,"mapa/Valldemar;MARGARIDA"
,"mapa/Segur_de_Calafell;MARIA DESVALLS"
,"mapa/Calafell_pueblo;MARIANO SOLER, PLAÇA"
,";MARINADA"
,"mapa/Segur_de_Calafell;MARITIM, PASSEIG"
,"mapa/Calafell_pueblo;MARQUES DE SAMA"
,"mapa/Segur_de_Calafell;MARTA MORAGAS"
,"mapa/Calafell_pueblo;MARTIRS"
,"mapa/Calafell_pueblo;MAS D'EN VIVES, CAMI"
,"mapa/Mas_romeu;MAS ROMEU, CAMI"
,"mapa/Segur_de_Calafell;MEDITERRANI, AVDA."
,"mapa/Segur_de_Calafell;MEDITERRANI, PLAÇA"
,"mapa/Segur_de_Dalt;MEDOL"
,"mapa/Calafell_paya;MERCAT, PÇA."
,"mapa/Lestany;MERCE RODOREDA"
,"mapa/Mas_Mel;MESTRAL"
,"mapa/Segur_de_Calafell;MEXIC"
,"mapa/Mas_Mel;MIGJORN"
,"mapa/Mas_Mel;MILA I FONTANALS"
,"mapa/Segur_de_Dalt;MIRADOR DE S. MIQUEL, AV."
,";MIRAMAR"
,"mapa/Segur_de_Calafell;MIÑO"
,"mapa/Prat_de_Calafell;MOLI"
,"mapa/Segur_de_Dalt;MOLINA"
,"mapa/Segur_de_Calafell;MONACO"
,"mapa/Calafell_Park;MONTPAO"
,"mapa/Calafell_playa;MONTSERRAT"
,"mapa/Calafell_Residencial;MONTSIA"
,"mapa/Calafel_playa;MONTURIOL"
,"mapa/Calafell_playa;MOSSEN JAUME SOLER, AV"
,"mapa/Valldemar;NARCIS"
,"mapa/Segur_de_Calafell;NERVION"
,"mapa/Segur_de_Calafell;NICARAGUA"
,"mapa/Calafell_Residencial;NOGUERA"
,"mapa/Mas_Mel;NORD"
,"mapa/Segur_de_Calafell;NORUEGA"
,"mapa/Calafell_playa;NOU"
,"mapa/Segur_de_Calafell;NURIA"
,"mapa/Segur_de_Calafell;OLIVERA"
,"mapa/Mas_Mel;ORATGELL"
,"mapa/Valldemar;ORQUIDIA"
,"mapa/Segur_de_Calafell;PABLO NERUDA"
,"mapa/Segur_de_Calafell;PABLO PICASSO"
,"mapa/Segur_de_Calafell;PACIFIC"
,";PAGESIA CATALANA"
,"mapa/Segur_de_Calafell;PALESTINA"
,"mapa/Segur_de_Calafell;PANAMA"
,"mapa/Segur_de_Calafell;PARAGUAI"
,"mapa/Segur_de_Calafell;PATAGONIA, AVDA."
,"mapa/Segur_de_Calafell;PATAGONIA, PASSATGE"
,"mapa/Segur_de_Dalt;PAU"
,"mapa/Segur_de_Calafell;PAU CASALS, PLAÇA"
,"mapa/Segur_de_Dalt;PEDRERA"
,"mapa/Calafell_pueblo;PENYES"
,"mapa/Mas Romeu;PEP VENTURA"
,"mapa/Segur_de_Calafell;PERU"
,"mapa/Prat_de_Calafell;PESCADOR"
,"mapa/Valldemar;PETUNIA"
,"mapa/Segur_de_Calafell;PINAR"
,"mapa/Calafell_playa;PINTOR MIR"
,"mapa/Segur_de_Calafell;PIRINEU"
,"mapa/Segur_de_Dalt;PISCINA"
,"mapa/Segur_de_Calafell;PISUERGA"
,"mapa/Segur_de_Calafell;PO"
,"mapa/Segur_de_Calafell;POLONIA"
,";POMPEU FABRA"
,"mapa/Segur_de_Calafell;PORT MARITIM"
,"mapa/Segur_de_Calafell;PORTUGAL"
,"mapa/Calafell_pueblo;POU"
,"mapa/Segur_de_Calafell;PRAT DE LA RIBA"
,"mapa/Calafell_pueblo;PRINCIPAL"
,"mapa/Calafell_Residencial;PRIORAT"
,";PUIG DE BASSEGODA"
,"mapa/Calafell_playa;RAFAEL CASANOVA"
,"mapa/Segur_de_Calafell;RECTOR TRIADO"
,"mapa/Segur_de_Calafell;REPOS"
,"mapa/Segur_de_Calafell;RETOMB"
,"mapa/Calafell_Residencial;RIBAGORÇA"
,"mapa/Calafell_Residencial;RIBERA D'EBRE"
,"mapa/Segur_de_Dalt;RIBES DE FRESER"
,"mapa/Mas_Romeu;RICARDO LOZANO, PÇA."
,"mapa/Segur_de_Calafell;RIN"
,"mapa/Calafell_Residencial;RIPOLLES"
,"mapa/Segur_de_Calafell;ROINE"
,"mapa/Segur_de_Calafell;ROMANI"
,"mapa/Segur_de_Calafell;ROMANIA"
,"mapa/Valldemar;ROSA"
," mapa/Segur_de_Dalt;RUBI"
,"mapa/Mas_Romeu;RUPERTO CHAPI"
,"mapa/Segur_de_Calafell;SAL"
,";SALARDU"
,"mapa/Segur_de_Calafell;SALVADOR"
,"mapa/Lestany;SALVADOR ESPRIU"
,"mapa/Calafell_playa;SANATORI, CARRETERA"
,"mapa/Calafell_playa;SANT ANTONI, PASSATGE"
,"mapa/Calafell_pueblo;SANT JOAN"
,"mapa/Calafell_playa;SANT JOAN DE DEU, AVDA."
,"mapa/Segur_de_Calafell;SANT MIQUEL, RONDA"
,"mapa/Calafell_playa;SANT PERE"
,"mapa/Segur_de_Calafell;SANT RAFAEL"
,";SANT TOMAS"
,"mapa/Segur_de_Calafell;SANTA AGNES"
,";SANTA OLIVA"
,"mapa/Mas_Mel;SANTIAGO RUSIÑOL"
,"mapa/Calafell_Residencial;SEGARRA"
,"mapa/Calafell_Residencial;SEGRIA"
,"mapa/Segur_de_Calafell;SEGURA"
,"mapa/Segur_de_Calafell;SENA"
,"mapa/Mas_Mel;SERÈ"
,"mapa/Calafell_pueblo;SINIA, AVDA."
,"mapa/Calafell_pueblo;SIS DE DESEMBRE"
,"mapa/Calafell_pueblo;SOL"
,"mapa/Segur_de_Calafell;STA Mª DE MONTSERRAT, AV."
,"mapa/Segur_de_Dalt;STA Mª DE MONTSERRAT, AV."
,"mapa/Segur_de_Dalt;STA Mª DE MONTSERRAT, PG."
,"mapa/Mas_Mel;SUD"
,"mapa/Segur_de_Calafell;SUD-ESTONIA"
,"mapa/Segur_de_Calafell;SUECIA"
,"mapa/Segur_de_Calafell;SUISSA"
,";SURIA"
,"mapa/Segur_de_Calafell;TAJO"
,"mapa/Segur_de_Calafell;TAMESI"
,"mapa/Segur_de_Calafell;TARRAGONA"
,"mapa/Bellamar;TARRAGONA, AVDA."
,"mapa/Calafell_Residencial;TARRAGONES"
,";TAULL"
,"mapa/Calafell_Residencial;TERRA ALTA"
,";TERRA BAIXA"
,"mapa/Mas_Mel;TERRAL"
,"mapa/Segur_de_Dalt;TIBIDABO, AVDA."
,"mapa/Mas_Romeu;TOMAS BRETON"
,"mapa/Segur_de_Dalt;TORRE DELS ESCIPIONS, AV."
,"mapa/Calafell_pueblo;TORREDEMBARRA"
,"mapa/Calafell_pueblo;TORREDEMBARRA, CAMI"
,"mapa/Prat_de_Calafell;TRAMUNTANA"
,"mapa/Calafell_Park;TRANSFORMADOR"
,"mapa/Calafell_Park;TREMP"
,"mapa/Valldemar;TULIPA"
,"mapa/Segur_de_Calafell;TURQUIA"
,"mapa/Segur_de_Calafell;TXECOSLOVAQUIA"
,"mapa/Calafell_pueblo;UNIO, PASSEIG"
,"mapa/Segur_de_Calafell;UNIVERSITAT, RONDA"
,"mapa/Calafell_Residencial;URGELL"
,"mapa/Segur_de_Calafell;URUGUAI"
,";VALL D'ARAN"
," mapa/Segur_de_Dalt;VALLES"
,"mapa/Calafell_pueblo;VENDRELL, CAMI"
,"mapa/Calafell_pueblo;VENDRELL, CARRETERA"
,"mapa/Segur_de_Calafell;VENEÇUELA"
,"mapa/Calafell_pueblo;VENTURA GASSOL"
,";VICTOR ALARI"
,"mapa/Mas_Mel;VICTOR CATALA"
,"mapa/Calafell_Park;VIELLA"
,"mapa/Calafell_playa;VILAMAR"
,"mapa/Calafell_pueblo;VILLARROEL"
,"mapa/Calafell_pueblo;VINYA LLARGA, AVDA."
,"mapa/Valldemar;VIOLETA"
,"mapa/Segur_de_Calafell;VISTA ALEGRE"
,";VISTA ALEGRE, PASSATGE"
,"mapa/Segur_playa;VISTULA"
,"mapa/Prat_de_Calafell;XALOC"
,"mapa/Mas_Romeu;XAVIER MONTSALVATGE"
,"mapa/Segur_de_Dalt;XERTA"
,"mapa/Segur_de_Calafell;XILE"
,"mapa/Segur_de_Calafell;XIPRE"
,"mapa/Segur_playa;XUQUER"
)

var totales		//numero de entradas encontradas
var Pagina		//string que contendra la pagina a mostrar
var Entradas		//string que va guardando las entrdas encontradas
var clave1, clave2	//palabra a buscar

//obtiene longitud de la base de datos
var longitud = BaseDatos.length


function Buscaclave(FormBusqueda, desde) {
	//busca la palabra clave en el array de palabras clave
	//devuelve -1 si no hay coincidencias
	var index = -1

	//recorre el array en busca de la palabra clave (en cualquier parte)
	for (x = desde; x < longitud; x++) {
		if ( (BaseDatos[x].search(clave1) != -1) || (BaseDatos[x].search(clave2) != -1) ) {
			index = x
			break
		}
	}

	return index
}

function IniciaPagina(FormBusqueda) {
	//crea la pagina a visualizar y la muestra

	//cabecera y apertura cuerpo
	Pagina = 	'<html><head><meta HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">\n' +
			'<meta NAME="AUTHOR" CONTENT="Calafellviva.com"><title>Resultados de la busqueda</title>\n' +
			'</head>\n' +
			'<body\n>' +
			'<table border="0" width="100%" cellspacing="0" cellpadding="2"\n>' +
			'<tr><td width="11%" bgcolor="#CCE1F2" valign="top">Calafellviva.com</td>\n' +
			'<td width="69%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="20">\n' +
			'<tr><td width="100%"><h3 align="left">Resultados de la búsqueda</h3>\n'

	if (totales != 0)
		Pagina += '<p>Se han encontrado ' + totales + ' resultados que contienen la palabra  <font color="#FF0000"><strong>' + FormBusqueda.palabra.value + '</strong></font>:</p>\n'
	else
		Pagina += '<p>No se han encontrado resultados para la palabra <font color="#FF0000"><strong>' + FormBusqueda.palabra.value + '</strong></font></p>\n'
}

function TerminaPagina() {

	//final cuerpo
	Pagina +=	'<p>&nbsp;</p><hr width="75%" color="#0000FF">\n' +
			'<div align="center"><center><table border="0" width="397" cellspacing="8"\n>' +
			'<tr><td width="387" align="center" valign="top" colspan="2"><small>(c) 2000 - Calafellviva.com</small></td>\n' +
			'</tr></table></center></div></td></tr></table></td>\n' +
			'<td width="20%" valign="top" align="center"><font color="#0000FF" face="Courier"><small>\n' +
			'<strong>{ Buscador }</strong></small></font><p>&nbsp;</p>\n' +
			'<p>&nbsp; </p><p>&nbsp;</td></tr></table></body></html>\n'
}

function CreaEntradas(indice) {

	var CadenasEntrada

	//divide la cadena de resultados en subcadenas y escribe los resultados
	CadenasEntrada = BaseDatos[indice].split(";")
	Entradas += CadenasEntrada[1] + '----' + '<a href="' + CadenasEntrada[0] + '.html" target="_self">' + CadenasEntrada[0] + '</a></p>\n'
	}

function MuestraPagina(Pagina) {
	//muestra el contenido del display
	window.document.open()
	window.document.write(Pagina)
	window.document.close()
}
	
function IniciaBuscador(FormBusqueda) {
	
	//inicia variables globales
	desde = 0
	totales = 0
	Pagina = ""
	Entradas = ""
	
	//elimina acentos
	var palabra_sin = elimina_especiales(document.forms["FormularioBusqueda"].palabra.value);
	
	//obtiene la expresion regular para la busqueda (global e ignorando case)
	clave1 = new RegExp(document.forms["FormularioBusqueda"].palabra.value, "gi")
	clave2 = new RegExp(palabra_sin, "gi")

	//inicia variables locales
	var indice = -1
	
	//busca entrada de pagina que contenga la clave
	do {
		indice = Buscaclave(FormBusqueda, indice + 1)
		if (indice != -1) {
			CreaEntradas(indice)
			totales++
		} 
	} while (indice != -1)
	
	//escribe pagina de resultados
	IniciaPagina(FormBusqueda)
	Pagina += Entradas
	TerminaPagina()

	//abre una ventana y escribe los resultados
	MuestraPagina(Pagina)
}

//SUSTITUYE TODAS LAS OCURRENCIAS DE UN CARACTER UNA CADENA POR OTRO CARACTER
function sustituye_caracter(cadena, caracter, nuevo_caracter) {
	var longitud, indice; 
 	
  	longitud = cadena.length;
  	indice = cadena.indexOf(caracter);
  	while (indice != -1) {
     		cadena = cadena.substring(0, indice) + nuevo_caracter + cadena.substring(indice + 1, longitud + 1);
      		indice = cadena.indexOf(caracter, indice);
      	}

	return cadena;
}

//ELIMINA CARACTERES ESPECIALES
function elimina_especiales(cadena) {

	//llamar a sustituye caracter con cada campo y cada caracter
	for (x = 0; x < 8; x++) {
		cadena = sustituye_caracter(cadena, caracter[x], caracter_nuevo[x]);
   	}
	
	return cadena;
}