// Funciones básicas para el tratamiento de Capas, para los navegadores Ns 4.* Ie4.* Ie5+ Ns6+ Mozilla...

// Sniffer, Último sniffer oficial bajado de http://developer.netscape.com/evangelism

 // convert all characters to lowercase to simplify testing
    var agt=navigator.userAgent.toLowerCase();

    // *** BROWSER VERSION ***
    // Note: On IE5, these return 4, so use is_ie5up to detect IE5.
    var is_major = parseInt(navigator.appVersion);
    var is_minor = parseFloat(navigator.appVersion);

    // Note: Opera and WebTV spoof Navigator.  We do strict client detection.
    // If you want to allow spoofing, take out the tests for opera and webtv.
    var is_nav  = ((agt.indexOf('mozilla')!=-1) && (agt.indexOf('spoofer')==-1)
                && (agt.indexOf('compatible') == -1) && (agt.indexOf('opera')==-1)
                && (agt.indexOf('webtv')==-1) && (agt.indexOf('hotjava')==-1));
    var is_nav2 = (is_nav && (is_major == 2));
    var is_nav3 = (is_nav && (is_major == 3));
    var is_nav4 = (is_nav && (is_major == 4));
    var is_nav4up = (is_nav && (is_major >= 4));
    var is_navonly      = (is_nav && ((agt.indexOf(";nav") != -1) ||
                          (agt.indexOf("; nav") != -1)) );
    var is_nav6 = (is_nav && (is_major == 5));
    var is_nav6up = (is_nav && (is_major >= 5));
    var is_gecko = (agt.indexOf('gecko') != -1);


    var is_ie     = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));
    var is_ie3    = (is_ie && (is_major < 4));
    var is_ie4    = (is_ie && (is_major == 4) && (agt.indexOf("msie 4")!=-1) );
    var is_ie4up  = (is_ie && (is_major >= 4));
    var is_ie5    = (is_ie && (is_major == 4) && (agt.indexOf("msie 5.0")!=-1) );
    var is_ie5_5  = (is_ie && (is_major == 4) && (agt.indexOf("msie 5.5") !=-1));
    var is_ie5up  = (is_ie && !is_ie3 && !is_ie4);
    var is_ie5_5up =(is_ie && !is_ie3 && !is_ie4 && !is_ie5);
    var is_ie6    = (is_ie && (is_major == 4) && (agt.indexOf("msie 6.")!=-1) );
    var is_ie6up  = (is_ie && !is_ie3 && !is_ie4 && !is_ie5 && !is_ie5_5);

    // KNOWN BUG: On AOL4, returns false if IE3 is embedded browser
    // or if this is the first browser window opened.  Thus the
    // variables is_aol, is_aol3, and is_aol4 aren't 100% reliable.
    var is_aol   = (agt.indexOf("aol") != -1);
    var is_aol3  = (is_aol && is_ie3);
    var is_aol4  = (is_aol && is_ie4);
    var is_aol5  = (agt.indexOf("aol 5") != -1);
    var is_aol6  = (agt.indexOf("aol 6") != -1);

    var is_opera = (agt.indexOf("opera") != -1);
    var is_opera2 = (agt.indexOf("opera 2") != -1 || agt.indexOf("opera/2") != -1);
    var is_opera3 = (agt.indexOf("opera 3") != -1 || agt.indexOf("opera/3") != -1);
    var is_opera4 = (agt.indexOf("opera 4") != -1 || agt.indexOf("opera/4") != -1);
    var is_opera5 = (agt.indexOf("opera 5") != -1 || agt.indexOf("opera/5") != -1);
    var is_opera5up = (is_opera && !is_opera2 && !is_opera3 && !is_opera4);

    var is_webtv = (agt.indexOf("webtv") != -1); 

    var is_TVNavigator = ((agt.indexOf("navio") != -1) || (agt.indexOf("navio_aoltv") != -1)); 
    var is_AOLTV = is_TVNavigator;

    var is_hotjava = (agt.indexOf("hotjava") != -1);
    var is_hotjava3 = (is_hotjava && (is_major == 3));
    var is_hotjava3up = (is_hotjava && (is_major >= 3));


	// Añadido por Isi...
		var is_dom = (is_gecko || is_ie5up || is_opera5up || is_nav6up);


// Instrucciones Necesarias para que al Variar de Tamaño el navegador haga un reload...

function recargar() { window.location.reload(); }
if (is_nav4) { window.captureEvents(Event.RESIZE); window.onresize=recargar;}

// Función pillada del Dreamweaver de Macromedia ...

function encontrar(n, d) { //v3.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=encontrar(n,d.layers[i].document); return x;
}

function estilo(id) {
	if (!is_dom) { ref=encontrar(id); if (is_ie4) {return ref.style} else if (is_nav4) {return ref} }
	else { return document.getElementById(id).style; }
	}

function referenciar(id) {
	if (!is_dom) {return encontrar(id); }
	else {return document.getElementById(id) || document.getElementByName(id); }
	}

function posicionar(id,x,y) { id=estilo(id); id.top=y; id.left=x; return false;}
function color(id,color) { id=estilo(id);  if (is_ie4up || is_dom) { id.fontWeight="bold"; } else if (is_nav4up) {id.bgColor=color; } return false; }
function grosor(id,grosor) { id=estilo(id); if (is_ie4up || is_dom) { id.fontWeight=grosor; } return false; }
function visibilidad(id,v) { id=estilo(id); vis=v?"visible":"hidden"; id.visibility=vis; }
function zindex(id,z) { id=estilo(id); id.zIndex=z; }
function clipear(id,x1,x2,y1,y2) {
	id=estilo(id);
	if (is_nav4up) { id.clip.top=y1; id.clip.bottom=y2; id.clip.left=x2; id.clip.right=x1; }
	else { id.clip='rect('+y1+','+x1+','+y2+','+x2+')'; }
	}
