// JavaScript Document

/* Variables Globales */
var isDHTML  = 0;
var isLayers = 0;
var isAll    = 0;
var isID     = 0;

/* Establece el tipo de Navegador */
if (document.getElementById){
  isID    = 1;
  isDHTML = 1;
} else {
  if (document.all){
    isAll   = 1;
    isDHTML = 1;
  } else {
    browserVersion = parseInt(navigator.appVersion);
    if    ((navigator.appName.indexOf('Netscape') != -1)
       && (browserVersion == 4)){
      isLayers = 1;
      isDHTML  = 1;
    }
  }
}

/*
 Captura el ID asociado del objeto deseado y crea el DOM
 correspondiente al navegador que está utilizando el visitante.
 Con esta función también se podrá modificar el estilo del
 objeto (withStyle=1) u otras propiedades asociadas con el
 objeto (withStyle=0).
*/
function findDOM(objectID, withStyle){
  // Devuelve el estilo del objeto.
  if (withStyle == 1){
    if (isID){
      return (document.getElementById(objectID).style);
    } else {
      if (isAll){
        return (document.all[objectID].style);
      } else if (isLayers){
          return (document.layers[objectID]);
      }
    }
  // Devuelve el DOM del objeto.
  } else {
    if (isID){
      return (document.getElementById(objectID));
    } else {
      if (isAll){
        return (document.all[objectID]);
      } else if (isLayers){
          return (document.layers[objectID]);
      }
    }
  }
}

/*-------------------------------------------------*/
/*
 * showTab(objectID, linkTab)
 * Cambia el estado del objeto de visible a no visible, y viceversa.
 */
function showTab(objectID, linkTab){
	hideAll();		
	
	domStyle = findDOM(objectID,1);
		
	if (domStyle.display != "block"){
		domStyle.display = "block";
		cambiar("on", objectID);
	}
	
	return;
}

/*
 * cambiar(estado, objectID)
 * Cambia el estado de los botones, de activo a no activo, es decir, la imagen.
 */
function cambiar(estado, objectID) {
	imagenSwap = new Image;
	img = objectID + "Img";
	
	if (estado == "on"){
		imagenSwap.src = "../images/" + objectID + "On.gif";
	} else {
		imagenSwap.src = "../images/" + objectID + "Off.gif";
	}

	document.images[img].src=imagenSwap.src;
}

/*
 * hideAll()
 * Inicializa todos los Tab.
 */
function hideAll(){
    var tabIdList = new Array();
    tabIdList[tabIdList.length] = "orderingInfo";
    tabIdList[tabIdList.length] = "citations";
    tabIdList[tabIdList.length] = "faqs";
    tabIdList[tabIdList.length] = "results";
    tabIdList[tabIdList.length] = "protocols";
	
	for(var i=0; i<tabIdList.length; i++) {
		cambiar("off", tabIdList[i]);
		domStyle = findDOM(tabIdList[i],1);
		domStyle.display = "none";
		domStyle = findDOM(tabIdList[i]+"Link",1);		
	}
}

function borrarTxt(campo){
    campo.value = "";      
}

function goToURL(urlDestino){
  window.location = urlDestino;
}

function showContenido(id, img_id){
	domStyle = findDOM(id,1);
	domStyleImg = findDOM(img_id,0);
	vista = (domStyle.display == 'none') ? 'block' : 'none';
	imagen = (domStyle.display == 'none') ? '/imagenes/minus.gif' : '/imagenes/plus.gif';
	domStyle.display = vista;
	domStyleImg.src = imagen;
}