﻿var _fn_navegar_js2_ = true;
var _stop_words_ = [':','a','acá','ahí','ahora','ajena','ajenas','ajeno','ajenos','al','algo','algún','alguna','algunas','alguno','algunos','all','allá','allí','almost','also','although','ambas','ambos','an','and','antes','any','aquel','aquella','aquellas','aquello','aquellos','aquí','are','as','así','at','aun','aún','aun','aún','aunque','be','because','been','both','but','by','cada','can','casi','caso','cierta','ciertas','cierto','ciertos','como','cómo','con','conmigo','consigo','contigo','cosa','cosas','could','cuál','cuáles','cualquier','cualquiera','cualquieras','cuan','cuán','cuando','cuándo','cuando','cuanta','cuánta','cuantas','cuántas','cuanto','cuánto','cuantos','cuántos','cuya','cuyas','cuyo','cuyos','d','de','dejar','del','demás','demasiada','demasiadas','demasiado','demasiados','desde','did','do','does','donde','e','either','el','él','ella','ellas','ello','ellos','en','entonces','entre','eran','eres','es','esa','ésa','esas','ésas','esas','ese','ése','ese','eso','esos','ésos','esta','está','ésta','estaba','estaban','estamos','están','estar','estas','éstas','este','éste','esto','estos','éstos','estoy','for','from','fue','ha','hace','hacen','hacer','hacia','hacía','hacia','hacía','hacían','had','han','haría','harían','has','hasta','have','having','hay','he','hecho','hechos','her','here','hers','him','his','how','however','i','if','in','into','is','it','its','jamás','junto','juntos','just','la','las','le','les','ll','lo','los','luego','mas','más','me','menos','mi','mía','mías','mientras','might','mío','míos','mis','misma','mismas','mismo','mismos','mr','mrs','ms','mucha','muchas','muchísima','muchísimas','muchísimo','muchísimos','mucho','muchos','muy','my','nada','nadie','ni','ninguna','ningunas','ninguno','ningunos','no','non','nor','nos','nosotras','nosotros','not','nuestra','nuestras','nuestro','nuestros','nunca','o','ó','of','on','one','only','onto','or','os','otra','otras','otro','otros','our','ours','para','parecer','pero','poca','pocas','poco','pocos','podía','podían','podría','podrían','por','porque','que','qué','querer','quien','quién','quienes','quiénes','quienesquiera','quienquiera','s','se','sea','ser','shall','she','should','si','sí','sido','siempre','sin','sín','since','sino','so','solamente','some','somos','son','soy','sr','sra','sres','sta','still','su','such','sus','suya','suyas','suyo','suyos','t','tal','tales','tambien','también','tambien','también','tan','tanta','tantas','tanto','tantos','te','tener','tengo','than','that','the','their','them','then','there','therefore','these','they','this','those','though','through','thus','ti','tiene','tienen','to','toda','todas','todavía','todo','todos','tomar','too','tú','tuve','tuvieron','tuvo','tuya','tuyo','ud','uds','un','una','unas','uno','unos','until','usted','ustedes','varias','varios','vd','ve','very','vosotras','vosotros','voy','vuestra','vuestras','vuestro','vuestros','was','we','were','what','when','where','whether','which','while','who','whose','why','will','with','would','y','ya','yet','yo','you','your','yours'];
/*Despliega las notas dentro del xslt*/
function fnVerNotas(obj,texto1,texto2,div){
//obtiene la nota, si es que la hay
 x=false;
if(navigator.appName == "Microsoft Internet Explorer"){
 
        if(div=='divNota')   {
             var nuevodiv='divNota_textoParte';   
             }
        else if(div=='divNotaBCN')   {
             var nuevodiv='divNotaBCN_textoParte';  
             }
        else if(div=='divNotaAlPie')   {
            var nuevodiv='divNotaAlPie_textoParte';
                }

        var notas_texto=' <div style="border:1px solid #bbbbbb;">'+document.getElementById(nuevodiv).innerHTML+'</div>';
        var notas=document.getElementById(nuevodiv);         
            

            if(notas.style.display=='none'){
                     notas.style.display='block';
                    document.getElementById('norma_texto').innerHTML+=notas_texto;
                     x=true;
                     
               }else{
                notas.style.display='none'; 
               document.getElementById('norma_texto').innerHTML=document.getElementById('old_div').innerHTML;
            } 
      
}
else{
 var notas=document.getElementsByName(div);
 for(var i=0;i<notas.length;i++){
   if(notas[i].style.display=='none'){
     notas[i].style.display='block';
     x=true;
   }else{
     notas[i].style.display='none';  
   }
  } 
 }//cambia el texto del boton
 if(x){obj.innerHTML=texto2;}else{obj.innerHTML=texto1;}

} // fin funcion

