
var seccion;
var texto;
var metodo;
var entidad;
var vecRepos;
var Analogias;
var Nivel;
var vecdonde;
var Deplega;
var Ordena;
var bus;
var vecOtros;
var like;
var cqTexto;
var Edicion;
var cober;
var period;
var Emlu;
var buscaSerie;
var CadSeries;
var Formato;
var iduser;
var repositorio;
var Idioma;
var tempoent;
var tempoEntidad;
var AvanzaMDM;
var liga;
var total;
var encontro=false;
var totalSecciones;


/*function Secciones(servidor,seccionBus,strTexto,metodoBus,ent,Repos,inAnalogias,cveNiv,repos,vdonde,srtDeplega,srtOrdena,busIn,vecOtros_R,con_like,cqTextoBus,noEdi,cobertura,periodo,conexionProd,strEmlu,buscaSerieCat,srCadSeries,Formato,usuario,explorador,idusuario,s,strIdioma,tempoentidad,tempoEntidad,color,strAvanzaMDM,permitecubos,conexionCubos)*/
function Secciones(seccionBus, strTexto, metodoBus, ent, Repos, inAnalogias, cveNiv, vdonde, srtDeplega, srtOrdena, busIn, vecOtros_R, con_like, cqTextoBus, noEdi, cobertura, periodo, strEmlu, buscaSerieCat, srCadSeries, Formato, idusuario, s, strIdioma, tempoentidad, tempoEntidad, color, strAvanzaMDM, permitecubos, ruta, avanzada, total) {
    
	//alert("entra");
    var resultado = document.getElementById('Lblotrasecciones');
    if (resultado.innerHTML == "") {
        resultado.innerHTML = "<center><img src='/img/simple.gif' style='visibility:visible'> Buscando en otras secciones...</center>";
    }
    seccion = seccionBus;
    texto = strTexto;
    metodo = metodoBus;
    entidad = ent;
    vecRepos = Repos;
    Analogias = inAnalogias;
    Nivel = cveNiv;
    vecdonde = vdonde;
    Deplega = srtDeplega;
    Ordena = srtOrdena;
    bus = busIn;
    vecOtros = vecOtros_R;
    like = con_like;
    cqTexto = cqTextoBus;
    Edicion = noEdi;
    cober = cobertura;
    period = periodo;
    Emlu = strEmlu;
    buscaSerie = buscaSerieCat;
    CadSeries = srCadSeries;
    Formato = Formato;
    iduser = idusuario;
    repositorio = s;
    Idioma = strIdioma;
    tempoent = tempoentidad;
    tempoEnti = tempoEntidad;
    AvanzaMDM = strAvanzaMDM;
    liga = ruta;
	//Buscar.Secciones(servidor,seccionBus,strTexto,metodoBus,ent,Repos,temarel,cveNiv,repos,vdonde,srtDeplega,srtOrdena,busIn,vecOtros_R,con_like,cqTextoBus,noEdi,cobertura,periodo,conexionProd,strEmlu,buscaSerieCat,srCadSeries,Formato,usuario,explorador,idusuario,Secciones_callBack);
	//Buscar.otrasSecciones(repos,Secciones_callBack);
    //intermediaAjax.regresaResultado(servidor,seccionBus,strTexto,metodoBus,ent,Repos,inAnalogias,cveNiv,repos,vdonde,srtDeplega,srtOrdena,busIn,vecOtros_R,con_like,cqTextoBus,noEdi,cobertura,periodo,conexionProd,strEmlu,buscaSerieCat,srCadSeries,Formato,usuario,explorador,idusuario,s,strIdioma,tempoentidad,tempoEntidad,color,strAvanzaMDM,permitecubos,conexionCubos,ruta,avanzada,total,Secciones_callBack);
   
    Buscador_tri.WSsearchResult.AjaxSecciones(seccionBus, strTexto, metodoBus, ent, Repos, inAnalogias, cveNiv, vdonde, srtDeplega, srtOrdena, busIn, vecOtros_R, con_like, cqTextoBus, noEdi, cobertura, periodo, strEmlu, buscaSerieCat, srCadSeries, Formato, idusuario, s, strIdioma, tempoentidad, tempoEntidad, color, strAvanzaMDM, permitecubos, ruta, avanzada, total, Secciones_callBack);
		//AjaxSecciones(servidor, seccionBus, strTexto, metodoBus, ent, Repos, inAnalogias, cveNiv, repos, vdonde, srtDeplega, srtOrdena, busIn, vecOtros_R, con_like, cqTextoBus, noEdi, cobertura, periodo, conexionProd, strEmlu, buscaSerieCat, srCadSeries, Formato, usuario, explorador, idusuario, s, strIdioma, tempoentidad, tempoEntidad, color, strAvanzaMDM, permitecubos, conexionCubos, ruta, avanzada, total, Secciones_callBack);
	//intermediaAjax.regresaResultado(servidor,seccionBus,strTexto,metodoBus,ent,"",inAnalogias,cveNiv,repos,vdonde,srtDeplega,srtOrdena,busIn,"",con_like,cqTextoBus,noEdi,cobertura,periodo,conexionProd,strEmlu,buscaSerieCat,srCadSeries,"",usuario,explorador,idusuario,s,strIdioma,tempoentidad,tempoEntidad,color,strAvanzaMDM,permitecubos,conexionCubos,Secciones_callBack);
}

