//----abrirventana(url,ancho,alto,valorOpciones) //----datosNumericos() //----trim(inputString) //----function checkEmail(str) //----verCalendario(elemento,txtElemento) //----changeImage(layer,imgName,imgObj) //----vaciar(campo) //----function ceckSugerencia // -- show(div) // -- hide(div) //----ConvertFecha(Fecha) //----ValidarFecha(Fecha) //----interlineado(tablaInicial, estilo1, estilo2, numFilaAplicar) //----MostrarSpain //----VerLetra( letra ) //----EsEntero( Valor ) //----EsPositivo( Valor ) //----resizeWindow( ancho,alto ) //----vaciarLista(lista) //----cargarLista(control,orden,id,texto) function abrirventana(url,ancho,alto,valorOpciones){ if (ancho==null) var ancho=550; if (alto==null) var alto=550; var left=(screen.width - ancho)/2; var top=(screen.height - alto)/2; if(valorOpciones) opciones='width='+ancho+',height='+alto+',left='+left+',top='+top+',location=yes,toolbar=yes,status=yes,menubar=yes,directories=yes,resizable=yes,scrollbars=yes,copyhistory=yes'; else opciones='width='+ancho+',height='+alto+',left='+left+',top='+top+',location=no,toolbar=no,status=no,menubar=no,directories=no,resizable=no,scrollbars=yes,copyhistory=no'; window.open(url,'newwin',opciones); } //--------------------------------------------------------------------- //--------------------------------------------------------------------- //--------------------------------------------------------------------- function showInfoVentana( indice, ancho, alto ) { if ( indice == '' ) return; if ( ancho == '' ) ancho = 900; if ( alto == '' ) alto = 900; var left=(screen.width - ancho)/2; var top=(screen.height - alto)/2; opciones='width='+ancho+',height='+alto+',left='+left+',top='+top+',location=no,toolbar=no,status=no,menubar=no,directories=no,resizable=no,scrollbars=yes,copyhistory=no'; window.open( '/Componentes/ventana/showVentana.php?indice='+indice,'newwin', opciones ); } //--------------------------------------------------------------------- //--------------------------------------------------------------------- //--------------------------------------------------------------------- function showFichero( indice ) { if ( indice == '' ) return; ancho = 900; alto = 900; var left=(screen.width - ancho)/2; var top=(screen.height - alto)/2; opciones='width='+ancho+',height='+alto+',left='+left+',top='+top+',location=yes,toolbar=yes,status=yes,menubar=yes,directories=yes,resizable=yes,scrollbars=yes,copyhistory=yes'; window.open( '/Componentes/ventana/showFichero.php?indice='+indice,'newwin', opciones ); } //--------------------------------------------------------------------- //--------------------------------------------------------------------- //--------------------------------------------------------------------- function datosNumericos(){ var key=window.event.keyCode; if(key<48 || key>57) window.event.keyCode=0; } //--------------------------------------------------------------------- //--------------------------------------------------------------------- //--------------------------------------------------------------------- function trim(inputString) { if (typeof inputString != "string") return inputString; var retValue = inputString; var ch = retValue.substring(0, 1); while (ch == " ") { // Check for spaces at the beginning of the string retValue = retValue.substring(1, retValue.length); ch = retValue.substring(0, 1); } ch = retValue.substring(retValue.length-1, retValue.length); while (ch == " ") { // Check for spaces at the end of the string retValue = retValue.substring(0, retValue.length-1); ch = retValue.substring(retValue.length-1, retValue.length); } while (retValue.indexOf(" ") != -1) { // Note that there are two spaces in the string - look for multiple spaces within the string retValue = retValue.substring(0, retValue.indexOf(" ")) + retValue.substring(retValue.indexOf(" ")+1, retValue.length); // Again, there are two spaces in each of the strings } return retValue; // Return the trimmed string back to the user } // Ends the "trim" function //--------------------------------------------------------------------- //--------------------------------------------------------------------- //--------------------------------------------------------------------- function checkEmail(str) { var at="@"; var dot="."; var lat=str.indexOf(at) ; var lstr=str.length ; var ldot=str.indexOf(dot); if (str.indexOf(at)==-1){ return false; } if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){ return false; } if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){ return false; } if (str.indexOf(at,(lat+1))!=-1){ return false; } if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){ return false; } if (str.indexOf(dot,(lat+2))==-1){ return false; } if (str.indexOf(" ")!=-1){ return false; } return true ; } //--------------------------------------------------------------------- //--------------------------------------------------------------------- //--------------------------------------------------------------------- function verCalendario(elemento,txtElemento) { showModalDialog('/Componentes/calendario/framesFechas.php',self,'dialogWidth:400px;dialogHeight:260px,location:no;toolbar:no;status:no;scrollbars:no;menubar:no;directories:no;resizable:no;copyhistory:no'); if (document.calendario.fecha.value!='') { txtElemento.value = document.calendario.fecha.value; var variableTmp = document.calendario.fecha.value; var arrElemento = variableTmp.split("/"); elemento.value = arrElemento[0]+"/"+arrElemento[1]+"/"+arrElemento[2]; } document.calendario.fecha.value=''; } //--------------------------------------------------------------------- //--------------------------------------------------------------------- //--------------------------------------------------------------------- function changeImage(layer,imgName,imgObj) { seleccionarOn = new Image(); seleccionarOn.src = '/pfw_files/tpl/general/calendario_rollover.gif'; seleccionarOff = new Image(); seleccionarOff.src = '/pfw_files/tpl/general/calendario.gif'; vaciarOn = new Image(); vaciarOn.src = '/pfw_files/tpl/general/vaciar_rollover.gif'; vaciarOff = new Image(); vaciarOff.src = '/pfw_files/tpl/general/vaciar.gif'; if (document.images) { if (document.layers && layer!=null) eval('document.'+layer+'.document.images["'+imgName+'"].src = '+imgObj+'.src') else document.images[imgName].src = eval(imgObj+".src") } } //--------------------------------------------------------------------- //--------------------------------------------------------------------- //--------------------------------------------------------------------- function vaciar(campo) { campo.value=''; } //--------------------------------------------------------------------- //--------------------------------------------------------------------- //--------------------------------------------------------------------- function ceckSugerencia( msg,msg2 ){ var comentario = document.Sugerencia.Sugerencia_sug_comentarios.value; if ( trim( comentario )=="" ) { alert( msg ); document.Sugerencia.Sugerencia_sug_comentarios.focus(); return false; } var email = document.Sugerencia.Sugerencia_sug_email.value; if ( email!='' ) { if ( !checkEmail( email ) ) { alert ( msg2 ); //document.Sugerencia.Sugerencia_sug_email.value=''; document.Sugerencia.Sugerencia_sug_email.focus(); return false; } } document.Sugerencia.submit(); } //--------------------------------------------------------------------- //--------------------------------------------------------------------- //--------------------------------------------------------------------- function show(div) { if (document.all[div]) { if (document.all[div]) { document.all[div].style.visibility=""; document.all[div].style.position=""; } } else { if (document.layers[div]) { document.layers[div].visibility = "show"; } } } //--------------------------------------------------------------------- //--------------------------------------------------------------------- //--------------------------------------------------------------------- function hide(div) { if (document.all[div]) { if (document.all[div]) { document.all[div].style.visibility="hidden"; document.all[div].style.position="absolute"; } } else { if (document.layers[div]) { document.layers[div].visibility = "hide"; } } } //--------------------------------------------------------------------- //--------------------------------------------------------------------- //--------------------------------------------------------------------- function ConvertFecha(Fecha) { if (Fecha!="") { ArrayFecha=Fecha.split("/"); return (ArrayFecha[1]+"/"+ArrayFecha[0]+"/"+ArrayFecha[2]); } return ""; } //--------------------------------------------------------------------- //--------------------------------------------------------------------- //--------------------------------------------------------------------- function ValidarFecha(Fecha) { //Convertimos la fecha al formato adecuado para validarla //El formato de entrada debe ser dd/mm/YYYY Fecha=ConvertFecha(Fecha); if (trim(Fecha)=="") return true; var slash1 = Fecha.indexOf("/"); if (slash1 == -1) { slash1 = Fecha.indexOf("-"); } // if no slashes or dashes, invalid date if (slash1 == -1) { return false; } var dateMonth = Fecha.substring(0, slash1) var dateMonthAndYear = Fecha.substring(slash1+1, Fecha.length); var slash2 = dateMonthAndYear.indexOf("/"); if (slash2 == -1) { slash2 = dateMonthAndYear.indexOf("-"); } // if not a second slash or dash, invalid date if (slash2 == -1) { return false; } var dateDay = dateMonthAndYear.substring(0, slash2); var dateYear = dateMonthAndYear.substring(slash2+1, dateMonthAndYear.length); if ( (dateMonth == "") || (dateDay == "") || (dateYear == "") ) { return false; } // if any non-digits in the month, invalid date for (var x=0; x < dateMonth.length; x++) { var digit = dateMonth.substring(x, x+1); if ((digit < "0") || (digit > "9")) { return false; } } // convert the text month to a number var numMonth = 0; for (var x=0; x < dateMonth.length; x++) { digit = dateMonth.substring(x, x+1); numMonth *= 10; numMonth += parseInt(digit); } if ((numMonth <= 0) || (numMonth > 12)) { return false; } // if any non-digits in the day, invalid date for (var x=0; x < dateDay.length; x++) { digit = dateDay.substring(x, x+1); if ((digit < "0") || (digit > "9")) { return false; } } // convert the text day to a number var numDay = 0; for (var x=0; x < dateDay.length; x++) { digit = dateDay.substring(x, x+1); numDay *= 10; numDay += parseInt(digit); } if ((numDay <= 0) || (numDay > 31)) { return false; } // February can't be greater than 29 (leap year calculation comes later) if ((numMonth == 2) && (numDay > 29)) { return false; } // check for months with only 30 days if ((numMonth == 4) || (numMonth == 6) || (numMonth == 9) || (numMonth == 11)) { if (numDay > 30) { return false; } } // if any non-digits in the year, invalid date for (var x=0; x < dateYear.length; x++) { digit = dateYear.substring(x, x+1); if ((digit < "0") || (digit > "9")) { return false; } } // convert the text year to a number var numYear = 0; for (var x=0; x < dateYear.length; x++) { digit = dateYear.substring(x, x+1); numYear *= 10; numYear += parseInt(digit); } // Year must be a 2-digit year or a 4-digit year if (dateYear.length != 4) { return false; } // if 2-digit year, use 50 as a pivot date if ( (numYear < 50) && (dateYear.length == 2) ) { numYear += 2000; } if ( (numYear < 100) && (dateYear.length == 2) ) { numYear += 1900; } if ((numYear <= 0) || (numYear > 9999)) { return false; } // check for leap year if the month and day is Feb 29 if ((numMonth == 2) && (numDay == 29)) { var div4 = numYear % 4; var div100 = numYear % 100; var div400 = numYear % 400; // if not divisible by 4, then not a leap year so Feb 29 is invalid if (div4 != 0) { return false; } // at this point, year is divisible by 4. So if year is divisible by // 100 and not 400, then it's not a leap year so Feb 29 is invalid if ((div100 == 0) && (div400 != 0)) { return false; } } // date is valid return true; } //--------------------------------------------------------------------- //--------------------------------------------------------------------- //--------------------------------------------------------------------- function interlineado(tablaInicial, estilo1, estilo2, numFilaAplicar) { var tabla = document.all[tablaInicial]; if (tabla) { // Por defecto pintamos un estilo diferente en cada fila grupoDeFilas = 2; for (i=numFilaAplicar; i<=tabla.rows.length; i++){ var fila = tabla.rows[i-1]; if((i%grupoDeFilas) == 0){ fila.className = estilo2; } else{ fila.className = estilo1; } } } } //--------------------------------------------------------------------- //--------------------------------------------------------------------- //--------------------------------------------------------------------- function VerLetra( letra ) { document.myform.letra.value=letra; document.myform.submit(); } //--------------------------------------------------------------------- //--------------------------------------------------------------------- //--------------------------------------------------------------------- function EsEntero( Valor ) { //if ( trim( Valor )=="" ) return false; var i; for (i=0;i=0 && currentCaracter <=9 ) && currentCaracter !='-') return false; } else { if ( !(currentCaracter>=0 && currentCaracter<=9) ) return false; } } return true; } //--------------------------------------------------------------------- //--------------------------------------------------------------------- //--------------------------------------------------------------------- function EsPositivo( Valor ) { //if ( trim( Valor )=="" ) return false; Valor=trim(Valor); var contador; for (contador=0;contador=0 && currentCaracter <=9 )) return false; } return true; } //--------------------------------------------------------------------- //--------------------------------------------------------------------- //--------------------------------------------------------------------- function resizeWindow( ancho,alto ) { if ( ancho=='' ) anchuraVentana = 500; else anchuraVentana = ancho; if ( alto=='' ) alturaVentana = 10; else alturaVentana = alto; var anchura = document.all["Capa"].scrollWidth; var altura = document.all["Capa"].scrollHeight; var screenWidth = screen.availWidth; var screenHeight = screen.availHeight; if ( altura > 500 ) { window.resizeTo( 600,500 ); coord_x = (screenWidth - 500)/2; coord_y = (screenHeight - 500)/2; } else { if ( altura < alturaVentana ) { var totale = altura-50; window.resizeTo( anchuraVentana,totale ); } else { var totale = altura+50; window.resizeTo( anchuraVentana,totale ); } coord_x = (screenWidth - anchuraVentana)/2; coord_y = (screenHeight - totale)/2; } window.moveTo( coord_x,coord_y ); } //--------------------------------------------------------------------- //--------------------------------------------------------------------- //--------------------------------------------------------------------- function vaciarLista(lista) { var longitud=lista.length; for (var i=0;i < longitud;i++) { lista.options[0]=null; } lista.selectedIndex=0; } //--------------------------------------------------------------------- //--------------------------------------------------------------------- //--------------------------------------------------------------------- function cargarLista(control,orden,id,texto) { myoption = new Option(texto,id,false,true); var mylista = eval(control); mylista.options[orden]=myoption; }