// CORRIGE defectos de IE para mostrar el menú emergente
// -----------------------------------------------------------------------------------------------
function iniciaMenuDesplegable() {
	if (document.all && document.getElementById) {
		if (document.getElementById("menuDesplegable")) {
			navRoot = document.getElementById("menuDesplegable");
			for (i=0; i < navRoot.childNodes.length; i++) {
				node = navRoot.childNodes[i];
				if (node.nodeName == "LI") {
					selects = document.getElementsByTagName("select");
					node.onmouseover = function() {
						this.className += " over";
						// ocultamos los combos
						for (i = 0; i != selects.length; i++) {
							selects[i].style.visibility = "hidden";
						}
					}
					node.onmouseout = function() {
						this.className = this.className.replace(" over", "");
						// mostramos los combos
						for (i = 0; i != selects.length; i++) {
							selects[i].style.visibility = "visible";
						}
					}
				}
			}
		}
	}
}

// Navegador
//------------------------------------------------------------------------------------------------
var ie = document.all ? 1 : 0;
var ns = document.layers ? 1 : 0;


// ABRE una ventana popup
// -----------------------------------------------------------------------------------------------
function abrePop(cual, nombre, alto, ancho, ajustable, scroll) {
	var ventana;
	var donde_x, donde_y;
	donde_x = (screen.width - ancho) / 2;
	donde_y = (screen.height - alto) / 2;
	if (ie) {
		ventana = window.open(cual, nombre, 'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars='+scroll+', resizable='+ajustable+', copyhistory=no, width='+ancho+', height='+alto+', top='+donde_y+', left='+donde_x+'');
	} else if (ns) {
		ventana = window.open(cual, nombre, 'width='+ ancho +', height='+ alto +', location=no,toolbar=no, directories=no, menubar=no, resizable='+ajustable+', scrollbars='+ scroll +', status=no, top='+donde_y+', left='+donde_x+'');
	} else {
		
		ventana = window.open(cual, nombre, 'width='+ ancho +', height='+ alto +', location=no,toolbar=no, directories=no, menubar=no, resizable='+ajustable+', scrollbars='+ scroll +', status=no, top='+donde_y+', left='+donde_x+'');
	}
	ventana.focus();
}


// CAMBIA el valor de una variable de nº de registros
// -----------------------------------------------------------------------------------------------
function cambiaNumRs(todo, varQuery, varQueryValor) {
	window.location = ""+todo+"&"+varQuery+"="+varQueryValor;
}


// AÑADE un 0 a la izda de un nº de una cifra
// -----------------------------------------------------------------------------------------------
function numDosCifras(num){
	var aux =num;
	if (num < 10){
		aux = "0" + aux;
	}
	return aux;
}

// INICIA el editor de textos para textareas
// -----------------------------------------------------------------------------------------------
function iniciaEditor(btnMostrar, cssMostrar, hojaCss, enlace){
	tinyMCE.init({
	mode : "textareas",							//dónde actuará
	editor_selector : "mceEditor",				//<textarea class="mceEditor"> convierte un textarea en editor
	entity_encoding : "raw", 					//para que no sustituya tildes por &...
	theme : "plexus", 							//tipo
	language : "es",							//idioma
	docs_language : "es",						//idioma de la ayuda
	convert_newlines_to_brs : false,
	force_br_newlines : false,
	popups_css : hojaCss,						//hoja de estilos que cogerán las pop-ups
	//auto_resize : true,						//el editor se redimensiona para ocupar todo el espacio del q dispone (quita el scroll)
	theme_plexus_layout_manager: "SimpleLayout",//para redimensionar
	theme_plexus_statusbar_location :"bottom",	//para redimensionar
	theme_plexus_resizing : true,				//para redimensionar
	theme_plexus_resize_horizontal : false,		//para no redimensionar horizontalmente
	theme_plexus_path : false,					//no queremos path
	content_css : hojaCss,
	theme_plexus_styles : cssMostrar,			// estilos para el combo
	theme_plexus_buttons1 : btnMostrar, 		//botones activos
	theme_enlace: enlace,
	relative_urls: false,  						// El path debe ser absoluto
	plugins : "searchreplace",					//plugins: botón de reemplazar
	height : "200",
	width:"100%",
//	etiquetas válidas e inválidas
//	valid_elements : "strong/b,em/i,strike,-ul,-li"
//	invalid_elements como referencia porque el script funciona con las que que son válidas
//	invalid_elements : "-div[id|dir|class|align|style]"
	invalid_elements : ""
	});
}