/*cambia la propiedad display de un objeto
*recibe el id del objeto
*/
function fnColapse(strdiv){
  if(document.getElementById(strdiv).style.display=='none'){
       document.getElementById(strdiv).style.display='block';
  }else{
       document.getElementById(strdiv).style.display='none';
  }
}



function fnCambiar2(strdiv,texto1,texto2){

  if(document.getElementById(strdiv).innerHTML==texto1){
    document.getElementById(strdiv).innerHTML=texto2;  
  }else{
     document.getElementById(strdiv).innerHTML=texto1;  
  }  
}

/*cambia el contenido de un objeto
*recibe (en orden) 
*id del objeto
*id del objeto2 que es visible o no. 
*/
function fnCambiar(strdiv,strdiv2){
//(document.getElementById(strdiv2).style.display);
  if(document.getElementById(strdiv2).style.display=='none'){
    document.getElementById(strdiv).innerHTML="<img src=\""+document.getElementById('urlImagen').value+"/more.gif\" title=\"Expandir\" alt=\"Expandir\" />";  
  }else{
    document.getElementById(strdiv).innerHTML="<img src=\""+document.getElementById('urlImagen').value+"/less.gif\" title=\"Contraer\" alt=\"Contraer\" />";
  }  
  
}

/*muestra las diferencias de texto entre la version original y la version de contexto
recibe el id del div de contexto, id div de version original,texto del boton que ejecuta la accion
el resultado de diferencia se muestra en el div de contexto, si el texto del boton no es el solicitado, se reestablece el texto sin marcas del div de contexto
*/
function fnVerEliminadas(obj,strdiv1,strdiv2,texto){
  old_div=document.getElementById(strdiv2).innerHTML;
  if(obj.innerHTML==texto){
    diffWords2(strdiv1,strdiv2,strdiv1);
  }else{
    remove(strdiv1);
  }
}

/* 
 serie de scripts para el menu de pesta�as

*/
 function init(){
var i;
    for( i=2; i<=4; i++){
        document.getElementById('contenido'+i).style.display = 'none';
    }
}

function viewSection(id){
var i;
    for (i=1; i<=8; i++){
        if(i!=id){
            document.getElementById('contenido'+i).style.display = 'none';
        }else{
            document.getElementById('contenido'+i).style.display = 'block';
            document.getElementById('li'+i).style.color='green';
        }
    }
}

/*para manejo del enter
recibe el evento, valor a buscar y el nombre del div donde buscar*/
var nav4 = window.Event ? true : false;
function fnBusca2(evt,val,div){
//OJO : Backspace = 8, Enter = 13, '0' = 48, '9' = 57
  var key = nav4 ? evt.which : evt.keyCode;
  if(key==13){
    fnBuscarentexto(val,div) 
  }
}
/*ejecuta la busqueda de un texto dentro del div de despliegue de la norma
* recibe el string de busqueda y el div de la norma
*/

// ---------------------------------
// inicio codigo nuevo para el buscador 
// ---------------------------------

function quitaacentos(texto) {
    texto = texto.replace(/á/gi, "a");
    texto = texto.replace(/é/gi, "e");
    texto = texto.replace(/í/gi, "i");
    texto = texto.replace(/ó/gi, "o");
    texto = texto.replace(/ú/gi, "u");
    texto = texto.replace(/ñ/gi, "n");
    return texto;
}

