//******************************************************* // ROUTINE JAVASCRIPT //******************************************************* //Per la visualizzazione del giorno della settimana function VisGiorno(g) { switch (g) { case 0: return ('Domenica'); case 1: return ('Lunedì'); case 2: return ('Martedì'); case 3: return ('Mercoledì'); case 4: return ('Giovedì'); case 5: return ('Venerdì'); case 6: return ('Sabato'); } } //Per la visualizzazione il mese dell'anno function VisMese(m) { switch (m) { case 1: return ('Gennaio'); case 2: return ('Febbraio'); case 3: return ('Marzo'); case 4: return ('Aprile'); case 5: return ('Maggio'); case 6: return ('Giugno'); case 7: return ('Luglio'); case 8: return ('Agosto'); case 9: return ('Settembre'); case 10: return ('Ottobre'); case 11: return ('Novembre'); case 12: return ('Dicembre'); } } // Calcola l'anno con 4 cifre function FourDigits(number) { return (number < 1000) ? number + 1900 : number; } //Visualizza data in formato gg/mm/aaaa function DTOS(dta) { return dta.getDate()+'/'+(dta.getMonth()+1)+'/'+dta.getYear(); } //Restituisce la data col mese,giorno,anno impostato function SetDate(gg,mm,aa) { var dta = new Date(); dta.setDate(gg); dta.setMonth(mm); dta.setFullYear(aa); return dta; } //Restituisce l'ultimo giorno del mese della data passata function EOM(m,a) { if (m==4 || m==6 || m==9 || m==11) return 30; if (a%4==0 && m==2) return 29; if (a%4!=0 && m==2) return 28; return 31; } //Open Window per links function OpenWinLink(L) { window.open(L,'Link','height=400,width=600,resizable=1,scrollbars=1'); } //Controlla campo se formato data gg/mm/aaaa function isData(e,req) { var d,g,m,a,arr,msg; e.style.borderStyle='hidden'; d=e.value; if ( (req==false) && d=='') return true; arr=d.split("/"); g=parseInt(arr[0]); m=parseInt(arr[1]); a=parseInt(arr[2]); msg=""; if (isNaN(a) || a<1900 || a>2050) msg='Anno valido solo se compreso tra 1900 e 2050'; else if (isNaN(m) || m<1 || m>12) msg='Mese non valido'; else if (isNaN(g) || g<0 || g>EOM(m,a)) msg='Giorno non valido'; if (msg!='') { e.style.borderColor='red'; e.style.borderStyle='solid'; alert(msg); e.select(); return false; } return true; } //Controlla campo se numerico function isDigit(e,tipo,da,a) { var v; e.style.borderStyle='hidden'; if (e.value=="") return; if (tipo=='I') v=parseInt(e.value); else v=parseFloat(e.value); if (isNaN(v)) { e.style.borderColor='red'; e.style.borderStyle='solid'; e.value=0; e.select(); return false; } else if ((da!=0 || a!=0) && (va)) { e.style.borderColor='red'; e.style.borderStyle='solid'; alert('Numero compreso tra '+da+' e '+a); e.value=0; e.select(); return false; } else e.value=v; return true; } //Controlla campo se alfanumerico function isAlphanum(e,req) { var s,c,i,Lett,Spec,Num,Match; Lett='ABCDEFGHIJKLMNOPQRSTUVWXYZ '; Spec='!£$&/()=?^*-_+.,<>|@'+'\x5C'; Num='0123456789'; Match=Lett+Spec+Num; e.style.borderStyle='hidden'; s=e.value.toUpperCase(); if ( (req==false) && s=='') return true; if ( (req==true) && s=='') { e.style.borderColor='red'; e.style.borderStyle='solid'; e.select(); return false; } for (i=0;i0) { f=f.substring(0,p)+'ON.GIF'; document.images[n].src=f; } } //Per il cambio di immagini durante il passaggio del Mouse Out function onImgOff(n) { var f,p; f=document.images[n].src.toUpperCase(); p=f.indexOf('ON.GIF'); if (p>0) { f=f.substring(0,p)+'OFF.GIF'; document.images[n].src=f; } } //Aggiungi a preferiti function AddPrefer(bookmarkurl,bookmarktitle) { if (document.all) window.external.AddFavorite(bookmarkurl,bookmarktitle) }