function info(name,link,info) {
 this.name=name;
 this.link=link;
 this.info=info;
}

var searchInfo=new Array();
searchInfo[0]=new info("El misterio de la conciencia y la brecha explicativa", "resumen/res_31a.htm"," JÖRG  ALEJANDRO  TELLKAMP. Filosofía de la Mente, NAGEL, Thomas, BLOCK, CHALMERS, Michael Tye, ROSENTHAL, DESCARTES, RYLE, CHURCHLAND.");
searchInfo[1]=new info("El programa de Roger Penrose contra el Dualismo", "resumen/res_31b.htm"," CARLOS  EDUARDO  MALDONADO. Filosofía de la mente, ciencias cognitivas, Penrose, teoría de los sistemas fundamentales, complejidad.");
searchInfo[2]=new info("Aborto: polarización y diálogo", "resumen/res_31c.htm"," ALFONSO  FLÓREZ  FLÓREZ");
searchInfo[3]=new info("La teodicea moderna y el problema de la inseguridad ontológica", "resumen/res_31d.htm"," LUIS  FERNANDO  CARDONA");
searchInfo[4]=new info("Conversación y reciprocidad. El otro imaginado", "resumen/res_31e.htm"," ANGELA  CALVO  DE  SAAVEDRA");
searchInfo[5]=new info("A propósito de la 'sensibilidad común' en Aristóteles", "resumen/res_31f.htm"," DIEGO  ANTONIO  PINEDA");
searchInfo[6]=new info("Es necesario filosofar: el Protréptico de Aristóteles", "resumen/res_31g.htm"," FABIO  RAMÍREZ  S.J.");

function find(formNum) {
	if(formNum==null)
		formNum=0;
	var yes=false, yesN=false, bold, boldN,found=0;
   	var out=parent.frames["right"];
 	status="Searching...";
 	var search=document.forms[formNum].searchInput.value,table; 
 	var searchFor=search.toUpperCase();
	if(searchFor.indexOf('"')!=-1)
		searchFor=" "+searchFor.substring(1,searchFor.lastIndexOf('"'))+" ";
	var score=new Array();
	var entry=new Array();
	var entryNum=0;
	var few=false;
	if(searchFor.length<3)
		few=true;
	if(!few) {
 	for(var i=0;i<searchInfo.length;i++) {
		var numFound=0;
    		if(searchInfo[i].info.toUpperCase().indexOf(searchFor)!=-1) {
                       	var text=searchInfo[i].info;
                        var loc=text.toUpperCase().indexOf(searchFor);
			bold=text.substring(0,loc);
			yes=true;
			while(loc!=-1) {
     				bold+="<b>";
     				bold+=text.substring(loc,loc+searchFor.length);
     				bold+="</b>";
                                			text=text.substring(loc+searchFor.length,text.length);
                               	 		loc=text.toUpperCase().indexOf(searchFor);
				if(loc!=-1)
					bold+=text.substring(0,loc);
				else
					bold+=text.substring(0,text.length);		
				numFound++;
			}
   		} else
			bold=searchInfo[i].info;
  			if(searchInfo[i].name.toUpperCase().indexOf(searchFor)!=-1) {
				yesN=true;
                        	var text=searchInfo[i].name;
                        	var loc=text.toUpperCase().indexOf(searchFor);
				boldN=text.substring(0,loc);
			while(loc!=-1) {
     				boldN+="<b>";
     				boldN+=text.substring(loc,loc+searchFor.length);
     				boldN+="</b>";
                               			text=text.substring(loc+searchFor.length,text.length);
                                			loc=text.toUpperCase().indexOf(searchFor);
				if(loc!=-1)
					boldN+=text.substring(0,loc);
				else
					boldN+=text.substring(0,text.length);	
				numFound++;	
			}
   		}
 		if(yes==false && yesN==true) { 
  			found++;
  			entry[entryNum]='<a href="'+searchInfo[i].link+'">'+boldN+'</a> -'+bold+'<br><i>'+searchInfo[i].link+'</i></tr></td>';
			score[entryNum]=numFound; 
			entryNum++;
  		}
 		if(yes==true) { 
  			found++;
  			if(yesN==false) { boldN=searchInfo[i].name;} 
  			entry[entryNum]='<a href="'+searchInfo[i].link+'">'+boldN+'</a>   -'+bold+'<br><i>'+searchInfo[i].link+'</i></tr></td>';
			score[entryNum]=numFound; 
			entryNum++;
  		}
		yes=false,yesN=false;
 	}
	var nums=new Array(),percent=new Array();
	var high=0,num=0;
	for(var i=0; i<found; i++) {
		if(score[i]>high) 
			high=score[i];
	}
	var percentEach=parseInt(100/high);
	do {
		for(var i=0; i<found; i++) { if(score[i]==high) {
			nums[num]=i;
			percent[num]=percentEach*high;
			num++;
		} }
		high--;
	} while(num<found);
		table="<script language=\"JavaScript\" src=\"searchoutput.js\"></script>";
		table+="<tr><td> </td><td bgcolor=ffffff><p><br><font size=+2><b>Results:</b> Found "+found+"<p></font></td></tr>"; 
		for(var i=0; i<entry.length; i++) {
			if(i%2==0)
				color="ffffcc";
			else
				color="ffffff";
			table+="<tr><td bgcolor="+color+" width=5%><font color='red' size=-2>"+percent[i]+"%</font></td><td bgcolor="+color+">"+entry[nums[i]]+"</td></tr>\n";
		}
		if(found>9)
			table+="<tr><td width=5%> </td><td bgcolor=FFFFFF><form onsubmit='find(1);return false;'><center><b>Search again: </b> <input type=text name=searchInput><input type=image src='searchbutton.gif'></center></form></td></tr></table></tr></td></table><noscript></body></html>\n";
		else 	
			table+="</table></td></tr></table><noscript></body></html>";
	} else {
		table="<script language=\"JavaScript\" src=\"searchoutput2.js\"></script>";
	}
	out.document.open();
	out.document.write(table);
  	out.document.close();
}