function doHighlight(bodyText, searchTerm, highlightStartTag, highlightEndTag, contadorToReplace, textToReplace) 
{
    var newText = "";
    var i = -1;
    var lcSearchTerm = searchTerm.toLowerCase();
    var lcBodyText = bodyText.toLowerCase();
    var contadorInterno = 0;
    if (typeof contadorToReplace == 'undefined'){
	contadorToReplace = contadorInterno;
    }
    if (typeof textToReplace == 'undefined'){
	textToReplace = searchTerm;
    }
	
    lcSearchTerm = quitaacentos(lcSearchTerm);
    lcBodyText = quitaacentos(lcBodyText);
    
    var aux = 0;
    var arreglo = new Array(3);
     
    while (bodyText.length > 0) {
      i = lcBodyText.indexOf(lcSearchTerm, i+1);
      if (i < 0) {
        newText += bodyText;
        bodyText = "";
      } else {
        // skip anything inside an HTML tag
        if (bodyText.lastIndexOf(">", i) >= bodyText.lastIndexOf("<", i)) {
          // skip anything inside a <script> block
          if (lcBodyText.lastIndexOf("/script>", i) >= lcBodyText.lastIndexOf("<script", i)) {
			newText += bodyText.substring(0, i) + preparaTag(highlightStartTag,textToReplace,contadorToReplace) + bodyText.substr(i, searchTerm.length) + highlightEndTag;
            bodyText = bodyText.substr(i + searchTerm.length);
            lcBodyText = quitaacentos(bodyText.toLowerCase());
            i = -1;
            aux = 1;
            contadorInterno = contadorInterno + 1;
	    contadorToReplace += 1;
          }
        }
      }
    }
    arreglo[0]=newText;
    arreglo[1]=aux;
    arreglo[2]=contadorInterno;
    return arreglo;
}
/*
 * highlightStartTag debe contener el texto: name='" + searchText + "'
 */
function preparaTag(highlightStartTag,searchTerm,contadorInterno){
	highlightStartTag = highlightStartTag.replace("name='"+searchTerm+"'","name='"+searchTerm+contadorInterno+"'");
	return highlightStartTag;
}

function fnBuscarentexto_desde_consulta(searchText, strdiv) //cuando viene de la consulta
{
	contadorPalabras = 0;
	MaxcontadorPalabras = 0;
	TextoBuscado = "";
	if(searchText!=""){
		searchText = searchText.replace(/^\s+/,"");
		searchText = searchText.replace(/\s+$/,"");
		document.getElementById(strdiv).innerHTML = document.getElementById('old_div').innerHTML;
		respaldo_norma_texto = document.getElementById('old_div').innerHTML;
		textColor='black';
		bgColor='yellow';
		treatAsPhrase=false; // para buscar por cada palabra colocar false;
		var searchArray = newSearchArray = [];
		if (treatAsPhrase) {
			searchArray = [searchText];
		} else {
			searchArray = searchText.split(" ");
			for(var j=0; j < searchArray.length; j++){
				if(searchArray[j] && !(searchArray[j].toLowerCase() in oc(_stop_words_))){
					newSearchArray.push(searchArray[j]);
				}
			}
			searchArray = newSearchArray;
		}
	       
		var bodyText = document.getElementById(strdiv).innerHTML;
		var arreglo = new Array(3);
		var aux = 0;
		for (var i = 0; i < searchArray.length; i++) {
			highlightStartTag = "<a id='resultado' name='" + searchArray[searchArray.length - 1] + "' style='border:0px solid black; color:" + textColor + "; background-color:" + bgColor + ";'>";
			highlightEndTag = "</a>";
			arreglo = doHighlight(bodyText, searchArray[i], highlightStartTag, highlightEndTag, MaxcontadorPalabras, searchArray[searchArray.length - 1] );
			bodyText = arreglo[0];
			MaxcontadorPalabras += arreglo[2];
			TextoBuscado = searchArray[i];
			if (arreglo[1] == 1 || aux == 1) { aux = 1; } else { aux = 0; }
		}
		document.getElementById(strdiv).innerHTML = bodyText;
		mostro_busqueda = true;
		ordenarLasNotas(strdiv);
  }
}

