var ubicacionActual=-1;
var t;
function irAncla(destino){
	donde=findPos(document.getElementById(destino),'y');
	if(navigator.appName=="Netscape"){ ubi=window.pageYOffset; }
	else{ ubi=document.documentElement.scrollTop; }
	if((ubi>donde+10 || ubi<donde-10) && ubicacionActual!=ubi){
		ubicacionActual=ubi;
		dest=ubicacionActual+((donde-ubicacionActual)/8);
		window.scroll(0,dest);
		t=setTimeout("irAncla('"+destino+"')",50);
	}
	else{
		clearTimeout(t);
	}
}

function findPos(obj,eje) {
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		curleft = obj.offsetLeft
		curtop = obj.offsetTop
		while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft
			curtop += obj.offsetTop
		}
	}
	if(eje=="x"){ return curleft; }
	if(eje=="y"){ return curtop; }
}


function offsetLeft(el)
{
    x = el.offsetLeft
    for (e = el.offsetParent; e; e = e.offsetParent)
    x += e.offsetLeft;
    return x
} 
function offsetTop(el)
{
    y = el.offsetTop
    for (e = el.offsetParent; e; e = e.offsetParent)
    y += e.offsetTop;
    return y
} 

function mostrarDivGlosario(event, palabra, definicion)
{
	var cont = document.all? document.body : document.documentElement;
	alto = cont.clientHeight;
	if(!document.all)
	{
		alto = cont.clientHeight + window.pageYOffset;
	}

	ancho = cont.clientWidth;
	if(!document.all)
	{
		ancho = cont.clientWidth + window.pageXOffset;
	}

	document.getElementById("palabra_glosario").innerHTML = palabra;
	document.getElementById("definicion_glosario").innerHTML = definicion;
	if (browser.isIE) {
		x = window.event.clientX + document.documentElement.scrollLeft
		+ document.body.scrollLeft;
		y = window.event.clientY + document.documentElement.scrollTop
		+ document.body.scrollTop;
	}
	if (browser.isNS) {
		x = event.clientX + window.scrollX;
		y = event.clientY + window.scrollY;
	}

	if (browser.isOpera) {
		x = window.event.clientX + document.documentElement.scrollLeft
		+ document.body.scrollLeft;
		y = window.event.clientY + document.documentElement.scrollTop
		+ document.body.scrollTop;
	}
	document.getElementById("glosario_noticias").style.left = (x + 3) + 'px';
	document.getElementById("glosario_noticias").style.top = (y + 3) + 'px';
	document.getElementById("glosario_noticias").style.display = 'inline';
	if((y + document.getElementById("glosario_noticias").offsetHeight)>(alto-50))
	{
		document.getElementById("glosario_noticias").style.top = ((alto-50) - document.getElementById("glosario_noticias").offsetHeight) + 'px';
	}
	if((x + document.getElementById("glosario_noticias").offsetWidth)>(ancho-30))
	{
		document.getElementById("glosario_noticias").style.left = ((ancho-30) - document.getElementById("glosario_noticias").offsetWidth) + 'px';
	}
	if (browser.isIE) {
		event.cancelBuble = true;
	}
	else
	{
		event.preventDefaullt();
	}

}

function cerrarDivGlosario()
{
	document.getElementById("glosario_noticias").style.display = 'none';
}

function Browser() {

  var ua, s, i;

  this.isIE    = false;  // Internet Explorer
  this.isOP    = false;  // Opera
  this.isNS    = false;  // Netscape
  this.version = null;

  ua = navigator.userAgent;

  s = "Opera";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isOP = true;
    this.version = parseFloat(ua.substr(i + s.length));
    return;
  }

  s = "Netscape6/";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isNS = true;
    this.version = parseFloat(ua.substr(i + s.length));
    return;
  }

  // Treat any other "Gecko" browser as Netscape 6.1.

  s = "Gecko";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isNS = true;
    this.version = 6.1;
    return;
  }

  s = "MSIE";
  if ((i = ua.indexOf(s))) {
    this.isIE = true;
    this.version = parseFloat(ua.substr(i + s.length));
    return;
  }
}

var browser = new Browser();