function escribir(navid,navtxt) {
	navid=referenciar(navid);
	if (is_ie4up || is_nav6up || is_opera5up || is_gecko) { navid.innerHTML=navtxt; }
	else if (is_nav4) {
			navid.document.open();
			navid.document.write(navtxt);
			navid.document.close();
			}
	}

function fExpandir(id) {
        tS1="../gfx/arbol1.gif";
        tS2="../gfx/arbol2.gif";
        t=estilo("capa"+id);
        tI=eval("document.imagen"+id);
        tI.src=(t.display=="block")?"../gfx/arbol1.gif":"../gfx/arbol2.gif";
        t.display=(t.display=="block")?"none":"block";
        }

function fVer(id) {
	t=estilo("capa"+id);
	t.display="block";
	}
function fOcultar(id) {
	t=estilo("capa"+id);
	t.display="none";
	}
BLANCO="#ff9900";
AZUL="#cee1f5";
o=new Array();
actual=0;

tContenido=new Array();

function cambiarFondo(obj,color) { obj.style.backgroundColor=color; }
function novisible(m) { document.getElementById(m).style.visibility="hidden"; document.getElementById(m).style.display="none"; }
function visible(m) { document.getElementById(m).style.visibility="visible"; document.getElementById(m).style.display="block"; }
function ver(m) { if (actual && actual!=m) { ocultar(actual); } actual=m; clearTimeout(o[m]); visible("capa"+m); }
function ocultar(m) { o[m]=setTimeout("novisible('capa"+m+"')",100); }

function crearAjax() {
        if (window.XMLHttpRequest) { objetoHttp=new XMLHttpRequest(); }
        else if (window.ActiveXObject) { objetoHttp=new ActiveXObject("Microsoft.XMLHTTP"); }
        return objetoHttp;
        }

function crearFS() {
	return new ActiveXObject("Scripting.FileSystemObject");
	}

tDiferencialX=0;
tDiferencialY=0;

tOInicial=0;
tOFinal=0;
tOIncremento=0;
tOProceso=null;

function fVerVentanaSeleccion(ancho,titulo) {
	tAncho=ancho?ancho:500;
	tTitulo=titulo?titulo:"Ventana de operaciones";
	tCF=document.getElementById("capaFrontal");
	tD=document.getElementById("capaVentanaSeleccion");
	tS=document.getElementById("capaSeleccion");
	tT=document.getElementById("ventanaSeleccionTitulo");
	tT.innerHTML=tTitulo;
	tCF.style.visibility="visible";
	tCF.style.width=document.body.scrollWidth;
	tCF.style.height=document.body.scrollHeight;
	tD.style.visibility="visible";
	tD.style.display="block";
	tS.style.display="block";
	tD.style.width=tAncho+"px";
	tOInicial=0;
	tOFinal=70;
	tOIncremento=5;
	iniciarSecuenciaOpacidad();
	}

function fOcultarVentanaSeleccion() {
	tCF=document.getElementById("capaFrontal");
	tD=document.getElementById("capaVentanaSeleccion");
	tS=document.getElementById("capaSeleccion");
	tCF.style.visibility="hidden";
	tD.style.visibility="hidden";
	tD.style.display="none";
	tS.style.display="none";
	tS.innerHTML="";
	}

function iniciarSecuenciaOpacidad() {
	tCF=document.getElementById("capaFrontal");
	tCF.style.filter="alpha(opacity="+tOInicial+")";
	tCF.style.opacity=tOInicial/100;
	tOProceso=setInterval("hacerSecuenciaOpacidad()",5);
	}

function hacerSecuenciaOpacidad() {
	tCF=document.getElementById("capaFrontal");
	tOInicial+=tOIncremento;
	tCF.style.filter="alpha(opacity="+tOInicial+")";
	tCF.style.opacity=tOInicial/100;
	if (tOInicial==tOFinal) { clearInterval(tOProceso); }
	}

function fEmpezarDragVentanaSeleccion(e) {
	if (is_ie) { 
		window.event.cancelBubble=true;
		window.event.returnValue=false;
		}
	tE=is_ie?event:e;
	tD=document.getElementById("capaVentanaSeleccion");
	tDiferencialX=tE.clientX-parseInt(tD.style.left);
	tDiferencialY=tE.clientY-parseInt(tD.style.top);
	document.onmousemove=fMoverDragVentanaSeleccion;
	document.onmouseup=fFinalizarDragVentanaSeleccion;
	document.onselectstart=function() { return false; }
	document.ondragstart=function() { return false; }
	document.body.focus();
	return false;
	}

function fMoverDragVentanaSeleccion(e) {
	tE=is_ie?event:e;
	tD=document.getElementById("capaVentanaSeleccion");
	tD.style.left=((tE.clientX-tDiferencialX)>1?tE.clientX-tDiferencialX:1)+"px";
	tD.style.top=((tE.clientY-tDiferencialY)>1?tE.clientY-tDiferencialY:1)+"px";
	document.body.focus();
	return false;
	}

function fFinalizarDragVentanaSeleccion(e) {
	document.onmousemove=null;
	return false;
	}