function fnBuscarentexto_sin_notas(searchText, strdiv) //cuando el texto sin notas se agranda 
{
	contadorPalabras = 0;
	MaxcontadorPalabras = 0;
	TextoBuscado = "";
  if(searchText==""){
     //alert("Debe indicar palabra o frase.");
     return false;
  }else
  {
      document.getElementById(strdiv).innerHTML = document.getElementById('old_norma_texto_sin_notas').innerHTML;
      searchText = searchText.replace(/^\s+/,"");
      searchText = searchText.replace(/\s+$/,"");
	  
      textColor='black';
      bgColor='yellow';
      treatAsPhrase=false; // para buscar por cada palabra colocar false;
      var newSearchArray = searchArray = [];
      if (treatAsPhrase) {
        searchArray = [searchText];
      } else {
	searchArray = searchText.split(" ");
	for(var j=0; j < searchArray.length; j++){
		if(searchArray[j] && !(searchArray[j].toLowerCase() in oc(_stop_words_))){
			newSearchArray.push(searchArray[j]);
		}
	}
	searchArray = newSearchArray;
      }
      
      var bodyText = document.getElementById(strdiv).innerHTML;
      var arreglo = new Array(2);
      var aux = 0;
      for (var i = 0; i < searchArray.length; i++) {
	highlightStartTag = "<a id='resultado' name='" + searchArray[searchArray.length - 1] + "' style='border:0px solid black; color:" + textColor + "; background-color:" + bgColor + ";'>";
	highlightEndTag = "</a>";
        arreglo = doHighlight(bodyText, searchArray[i], highlightStartTag, highlightEndTag, MaxcontadorPalabras, searchArray[searchArray.length - 1]);
        bodyText = arreglo[0];
	MaxcontadorPalabras += arreglo[2];
	TextoBuscado = searchArray[i];
        if (arreglo[1] == 1 || aux == 1) { aux = 1; } else { aux = 0; }
      }
      document.getElementById(strdiv).innerHTML = bodyText;
    }
}


function fnBuscarentexto(searchText, strdiv) //cuando esta navegando
{
	var	es_busqueda_con_notas = false; 
	contadorPalabras = 0;
	MaxcontadorPalabras = 0;
	TextoBuscado = "";
  if(searchText==""){
     alert("Debe indicar palabra o frase.");
     return false;
  }else
  {
      if (strdiv == 'norma_texto') {
	  es_busqueda_con_notas = true; 
          document.getElementById(strdiv).innerHTML = document.getElementById('old_div').innerHTML;
          respaldo_norma_texto = document.getElementById('old_div').innerHTML;
      } else {
          document.getElementById(strdiv).innerHTML = document.getElementById('old_norma_texto_sin_notas').innerHTML;
      }
      searchText = searchText.replace(/^\s+/,"");
      searchText = searchText.replace(/\s+$/,"");
      textColor='black';
      bgColor='yellow';
      treatAsPhrase=false; // para buscar por cada palabra colocar false;
      var searchArray = [];
      var newSearchArray = [];
      if (treatAsPhrase) {
        searchArray = [searchText];
      } else {
        searchArray = searchText.split(" ");
	for(var j=0; j < searchArray.length; j++){
		if(searchArray[j] && !(searchArray[j].toLowerCase() in oc(_stop_words_))){
			newSearchArray.push(searchArray[j]);
		}
	}
	searchArray = newSearchArray;
      }
      
      var bodyText = document.getElementById(strdiv).innerHTML;
	  
      //Agregado para eliminar los caracteres "que no existen" de la busqueda
      bodyText = replace(bodyText,cadenaSaltosObligados,"<br />&nbsp;");
	  
      var arreglo = new Array(2);
      var aux = 0;
      MaxcontadorPalabras = 0;
      for (var i = 0; i < searchArray.length; i++) {
	var highlightStartTag = "<a id='resultado' name='" + searchArray[searchArray.length - 1 ] + "' style='border:0px solid black; color:" + textColor + "; background-color:" + bgColor + ";'>";
	var highlightEndTag = "</a>";
        arreglo = doHighlight(bodyText, searchArray[i], highlightStartTag, highlightEndTag, MaxcontadorPalabras, searchArray[searchArray.length - 1 ]);
        bodyText = arreglo[0];
	MaxcontadorPalabras += arreglo[2];
	TextoBuscado = searchArray[i];
        if (arreglo[1] == 1 || aux == 1) { aux = 1; } else { aux = 0; }
      }
      document.getElementById(strdiv).innerHTML = bodyText;
	if (es_busqueda_con_notas){
	  	ordenarLasNotas(strdiv);
	  }
	  nextWord();
      if (aux==0) { alert("No se encontraron coincidencias."); }
      return true;
    }
}
var contadorPalabras = 0;
var MaxcontadorPalabras = 0;
var TextoBuscado = "";
function nextWord(){
	if (contadorPalabras < MaxcontadorPalabras) {
	}else{
		contadorPalabras = 0;
	}
	var ubicacion = document.location.toString();
	ubicacion = ubicacion.split("#");
	document.location = ubicacion[0]+ "#" + TextoBuscado + contadorPalabras;
	contadorPalabras = contadorPalabras + 1;
}
// ---------------------------------
// fin codigo nuevo para el buscador 
// ---------------------------------


