function Prueba(texto) {
	document.getElementById('mensajeGeneraBoletin').innerHTML=texto;
}

function pulsaEnter(evento,campo,accion) {
var tecla;
	if (evento.keyCode)
         tecla = evento.keyCode;
     else if (evento.which)
         tecla = evento.which;
     else
         return false;

		if (tecla == 13) 
			if (accion=="envio")
				document.getElementById(campo).click();
			else
				document.getElementById(campo).focus();

	return true; 
}

/* Funcion para seleccionar todos los campos checkbox de una lista de registros. */
function SeleccionaTodos(formulario) {
	for (i=0; i < eval('document.'+formulario+'.elements.length'); i++) {
	  if(eval('document.'+formulario+'.elements['+i+'].type') == 'checkbox') {
			eval('document.'+formulario+'.elements['+i+']').checked =!(eval('document.'+formulario+'.elements['+i+']').checked);
		}
	}
};

/* Funcion para cambiar el estado de DISABLED de los campos checkbox de una lista. */
/*
function EstadoOpcionesMenu(formulario,nombremenu,nombreopcion,numeroOpciones) {
	if (eval('document.'+formulario+'.'+nombremenu).checked) {
		for(x=1;x<=numeroOpciones;x++) {
			eval('document.'+formulario+'.'+nombreopcion+'_'+x).disabled=false;
		}
	} else {
		for(x=1;x<=numeroOpciones;x++) {
			eval('document.'+formulario+'.'+nombreopcion+'_'+x).disabled=true;
		}
	}
};
*/
function EstadoOpcionesMenu(formulario,numeroMenu,listaOpciones) {
var opciones=listaOpciones.split(",");
var numeroOpciones=opciones.length;

	if (eval('document.'+formulario+'.menu'+nombremenu).checked) {
		for(x=0;x<numeroOpciones;x++) {
			eval('document.'+formulario+'.menu'+opciones[x]).disabled=false;
		}
	} else {
		for(x=1;x<=numeroOpciones;x++) {
			eval('document.'+formulario+'.menu'+opciones[x]).disabled=true;
		}
	}
};



/*Funcion para limpiar los campos de un formulario*/
function limpiaForm(formulario) {
 eval('document.'+formulario+'.reset()');
}

/*Asigna un valor a un campo de formulario*/
function AsignaValor(iddato,valor) {
	document.getElementById(iddato).value=valor;
}

/* Función para escribir un mensaje en una capa. Lo uso tambien para limpiar la barra de mensajes*/
function poneMensaje(capa,mensaje) {
	document.getElementById(capa).innerHTML=mensaje;
}

/* Funcion para seleccionar una opcion de un select*/
function seleccionaOpcion(campoSelect,valor) {
//alert(campoSelect);
//alert(valor);
	var numOptions = document.getElementById(campoSelect).length;
	for (i = 0; i < numOptions; i++) {
		if (document.getElementById(campoSelect).options[i].value == valor) {
			document.getElementById(campoSelect).options[i].selected = true;
		}
	}
}



/*Funcion para obtener la relación de campos checkbox seleccionados de una lista de registros */
function CuentaSeleccionados(formulario,seleccionados){
	var seleccion="";
	for (x=0;x<eval('document.'+formulario+'.elements.length');x++) {
		if (eval('document.'+formulario+'.elements['+x+'].type')== 'checkbox')
		if (eval('document.'+formulario+'.elements['+x+'].checked')) {
			seleccion=seleccion+eval('document.'+formulario+'.elements['+x+'].value')+',';
		}
	}
	eval('document.'+formulario+'.'+seleccionados+'.value=seleccion.substr(0,seleccion.length-1)');
}

/*Funcion para mostrar un mensaje para confirmar el borrado de registros.*/
function ConfirmaBorrado() {
	if (confirm("¿Desea borrar los datos seleccionados?"))
		return true;
	else
		return false;
};


/*Funcion para mostrar una capa*/
function MuestraCapa(capa1) {
	document.getElementById(capa1).style.display='block';
	document.getElementById(capa1).style.visibility="visible";
}


/*Funcion para ocultar una capa*/
function OcultaCapa(capa) {
	document.getElementById(capa).style.visibility="hidden";
	document.getElementById(capa).style.display='none';
}

