function OpenCloseDivIndirizziAdmin(check, obj) { if(check.checked == true){ obj.style.display = ''; }else{ obj.style.display = 'none'; } } // mostro / nascondo il del dettaglio acquisto function OpenCloseDettaglio(id_obj) { obj = document.getElementById('dett' + id_obj); if (obj.style.display == 'block') { obj.style.display = 'none'; } else { obj.style.display = 'block'; } } // mostro / nascondo il delle provincie nel form di registrazione utente function ShowTrProvincie(obj, num, obj_select) { // default value for "num" num = typeof(num) != 'undefined' ? num : ''; var trp = document.getElementById('tr_provincie'+num); if (obj.value == 468) { trp.style.visibility = 'visible'; } else { trp.style.visibility = 'hidden'; if(typeof(obj_select) != 'undefined'){ obj_select.selectedIndex = 0; } } } function ShowTrCodiceFiscale(obj, num, obj_select) { // default value for "num" num = typeof(num) != 'undefined' ? num : ''; var trp = document.getElementById('tr_codice_fiscale'+num); if (obj.value == 468) { trp.style.visibility = 'visible'; document.getElementById('controlla_codice_fiscale').value = 1; } else { trp.style.visibility = 'hidden'; document.getElementById('controlla_codice_fiscale').value = 0; if(typeof(obj_select) != 'undefined'){ obj_select.selectedIndex = 0; } } } // mostro / nascondo il
con l'input per i monogrammi nelle opzioni camicie function ShowDivMonogrammi(obj) { var dm = document.getElementById('div_monogrammi'); if (obj.value != 9) { dm.style.visibility = 'visible'; } else { dm.style.visibility = 'hidden'; } } // mostro / nascondo il
per gli indirizzi function ShowDivIndirizzi(div) { var dm = document.getElementById(div); if (dm.style.visibility == 'hidden') { dm.style.visibility = 'visible'; dm.style.height = '100%'; } else { dm.style.visibility = 'hidden'; dm.style.height = '0px'; } } // verifico i campi della form di registrazione (/registrazione-utente) function RegUtenteCheckForm() { var errori = new Array(); var frm = document.forms['registrazione']; if (frm.f400_nome.value == '') { errori.push('inserire il nome'); } if (frm.f400_cognome.value == '') { errori.push('il cognome non puo\' essere vuoto'); } if(typeof(frm.f401_codice_fiscale) != 'undefined' && document.getElementById('controlla_codice_fiscale').value == 1){ if(typeof(frm.tipo_persona) != 'undefined'){ if(frm.tipo_persona.options[frm.tipo_persona.selectedIndex].value == 1){ if (frm.f401_codice_fiscale.value == '') { errori.push('inserire il codice fiscale'); }else if(ControllaCF(frm.f401_codice_fiscale.value) == false){ errori.push('il codice fiscale non \u00E8 valido'); } } }else{ if (frm.f401_codice_fiscale.value == '') { errori.push('inserire il codice fiscale'); }else if(ControllaCF(frm.f401_codice_fiscale.value) == false){ errori.push('il codice fiscale non \u00E8 valido'); } } } if (frm.f400_mail.value == '') { errori.push('inserire l\' email'); } if (frm.f400_password) { if (frm.f400_password.value == '') { errori.push('indicare una password'); } if (frm.f400_password.value.length < 6) { errori.push('indicare una password lunga almeno 6 caratteri'); } if (frm.f400_password.value == frm.f400_username.value) { errori.push('indicare una password diversa dallo username'); } } if (frm.f400_username.value == '') { alert('lo username non puo\' essere vuoto'); } else if (frm.f400_username.value.length < 6) { alert('lo username deve essere lungo almeno 6 caratteri'); } else { // lo username � gi� in uso ? RegUtenteCheckUsernameAvailable(frm.f400_username.value, frm.f400_id_utenti.value); } } function RegUtenteCheckForm2() { var errori = new Array(); var frm = document.forms['registrazione']; if (frm.f400_nome.value == '') { errori.push('inserire il nome'); } if (frm.f400_cognome.value == '') { errori.push('il cognome non puo\' essere vuoto'); } if(frm.tipo_persona.options[frm.tipo_persona.selectedIndex].value == 1 && document.getElementById('controlla_codice_fiscale').value == 1){ if (frm.f401_codice_fiscale.value == '') { errori.push('inserire il codice fiscale'); }else if(!ControllaCF(frm.f401_codice_fiscale.value)){ errori.push('il codice fiscale non \u00E8 valido'); } } if(frm.tipo_persona.options[frm.tipo_persona.selectedIndex].value == 2){ if (frm.f401_partita_iva.value == '') { errori.push('inserire la partita iva'); }else if(ControllaPIVA(frm.f401_partita_iva.value) == false){ errori.push('la partita iva non \u00E8 valida'); } } if (frm.f401_r451_id_nazioni.value == '') { errori.push('inserire la nazione'); } if(frm.f401_r451_id_nazioni.value != 468 && frm.f400_luogo_nascita.value == ''){ errori.push('inserire il luogo di nascita'); } if (frm.f400_mail.value == '') { errori.push('inserire l\' email'); } if (frm.accetta.checked != true) { errori.push('dare il consenso al trattamento dei dati personali'); } if (frm.f400_password) { if (frm.f400_password.value == '') { errori.push('indicare una password'); } if (frm.f400_password.value.length < 6) { errori.push('indicare una password lunga almeno 6 caratteri'); } if (frm.f400_password.value == frm.f400_username.value) { errori.push('indicare una password diversa dallo username'); } if (frm.f400_password.value != frm.f400_password_conferma.value) { errori.push('la password e la conferma non coincidono'); } } if (errori.length == 0) { frm.submit(); return false; } else { var txt_alert = 'Per completare la registrazione occorre:\n\n'; for (x=0; x < errori.length; x++) { txt_alert = txt_alert + ' - ' + errori[x] + '\n'; } txt_alert = txt_alert + '\n'; alert(txt_alert); return false; } } function RegUtenteCheckForm3() { var errori = new Array(); var frm = document.forms['registrazione']; if (frm.f400_nome.value == '') { errori.push('inserire il nome'); } if (frm.f400_cognome.value == '') { errori.push('il cognome non puo\' essere vuoto'); } if (frm.f400_mail.value == '') { errori.push('inserire l\' email'); } if (errori.length == 0) { frm.submit(); return false; } else { var txt_alert = 'Per completare la registrazione occorre:\n\n'; for (x=0; x < errori.length; x++) { txt_alert = txt_alert + ' - ' + errori[x] + '\n'; } txt_alert = txt_alert + '\n'; alert(txt_alert); return false; } } // verifico la validit� dello username, via AJAX function RegUtenteCheckUsernameAvailable(username, f400_id_utenti) { // variabili di funzione var // assegnazione oggetto XMLHttpRequest ajax = assegnaXMLHttpRequest(); // se l'oggetto XMLHttpRequest non � nullo if(ajax) { // impostazione richiesta asincrona in GET // del file specificato ajax.open("post", "/ecommerce/utenti_registrazione_check_username.php", true); ajax.setRequestHeader("content-type", "application/x-www-form-urlencoded"); ajax.setRequestHeader("connection", "close"); // impostazione controllo e stato della richiesta ajax.onreadystatechange = function() { // verifica dello stato if(ajax.readyState === readyState.COMPLETATO) { // verifica della risposta da parte del server if(statusText[ajax.status] === "OK") { // operazione avvenuta con successo, ritorno al chiamante un ok / ko //alert(ajax.responseText); user_available = ajax.responseText; if (user_available == 'ok1') { RegUtenteCheckForm2(); } else if (user_available == 'ok2') { RegUtenteCheckForm3(); } else if (user_available == 'ko_bad_chars') { alert('Lo username contiene caratteri non validi.'); } else { alert('Lo username che hai scelto \u00E8 gi\u00E0 in uso\nPer favore scegline uno diverso.'); } } } } // invio richiesta ajax.send("username="+encodeURIComponent(username)+"&f400_id_utenti="+f400_id_utenti); } } // funzione chiamata dal check-out per salvare il testo del pacchetto regalo function SalvaPacchettoRegalo(id_acquisto, testo){ // variabili di funzione var // assegnazione oggetto XMLHttpRequest ajax = assegnaXMLHttpRequest(); // se l'oggetto XMLHttpRequest non � nullo if(ajax){ // impostazione richiesta asincrona in GET // del file specificato ajax.open("post", "/ecommerce/check_out_pacchetto_regalo_salva.php", true); ajax.setRequestHeader("content-type", "application/x-www-form-urlencoded"); ajax.setRequestHeader("connection", "close"); // impostazione controllo e stato della richiesta ajax.onreadystatechange = function() { // verifica dello stato if(ajax.readyState === readyState.COMPLETATO) { // verifica della risposta da parte del server if(statusText[ajax.status] === "OK") { // operazione avvenuta con successo, ritorno al chiamante un ok / ko if (ajax.responseText === 'OK') { document.metodo_pagamento.pacchetto_regalo_default.value = testo; } else { //Errore alert('Errore nel salvataggio del testo del pacchetto regalo.'); } } } } } // invio richiesta ajax.send("id_acquisti="+id_acquisto+"&testo="+testo); } // funzione chiamata dal check-out per salvare le note per il venditore function SalvaNoteVenditore(id_acquisto, testo){ // variabili di funzione var // assegnazione oggetto XMLHttpRequest ajax = assegnaXMLHttpRequest(); // se l'oggetto XMLHttpRequest non � nullo if(ajax){ // impostazione richiesta asincrona in GET // del file specificato ajax.open("post", "/ecommerce/check_out_note_venditore_salva.php", true); ajax.setRequestHeader("content-type", "application/x-www-form-urlencoded"); ajax.setRequestHeader("connection", "close"); // impostazione controllo e stato della richiesta ajax.onreadystatechange = function() { // verifica dello stato if(ajax.readyState === readyState.COMPLETATO) { // verifica della risposta da parte del server if(statusText[ajax.status] === "OK") { // operazione avvenuta con successo, ritorno al chiamante un ok / ko if (ajax.responseText === 'OK') { document.metodo_pagamento.note_venditore_default.value = testo; } else { //Errore alert('Errore nel salvataggio delle note per il venditore.'); } } } } } // invio richiesta ajax.send("id_acquisti="+id_acquisto+"&testo="+testo); } function ControllaCF(cf) { var validi, i, s, set1, set2, setpari, setdisp; if( cf == '' ) return ''; cf = cf.toUpperCase(); if( cf.length != 16 ) return false; validi = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; for( i = 0; i < 16; i++ ){ if( validi.indexOf( cf.charAt(i) ) == -1 ) 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) ) return false; return true; } function ControllaPIVA(pi) { if( pi == '' ) return ''; if( pi.length != 11 ) return false; validi = "0123456789"; for( i = 0; i < 11; i++ ){ if( validi.indexOf( pi.charAt(i) ) == -1 ) 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) ) return false; return true; } function IdentificaBrowser(){ var BrowserDetect = { init: function () { this.browser = this.searchString(this.dataBrowser) || "An unknown browser"; this.version = this.searchVersion(navigator.userAgent) || this.searchVersion(navigator.appVersion) || "an unknown version"; this.OS = this.searchString(this.dataOS) || "an unknown OS"; }, searchString: function (data) { for (var i=0; i < data.length; i++) { var dataString = data[i].string; var dataProp = data[i].prop; this.versionSearchString = data[i].versionSearch || data[i].identity; if (dataString) { if (dataString.indexOf(data[i].subString) != -1) return data[i].identity; } else if (dataProp) return data[i].identity; } }, searchVersion: function (dataString) { var index = dataString.indexOf(this.versionSearchString); if (index == -1) return; return parseFloat(dataString.substring(index+this.versionSearchString.length+1)); }, dataBrowser: [ { string: navigator.userAgent, subString: "Chrome", identity: "Chrome" }, { string: navigator.userAgent, subString: "OmniWeb", versionSearch: "OmniWeb/", identity: "OmniWeb" }, { string: navigator.vendor, subString: "Apple", identity: "Safari", versionSearch: "Version" }, { prop: window.opera, identity: "Opera", versionSearch: "Version" }, { string: navigator.vendor, subString: "iCab", identity: "iCab" }, { string: navigator.vendor, subString: "KDE", identity: "Konqueror" }, { string: navigator.userAgent, subString: "Firefox", identity: "Firefox" }, { string: navigator.vendor, subString: "Camino", identity: "Camino" }, { // for newer Netscapes (6+) string: navigator.userAgent, subString: "Netscape", identity: "Netscape" }, { string: navigator.userAgent, subString: "MSIE", identity: "Explorer", versionSearch: "MSIE" }, { string: navigator.userAgent, subString: "Gecko", identity: "Mozilla", versionSearch: "rv" }, { // for older Netscapes (4-) string: navigator.userAgent, subString: "Mozilla", identity: "Netscape", versionSearch: "Mozilla" } ], dataOS : [ { string: navigator.platform, subString: "Win", identity: "Windows" }, { string: navigator.platform, subString: "Mac", identity: "Mac" }, { string: navigator.userAgent, subString: "iPhone", identity: "iPhone/iPod" }, { string: navigator.platform, subString: "Linux", identity: "Linux" } ] }; BrowserDetect.init(); return BrowserDetect.browser; } function Stampa(){ var browser = IdentificaBrowser(); if(browser != 'Chrome'){ window.print(); }else{ alert('Attenzione! Google Chrome ha noti problemi di stampa.\nSi consiglia di usare un altro browser.'); return false; } }