<!--
/* global variables */
var section;

var Imagen1 = new Image(90,45);
Imagen1.src="imagenes/acer_ing1.gif";
var Imagen2 = new Image(90,45);
Imagen2.src="imagenes/acer_ing2.gif";   
var Imagen3 = new Image(90,45);
Imagen3.src="imagenes/acces_ing1.gif";
var Imagen4 = new Image(90,45);
Imagen4.src="imagenes/acces_ing2.gif";


/* Leer los argumentos */

	var args = new Object(); 
	var query = location.search.substring(1);
	var pairs = query.split(";");
	for(var i = 0; i < pairs.length; i++) { 
   		var pos = pairs[i].indexOf('='); 
   		if (pos == -1) continue; 
       
        var argname = pairs[i].substring(0,pos); 
        var value = pairs[i].substring(pos+1);
        args[argname] = unescape(value);
	}

/* just a bit of browser sniffing is necessary. */

var ie = (document.all) ? true: false; 
var isWin = (navigator.platform.indexOf("Win") != -1) ? true : false;

var ieWin = (ie && isWin) ? true : false;

var ieWin50 = (isWin && navigator.appVersion.indexOf('MSIE 5.0') != -1) ? true : false;

/*var nn4x = (document.layer) ? true : false;*/
var isns = (navigator.appName.indexOf("Netscape") != -1) ? true : false;
var nsver = (navigator.appVersion.indexOf("4") != -1) ? true : false;
var isop = (navigator.appName.indexOf("Opera") != -1) ? true : false;

var nn4x = ((isns) && nsver) ? true : false;
var opx = isop;

/* the menu open/close function. */

function togglemenu(num) { 

/* set local variables. */
var submenu = "sub"+num;
var square = "sq"+num;
var topmenu = "top"+num;

/* Set the display style to "none" if the value is null */
if (document.getElementById(submenu).style.display == null) {
 document.getElementById(submenu).style.display = "none";
 }
 
/* The toggle section. 
If the value of the submenu element's display is "none", 
then it's set to "block"; if the value is "block", it's set to "none".
The plus/minus GIF is also reset accordingly.
*/

if (document.getElementById(submenu).style.display == "none") {
	document.getElementById(submenu).style.display = "block";
	document.getElementById(square).src = "imagenes/minus.gif";
	document.getElementById(topmenu).style.backgroundColor = "#669966";
}
else {
	document.getElementById(submenu).style.display = "none";
	document.getElementById(square).src = "imagenes/plus.gif";
	document.getElementById(topmenu).style.backgroundColor = "#FFFFFF";
 }
}


/* Get all the elements with a given class name */

function getElementsByClassName(tagname, classname) {
 
 /* only execute in 5+ browsers. */
 if (!document.getElementById) return false;

 /* get all elements with the tag name tagname. */

 var TagElements = document.getElementsByTagName(tagname);

 /* define an array which will hold the elements with the class name classname. */
 var elementsByClassName = new Array();

 /* Look at all the elements in TagElements, and find the ones with the class name classname. */

 for (i=0; i<TagElements.length; i++) {
  if (TagElements[i].className == classname) {
    elementsByClassName[elementsByClassName.length] = TagElements[i];
    }
 }
  return elementsByClassName;
}


function changeclassstyle(tagname,classname,styleproperty,newstyle) {
	//var args = getArgs();
	var MAXGRUPOSBIOL = 50;
	var grupMat = new Array(MAXGRUPOSBIOL);
	if (args.gb) {
		var gruposBiol = args.gb.split(",");
		for(var i = 0; i < grupMat.length ; i++) { grupMat[i] = 0; }
		for(var j = 0; j < gruposBiol.length; j++) { grupMat[ gruposBiol[j] - 1 ] = 1; }
	}
	else {
		grupMat = grupoLeer();
	}
	//alert(grupMat.length);
	var tochange = getElementsByClassName(tagname,classname);
	for (k=0; k < tochange.length; k++) {
		if ( grupMat[k] == 1 ) newstyle = "block";
		eval("tochange[k].style." + styleproperty + " = " + "'" + newstyle + "'");
		newstyle = "none"
	}
}