/*reemplaza el texto marcado por la busqueda por el limpio
recibe el nombre del div que contiene el texto
*/
function remove(strdiv){
  document.getElementById("frase").value="";
  document.getElementById(strdiv).innerHTML= document.getElementById('old_div').innerHTML;
  //alert("display"+document.getElementById('btnlimpiar').style.display+"old_div="+document.getElementById('old_div').innerHTML);
}

function limpiar(){
	contadorPalabras = 0;
	MaxcontadorPalabras = 0;
	TextoBuscado = "";	
    document.getElementById("frase").value="";
    var divTexto = document.getElementById('norma_texto');
    if (divTexto.style.display=='block') 
    {
        divTexto.innerHTML = document.getElementById('old_div').innerHTML;
		ordenarLasNotas("norma_texto");
    }
    else 
    {
        var divNotaSinTexto = document.getElementById('norma_texto_sin_notas');
        if(divNotaSinTexto.style.display=='block') {
           divNotaSinTexto.innerHTML = document.getElementById('old_norma_texto_sin_notas').innerHTML;
        }
    }
}

//***************************************************************************************************
//       Funciones necesarias para la exportación
//
//***************************************************************************************************

/*almacena el formato de exportaci�n seleccionado, hace vsible el div de las opciones de exportacion*/
function setFormato(formato){
  formato_export=formato;
  fnColapse('div_exporta');
}

/*abre un popup centrado en la pantalla del navegador, 
recibe la url, target,algun seteo propio del popup, ancho y alto de la nueva ventana*/
function fnCenterPopup(url,titulo,features, ancho, alto) { 
  //alert(url)
  if(window.screen){
    var izq = (screen.width-ancho)/2;
    var superior = (screen.height-alto)/2;
    features+=(features!='')?',':'';
    features+=',left='+izq+',top='+superior;
  }
 var x= window.open(url,titulo,features+((features!='')?',':'')+'width='+ancho+',height='+alto);
 x.focus();
} 

/* llama a la funcion que compara.
obj es el obj boton
str1 es el div en el cual se compara
str2 es el div con el cual se compara str1
str3 es donde se respalda la version anterior de str1
texto 1 es 'Comparar en Version/Contexto y texto2 'Reestablecer'
boton nombre del boton contrario para deshabilitarlo
*/
function fnllamaDiffString(obj,str1,str2,str3,texto1,texto2,boton)  
{
 
 if (str1 == 'norma_contexto'){ 
     var indice = 0;
     var cont = 1;
 }else if(str1=='norma_version'){
     var indice=1;
     var cont = 0;
 }
  //parent.frames[indice].document.getElementById(str3).innerHTML=parent.frames[indice].document.getElementById(str1).innerHTML; 
if(obj.innerHTML==texto1){
      var str_1=parent.frames[indice].document.getElementById(str1).innerHTML;
      parent.frames[indice].document.getElementById(str3).innerHTML= parent.frames[indice].document.getElementById(str1).innerHTML;
      var str_2= parent.frames[cont].document.getElementById(str2).innerHTML;
      parent.frames[indice].document.getElementById(str1).innerHTML=diffString(str_1,str_2);
      parent.frames['down_'].document.getElementById(boton).disabled=true;
      obj.innerHTML=texto2;}
 else{
     parent.frames[indice].document.getElementById(str1).innerHTML= parent.frames[indice].document.getElementById(str3).innerHTML;
     obj.innerHTML=texto1; 
     parent.frames['down_'].document.getElementById(boton).disabled=false;}
  }
  
