
 var query = "";


 var INPUTFRAME  = parent.frames['Suche'];
 var OUTPUTFRAME = parent.frames['Anzeige'];


 var INPUT  = INPUTFRAME.document;
 var OUTPUT = OUTPUTFRAME.document;



function noumlaut( str )
{
	var l = 0; 		// Laenge des Strings
	var i = 0; 		// Index im Strings
	var newstr = ""; 	// Rueckgabestring
	var a = "";		// aktuelles Zeichen

	l = str.length;
	for (i=0; i<l;i++)
	{

		// i-tes Zeichen gegebfalls aendern
		a = str.charAt(i);

		// ISO 8859-1 Entities
		if ( a == "ä") { a = "&auml;" };
		if ( a == "ö") { a = "&ouml;" };
		if ( a == "ü") { a = "&uuml;" };
		if ( a == "Ä") { a = "&Auml;" };
		if ( a == "Ö") { a = "&Ouml;" };
		if ( a == "Ü") { a = "&Uuml;" };
		if ( a == "ß") { a = "&szlig;" };
		
		// Neuen String zusammensetzen
		newstr = newstr + a ;
	}
	
	return newstr;
}


 function found( str )
 {

	
	 var isfound = false;
	 var s = "";
	 var q = "";
	
	
	 s = str.toLowerCase();	
	 q = query.toLowerCase();

	 q = noumlaut( q );

	
	 s = " " + s + " ";	

	
	
	 isfound = ( s.indexOf( q ) > -1 ) 

	 return( isfound );
}


function HTMLHeader()
{
	with ( OUTPUT )
	{
		writeln("<head>");
		writeln("<title>");
		writeln("</title>");		writeln("<LINK href=scripts/fabi.css type=text/css rel=STYLESHEET>");
		writeln("</head>");
	}
}


function HTMLOpenBody()
{
	with ( OUTPUT )
	{
	write("<BODY aLink=#000000 bgColor=#EDF5EB leftMargin=5 link=#000000 text=#000000 vlink=#000000 class=body>");
	writeln("<TABLE cellSpacing=0 cellPadding=0 width=580 border=0>");
	writeln("<TR>");
	writeln("<TD width=0 height=5><IMG height=5 src=pictures/empty.gif width=0></TD>");
	writeln("<TD width=395 height=5><IMG height=5 src=pictures/empty.gif width=395></TD>");
	writeln("<TD width=20 height=5><IMG height=5 src=pictures/empty.gif width=20></TD>");
	writeln("</TR>");
	writeln("<TR>");
	writeln("<TD width=0 height=5><IMG height=5 src=pictures/empty.gif width=0></TD>");
	writeln("<TD vAlign=top>");
	writeln("<TABLE cellSpacing=0 cellPadding=0 width=550 border=0>");
	writeln("<TR>");
	writeln("<TD width=1 bgColor=#2B4A21><IMG height=1 src=/pictures/empty.gif width=1></TD>");
	writeln("<TD class=text1 bgColor=#2B4A21 height=15> &nbsp; RESULTADOS DE LA BUSQUEDA</TD>");
	writeln("<TD class=headline bgColor=#2B4A21 height=15 align=right><img border=0 src=pictures/aktionsfeld_balken_blau.gif width=171 height=17></TD>");
	writeln("<TD width=1 bgColor=#2B4A21><IMG height=1 src=pictures/empty.gif width=1></TD>");
	writeln("</TR>");
	writeln("<TR>");
	writeln("<TD width=1 bgColor=#2B4A21><IMG height=1 src=pictures/empty.gif width=1></TD>");
	writeln("<TD width=407 bgcolor=#FFFFFF colspan=2>");
	writeln("<TABLE cellSpacing=0 cellPadding=0 width=450 align=center border=0 class=text>");
	writeln("<tr>");
	writeln("<TD><IMG border=0 height=1 hspace=0 src=pictures/pixel-trans.gif width=78></TD>");
	writeln("</tr>");
	writeln("<tr class=text>");
	writeln("<TD class=text align=left><p align=left>");
	  
		
	}
}


