// --------------------------------------------------------------------------
// Compatibilización entre navegadores en el manejo de capas.
// --------------------------------------------------------------------------
// Programado por Javier Sánchez García 
// --------------------------------------------------------------------------
// Las capas se generarán mediante el tag <Div Id="capa"></div>
// --------------------------------------------------------------------------

var esNS4 = (document.layers) ? true : false;
var esIE4 = (document.all && !document.getElementById) ? true : false;
var esIE5 = (document.all && document.getElementById) ? true : false;
var esNS6 = (!document.all && document.getElementById) ? true : false;

var referenciaEstilo=(esNS4)?"":".style";;
var capaVisible;
var navegador;

function refCapa(nombreCapa) {
  if (esNS4) { return "document.layers['"+nombreCapa+"']"; }
  else if (esIE4)  { return "document.all['"+nombreCapa+"']"; }
  return "document.getElementById(\""+nombreCapa+"\")"; 
}

function stopEvent(e)
{
	if (!e) var e = window.event;
	e.cancelBubble = true;
	if (e.stopPropagation) e.stopPropagation();
}


 
var noabrir=false;
function cargar(n,s){ noabrir=true; eval('var v='+n+'.location.href="'+s+'";'); return false; }


function ocultarCapa(nombreCapa) { eval(refCapa(nombreCapa)+referenciaEstilo+'.display = "none"'); }
function mostrarCapa(nombreCapa) { eval(refCapa(nombreCapa)+referenciaEstilo+'.display = "block"'); }

function visibleCapa(nombreCapa) {
	if (noabrir) { noabrir=false; return false;}
	var x=eval(refCapa(nombreCapa)+referenciaEstilo+'.display');
	x=(x=="none")?"block":"none";
	//getScroll();
	eval(refCapa(nombreCapa)+referenciaEstilo+'.display = "'+x+'"');
	//setScroll();
	return (x=="none")?false:true;
}

function refIframe(nombre) {
	var iframes = document.getElementsByTagName("IFRAME");
	alert(iframes[0].contentDocument.title);
	return iframes[0];
	if (nombre.contentDocument) {
			return nombre.contentDocument; // NS6
	} else if (nombre.contentWindow) {
			return nombre.contentWindow.document; 	// IE5.5 , IE6
	} else if (nombre.document) {
			return nombre.document;     // IE5
	} else { return false; }
}