/* esta funcion permite salir al usuario de  controlCambio*/

function fnsalirComparar(){
 
 top.window.close();  
}

// solicitud no conforme
function enviarSOLI(url){
    var intWidth=550;
    var intHeight=400;
    window.open(url,"enviar","width="+intWidth+",height="+intHeight+",scrollbars=yes");
}

// llama al popup exportarNormaoParte, donde se selecciona la norma exportar
// completa o solo parte de ella
function fnExportarNormaoParte(tipo){
var tipoExportar = tipo; //pdf o word o txt o link o mail
var idNorma = document.getElementById('idNorma').value;
var idVersion = document.getElementById('idVersion').value;
var idParte = document.getElementById('idParte').value;

  if(tipo!='link'){
  var url=document.getElementById('urlPts').value+'/exportarNormaoParte?idNorma='+idNorma+'&idVersion='+idVersion+'&tipoExportar='+tipoExportar+'&idParte='+idParte;
 centerPopup(url, 'exportarNormaoParte','','270','125');
     } else if(tipo=='link'){
 
  var url2=document.getElementById('urlPts').value+'/ExportaraLink?idNorma='+idNorma+'&idVersion='+idVersion; //+'&normaoparte='+normaoparte;
  centerPopup(url2,'ExportaraLink','', 450, 200);
 }
}

//le da foco a la ventana 
var TieneFoco = true
function DaFoco() 
{
    if (TieneFoco == true)
        setTimeout("self.focus();", 0)
}

function centerPopup(url,titulo,features, ancho, alto) { 
    //ejemplo de llamada <A href="javascript:;" onClick="centerPopup('http://localhost','Test','','300','300')">
    if(window.screen){
        var izq = (screen.width-ancho)/2;
        var superior = (screen.height-alto)/2;
        features+=(features!='')?',':'';
        features+=',left='+izq+',top='+superior;
    }
    window.open(url,titulo,features+((features!='')?',':'')+'width='+ancho+',height='+alto);
}

function fnExportar(){

// norma completa = 1 || parte de la norma = 0
var tipoExportar = document.getElementById('tipoExportar').value; // pdf o word o txt 
var idNorma = document.getElementById('idNorma').value;
var idVersion = document.getElementById('idVersion').value;
var idParte = document.getElementById('idParte').value;
var normaoparte = document.getElementById('normaoparte').value;

if(normaoparte==1){
    var url = document.getElementById('urlPts').value+'/ExportarNormaCompleta?idNorma='+idNorma+'&idVersion='+idVersion+'&tipoExportar='+tipoExportar;
    window.open(url);
    document.getElementById('formulario').action = 'ExportarNormaCompleta';
    document.getElementById('formulario').submit();
    window.close();
} else if(normaoparte==0){
      var url = document.getElementById('urlPts').value+'/ExportarParteNorma?idNorma='+idNorma+'&idVersion='+idVersion+'&tipoExportar='+tipoExportar+'&idParte='+idParte;
    window.open(url);
    document.getElementById('formulario').action = 'ExportarParteNorma';
    document.getElementById('formulario').submit();
    window.close();      
    
}
}

/*coloca un borde plomo al objeto*/
function fnAmplia(obj){

  obj.style.border="1px solid #bbbbbb";
}
/*coloca un borde blanco al objeto*/
function fnReduce(obj){
 
  obj.style.border="1px solid #ffffff";
}

// valida que los caracteres ingresados en el textbox correspondan
// mas o menos a un mail valido

