// **funzione per la finestra popup centrata rispetto allo schermo function openCenteredWindow(thepage,thewname,wheigth,wweigth,scroll_,menu_,tool_,resize_){ var aw = screen.availWidth; var ah = screen.availHeight; var film_width = wweigth; var film_heigth = wheigth; posW = (screen.availWidth/2)-(film_width/2); posH = (screen.availHeight/2)-(film_heigth/2); if(document.all) newWin = window.open(thepage,thewname,"toolbar="+tool_+",scrollbars="+scroll_+",menubar="+menu_+",resizable="+resize_+",height="+film_heigth+",width="+film_width+",left="+posW+",top="+posH); else newWin = window.open(thepage,thewname,"toolbar="+tool_+",scrollbars="+scroll_+",menubar="+menu_+",resizable="+resize_+",height="+film_heigth+",width="+film_width+",screenX="+posW+",screenY="+posH); newWin.focus(); } function ChkEmail(form,campo,lingua,obbligatorio){ var message=''; if(lingua=='it') var message = "Indirizzo email non valido!"; else var message = "Not valid e-mail address!"; if(document[form][campo].value.length > 7 ){ var stremail = document[form][campo].value; var result1 = stremail.indexOf("@"); var result2 = stremail.indexOf("."); if(result1 < 0 || result2 < 0){ alert(message); document[form][campo].focus(); document[form][campo].select(); return false; } }else if(obbligatorio == 'S'){ alert(message); document[form][campo].focus(); document[form][campo].select(); return false; } return true; } ///////////////////////// controllo partita iva /////////////////////////// function ControllaPIVA(pi,theform,thefield){ var campo=document[theform][thefield]; if( pi != '' ) { if( pi.length != 11 ){ alert( "La lunghezza della partita IVA non è\n" + "corretta: la partita IVA dovrebbe essere lunga\n" + "esattamente 11 caratteri.\n"); campo.focus(); campo.select(); return false; } validi = "0123456789"; for( i = 0; i < 11; i++ ){ if( validi.indexOf( pi.charAt(i) ) == -1 ){ alert("La partita IVA contiene un carattere non valido `" + pi.charAt(i) + "'.\nI caratteri validi sono le cifre.\n"); campo.focus(); campo.select(); return false; } } s = 0; for( i = 0; i <= 9; i += 2 ) s += pi.charCodeAt(i) - '0'.charCodeAt(0); for( i = 1; i <= 9; i += 2 ){ c = 2*( pi.charCodeAt(i) - '0'.charCodeAt(0) ); if( c > 9 ) c = c - 9; s += c; } if( ( 10 - s%10 )%10 != pi.charCodeAt(10) - '0'.charCodeAt(0) ){ alert("La partita IVA non è valida:\n" + "il codice di controllo non corrisponde.\n"); campo.focus(); campo.select(); return false; } } return true; } ////////////////////////// controllo codicefiscale /////////////////////////////// function ControllaCF(cf,theform,thefield){ var campo=document[theform][thefield]; var validi, i, s, set1, set2, setpari, setdisp; if( cf != '' ) { cf = cf.toUpperCase(); if( cf.length != 16 ){ alert( "La lunghezza del codice fiscale non è \n" +"corretta: il codice fiscale dovrebbe essere lungo\n" +"esattamente 16 caratteri.\n"); campo.focus(); campo.select(); return false; } validi = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; for( i = 0; i < 16; i++ ){ if( validi.indexOf( cf.charAt(i) ) == -1 ){ alert( "Il codice fiscale contiene un carattere non valido `" + cf.charAt(i) + "'.\nI caratteri validi sono le lettere e le cifre.\n"); campo.focus(); campo.select(); return false; } } set1 = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"; set2 = "ABCDEFGHIJABCDEFGHIJKLMNOPQRSTUVWXYZ"; setpari = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; setdisp = "BAKPLCQDREVOSFTGUHMINJWZYX"; s = 0; for( i = 1; i <= 13; i += 2 ) s += setpari.indexOf( set2.charAt( set1.indexOf( cf.charAt(i) ))); for( i = 0; i <= 14; i += 2 ) s += setdisp.indexOf( set2.charAt( set1.indexOf( cf.charAt(i) ))); if( s%26 != cf.charCodeAt(15)-'A'.charCodeAt(0) ){ alert( "Il codice fiscale non è corretto:\n"+ "il codice di controllo non corrisponde.\n"); campo.focus(); campo.select(); return false; } } return true; } /////////////////////////////////////////////////////////////////////////// ////////////////////////////////*****controllo di un campo numerico ///////////////////////////// function CheckDigitField(form,campo,lingua){ var errors=""; var campo2=document[form][campo]; for(var j=0;j< campo2.value.length;j++){ var c=campo2.value.charAt(j); if ((c < '0' || c > '9') && c !='.'){ if(lingua=='it') errors="il campo può contenere solo cifre!"; else errors="The field must contains only digits!"; break; } } if (errors){ alert(errors); campo2.select(); //campo2.focus(); return false; } else return true; } function checkFormRegister(theform){ var message='Campi mancanti:\n'; var cont=0; if(document[theform].cogn_ragsoc_ut.value.length == 0) { ++cont; message+='ragione sociale\n'; } if(document[theform].ind_ut.value.length == 0) { ++cont; message+='indirizzo\n'; } if(document[theform].cap_ut.value.length == 0) { ++cont; message+='CAP\n'; } if(document[theform].citta_ut.value.length == 0) { ++cont; message+='città\n'; } if(document[theform].prov_ut.value.length == 0) { ++cont; message+='provincia\n'; } if(document[theform].tipo_ut[0].checked === true && document[theform].piva_ut.value.length == 0 ) { ++cont; message+='partita iva\n'; } if(document[theform].tipo_ut[1].checked === true && document[theform].cf_ut.value.length == 0 ) { ++cont; message+='codice fiscale\n'; } if(document[theform].tel_ut.value.length == 0 && document[theform].cell_ut.value.length == 0) { ++cont; message+='telefono o cellulare sono obbligatori\n'; } if(document[theform].email_ut.value.length == 0) { ++cont; message+='email\n'; } if(document[theform].login_ut.value.length == 0) { ++cont; message+='username\n'; } if(document[theform].pwd_ut.value.length == 0) { ++cont; message+='password\n'; } if(document[theform].letto.value != 'S') { ++cont; message+='\n necessario leggere l\'informativa! \n'; } if(cont > 0){ alert(message); return false; }else return true; } function CercaProd(){ if(document.cercaprod.tiposearch[0].checked == true){ document.cercaprod.action='categorie.php'; }else if(document.cercaprod.tiposearch[1].checked == true){ document.cercaprod.action='ricerca_prodotti.php'; } document.cercaprod.submit(); } function ScrollResult(nomeform,pagina,gruppo){ document.getElementById(nomeform).gruppo.value = gruppo; document.getElementById(nomeform).page.value = pagina; document.getElementById(nomeform).submit(); } function ControllaTracking(codice){ openCenteredWindow('http://www.sda.it/index.jsp?ixPageId=1&ixMenuId=10','SDAHome',400,500,'yes','yes','yes','yes'); } //********************funzione per la conferma dell'inserimento di un elemento function ConfirmInsert(lingua){ if(lingua == 'it') var message = 'Confermare l\'inserimento?'; else var message = 'Do you want to confirm insert?'; var risposta = confirm(message); if (risposta) return true; else return false; } //*****************************funzione per la conferma delle modifiche apportate function ConfirmModify(lingua){ if(lingua == 'it') var message = 'Confermare le modifiche apportate?'; else var message = 'Do you want to save changes?'; var risposta = confirm(message); if (risposta) return true; else return false; } function checkContFields(theform){ if (document[theform].dip_continental[0].checked === true){ document[theform].dip_continental_badge.disabled=false; document[theform].dip_continental_sede.disabled=false; document[theform].dip_continental_badge.style.backgroundColor="#ffffff"; document[theform].dip_continental_sede.style.backgroundColor="#ffffff"; }else{ document[theform].dip_continental_badge.disabled='disabled'; document[theform].dip_continental_badge.style.backgroundColor="#999999"; document[theform].dip_continental_sede.disabled ='disabled'; document[theform].dip_continental_sede.style.backgroundColor="#999999"; } } function arrotonda(numero, numeroDecimali){ var modificatore = '1'; for(var i=0;i 1 ? ',' + x[1] : ''; var rgx = /(\d+)(\d{3})/; while (rgx.test(x1)) x1 = x1.replace(rgx, '$1' + ',' + '$2'); return x1 + x2; } // This function removes non-numeric characters function stripNonNumeric( str ){ str += ''; var rgx = /^\d|\.|-$/; var out = ''; for( var i = 0; i < str.length; i++ ){ if( rgx.test( str.charAt(i) ) ){ if( !( ( str.charAt(i) == '.' && out.indexOf( '.' ) != -1 ) || ( str.charAt(i) == '-' && out.length != 0 ) ) ){ out += str.charAt(i); } } } return out; } function AnnullaOrdine(idordine,idstatus){ var risposta = confirm ('Si desidera davvero annnullare l\'ordine?'); if(risposta){ if(idordine != ''){ http = createRequestObject(); http.onreadystatechange = checkStatus; http.open("GET", 'ajax/ajax_status.php?idordine=' + idordine+'&idstatus='+idstatus); http.send(null); } } } function checkStatus(){ if( http.readyState == 4 ) { alert( 'Ordine annullato!'); document.location.href='storico_ordini.php'; } }