function HTMLCloseBody()
{
	with ( OUTPUT )
	{
				writeln("</p></TD></tr><tr><TD class=text vAlign=middle align=center></TD>");
		writeln("</tr></TABLE><BR></TD><TD width=1 bgColor=#2B4A21><IMG height=1 src=pictures/empty.gif width=1></TD></TR>");
		writeln("<TR><TD width=1 bgColor=#2B4A21><IMG height=1 src=pictures/empty.gif width=1></TD><TD width=407 bgColor=#2B4A21 height=1 colspan=2>");
		writeln("<IMG height=1 src=pictures/empty.gif width=1></TD><TD width=1 bgColor=#2B4A21><IMG height=1 src=pictures/empty.gif width=1></TD></TR>");
		writeln("<TR><TD colSpan=4 width=410><IMG height=1 alt= src=pictures/empty.gif width=363 border=0> </TD></TR></TABLE></TD><TD width=20 height=5>");
		writeln("<IMG height=5 src=pictures/empty.gif width=20><BR><BR><BR></TD></TR></TABLE>");		writeln("</body>");
	}
}




function HTMLOpenFont()
{
	with ( OUTPUT )
	{
		with( INPUT.QueryForm )
		{
		 write("<font" );
		

		 if (font_face.value)
		  write(" face=\""+font_face.value+"\"");
		  

		 if (font_size.value)
		  write(" size=\""+font_size.value+"\"");

		writeln(">" );
		}  
		
	}
}


function HTMLCloseFont()
{
	with ( OUTPUT )
	{
		writeln("</font>");
	}
}





function ListSearch()
{

	var count = 0;

	query = INPUT.QueryForm.query.value;

	with ( OUTPUT )
	{
		open();
		writeln("<html>");

		HTMLHeader();
		HTMLOpenBody();
		HTMLOpenFont();
		              
		writeln("<br><b>&nbsp;&nbsp;&nbsp;Buscar: ", query, "</b>" );
		
		writeln("<ol class=text>");
		
		for (var i=1 ; i<Entry.length; i++)
		{

			if ( found( Entry[i].Title )
			||   found( Entry[i].Keywords )
			||   found( Entry[i].Description )
			   ) 
			{
				writeln("<li><p>");
				writeln( Entry[i].Format() );
				writeln("</p></li>");
				count++;
			}
		}
   		writeln("</ol>");


		if ( count == 0 )
	   	{
			writeln("<p>&nbsp;&nbsp;&nbsp;No ha sido encontrado ningun dato");
		}

		writeln("<p><b>&nbsp;&nbsp;&nbsp;La busqueda ha terminado</b><br>&nbsp;&nbsp;&nbsp;&copy; Almanzora 1997-2001" );		
		HTMLCloseFont();
						
		HTMLCloseBody();
		writeln('</html>');
		close();
   	}
}


function Validator()
{



	if ( INPUT.QueryForm.query.value.length < 3 )
	{
		alert( "Hay que insertar mas de 2 digitos" );
		INPUT.QueryForm.query.focus();
	}
	else
	{
		ListSearch();
	}
	
}


function QueryEnter()
{
	Validator();
	return (false);
}



function Help( url )
{
	OUTPUT.location = url;
}




 function Format() 
 {

	with( this )  // mit dem Element tue das Folgende
	{

	// Deklaration des RueckgabeStrings
	// (enthaelt die HTML-formatierte Ausgabe des Eintrages)
	var e = "";

	// 1. Zeile, der Titel und Hyperlink (bold)	

	e = e + "<a href=\"" + this.Url + "\" target=Anzeige>";
	e = e + "<b>" + Title + "</b>\n";
	e = e + "</a>\n";
	
	// 2. Zeile, Beschreibung (kursiv), wenn vorhanden
	if ( Description && ( Description != "-" ))
		
	 e = e + "<br>" + Description + "\n";
	 
	}
	return(e);
}



function Element(Url,Title,Description,Keywords) 
{

	// Eigenschaften
	this.Url           = Url;
	this.Title         = Title;
	this.Description   = Description;
	this.Keywords      = Keywords;
	
	// Methoden
	this.Format        = Format;
}

Entry    = new Array();