/*Funcion para ocultar todas las capas superiores*/
function OcultarCapas() {
	var capas=Array('calendario','BarraIconos');

	for(x=0;x<capas.length;x++) {
		document.getElementById(capas[x]).style.visibility='hidden';
		document.getElementById(capas[x]).style.display='none';
	}
}

/*
	Funcion para obtener la posicion de un elemento HTML. Usa como parametro el ID del elemento o el elemento en sí.
	Devuelve un objeto con los valores. X - Y
*/
function posicionAbsoluta(elemento) {
  if (typeof elemento == "string")
    elemento = document.getElementById(elemento)

  if (!elemento) return { top:0,left:0 };

  var y = 0;
  var x = 0;
  while (elemento.offsetParent) {
    x += elemento.offsetLeft;
    y += elemento.offsetTop;
    elemento = elemento.offsetParent;
  }
  return {top:y,left:x};
}


/*Funcion para posicionar el calendario en pantalla*/
function MuestraCalendario(imagen,campo) {
  var elemento = document.getElementById(imagen);
  var pos = posicionAbsoluta(elemento);

//	arriba=pos.top-200;
//	izquierda=pos.left-230;

	arriba=pos.top;
	izquierda=pos.left;
	
	document.getElementById('calendario').style.display			=	'inline';
	document.getElementById('calendario').style.top					=	arriba;
	document.getElementById('calendario').style.left				=	izquierda;
	document.getElementById('calendario').style.visibility	=	"visible";

	return xajax_Calendario(campo);
}

/* Copia el contenido del editor en una variable. Es necesario hacerlo así al usar ajax.*/
function copiaTextoEditor(campoEditor,campoTexto) {
	if (campoEditor=="") campoEditor='textoEdictoFCK';
	if (campoTexto=="") campoTexto='textoEdicto';
	var oIntro = FCKeditorAPI.GetInstance(campoEditor) ;
	var dc1 = oIntro.GetHTML();
	document.getElementById(campoTexto).value=dc1;
}

/*Limpia el contenido del editor de texto*/
function limpiaTextoEditor() {
	var oIntro = FCKeditorAPI.GetInstance('textoEdictoFCK') ;
	oIntro.SetData('');
	document.getElementById('textoEdicto').value="";
}

function pegaTextoEditor(texto) {
	var oIntro = FCKeditorAPI.GetInstance('textoEdictoFCK') ;
	oIntro.SetData(texto);
}

function insertaTextoEditor(texto,campoEditor) {
	if (campoEditor=="") campoEditor='textoEdictoFCK';
	var oIntro = FCKeditorAPI.GetInstance(campoEditor);
	oIntro.InsertHtml(texto);
}

function menuBop(opcion) {
	switch(opcion) {
		case "servicios":
			document.getElementById('serviciosUL').style.visibility='visible';
			document.getElementById('serviciosUL').style.display='block';
			document.getElementById('presentacionUL').style.visibility='hidden';
			document.getElementById('presentacionUL').style.display='none';
			document.getElementById('normativaUL').style.visibility='hidden';
			document.getElementById('normativaUL').style.display='none';
			break;
		case "presentacion":
			document.getElementById('serviciosUL').style.visibility='hidden';
			document.getElementById('serviciosUL').style.display='none';
			document.getElementById('presentacionUL').style.visibility='visible';
			document.getElementById('presentacionUL').style.display='block';
			document.getElementById('normativaUL').style.visibility='hidden';
			document.getElementById('normativaUL').style.display='none';
			break;
		case "normativa":
			document.getElementById('serviciosUL').style.visibility='hidden';
			document.getElementById('serviciosUL').style.display='none';
			document.getElementById('presentacionUL').style.visibility='hidden';
			document.getElementById('presentacionUL').style.display='none';
			document.getElementById('normativaUL').style.visibility='visible';
			document.getElementById('normativaUL').style.display='block';
			break;
		case "boletines":
			document.getElementById('serviciosUL').style.visibility='hidden';
			document.getElementById('serviciosUL').style.display='none';
			document.getElementById('presentacionUL').style.visibility='hidden';
			document.getElementById('presentacionUL').style.display='none';
			document.getElementById('normativaUL').style.visibility='hidden';
			document.getElementById('normativaUL').style.display='none';
			break;
	}
}