function changeclassstyleold(tagname,classname,styleproperty,newstyle) {
	var grupMat = grupoLeer();
	//alert(grupMat.length);
	var tochange = getElementsByClassName(tagname,classname);
	for (k=0; k < tochange.length; k++) {
		if ( grupMat[k] == 1 ) newstyle = "block";
		eval("tochange[k].style." + styleproperty + " = " + "'" + newstyle + "'");
		newstyle = "none"
	}
}

/* change the cursor style */
function changecursor(num) {
var square = "sq" + num;
if (ieWin50) {
 var cursorstyle = 'hand'; }
else {
 var cursorstyle = 'pointer';
 }
 
document.getElementById(square).style.cursor = cursorstyle;
}

function imagen_square(num) {
var square = "sq"+num;

if (nn4x || opx) {
	document.write('<img src="imagenes/plus.gif" class="square" alt="" width="15" height="16" />');
}
else {
	document.write(' <img src="imagenes/plus.gif" class="square" alt="" width="15" height="16" id=');
	document.write(square);
	document.write(' onclick="togglemenu(');
	document.write(num);
	document.write(')" onmouseover="changecursor(')
	document.write(num);
	document.write(')" /> ');
}
}

var section;
function init() {
	if (document.getElementById) {
		changeclassstyle('div','sublevel','display','none');
		/*changeclassstyle('td','pic','display','none');*/
		if (section > 0) { togglemenu(section); }
	}
}

  function imagen(loc, img){  
      document [loc].src = eval(img).src; 
    } 
 
  var cadVariables = location.search.substring(1,location.search.length);
  
  function lanza(titulo, direccion) {
	msg=open("", titulo);
	msg.location = direccion; 
  }
 
  function advertencias() { 
    msg=open("","Advertencias");
    msg.location = "advertencia.html"
  }

  function comentarios() { 
    msg=open("","Comentarios");
    msg.location = "comentarios.html"
  }
  
  function simbologia() { 
    msg=open("","Simbologia","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no, copyhistory=yes,width=350,height=300");
    msg.location = "simbologia.html"
  }

  function colecciones() { 
    col=open("","Coleccion","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes, copyhistory=yes,width=700,height=650");
    col.location = "colecciones.html"
  }

  function basesexternas() { 
    msg=open("","Basesexternas");
    msg.location = "basesexternas.html"
  }
  
  function datos() { 
    msg=open("","Datos");
    msg.location = "http://www.conabio.gob.mx/remib/doctos/datos_colecciones_bd.html"
  }

  function hits() { 
    msg=open("","Datos");
    msg.location = "../../remib/doctos/remibhits.html"
  }
  
  function paises() {
	msg=open("", "paises");
	msg.location = "paises.html";
  }