function navegarOnResize(){
	try {
		if (parseInt(navigator.appVersion) > 3) {
			if (navigator.appName.indexOf("Microsoft") != -1) {
				//alert("entra 7");
				//var winW = document.body.offsetWidth;
				//var ancho = winW - 300;
				//var style_width = ancho + 'px';
				//try {
					//document.getElementById('div_general').style.width = style_width;
					//ajustarTam('norma','iframeContenido_norma');
				//} 
				//catch (e) {
				//}
				//try {
					//var pres = document.getElementById('pre_sin_notas');
					//pres.style.width = ancho + 'px';
				//} 
				//catch (e) {
				//}
			}
		}
/*        if ((verifica_notas_bcn=='' || verifica_notas_bcn[0].style.display=='none') &&
             (verifica_notas_al_pie=='' || verifica_notas_al_pie[0].style.display=='none') &&
             (verifica_notas_originales=='' || verifica_notas_originales[0].style.display=='none')) {
             var verifica=true;
         }else{
             var verifica=false;
		 }
		 modifica_ancho_etiqueta_pre(verifica);*/
	} 
	catch (e) {
	
	}
}


function cambiarMensajeEsperaIE(idDiv){
	if(window.navigator.appName.indexOf("Internet Explorer") > -1){
		var div  = document.getElementById(idDiv);
		div.innerHTML = "Descargando norma desde el Servidor "+getImagenCargando("");
	}
}

