function changeObjectVisibility(objectId, newVisibility) { // Lo primero es coger la referencia a partir del estilo del navegador y // asegurarse que el objeto existe var styleObject = getStyleObject(objectId); if(styleObject) { styleObject.visibility = newVisibility; return true; } else { // Si no podemos encontrar el objeto, no podemos cambiar su visibilidad return false; } } function getStyleObject(objectId) { // check W3C DOM, luego MSIE 4, luego NN 4. if(document.getElementById && document.getElementById(objectId)) { return document.getElementById(objectId).style; } else if (document.all && document.all(objectId)) { return document.all(objectId).style; } else if (document.layers && document.layers[objectId]) { return document.layers[objectId]; } else { return false; } } function enlaza (index) { var bucle; p_formid = index; for (bucle=0; bucle < document.forms[index].elements.length; bucle++) { if (document.forms[index].elements[bucle].type == 'text') { document.forms[index].elements[bucle].onblur = lostfocus; document.forms[index].elements[bucle].onfocus = gotfocus; } } } function submitclick() { var bucle; var resultado; var returnval; for (bucle=0; bucle < document.forms[0].elements.length; bucle++) { if (document.forms[0].elements[bucle].type == 'text') { if (comprobar (document.forms[0].elements[bucle]) == 0) { resultado = "error"; } } } if (resultado == "error") { alert ("Compruebe los campos."); returnval = false; } else { returnval = true; } return returnval; } function lostfocus() { if (window.event.srcElement.name.split("___")[3] == '1') { if (window.event.srcElement.value == '') { window.event.srcElement.className='boton3'; } else { window.event.srcElement.className='boton2'; } } else { window.event.srcElement.className='boton2'; } } function gotfocus() { window.event.srcElement.className='boton3'; } function seleccion() { window.event.srcElement.focus(); } function letranif(cadena) { var tmpletra; var posicion; posicion = 0 + (cadena % 23); tmpletra = "TRWAGMYFPDXBNJZSQVHLCKE".substring (posicion, posicion + 1); return tmpletra; } function comprobar (objeto) { var condiciones; var o_span; var bucle; var letra; var asciicharacter; condiciones = separar_cadena(objeto.name, "condiciones"); o_span = document.getElementById("span_" + objeto.id) o_span.innerHTML = ""; objeto.className = 'normal'; if (condiciones.indexOf ("r") != -1) { if (objeto.value == "") { o_span.innerHTML = "Campo obligatorio"; objeto.className='error'; return "0"; } else { objeto.className='normal'; } } if (condiciones.indexOf ("d") != -1) { for (bucle=0; bucle < 8; bucle++) { letra = objeto.value.substring(bucle, bucle + 1); asciicharacter = letra.charCodeAt(0); if ((asciicharacter >= 48) && (asciicharacter <= 57)) { } else { o_span.innerHTML = "Formato incorrecto del DNI"; objeto.className='error'; return "0"; } } if (objeto.value.substring (8, 9) != "-") { if (objeto.value.length == 8) { objeto.value = objeto.value + "-"; } } if (objeto.value.substring (8, 9) != "-") { o_span.innerHTML = "Formato incorrecto del DNI"; objeto.className='error'; return "0"; } letra = (letranif(objeto.value.substring(0, 8))); if (objeto.value.length == "9") { if (letra != objeto.value.substring(9, 10)) { if (objeto.value.substring(9, 10) == "") { objeto.value = objeto.value + letra; return "0"; } else { o_span.innerHTML = "Formato incorrecto del DNI"; objeto.className='error'; return "0"; } } else { return "1"; } } else { if (letra != objeto.value.substring(9, 10)) { o_span.innerHTML = "Formato incorrecto del DNI"; objeto.className='error'; return "0"; } else { return "1"; } } } return "1"; } function separar_cadena(cadena, tipo) { var simbolo; var guion; var temporal; var resultado; simbolo = cadena.indexOf ("¬"); if (simbolo == 0) { guion = cadena.indexOf ("_"); } else { temporal = cadena.substring(0, simbolo); guion = temporal.indexOf ("_"); } switch(tipo) { case "condiciones": resultado = cadena.substring(0, guion); return resultado; break; case "nombre": resultado = cadena.substring(guion + 1, simbolo); return resultado; break; case "tipo": resultado = cadena.substring(simbolo + 1, simbolo + 4); return resultado; break; case "tabla": resultado = cadena.substring (simbolo + 4, cadena.length); return resultado; break; } } function tFormato(importe) { var resultado; resultado = ""; if (importe == 0) { return "Vista previa. Introduzca los decimales con el símbolo del punto."; } else { miFloat = parseFloat(importe) if (isNaN(miFloat) == false) { miFloat = parseFloat(importe).toFixed(2).toString(); longitud = miFloat.substring(1, miFloat.length - 2).length; cantidadceros = parseInt(longitud / 3).toFixed(0); primerpunto = longitud % 3; for (bucle=0; bucle < miFloat.substring(1, miFloat.length - 2).length; bucle++) { if (cantidadceros > 0) { if ((bucle == primerpunto) && bucle != 0) { resultado = resultado + "."; } if (bucle != 0 && bucle != 1 && bucle != 2) { indice = (Math.floor(bucle / 3) * 3); if (bucle == primerpunto + indice) {resultado = resultado + ".";} } } resultado = resultado + miFloat.substring(bucle, bucle + 1); } return resultado + "," + miFloat.substring(miFloat.length - 2, miFloat.length) + " €"; } else { return "Vista previa. Introduzca los decimales con el símbolo del punto ."; } } } function confirmar(mensaje) { if (mensaje == "") {mensaje="¿Esta seguro que desea eliminar esta ficha?";} if (mensaje == null) {mensaje="¿Esta seguro que desea eliminar esta ficha?";} vconfirmar=confirm(mensaje); if (vconfirmar) {return true;} else {return false;} } function maximaLongitud(texto,maxlong) { var tecla, in_value, out_value; if (texto.value.length > maxlong) { in_value = texto.value; out_value = in_value.substring(0,maxlong); texto.value = out_value; return false; } return true; } function addOpt(oControl, iPos, sTxt, sVal, selected) { var selOpcion=new Option(sTxt, sVal); eval(oControl.options[iPos]=selOpcion); eval(oControl.options[iPos].selected = selected); } var ventana_pop=false; function Pop_UP(url, ancho, alto, titulo) { if (typeof ventana_pop.document == "object") {ventana_pop.close()} LeftPosition = (screen.width) ? (screen.width-ancho)/2 : 0; TopPosition = (screen.height) ? (screen.height-alto)/2 : 0; destino = "imagen.php?url=" + url + "&titulo=" + titulo; ventana_pop = window.open(destino, "Imagen", "status = 1, left = " + LeftPosition + ", top = " + TopPosition + ", height = " + alto + ", width = " + ancho + ", resizable = 0" ) } var ventana_imprimir=false; function tImprimir(url, ancho, alto, titulo) { if (typeof ventana_imprimir.document == "object") {ventana_imprimir.close()} LeftPosition = (screen.width) ? (screen.width-ancho)/2 : 0; TopPosition = (screen.height) ? (screen.height-alto)/2 : 0; destino = "imprimir.php?url=" + url + "&titulo=" + titulo; ventana_imprimir = window.open(url, "Imagen", "status = 1, left = " + LeftPosition + ", top = " + TopPosition + ", height = " + alto + ", width = " + ancho + ", resizable = 0, scrollbars = yes" ) } var ventana_ficha=false; function tFicha(url, ancho, alto) { if (typeof ventana_ficha.document == "object") {ventana_ficha.close()} LeftPosition = (screen.width) ? (screen.width-ancho)/2 : 0; TopPosition = (screen.height) ? (screen.height-alto)/2 : 0; destino = url; ventana_ficha = window.open(destino, "Imagen", "status = 1, left = " + LeftPosition + ", top = " + TopPosition + ", height = " + alto + ", width = " + ancho + ", resizable = 0, scrollbars=yes" ) } var ventana_ayuda=false; function tAyuda(url, ancho, alto) { if (typeof ventana_ayuda.document == "object") {ventana_ayuda.close()} LeftPosition = (screen.width) ? (screen.width-ancho)/2 : 0; TopPosition = (screen.height) ? (screen.height-alto)/2 : 0; destino = url; ventana_ayuda = window.open(destino, "Imagen", "status = 1, left = " + LeftPosition + ", top = " + TopPosition + ", height = " + alto + ", width = " + ancho + ", resizable = 0, scrollbars=yes" ) } function solonumeros() { var key=window.event.keyCode; if (key < 48 || key > 57) { if (key != 46 && key != 44) {window.event.keyCode=0;} } } function soloprecio() { var key=window.event.keyCode; if (key < 48 || key > 57) { if (key != 46) {window.event.keyCode=0;} } } var ventanaCalendario=false var ventanaCatalogo=false function muestraCalendario(ruta, formulario_destino, campo_destino, fecha_ini, fecha_fin, defecto) { if (typeof ventanaCalendario.document == "object") { ventanaCalendario.close() } ventanaCalendario = window.open(ruta + "modulo_calendario.php?formulario=" + formulario_destino + "&nomcampo=" + campo_destino + "&fecha_min="+fecha_ini+"&fecha_max="+fecha_fin+"&defecto="+defecto,"calendario","width=300,height=300,left=100,top=100,scrollbars=no,menubars=no,statusbar=NO,status=NO,resizable=YES,location=NO") }