/* Para los cookies */

	function grupoSel() {
  
		var grupos = getGruposSelecionados();
		document.cookie = "grupos=" + escape(grupos);
	}
  
	function grupoLeer() {
  
		var value;
		var allCookies = document.cookie;
		var pos = allCookies.indexOf("grupos=");
		if (pos != -1) {
			var start = pos + 7;
			var end = allCookies.indexOf(";", start);
			if (end == -1) end = allCookies.length;
			value = allCookies.substring(start, end);
			value = unescape(value);
		}
		else { value = ""; }
		var gruposMat = value.split(",");
		return gruposMat;
	}

  function getGruposSelecionados() {
 
	if (!document.getElementById) return false;
	var grupoSeleccionado = "";
	var elementos = getElementsByClassName('div','sublevel');
	for (i=1; i<=elementos.length; i++) {
		if (document.getElementById("sub"+i).style.display == "none") {
			if (grupoSeleccionado == "") { grupoSeleccionado = "0"; }
			else { grupoSeleccionado = grupoSeleccionado + ",0"; }
		}
		if (document.getElementById("sub"+i).style.display == "block") {
			if (grupoSeleccionado == "") { grupoSeleccionado = "1"; }
			else { grupoSeleccionado = grupoSeleccionado + ",1";}
		}
	}
    return grupoSeleccionado;
  }
  
  function getArgs() {
	var args = new Object(); 
	var query = location.search.substring(1);
	var pairs = query.split(";");
	for(var i = 0; i < pairs.length; i++) { 
   		var pos = pairs[i].indexOf('='); 
   		if (pos == -1) continue; 
       
        var argname = pairs[i].substring(0,pos); 
        var value = pairs[i].substring(pos+1);
        args[argname] = unescape(value);
	}
	
    return args;
  }
  
  function selCol() {
  

	if (args.col || args.c) {
		if (args.c) args.col = args.c;
		var colecciones = args.col.split(",");
		for(var i = 0; i < colecciones.length; i++) {
			var prendeColeccion = 'document.colecciones.col' + colecciones[i] + '.checked = true';
			var coleccion = 'document.colecciones.col' + colecciones[i];
			if ( eval(coleccion) != null ) {
				eval(prendeColeccion);
			}

		}
	}
	if (args.taxon || args.t) {
		if (args.t) args.taxon = args.t;
		var texto = new String;
		texto = unescape(args.taxon);
		texto = texto.replace(/\*/g, "%");
		document.colecciones.taxon.value = texto;
	}
  }


 function catTax(lengua) {
 
    var famtext = new Object();
    var gentext = new Object();
    var esptext = new Object();
    famtext['es-MX'] = 'FAMILIA'; famtext['EN'] = 'FAMLIY';
    gentext['es-MX'] = 'GÉNERO'; gentext['EN'] = 'GENUS';
	esptext['es-MX'] = 'ESPECIE'; esptext['EN'] = 'SPECIES';
   	var familia = ' <option value="familia">' + famtext[lengua] + '</option> ';
	var genero = ' <option value="genero">' + gentext[lengua] + '</option> ';
	var especie = ' <option value="especie">' + esptext[lengua] + '</option> ';
	if (args.nt  == "familia" || args.nt  == "f") { familia = ' <option value="familia" selected="selected">' + famtext[lengua] + '</option> '; }
    else if (args.nt == "genero" || args.nt == "g") { genero = ' <option value="genero" selected="selected"">' + gentext[lengua] + '</option> '; }
    else if (args.nt == "especie" || args.nt == "s") { especie = ' <option value="especie" selected="selected">' + esptext[lengua] + '</option> '; } 
    else { familia = ' <option value="familia" selected="selected">' + famtext[lengua] + '</option> '; }
    document.write(familia);  document.write(genero);  document.write(especie);
  }

  function pais(lengua) {
  
  	if (args.p) args.pais = args.p;
  	var mexicotext = new Object();
  	var euatext = new Object();
  	var crtext = new Object();
  	var todostext = new Object();
	var otrotext = new Object();
	mexicotext['es-MX'] = 'México'; 	mexicotext['EN'] = 'Mexico';
	euatext['es-MX'] = 'EUA'; 			euatext['EN'] = 'USA';
	crtext['es-MX'] = 'Costa Rica'; 	crtext['EN'] = 'Costa Rica';
	todostext['es-MX'] = 'TODOS'; 		todostext['EN'] = 'ALL';
	otrotext['es-MX'] = 'OTRO'; 		otrotext['EN'] = 'OTHER';
	var cr = ' <option value="cr">' + crtext[lengua] + '</option> ';
    var eua = ' <option value="eua">' + euatext[lengua] + '</option> ';
    var mexico = ' <option value="mexico">' + mexicotext[lengua] + '</option> ';
    var todos = ' <option value="Todos">' + todostext[lengua] + '</option> ';
    var otro = ' <option value="Otro">' + otrotext[lengua] + '</option> ';
    if (args.pais == "cr") { cr = ' <option value="cr" selected="selected">' + crtext[lengua] + '</option> '; }
    else if (args.pais == "eua" || args.pais == "ue") { eua = ' <option value="eua" selected="selected">' + euatext[lengua] + '</option> '; }
    else if (args.pais == "mexico" || args.pais == "mx") { mexico = ' <option value="mexico" selected="selected">' + mexicotext[lengua] + '</option> '; }
	else if (args.pais == "todos" || args.pais == "t") { todos = ' <option value="Todos" selected="selected">' + todostext[lengua] + '</option> '; }
	else if (args.pais == "otro" || args.pais == "o") { otro = ' <option value="Otro" selected="selected">' + otrotext[lengua] + '</option> '; }
	else { mexico = ' <option value="mexico" selected="selected">' + mexicotext[lengua] + '</option> '; }
	document.write(cr);  document.write(eua);  document.write(mexico);  document.write(todos);  document.write(otro);  
  }


// -->