function clsQUERY()
{

    msgTXT = document.getElementById("msg");
    msgTXT.style.visibility = "hidden";

    msgRES = document.getElementById("result");
    msgRES.style.visibility = "hidden";

    msgINT = document.getElementById("introduccion");
    msgINT.style.visibility = "visible";

    document.buscar.expresion.value = "";

}


function runQUERY()
{
	idx = document.buscar.idSEARCH.selectedIndex;
	idx = (idx < 0 ? 0 : idx);
	idSEARCH = document.buscar.idSEARCH.options[idx].value;
	if (idSEARCH!="") idSEARCH = "[" + idSEARCH + ". ]";

    exp = document.buscar.expresion.value;
    exp = exp.toLowerCase();

    if (exp.length==0) return;

	tbusq = (document.buscar.tbusq[0].checked ? "and" : "or");
	
    msgTXT = document.getElementById("msg");
    msgTXT.style.visibility = "visible";

    msgRES = document.getElementById("result");
    msgRES.style.visibility = "visible";

    msgINT = document.getElementById("introduccion");
    msgINT.style.visibility = "hidden";


/********************
 * Ubica los registros
 ********************/

    res = ""; arrEXP = exp.split(" "); idxRES="";totREG = 0;
    totDATA = document.cdDATA.keyWORD.length;

//alert(document.cdDATA.recDATA.length);

    for(ix=0;ix<totDATA;ix++)
    {
        addRECORD=(tbusq=="and" ? true : false);

        for (ax=0;ax<arrEXP.length;ax++)
        {
            keyWORD = " "+document.cdDATA.keyWORD.options[ix].value;
			expUBIC = arrEXP[ax];
			
			if (tbusq=="and"){
	            if (keyWORD.indexOf(expUBIC)==-1){
				 addRECORD = false; ax = arrEXP.length + 1;
				 }
				
			} else {
	            if (keyWORD.indexOf(expUBIC)>=0) addRECORD = true;
			}

        }

        if (addRECORD==true){

			 if (idSEARCH!=""){
			   if (keyWORD.indexOf(idSEARCH)==-1)  addRECORD = false;
			 }

			 if (addRECORD) {
		            totREG++; 
		            res = res + "<b>" + totREG + ".</b> " +document.cdDATA.recDATA.options[ix].value +"<p>";
			 }
			 
        }
    }

    msgTXT.style.visibility = "hidden";
    msgSEARCH = "No se recuperaron registros";
    if (document.buscar.idioma.value=="I") msgSEARCH = "No records found";
    if (document.buscar.idioma.value=="P") msgSEARCH = "Registros não recuperados";

    msgRESULT = "Total Registros";
    if (document.buscar.idioma.value=="I") msgRESULT = "Hits";
    if (document.buscar.idioma.value=="P") msgRESULT = "Total Registros";

    if (res=="") result.innerHTML = msgSEARCH + " <br><br><hr size=1 color=#c5960a>";
    else result.innerHTML = "<b>" + msgRESULT + ":</b> " + totREG + "<br><br>\n" + res + "<hr size=1 color=#c5960a>";

}


function inputTEC(e)
{
    if (e.keyCode==13) runQUERY();
}