function Secciones_callBack(response)
{
    var resultado = document.getElementById('Lblotrasecciones');
    var Noencontro = document.getElementById('LblResultados');
    var Rango = document.getElementById('LblRango');
    resultado.innerHTML = "<center><img src='/img/simple.gif' style='visibility:visible'> Buscando en otras secciones...</center>";
		
		if (response != null && response != ""  ) {
		    if (Rango != null) {
		        if (response.toString().indexOf("Lo sentimos,") < 0) {
		            resultado.innerHTML = response;
		        }
		        else {
		            resultado.innerHTML = "";
		         }
		    }
		    else {
		            resultado.innerHTML = response;
		     }
		 }
		// obtenSeccionesBus(seccion, texto, metodo, entidad, vecRepos, Analogias, Nivel, vecdonde, Deplega, Ordena, bus, vecOtros, like, cqTexto, Edicion, cober, period, Emlu, buscaSerie, CadSeries, Formato, iduser, repositorio, Idioma, tempoent, tempoEnti, AvanzaMDM, liga);}

function obtenSeccionesBus(seccionBus, strTexto, metodoBus, ent, Repos, inAnalogias, cveNiv, vdonde, srtDeplega, srtOrdena, busIn, vecOtros_R, con_like, cqTextoBus, noEdi, cobertura, periodo, strEmlu, buscaSerieCat, srCadSeries, Formato, idusuario, s, strIdioma, tempoentidad, tempoEntidad, strAvanzaMDM, ruta,resultados) {
    seccion = seccionBus;
    texto = strTexto;
    metodo = metodoBus;
    entidad = ent;
    vecRepos = Repos;
    Analogias = inAnalogias;
    Nivel = cveNiv;
    vecdonde = vdonde;
    Deplega = srtDeplega;
    Ordena = srtOrdena;
    bus = busIn;
    vecOtros = vecOtros_R;
    like = con_like;
    cqTexto = cqTextoBus;
    Edicion = noEdi;
    cober = cobertura;
    period = periodo;
    Emlu = strEmlu;
    buscaSerie = buscaSerieCat;
    CadSeries = srCadSeries;
    Formato = Formato;
    iduser = idusuario;
    repositorio = s;
    Idioma = strIdioma;
    tempoent = tempoentidad;
    tempoEnti = tempoEntidad;
    AvanzaMDM = strAvanzaMDM;
    liga = ruta;
    total = resultados;
    var resultado = document.getElementById('Lblotrasecciones');
    resultado.innerHTML = "<center><img src='/img/simple.gif' style='visibility:visible'> Buscando en otras secciones...</center>";
    Buscador_tri.WSsearchResult.vectorSecciones(obtenSeccionesBus_callBack);
}

function obtenSeccionesBus_callBack(result) {
    var mod;
    totalSecciones = (result.length / 6) + 1;
    if (seccion == "") {
        seccion = "it";
    }
    for (i = 0; i < result.length; i++) {
        mod = i % 6;
        if (mod == 0) {
            if (result[i] != seccion) {
                //Buscador_tri.WSsearchResult.obtenDatosSeccion(result[i], texto, metodo, entidad, "", Analogias, Nivel, vecdonde, Deplega, Ordena, bus, "", like, cqTexto, Edicion, cober, period, Emlu, buscaSerie, CadSeries, "", iduser, repositorio, Idioma, tempoent, tempoEnti, "", AvanzaMDM, "", liga, result[i + 1], agregaDivSecciones_callBack);
                Buscador_tri.WSsearchResult.obtenDatosSeccionDerecha(result[i], texto, metodo, entidad, "", Analogias, Nivel, vecdonde, Deplega, Ordena, bus, "", like, cqTexto, Edicion, cober, period, Emlu, buscaSerie, CadSeries, "", iduser, repositorio, Idioma, tempoent, tempoEnti, "", AvanzaMDM, "", liga, result[i + 1], agregaDivSecciones_callBack);
            }
        }
       
     }
     //Buscador_tri.WSsearchResult.obtenDatosSeccion("cubos", texto, metodo, entidad, "", Analogias, Nivel, vecdonde, Deplega, Ordena, bus, "", like, cqTexto, Edicion, cober, period, Emlu, buscaSerie, CadSeries, "", iduser, repositorio, Idioma, tempoent, tempoEnti, "", AvanzaMDM, "", liga, "Consulta interactiva de datos", agregaDivSecciones_callBack);
     Buscador_tri.WSsearchResult.obtenDatosSeccionDerecha("cubos", texto, metodo, entidad, "", Analogias, Nivel, vecdonde, Deplega, Ordena, bus, "", like, cqTexto, Edicion, cober, period, Emlu, buscaSerie, CadSeries, "", iduser, repositorio, Idioma, tempoent, tempoEnti, "", AvanzaMDM, "", liga, "Consulta interactiva de datos", agregaDivSecciones_callBack);
 }

 function agregaDivSecciones_callBack(result) {
     totalSecciones = totalSecciones - 1;
     var divSeccion;
     if (result != "" && result != null) {
         encontro = true;
         //  var divSeccion = document.getElementById("divsecciones");
         divSeccion = document.getElementById("Lblotrasecciones");
         var divNewseccion;
         var temposeccion;
         var indice;
         if (divSeccion.innerHTML != "") {
             if (divSeccion.innerHTML.toString().indexOf("Buscando en otras secciones...") > -1) {
                 divSeccion.innerHTML = "";
              }
          }
       divNewseccion = document.createElement("DIV");
       divNewseccion.id = "div" + seccion;
       divNewseccion.align = "left";
       
       if (divSeccion.innerHTML == "") {
           if (Idioma != "i") {
               if (total == 0) {
                   divNewseccion.innerHTML = "Se encontraron elementos para el texto <b>" + texto + "</b> en:<br>";
               }
               else {
                   divNewseccion.innerHTML = "<b><font size='-1'>Tambi&eacute;n se encontraron elementos en:</font></b>";
                }
           }
           else {
           if (total == 0) {
               divNewseccion.innerHTML = "Elements were founded for <b>" + texto + "</b><br>";
               }
               else
               {
                   divNewseccion.innerHTML = "<b>There are elements in the following sections:</b>";
               }
            }
       }
       divNewseccion.innerHTML += result;
       indice = divNewseccion.innerHTML.toString().indexOf("/img/ico_");
       temposeccion = divNewseccion.innerHTML.toString().substring(indice);
       indice = temposeccion.indexOf("\"");
       temposeccion = temposeccion.substring(0, indice);

       
       if (divSeccion.toString().indexOf(temposeccion) < 0) {
           divSeccion.appendChild(divNewseccion);
       }
   }
   if (totalSecciones == 1) 
   {
       if (encontro == false) {
           var divResultados = document.getElementById("Lblotrasecciones");
           if (divResultados.innerHTML != "") {
               if (divResultados.innerHTML.toString().indexOf("Buscando en otras secciones...") > -1) {
                   divResultados.innerHTML = "";
               }
           }
           if (total == 0) {
               divSeccion = document.getElementById("LblResultados");
               if (Idioma == "i") {
                   divSeccion.innerHTML = "<center><table width='55%' border='0' cellspacing='0' cellpadding='1' bgcolor='#CCCCCC'><tr><td><table width='100%' height='10'  border='0' cellspacing='0' cellpadding='1' bgcolor='#F5F5F5'><tr height='10'><td align='center'><font color='#FF7624'>&nbsp;&nbsp;&nbsp;&nbsp;Sorry. No elements were founded:<B>";
                   divSeccion.innerHTML += texto + "</B> </td>	</tr>		<tr height='10'>				<td align='center'><font color='#FF7624'><b>Suggestions:</b></td>			</tr>			<tr height='10'>				<td align='center'><font color='#FF7624'>Verify Spelling.</td>			</tr>			<tr height='10'>				<td align='center'><font color='#FF7624'>Try different words that mean the same thing.</td>			</tr>			<tr height='10'>				<td align='center'><font color='#FF7624'>&nbsp;&nbsp; That it is not necessary to include AND, OR or other operators";
                   if (AvanzaMDM == "1") {
                       divSeccion.innerHTML += ".</td>";
                   }
                   else {
                       divSeccion.innerHTML += ", since these are formed by means of <a href='" + "?s=" + repositorio + "&av=1&e=" + tempoEnti + "&seccionBus=" + seccion + "&noBuscar=1&temarel=&emlu=" + Emlu + "&aBusBIE=3&i=";
                       divSeccion.innerHTML += Idioma + "'>Advanced Search.</a></td>";
                   }
               }
               else {

                   divSeccion.innerHTML = "<center><table width='55%' border='0' cellspacing='0' cellpadding='1' bgcolor='#CCCCCC'><tr><td><table width='100%' height='10'  border='0' cellspacing='0' cellpadding='1' bgcolor='#F5F5F5'><tr height='10'><td align='center'><font color='#FF7624'>&nbsp;&nbsp;&nbsp;&nbsp;Lo sentimos, no se encontraron elementos para:<B>";
                   divSeccion.innerHTML += texto + "</B> </td>	</tr>		<tr height='10'>				<td align='center'><font color='#FF7624'><b>Sugerencias:</b></td>			</tr>			<tr height='10'>				<td align='center'><font color='#FF7624'>Verifique que las palabras est&eacute;n escritas correctamente.</td>			</tr>			<tr height='10'>				<td align='center'><font color='#FF7624'>Intente usar otras palabras.</td>			</tr>			<tr height='10'>				<td align='center'><font color='#FF7624'>&nbsp;&nbsp; No es necesario incluir AND, OR u otros operadores";
                   //divSeccion.innerHTML += "</tr><tr height='10'><td align='center'><font color='#FF7624'>&nbsp;&nbsp; No es necesario incluir AND, OR u otros operadores";
                   if (AvanzaMDM != "1") {
                       divSeccion.innerHTML += ", ya que estos son configurados por medio de la <a href='" + liga + "?s=" + repositorio + "&av=1&e=" + tempoEnti + "&seccionBus=" + seccion + "&noBuscar=1&temarel=&emlu=" + Emlu + "&aBusBIE=3'>B&uacute;squeda avanzada.</a></td>";
                   }
                   else {
                       divSeccion.innerHTML += ".</td>";
                   }
               }
               divSeccion.innerHTML += "  </tr>		 </table>    </td>   </tr> </table></center><br>";
               divSeccion.innerHTML = divSeccion.innerHTML.replace("</B></FONT></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE></CENTER>", "");
               divSeccion.innerHTML = divSeccion.innerHTML.replace("</FONT></FONT></FONT></FONT>", "");
           }
       }
    }
  }