// Navegador var ie = document.all ? 1 : 0; var ns = document.layers ? 1 : 0; // Popups //------------------------------------------------------------------------------------------------ var ventana; function abrePop(cual, nombre, alto, ancho, ajustable, scroll) { 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, 'left='+ donde_x +', top='+ donde_y +', width='+ ancho +', height='+ (alto+5) +', location=no, toolbar=no, directories=no, resizable='+ ajustable +', scrollbars='+ scroll +', status=no'); } ventana.focus(); } // función GENÉRICA para cualquier formulario //------------------------------------------------------------------------------------------------ function chekea(cual) { var i, tipo, valor; if (cual.elements) { for (i=0; i parseInt(tipo[4],10)) { alert("El campo \""+tipo[6]+"\" NO puede ser mayor de "+tipo[4]+" caracteres"); if (cual.elements[i].type!="hidden"){ cual.elements[i].focus(); } return false; } break; case "str": // Primero veo si es obligatorio RELLENARLO if ((valor.length == 0) && tipo[5] == "true") { alert("El campo \""+tipo[6]+"\" es OBLIGATORIO"); if (cual.elements[i].type!="hidden"){ cual.elements[i].focus(); } return false; } // Después veo si es menor que el mínimo if (tipo[5] == "true" && valor.length < parseInt(tipo[3],10)) { alert("El campo \""+tipo[6]+"\" NO puede ser menor de "+tipo[3]+" caracteres"); if (cual.elements[i].type!="hidden"){ cual.elements[i].focus(); } return false; } // Y por último si es mayor que el máximo if (valor.length > parseInt(tipo[4],10)) { alert("El campo \""+tipo[6]+"\" NO puede ser mayor de "+tipo[4]+" caracteres"); if (cual.elements[i].type!="hidden"){ cual.elements[i].focus(); } return false; } break; case "int": // Primero veo si es obligatorio RELLENARLO if ((valor.length == 0) && tipo[5] == "true") { alert("El campo \""+tipo[6]+"\" es OBLIGATORIO"); if (cual.elements[i].type!="hidden"){ cual.elements[i].focus(); } return false; } // Después compruebo que sea NUMÉRICO if (!(esnumerico(valor))) { alert("El campo \""+tipo[6]+"\" debe ser NUMÉRICO"); if (cual.elements[i].type!="hidden"){ cual.elements[i].focus(); cual.elements[i].select(); } return false; } // Después veo si es menor que el mínimo if (parseInt(valor,10) < parseInt(tipo[3],10)) { alert("El campo \""+tipo[6]+"\" NO puede ser menor que "+tipo[3]); if (cual.elements[i].type!="hidden"){ cual.elements[i].focus(); } return false; } // Y por último si es mayor que el máximo if (parseInt(valor,10) > parseInt(tipo[4],10)) { alert("El campo \""+tipo[6]+"\" NO puede ser mayor que "+tipo[4]); if (cual.elements[i].type!="hidden"){ cual.elements[i].focus(); cual.elements[i].select(); } return false; } break; case "date": // Primero veo si es obligatorio RELLENARLO if ((valor.length == 0) && tipo[5] == "true") { alert("El campo \""+tipo[6]+"\" es OBLIGATORIO"); if (cual.elements[i].type!="hidden"){ cual.elements[i].focus(); } return false; } // Después compruebo que sea FECHA if (esfecha(valor) != "si" && valor != "") { alert("El campo \""+tipo[6]+"\" debe ser de tipo fecha: DD/MM/AAAA\n"+esfecha(valor)); if (cual.elements[i].type!="hidden"){ cual.elements[i].focus(); } return false; } // Después veo si es menor que el mínimo if (convierteFecha(valor) < convierteFecha(tipo[3])) { alert("El campo \""+tipo[6]+"\" NO puede ser menor de "+tipo[3]); if (cual.elements[i].type!="hidden"){ cual.elements[i].focus(); } return false; } // Después veo si es mayor que el máximo if (convierteFecha(valor) > convierteFecha(tipo[4])) { alert("El campo \""+tipo[6]+"\" NO puede ser mayor de "+tipo[4]); if (cual.elements[i].type!="hidden"){ cual.elements[i].focus(); } return false; } break; case "eml": //E-mail // Primero veo si es obligatorio RELLENARLO if ((tipo[5] == "true") && (valor.length == 0)) { alert("El campo \""+tipo[6]+"\" es OBLIGATORIO"); if (cual.elements[i].type!="hidden"){ cual.elements[i].focus(); } return false; } // Después compruebo que sea EMAIL válido if ((esMail(valor)!=true) && (valor!="")){ alert("El campo \""+tipo[6]+"\" debe ser una dirección de correo válida"); if (cual.elements[i].type!="hidden"){ cual.elements[i].focus(); } return false; } break; case "alf": // Es el tipo alfanumérico // Primero veo si es obligatorio RELLENARLO if ((valor.length == 0) && tipo[5] == "true") { alert("El campo \""+tipo[6]+"\" es OBLIGATORIO"); if (cual.elements[i].type!="hidden"){ cual.elements[i].focus(); } return false; } // Después veo si es menor que el mínimo if (tipo[5] == "true" && valor.length < parseInt(tipo[3],10)) { alert("El campo \""+tipo[6]+"\" NO puede ser menor de "+tipo[3]+" caracteres"); if (cual.elements[i].type!="hidden"){ cual.elements[i].focus(); } return false; } // Y por último si es mayor que el máximo if (valor.length > parseInt(tipo[4],10)) { alert("El campo \""+tipo[6]+"\" NO puede ser mayor de "+tipo[4]+" caracteres"); if (cual.elements[i].type!="hidden"){ cual.elements[i].focus(); } return false; } // Después compruebo que sea alfanumerico if ((esAlfanumerico(valor)!=true) && (valor!="")){ alert("El campo \""+tipo[6]+"\" debe estar formado por letras y numeros"); if (cual.elements[i].type!="hidden"){ cual.elements[i].focus(); } return false; } break; case "file": // Primero veo si es obligatorio RELLENARLO if ((valor == "") && tipo[5] == "true") { alert("El campo \""+tipo[6]+"\" es OBLIGATORIO"); if (cual.elements[i].type!="hidden"){ cual.elements[i].focus(); } return false; } break; default: alert("No existen restricciones de tipo \""+tipo[2]+"\""); return false; break; } } } } } return true; } //COMPRUEBA las fechas de un buscadores //------------------------------------------------------------------------------------------------ function chekeaFrmBsq(cual, mensaje){ var seguir=true; var valor = cual.elements["bsqFechaDesde"].value; if (esfecha(valor) != "si" && valor != "") { alert(mensaje); cual.elements["bsqFechaDesde"].focus(); seguir = false; } valor = cual.elements["bsqFechaHasta"].value; if (esfecha(valor) != "si" && valor != "" && seguir==true) { alert(mensaje); cual.elements["bsqFechaHasta"].focus(); seguir = false; } return seguir; } //COMPRUEBA que el campo sea fecha //------------------------------------------------------------------------------------------------ function esfecha(dato) { var fecha_split; var i; var tdia, tmes, tano; fecha_split = dato.split('.'); if(fecha_split.length != 3) {return "Debe tener DD.MM.AAAA";} tdia = parseInt(fecha_split[0],10); tmes = parseInt(fecha_split[1],10); tano = parseInt(fecha_split[2],10); if ((fecha_split[0].length!=2) || (!esNumeroEstricto(fecha_split[0])) ) {return "El día no es correcto. Formato: DD.MM.AAAA";} if ((fecha_split[1].length!=2) || (!esNumeroEstricto(fecha_split[1])) ) {return "El mes no es correcto. Formato: DD.MM.AAAA";} if ((fecha_split[2].length!=4) || (!esNumeroEstricto(fecha_split[2])) ) {return "el año no es correcto. Formato: DD.MM.AAAA";} // Comprobamos que sean 3 elementos // Comprobamos que no sean ceros for (i=0; i'9' || dato.charAt(i)<'0') { return false;} } return true; } // Recarga la página añadiendo una variable al querystring // ----------------------------------------------------------------------------------------------- function recargaPagina(todo, varQuery, varQueryValor) { window.location = ""+todo+"&"+varQuery+"="+varQueryValor; } // MUESTRA o no una capa mediante la propiedad display // ------------------------------------------------------------------------------------------------ function abrirCerrarCapa(capa){ if(document.getElementById(capa).style.display=='none'){ document.getElementById(capa).style.display='block'; if(document.getElementById("btnAbrirCerrar")){ document.getElementById("btnAbrirCerrar").src="img/btnFlechaAr.gif"; } }else{ document.getElementById(capa).style.display='none'; if(document.getElementById("btnAbrirCerrar")){ document.getElementById("btnAbrirCerrar").src="img/btnFlechaAb.gif"; } } } // VALIDA un email //------------------------------------------------------------------------------------------------ function esMail(texto){ var valido = true; var cadena = "abcdefghijklmnñopqrstuvwxyzABCDEFGHIJKLMNÑOPQRSTUVWXYZ1234567890@._-"; var arroba = texto.indexOf("@", 0); if ((texto.lastIndexOf("@")) != arroba) arroba = -1; var punto = texto.lastIndexOf("."); var i; for (i=0 ;i 1) && (arroba + 1 < punto) && (punto + 1 < (texto.length)) && (valido == true) && (texto.indexOf("..",0) == -1)){ valido = true; }else{ valido = false; } return valido; } // REDIRIGE un banner //------------------------------------------------------------------------------------------------ function abreBanner(enlace){ window.open(enlace); // window.location = enlace; } // MUESTRA un banner con enlaces (se llama directamente desde el banner) //---------------------------------------------------------------------------------------------------------------------- function muestraBannerEnlaces(enlaces){ var aux, clase; aux=desordenar(enlaces); document.write(""); for(i=0;i"); } document.write("
"+aux[i]+"
"); } // DESORDENAR un array //---------------------------------------------------------------------------------------------------------------------- function desordenar(array){ var aux=array; var i=aux.length; var j; var tmp; while(i--){ j=Math.floor( Math.random() * (i+1) ); tmp=aux[i]; aux[i]=aux[j]; aux[j]=tmp; } return aux; } // VALIDA un texto de tipo alfanumerico // ----------------------------------------------------------------------------------------------- function esAlfanumerico(texto){ var valido = true; var cadena = "abcdefghijklmnñopqrstuvwxyzABCDEFGHIJKLMNÑOPQRSTUVWXYZ1234567890"; var i; for (i=0 ;i 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:"625", // 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 : "" }); } // RECARGA la pagina al seleccionar un año o un mes distinto en el combo del calendario // --------------------------------------------------------------------------------------- function recargaCalendario(destino){ var ano, mes, fechaIni, fechaFin; ano=document.frmCalendario.anoCalendario.value; mes=document.frmCalendario.mesCalendario.value; fechaIni="01."+numDosCifras(mes)+"."+ano; fechaFin=nDiasMes(ano, mes)+"."+numDosCifras(mes)+"."+ano; // con esta opcion enviamos tambien las fechas del primer y último día del mes seleccionado // window.location.href = destino+"&anoCalendario="+ano+"&mesCalendario="+mes+"&bsqFechaDesde="+fechaIni+"&bsqFechaHasta="+fechaFin; // con esta opcion solo enviamos el mes y año del calendario para posicionarlo en esa posicion al recargar la página window.location.href = destino+"&anoCalendario="+ano+"&mesCalendario="+mes; } // DEVUELVE el nº de días de un mes // --------------------------------------------------------------------------------------- function nDiasMes(ano, mes){ var msDia, msFecha, fecha; msDia = 86400000; //nº de ms de un dia msFecha = new Date(ano, mes, 1).getTime();// nº de ms hasta el dia 1 del mes siguiente al seleccionado fecha = new Date(msFecha - msDia); // fecha del último día del mes return fecha.getDate(); } // 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; } // AUMENTA O DISMINUYE el texto que hay dentro de un div // ------------------------------------------------------------------------------------------------ function zoomTexto(accion, elemento, maximo){ //inicializaciones if(document.getElementById(elemento)){ obj=document.getElementById(elemento); if (obj.style.fontSize==""){ valor=parseInt(maximo); obj.style.fontSize=valor+"%"; } actual=parseInt(obj.style.fontSize); //valor actual del tamaño del texto incremento=10;// el valor del incremento o decremento en el tamaño //accion sobre el texto if(accion=="reestablecer"){ valor=parseInt(maximo); obj.style.fontSize=valor+"%" } if(accion=="aumentar" && actual<=150){ valor=actual+incremento; obj.style.fontSize=valor+"%" } if(accion=="disminuir" && actual>=50){ valor=actual-incremento; obj.style.fontSize=valor+"%" } } } // CREA un objeto para AJAX según disponibilidad del navegador // ------------------------------------------------------------------------------------------- function GetXmlHttpObject() { var objXMLHttp = null; if (window.XMLHttpRequest) { objXMLHttp = new XMLHttpRequest(); } else if (window.ActiveXObject) { objXMLHttp = new ActiveXObject("Microsoft.XMLHTTP"); } return objXMLHttp; } // // ------------------------------------------------------------------------------------------- function consultaAjax(destino, funcion) { var devolver; devolver = ""; var xmlHttp = GetXmlHttpObject(); if (xmlHttp==null) { alert ("Browser does not support HTTP Request"); //return; } xmlHttp.onreadystatechange = function(){ if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") { if (xmlHttp.responseText == -1000){ // id incorrecto devolver = ""; }else{ // id correcto devolver = xmlHttp.responseText; } eval(funcion)(devolver); } }; xmlHttp.open("GET", "consultaAjax.php"+ destino , true); xmlHttp.send(null); } // CAMBIA la información de un bloque // --------------------------------------------------------------------------------------- function cambiaInfoBloq(idBloque, cuantos, direccion, seccion){ var i; for(i=0; i < cuantos; i++){ if(document.getElementById("cntBloque_"+ idBloque +"_"+ cuantos +"_"+ i).style.display == ""){ seleccionado = i; } } if(document.getElementById("cntBloque_"+ idBloque +"_"+ cuantos +"_"+ eval(seleccionado + direccion))){ document.getElementById("cntBloque_"+ idBloque +"_"+ cuantos +"_"+ seleccionado).style.display = "none"; document.getElementById("cntBloque_"+ idBloque +"_"+ cuantos +"_"+ eval(seleccionado + direccion)).style.display = ""; } seleccionado = eval(seleccionado + direccion); if(seleccionado <= 0){ document.getElementById("flIzdaBloq_"+ idBloque +"_"+ seleccionado +"_-1").style.visibility = "hidden"; }else{ document.getElementById("flIzdaBloq_"+ idBloque +"_"+ seleccionado +"_-1").style.visibility = ""; } if(seleccionado >= (cuantos-1)){ document.getElementById("flDchaBloq_"+ idBloque +"_"+ seleccionado +"_1").style.visibility = "hidden"; }else{ document.getElementById("flDchaBloq_"+ idBloque +"_"+ seleccionado +"_1").style.visibility = ""; } actualizaVisitaOJD(seccion); } // CAMBIA la pestaña de un bloque // --------------------------------------------------------------------------------------- function cambiaInfoBloqPestana(idBloque, idPestana, cuantos, direccion, seccion){ var i; for(i=0;i