version=navigator.appVersion; 
dom=document.getElementById?1:0; 

ie5=(version.indexOf("MSIE 5")>-1 &&  dom)?1:0; 
ie6=(version.indexOf("MSIE 6")>-1 &&  dom)?1:0; 
ie4=(document.all && !dom)?1:0; 
ns5=(dom && parseInt(version) >= 5) ?1:0; 
ns4=(document.layers && !dom)?1:0;


function ocultarCapa(){
	if(ns5){
		document.getElementById("cargando").style.visibility='hidden';
		document.getElementById("web").style.visibility='visible';
	}
	else if(ns4){
		document.cargando.visibility='hidde';
		document.web.visibility='show';
	}
	else{
		document.all["cargando"].style.visibility='hidden';
		document.all["web"].style.visibility='visible';
	}
}

function aumentaImage(capa,img,dir,ancho,alto){
	inc=2; // Siempre par
	tope=alto*inc; // Alto máximo
	imagen=document.getElementById(img);
	objeto=document.getElementById(capa);
	objeto.style.zIndex=99;
	if (imagen.height<tope){
			coef=ancho/alto;
			imagen.height=parseInt(imagen.height)+parseInt(inc);
			imagen.width=parseInt(imagen.width)+parseInt(inc*coef);
			objeto.style.top=parseInt(objeto.style.top)-parseInt(inc);
			if (coef>1 && coef<2) coef=1;
			if (dir=="c")
				objeto.style.left=parseInt(objeto.style.left)-parseInt((inc*coef)/2);
			if (dir=="i")
				objeto.style.left=parseInt(objeto.style.left)-parseInt(inc*coef);
	}
	a=setTimeout("aumentaImage('"+capa+"','"+img+"','"+dir+"',"+ancho+","+alto+")",15);
}

function disImage(capa,img,ancho,alto,izq,arriba){

	clearTimeout(a);
	//alert(imagen.height+","+imagen.width);

	imagen=document.getElementById(img);
	objeto=document.getElementById(capa);
	objeto.style.zIndex=1;
	objeto.style.left=izq;
	objeto.style.top=arriba;
	imagen.width=ancho;
	imagen.height=alto;
}

function X(obj){
    var curleft = 0;
    if(obj.offsetParent)
        while(1){
          curleft += obj.offsetLeft;
          if(!obj.offsetParent) break;
          obj = obj.offsetParent;
        }
    else if(obj.x)
        curleft += obj.x;
    return curleft;
  }

  function Y(obj){
    var curtop = 0;
    if(obj.offsetParent)
        while(1){
          curtop += obj.offsetTop;
          if(!obj.offsetParent) break;
          obj = obj.offsetParent;
        }
    else if(obj.y)
        curtop += obj.y;
    return curtop;
  }
	

function iman(){

	scrollH = document.body.scrollTop;
	scrollL = document.body.scrollLeft;
	
	ventanaX = document.body.clientWidth
	ventanaY = document.body.clientHeight

	objMetal = document.getElementById('menu');
	objIman = document.getElementById('iman');
	
	y = ( ventanaY <= Y(objIman)) ? ventanaY : Y(objIman);
	x = ( ventanaX <= X(objIman)) ? ventanaX : X(objIman)+6;
	
	x = x + scrollL;
	y = y + scrollH;

	objMetal.style.left = x - objMetal.clientWidth ;
	objMetal.style.top = y - objMetal.clientHeight;

	setTimeout('iman()',50);
}
