// if js is disabled we want app elements to be visible
// so they are visible by default in the CSS
document.write("<" + "style type='text/css'>.subOpc{display:none;}<" + "/" + "style>");

/// Función aplicar los márgenes de la página en función de la resolución
if (screen.width <= 800) {
	var margen = 1;
	document.write("<style type='text/css' media='screen'>body{margin: 5px " + margen + "% 10px " + margen + "%;}</style>");
}  else {
	var margen = screen.width/199+3;
	document.write("<style type='text/css' media='screen'>body{margin: 5px " + margen + "% 10px " + margen + "%;}</style>");
}

// Función para redimensionar el Flash
function Flash() {
	var anchoFlash = document.getElementById("flashHome").offsetWidth;
	var altoFlash = anchoFlash/3.2;
	document.getElementById("flashHome").style.height = altoFlash + 'px';
}

// Javascript para ocultar o mostrar el menú izquierdo
 function ocultaMenu() {
	var estado = document.getElementById("menuLateral").style.display;
	if (estado == "none") {
	document.getElementById("contenido").className = "contenidoEstrecho";
	document.getElementById("menuLateral").style.display = "block";
	document.getElementById("principal").className = "mostrarMenu";
	document.getElementById("solapillaOcultar").src="../../images/ocultaMenu.gif";
	} else if (estado == "block") {
	document.getElementById("contenido").className="contenidoAncho";
	document.getElementById("menuLateral").style.display = "none";
	document.getElementById("principal").className = "ocultarMenu";
	document.getElementById("solapillaOcultar").src="../../images/muestraMenu.gif";
	}
}

// Javascript para el menú izquierdo
function menuIzq()
{
  var ln=1, // lnk number
      lo=1; // lnk object

  for (; lo; ++ln) {
    lo = document.getElementById('opc' + ln);
    if (lo) {
      lo.subOpcId = 'subOpc' + ln;
      lo.onclick = menuIzq_onclick;
    }
  }
  window.currentSubOpcId = null; // global
}
// assumes app elements have display:none initially
function menuIzq_onclick()
{
  var e;
  if (currentSubOpcId && currentSubOpcId != this.subOpcId) {
    e = document.getElementById(currentSubOpcId);
    e.style.display = 'none';
  }
  e = document.getElementById(this.subOpcId);
  if (e.style.display == 'block') {
    e.style.display = 'none';
    currentSubOpcId = null;
  }
  else {
    e.style.display = 'block';
    currentSubOpcId = this.subOpcId;
  }
  return false;
}

// Javascript para mostrar u ocultar elementos
 function muestraCapa(idCapa) {
	var estado = document.getElementById(idCapa).style.display;
	if (estado == "block") {
	document.getElementById(idCapa).style.display = "none";
	} else if (estado == "none") {
	document.getElementById(idCapa).style.display = "block";
	}
}  

// Esta función aplica un estilo distinto a la opción de menú seleccionada
function mostrarMenuSecundario(idMenu){	
		
	document.getElementById(idMenu).style.display = 'block';
}

function opcionActiva(idMenu){	
		
	document.getElementById(idMenu).className = 'opcActiva';
}

//Javascript para mostrar y ocultar divs en cifras
 function muestraOcultaDivs (obj) {
 	if (document.getElementById(obj).style.display == "none") {
		document.getElementById(obj).style.display = "block";
	} else {
		document.getElementById(obj).style.display = "none";
	}
 }
 
 //Mostrar y ocultar secciones FAQ
function MM_findObj(n, d) {
  var p,i,x;
	
	if(!d) {
	d=document;
	} else if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);
	} else 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=MM_findObj(n,d.layers[i].document);
	}
  
	if(!x && d.getElementById) {
	x=d.getElementById(n);
	return x;
	}
}

function muestraOcultaCapas() {
  var i,p,v,obj,args=muestraOcultaCapas.arguments;
  for (i=0; i<(args.length-2); i+=3) {
		if ((obj=MM_findObj(args[i]))!=null) {
			v=args[i+2];
   	 	if (obj.style) { 
				obj=obj.style; v=(v=='mostrar')?'':(v=='ocultar')?'none':v; 
			}
    	obj.display=v;
		}
	}
}