var mostro_busqueda = false;
function mostrarBusquedaCNotas(){
	if (document.getElementById('ops_ver_marcas').value == "1") {
		try {
			var buscarTexto = document.getElementById('frase').value;
		} 
		catch (e) {
			var buscarTexto = document.getElementById('buscar').value;
		} 
        fnBuscarentexto_desde_consulta(buscarTexto, 'norma_texto');
	}
	
	mostro_busqueda = true;
	
}
var __interval_mostrar_jurisprudencia__ = null;
var __interval_mostrar_enlaces_proy__ 	= null;
var __interval_mostrar_enlaces_hl__ 	= null;
var __interval_mostrar_enlaces_os__ 	= null;
var __interval_mostrar_doctrina__ 		= null;
var __interval_mostrar_datos__ 			= null;
function revisarOpcionesJurisprudencia(){
	var jurisprudencia = $F('jurisprudencia');
	if (jurisprudencia) {
		__interval_mostrar_jurisprudencia__ = setInterval("mostrarJurisprudencia('"+jurisprudencia+"');", 2000);
	}
	var enlaces_proy = $F('enlaces_proy');
	if (enlaces_proy) {
		__interval_mostrar_enlaces_proy__ = setInterval("mostrarEnlacesProy('"+jurisprudencia+"');", 2000);
	}
	var enlaces_hl = $F('enlaces_hl');
	if (enlaces_hl) {
		__interval_mostrar_enlaces_hl__ = setInterval("mostrarEnlacesHL('"+jurisprudencia+"');", 2000);
	}
	var enlaces_os = $F('enlaces_os');
	if (enlaces_os) {
		__interval_mostrar_enlaces_os__ = setInterval("mostrarEnlacesOS('"+jurisprudencia+"');", 2000);
	}
	var doctrina = $F('doctrina');
	if (doctrina) {
		__interval_mostrar_doctrina__ = setInterval("mostrarDoctrina('"+jurisprudencia+"');", 2000);
	}
	var ver_datos = $F('ver_datos');
	if (ver_datos) {
		__interval_mostrar_datos__ = setInterval("mostrarDatos();", 2000);
	}
	
}
var __debe_mostrar_doctrina__		= false;
var __debe_mostrar_enlaces_hl__     = false;
var __debe_mostrar_enlaces_os__     = false;
var __debe_mostrar_enlaces_proy__ 	= false;
var __debe_mostrar_jurisprudencia__ = false;
function mostrarDocrtina(doctrina){
	if (!__debe_mostrar_doctrina__) {
		return true;
	}
	clearInterval(__interval_mostrar_doctrina__);
	__interval_mostrar_doctrina__ = null;
	var item = $('item9');
	if(item.style.display != "none"){
		verInfo('info','doctrina');
		cambiaClase('item9');
		var pos_element = findPos(item);
		posX = pos_element[0];
		posY = pos_element[1];
		window.scrollTo(posX, posY);
	}
}
function mostrarEnlacesHL(enlaces_hl){
	if (!__debe_mostrar_enlaces_hl__) {
		return true;
	}
	clearInterval(__interval_mostrar_enlaces_hl__);
	__interval_mostrar_enlaces_hl__ = null;
	var item = $('item3');
	if(item.style.display != "none"){
		verInfo('info','historia');
		cambiaClase('item3');
		var pos_element = findPos(item);
		posX = pos_element[0];
		posY = pos_element[1];
		window.scrollTo(posX, posY);
	}
}
function mostrarEnlacesOS(enlaces_os){
	if (!__debe_mostrar_enlaces_os__) {
		return true;
	}
	clearInterval(__interval_mostrar_enlaces_os__);
	__interval_mostrar_enlaces_os__ = null;
	var item = $('item5');
	if(item.style.display != "none"){
		verInfo('info','enlaces');
		cambiaClase('item5');
		var pos_element = findPos(item);
		posX = pos_element[0];
		posY = pos_element[1];
		window.scrollTo(posX, posY);
	}
}
function mostrarEnlacesProy(enlaces_proy){
	if (!__debe_mostrar_enlaces_proy__) {
		return true;
	}
	clearInterval(__interval_mostrar_enlaces_proy__);
	__interval_mostrar_enlaces_proy__ = null;
	var item = $('item4');
	if(item.style.display != "none"){
		verInfo('info','proyectos');
		cambiaClase('item4');
		var pos_element = findPos(item);
		posX = pos_element[0];
		posY = pos_element[1];
		window.scrollTo(posX, posY);
	}
}
function mostrarDatos(){
	clearInterval(__interval_mostrar_datos__);
	__interval_mostrar_datos__ = null;
	var item = $('item7');
	if(item.style.display != "none"){
		verInfo('info','datos');
		cambiaClase('item7');
		CargarMetadatos();
		var pos_element = findPos(item);
		posX = pos_element[0];
		posY = pos_element[1];
		window.scrollTo(posX, posY);
	}
}
function mostrarJurisprudencia(jurisprudencia){
	if (!__debe_mostrar_jurisprudencia__) {
		return true;
	}
	
	clearInterval(__interval_mostrar_jurisprudencia__);
	__interval_mostrar_jurisprudencia__ = null;
	
	var boxJurisprudencia = $('boxJurisprudencia');
	
	var uls = boxJurisprudencia.getElementsByTagName("ul");
	
	var nodoPadre = null;
	for (var i = 0; i < uls.length; i++) {
		var firstChild = uls[i].firstChild;
		if (firstChild.nodeName.toLowerCase().indexOf('text') > -1) {
			if (firstChild.nodeValue.toLowerCase() == jurisprudencia.toLowerCase()) {
				nodoPadre = uls[i];
				break;
			}
		}
	}
	var encontro_juri = false;
	if (nodoPadre) {
		var links = nodoPadre.getElementsByTagName('a');
		/***************
		 * Despliego los Dictamenes
		 ***************/
		for (var i = 0; i < links.length; i++) {
			var inner = links[i].innerHTML;
			if (inner.toLowerCase().indexOf("dictamenes") > -1 || inner.toLowerCase().indexOf("dictámenes") > -1) {
				var onclick = links[i].getAttribute('onclick');
				eval(onclick);
				encontro_juri = true;
				break;
			}
		}
	}
	
	/**************************
	 * Muestro la información desplegada;
	 **************************/
	if (encontro_juri || $('item8').style.display != 'none') {
		verInfo('info', 'jurisprudencia');
		cambiaClase('item8');
		
		var pos_element = findPos(nodoPadre);
		posX = pos_element[0];
		posY = pos_element[1];
		window.scrollTo(posX, posY);
	}
}
function CargaNormaAlternativa(idNorma, idVersion, idParte, url, buscar){
	if(!document.getElementById('status')){
		setTimeout(function(){CargaNormaAlternativa(idNorma, idVersion, idParte, url, buscar)},10);
		return false;
	}
	document.getElementById('status').style.display = 'none';
	document.getElementById('status').innerHTML = "";

	var _XML_ = document.getElementById('_XML_').value;
	XML = escape(_XML_);
	
	creaToc();
    
	if (Interval_CompletarCargaTexto == -1) {
		Interval_CompletarCargaTexto = setInterval('CompletarCargaTexto()', 500);
	}
}
