function salva_cookie(codice_inserzione, azione) { var xmlHttp = getXmlHttpObject(); // alert("./cookie.php?funzione=salva_annuncio&codice_inserzione="+codice_inserzione+"&azione="+azione); xmlHttp.open('GET', "./cookie.php?funzione=salva_annuncio&codice_inserzione="+codice_inserzione+"&azione="+azione, true); xmlHttp.onreadystatechange = stateChanged; xmlHttp.send(null); function stateChanged() { if(xmlHttp.readyState == 4) { //Stato OK if (xmlHttp.status == 200) { var resp = xmlHttp.responseText; if(resp!="") { if(azione==1) { document.getElementById('annuncio_salvato').style.display="block"; document.getElementById('annuncio_eliminato').style.display="none"; document.getElementById('salva_annuncio_'+codice_inserzione).style.display="none"; document.getElementById('no_salva_annuncio_'+codice_inserzione).style.display="block"; }else{ document.getElementById('annuncio_eliminato').style.display="block"; document.getElementById('annuncio_salvato').style.display="none"; document.getElementById('salva_annuncio_'+codice_inserzione).style.display="block"; document.getElementById('no_salva_annuncio_'+codice_inserzione).style.display="none"; } } } } } } // funzione per il cambio stile nel risultato ricerca function cambia_stili(tipo_selezione, div_sx, div_centro, div_dx, popup) { if(tipo_selezione=="selezionato") { document.getElementById(div_sx).className="risultatoRicercaSxSelezionato"; document.getElementById(div_centro).className="risultatoRicercaCentroSelezionato"; document.getElementById(div_dx).className="risultatoRicercaDxSelezionato"; document.getElementById(popup).style.display="block"; }else{ document.getElementById(div_sx).className="risultatoRicercaSx"; document.getElementById(div_centro).className="risultatoRicercaCentro"; document.getElementById(div_dx).className="risultatoRicercaDx"; document.getElementById(popup).style.display="none"; } } // funzione per l'ordinamento nel risultato ricerca function ordinaRisultati(valore) { var valore; if(valore=="prezzo") { document.getElementById('ordinaRisultati').order_by.value="prezzo"; document.getElementById('ordinaRisultati').order_direction.value="asc"; }else if(valore=="prezzo_desc"){ document.getElementById('ordinaRisultati').order_by.value="prezzo"; document.getElementById('ordinaRisultati').order_direction.value="desc"; }else if(valore=="marca"){ document.getElementById('ordinaRisultati').order_by.value="marca"; document.getElementById('ordinaRisultati').order_direction.value="asc"; }else if(valore=="marca_desc"){ document.getElementById('ordinaRisultati').order_by.value="marca"; document.getElementById('ordinaRisultati').order_direction.value="desc"; }else if(valore=="modello"){ document.getElementById('ordinaRisultati').order_by.value="modello"; document.getElementById('ordinaRisultati').order_direction.value="asc"; }else if(valore=="modello_desc"){ document.getElementById('ordinaRisultati').order_by.value="modello"; document.getElementById('ordinaRisultati').order_direction.value="desc"; }else if(valore=="anno"){ document.getElementById('ordinaRisultati').order_by.value="anno"; document.getElementById('ordinaRisultati').order_direction.value="asc"; }else if(valore=="anno_desc"){ document.getElementById('ordinaRisultati').order_by.value="anno"; document.getElementById('ordinaRisultati').order_direction.value="desc"; }else if(valore=="chilometraggio"){ document.getElementById('ordinaRisultati').order_by.value="chilometraggio"; document.getElementById('ordinaRisultati').order_direction.value="asc"; }else if(valore=="chilometraggio_desc"){ document.getElementById('ordinaRisultati').order_by.value="chilometraggio"; document.getElementById('ordinaRisultati').order_direction.value="desc"; }else{ document.getElementById('ordinaRisultati').order_by.value=""; document.getElementById('ordinaRisultati').order_direction.value="asc"; } document.getElementById('ordinaRisultati').submit(); } //funzione per intercettare la pressione del tasto invio per il submit function intercetta_tasti(tasto,azione) { //ATTENZIONE //se nel parametro azione devo passare degli apici,li sostituisco con X-Y e Y-X //poi li risostituisco azione=azione.replace("X-Y","'"); azione=azione.replace("Y-X","'"); //premendo invio (codice 13) lancio il submit della ricerca if(tasto==13) { if(azione!="") { eval(azione+"()"); } } } // Controllo delle conversioni AdWords function conta_email_google() { //Apro la pagina x il controllo di Google sulle e-mail inviate var xmlHttp = getXmlHttpObject(); xmlHttp.open('GET', "./include/email_inviate.php", true); xmlHttp.send(null); } // Registrazione concessionari function registrazioneConcessionari() { procedi=true; document.registrazione.nome.className="email03"; document.registrazione.email.className="email03"; var email=document.registrazione.email.value; document.registrazione.via.className="email03"; var valori_email=/[a-zA-Z0-9._%-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/; // Verifico se l'e-mail è già in uso var xmlHttp = getXmlHttpObject(); xmlHttp.open('GET', "./include/ajax.php?funzione=controlloEmail&email="+email, true); xmlHttp.onreadystatechange = stateChanged; xmlHttp.send(null); function stateChanged() { if(xmlHttp.readyState == 4) { //Stato OK if (xmlHttp.status == 200) { var resp = xmlHttp.responseText; if(resp==1) { procedi=false; alert("Attezione! Questa e-mail risulta già registrata.\nE' necessario utilizzare un altro indirizzo e-mail"); }else{ if(document.registrazione.nome.value=="") { procedi=false; document.registrazione.nome.focus(); document.registrazione.nome.className="emailErrore04"; alert("Attenzione! Inserire il nome"); }else if((document.registrazione.email.value=="")||(!document.registrazione.email.value.match(valori_email))){ procedi=false; document.registrazione.email.focus(); document.registrazione.email.className="emailErrore04"; alert("Attenzione! Inserire un indirizzo e-mail valido"); }else if(document.registrazione.comune.value==""){ procedi=false; document.registrazione.comune.focus(); alert("Attenzione! Inserire la regione"); }else if(document.registrazione.provincia.value==""){ procedi=false; document.registrazione.provincia.focus(); alert("Attenzione! Inserire la provincia"); }else if(document.registrazione.via.value==""){ procedi=false; document.registrazione.via.focus(); document.registrazione.via.className="emailErrore04"; alert("Attenzione! Inserire l'indirizzo"); }else if(document.registrazione.privacy[1].checked==true){ procedi=false; alert("Attenzione! Per registrarsi è necessario accettare il trattamento dei dati personali"); } if(procedi==true) { document.registrazione.submit(); } } } } } } // Registrazione utenti privati function registrazionePrivati() { procedi=true; document.getElementById('registrazione').nome.className="email03"; document.getElementById('registrazione').cognome.className="email03"; document.getElementById('registrazione').email.className="email03"; var email=document.getElementById('registrazione').email.value; document.getElementById('registrazione').via.className="email03"; document.getElementById('registrazione').telefono.className="email03"; document.getElementById('registrazione').cap.className="email03"; document.getElementById('registrazione').citta.className="email03"; var valori_email=/[a-zA-Z0-9._%-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/; // Verifico se l'e-mail è già in uso var xmlHttp = getXmlHttpObject(); xmlHttp.open('GET', "./include/ajax.php?funzione=controlloEmail&email="+email, true); xmlHttp.onreadystatechange = stateChanged; xmlHttp.send(null); function stateChanged() { if(xmlHttp.readyState == 4) { //Stato OK if (xmlHttp.status == 200) { var resp = xmlHttp.responseText; if(resp==1) { procedi=false; document.getElementById('registrazione').email.focus(); document.getElementById('registrazione').email.className="emailErrore03"; alert("Attezione! Questa e-mail risulta già registrata.\nE' necessario utilizzare un altro indirizzo e-mail"); }else{ if(document.getElementById('registrazione').nome.value=="") { procedi=false; document.getElementById('registrazione').nome.focus(); document.getElementById('registrazione').nome.className="emailErrore03"; alert("Attenzione! Inserire il nome"); }else if(document.getElementById('registrazione').cognome.value==""){ procedi=false; document.getElementById('registrazione').cognome.focus(); document.getElementById('registrazione').cognome.className="emailErrore03"; alert("Attenzione! Inserire il cognome"); }else if((document.getElementById('registrazione').email.value=="")||(!document.getElementById('registrazione').email.value.match(valori_email))){ procedi=false; document.getElementById('registrazione').email.focus(); document.getElementById('registrazione').email.className="emailErrore03"; alert("Attenzione! Inserire un indirizzo e-mail valido"); }else if((document.getElementById('registrazione').telefono.value=="")||(isNaN(document.getElementById('registrazione').telefono.value))||(document.getElementById('registrazione').telefono.value=="undefined")){ procedi=false; document.getElementById('registrazione').telefono.focus(); document.getElementById('registrazione').telefono.className="emailErrore03"; alert("Attenzione! Inserire un numero di telefono valido e nella forma 'prefisso.numero' senza spazi"); }else if(document.getElementById('registrazione').regione.value==""){ procedi=false; document.getElementById('registrazione').regione.focus(); alert("Attenzione! Inserire la regione"); }else if(document.getElementById('registrazione').provincia.value==""){ procedi=false; document.getElementById('registrazione').provincia.focus(); alert("Attenzione! Inserire la provincia"); }else if(document.getElementById('registrazione').via.value==""){ procedi=false; document.getElementById('registrazione').via.focus(); document.getElementById('registrazione').via.className="emailErrore03"; alert("Attenzione! Inserire l'indirizzo"); }else if((document.getElementById('registrazione').cap.value=="")||(isNaN(document.getElementById('registrazione').cap.value))||(document.getElementById('registrazione').cap.value=="undefined")){ procedi=false; document.getElementById('registrazione').cap.focus(); document.getElementById('registrazione').cap.className="emailErrore03"; alert("Attenzione! Inserire il C.A.P."); }else if(document.getElementById('registrazione').citta.value==""){ procedi=false; document.getElementById('registrazione').citta.focus(); document.getElementById('registrazione').citta.className="emailErrore03"; alert("Attenzione! Inserire la città"); }else if(document.getElementById('registrazione').privacy[1].checked==true){ procedi=false; alert("Attenzione! Per registrarsi è necessario accettare il trattamento dei dati personali"); } if(procedi==true) { document.getElementById('registrazione').submit(); } } } } } } // Funzione per la login function verificaLogin(punti) { procedi=true; document.getElementById('login').username.className="email03"; document.getElementById('login').password.className="email03"; var username=document.getElementById('login').username.value; var password=document.getElementById('login').password.value; var etichetta_password=password.replace('+', 'XXXX'); if(document.getElementById('login').username.value=="") { procedi=false; document.getElementById('login').username.focus(); document.getElementById('login').username.className="emailErrore03"; alert("Inserire l'username!"); }else if(document.getElementById('login').password.value==""){ procedi=false; document.getElementById('login').password.focus(); document.getElementById('login').password.className="emailErrore03"; alert("Inserire la password!"); } // Se i campi son compilati invio la richiesta ajax per il controllo utente if(procedi==true) { var xmlHttp = getXmlHttpObject(); xmlHttp.open("GET", punti+"include/ajax.php?tabella=utenti&username="+username+"&password="+etichetta_password, true); xmlHttp.onreadystatechange = stateChanged; xmlHttp.send(null); } function stateChanged() { if(xmlHttp.readyState == 4) { //Stato OK if (xmlHttp.status == 200) { var resp = xmlHttp.responseText; // Se l'utente è attivo lo reindirizzo alla pagina corretta if((resp!="1")&&(resp!="2")) { location.href=punti+'area_clienti/index.php'; }else if(resp=="1"){ alert("ATTENZIONE! Impossibile accedere all'area riservata.\nACCOUNT SCADUTO O NON ATTIVO"); }else if(resp=="2"){ alert("ATTENZIONE! Impossibile accedere all'area riservata.\nVERIFICARE USERNAME E PASSWORD"); } } } } //alert("ATTENZIONE! Area riservata momentaneamente disattivata per l'aggiornamento dei nostri sistemi. L'operazione durerà fino a Martedì 27 Luglio."); } // Funzione invio e-mail modulo contatti function inviaEmailContatti() { procedi=true; var codice_inserzione=document.getElementById("contatti").codice_inserzione.value; var nome_2=document.getElementById("contatti").nome.value; document.getElementById("contatti").nome.className="email03"; var email=document.getElementById("contatti").email.value; document.getElementById("contatti").email.className="email03"; var indirizzo=document.getElementById("contatti").indirizzo.value; var cap=document.getElementById("contatti").cap.value; var comune=document.getElementById("contatti").comune.value; document.getElementById("contatti").comune.className="email03"; var provincia=document.getElementById("contatti").provincia.value; document.getElementById("contatti").provincia.className="email03"; var telefono=document.getElementById("contatti").telefono.value; var messaggio=document.getElementById("contatti").messaggio.value; document.getElementById("contatti").messaggio.style.border="1px solid #7f9db9"; var valori_email=/[a-zA-Z0-9._%-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/; if(nome_2=="") { procedi=false; document.getElementById("contatti").nome.className="emailErrore03"; document.getElementById("contatti").nome.focus(); alert("Attenzione! Inserisci il nome o la ragione sociale"); }else if((email=="")||(!document.getElementById("contatti").email.value.match(valori_email))){ procedi=false; document.getElementById("contatti").email.focus(); document.getElementById("contatti").email.className="emailErrore03"; alert("Attenzione! Inserisci un indirizzo e-mail valido"); }else if(comune==""){ procedi=false; document.getElementById("contatti").comune.focus(); document.getElementById("contatti").comune.className="emailErrore03"; alert("Attenzione! Inserisci il comune"); }else if(provincia==""){ procedi=false; document.getElementById("contatti").provincia.focus(); document.getElementById("contatti").provincia.className="emailErrore03"; alert("Attenzione! Inserisci la provincia"); }else if(messaggio==""){ procedi=false; document.getElementById("contatti").messaggio.focus(); document.getElementById("contatti").messaggio.style.border="2px solid #e75011"; alert("Attenzione! Inserisci il testo del messaggio"); }else if(document.getElementById("contatti").privacy[1].checked==true){ procedi=false; document.getElementById("contatti").privacy[0].checked=true; alert("Attenzione! Per poter inviare il messaggio devi accettare il trattamento dei dati personali"); } if(procedi==true) { var xmlHttp = getXmlHttpObject(); xmlHttp.open('GET', "./include/ajax.php?tabella=contatti&codice_inserzione="+codice_inserzione+"&nome="+nome_2+"&email="+email+"&indirizzo="+indirizzo+"&cap="+cap+"&comune="+comune+"&provincia="+provincia+"&telefono="+telefono+"&messaggio="+messaggio, true); xmlHttp.send(null); document.getElementById("feedback").style.display="block"; document.getElementById("contatti").nome.value=""; document.getElementById("contatti").indirizzo.value=""; document.getElementById("contatti").cap.value=""; document.getElementById("contatti").comune.value=""; document.getElementById("contatti").provincia.value=""; document.getElementById("contatti").messaggio.value=""; document.getElementById("contatti").telefono.value=""; } } // Funzione conttati dal form altre occasioni function contattaConc() { procedi=true; var nome=document.getElementById('contattiConc').nome.value; document.getElementById('contattiConc').nome.className="email02"; var email=document.getElementById('contattiConc').email.value; document.getElementById('contattiConc').email.className="email02"; var messaggio=document.getElementById('contattiConc').messaggio.value; var telefono=document.getElementById('contattiConc').telefono.value; var codice_cliente=document.getElementById('contattiConc').codice_cliente.value; document.getElementById('contattiConc').messaggio.style.border="1px solid #7f9db9"; var valori_email=/[a-zA-Z0-9._%-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/; if(nome=="") { procedi=false; document.getElementById('contattiConc').nome.focus(); document.getElementById('contattiConc').nome.className="emailErrore02"; alert("Attenzione! Inserisci il nome"); }else if((email=="")||(!document.getElementById('contattiConc').email.value.match(valori_email))){ procedi=false; document.getElementById('contattiConc').email.focus(); document.getElementById('contattiConc').email.className="emailErrore02"; alert("Attenzione! Inserisci un indirizzo e-mail valido"); }else if(messaggio==""){ procedi=false; document.getElementById('contattiConc').messaggio.focus(); document.getElementById('contattiConc').messaggio.style.border="1px solid #e75011"; alert("Attenzione! Inserisci il testo del messaggio"); } if(procedi==true) { var xmlHttp = getXmlHttpObject(); xmlHttp.open('GET', "./include/ajax.php?tabella=contattiConc&nome="+nome+"&email="+email+"&telefono="+telefono+"&messaggio="+messaggio+"&codice_cliente="+codice_cliente, true); xmlHttp.send(null); document.getElementById("feedback").style.display="block"; alert("Messaggio inviato correttamente"); document.getElementById('contattiConc').nome.value=""; document.getElementById('contattiConc').email.value=""; document.getElementById('contattiConc').telefono.value=""; document.getElementById('contattiConc').messaggio.value=""; } } // Motore di ricerca annunci dei concessionari function motoreRicercaConcessionario(codice_cliente, pagina) { document.getElementById("risultatiRicerca").style.display="none"; document.getElementById("elaborazione").style.display="block"; var xmlHttp = getXmlHttpObject(); xmlHttp.open("GET", "./include/ajax.php?tabella=ricercaAnnunciConcessionario&codice_cliente="+codice_cliente+"&pagina="+pagina, true); xmlHttp.onreadystatechange = stateChanged; xmlHttp.send(null); function stateChanged() { if(xmlHttp.readyState == 4) { //Stato OK if (xmlHttp.status == 200) { var resp = xmlHttp.responseText; var contenuti=resp.split("#;#"); document.getElementById("risultatiRicerca").innerHTML=contenuti[0]; document.getElementById("ordinamentoPagina").innerHTML=contenuti[1]; document.getElementById("ordinamentoPagina02").innerHTML=contenuti[1]; document.getElementById("elaborazione").style.display="none"; document.getElementById("risultatiRicerca").style.display="block"; document.location.href="#top"; } } } } // Funzione per la ricerca concessionario function trovaConcessionario(numero_form) { document.getElementById("elaborazione").style.display="block"; document.getElementById("risultato").style.display="none"; // Se numero_form=="" vuol dire che la richiesta arriva direttamente dal form, altrimenti dal bottone numero pag. if(numero_form=="0") { var nome; var regione; var provincia; nome=document.getElementById('formRicercaConcessionario').nome.value; regione=document.getElementById('formRicercaConcessionario').regione.value; provincia=document.getElementById('formRicercaConcessionario').provincia.value; var pagina=document.getElementById('formRicercaConcessionario').pagina.value; }else{ var nome; var regione; var provincia; nome=document.getElementById('formRicercaConcessionario').nome.value; regione=document.getElementById('formRicercaConcessionario').regione.value; provincia=document.getElementById('formRicercaConcessionario').provincia.value; var pagina=eval("document.getElementById('formRicercaConcessionario02').pagina_"+numero_form+".value"); } // Chiamata ajax per creare l'elenco concessionari in base alla richeista var xmlHttp = getXmlHttpObject(); xmlHttp.open('GET', "./include/ajax.php?funzione=concessionario&nome="+nome+"®ione="+regione+"&provincia="+provincia+"&pagina="+pagina, true); xmlHttp.onreadystatechange = stateChanged; xmlHttp.send(null); function stateChanged() { if(xmlHttp.readyState == 4) { //Stato OK if (xmlHttp.status == 200) { var resp = xmlHttp.responseText; // Inserisco nel div l'elenco dei concessionari document.getElementById("risultato").style.display="block"; var valore = resp; document.getElementById("risultato").innerHTML=valore; document.getElementById("elaborazione").style.display="none"; } } } } // Registrazione alla newsletter function registrazioneNewsletter() { procedi=true; document.getElementById('newsletter').nome.className="email03"; document.getElementById('newsletter').cognome.className="email03"; document.getElementById('newsletter').email.className="email03"; document.getElementById('newsletter').regione.className="ricerca"; document.getElementById('newsletter').provincia.className="ricerca"; var valori_email=/[a-zA-Z0-9._%-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/; if(document.getElementById('newsletter').nome.value=="") { procedi=false; document.getElementById('newsletter').nome.focus(); document.getElementById('newsletter').nome.className="emailErrore03"; alert("Attenzione! Inserire il nome"); }else if(document.getElementById('newsletter').cognome.value==""){ procedi=false; document.getElementById('newsletter').cognome.focus(); document.getElementById('newsletter').cognome.className="emailErrore03"; alert("Attenzione! Inserire il cognome"); }else if(document.getElementById('newsletter').regione.value==""){ procedi=false; document.getElementById('newsletter').regione.focus(); document.getElementById('newsletter').regione.className="emailErrore03"; alert("Attenzione! Inserire la regione"); }else if(document.getElementById('newsletter').provincia.value==""){ procedi=false; document.getElementById('newsletter').provincia.focus(); document.getElementById('newsletter').provincia.className="emailErrore03"; alert("Attenzione! Inserire la provincia"); }else if((document.getElementById('newsletter').email.value=="")||(!document.getElementById('newsletter').email.value.match(valori_email))){ procedi=false; document.getElementById('newsletter').email.focus(); document.getElementById('newsletter').email.className="emailErrore03"; alert("Inserire un indirizzo e-mail valido"); }else if(document.getElementById('newsletter').privacy[1].checked==true){ procedi=false; alert("Attenzione! Per registrarsi alla newsletter bisogna accettare il trattamento dei dati personali"); } if(procedi==true){ document.getElementById('newsletter').submit(); } } // Cerca auto per me - controllo campi function cercaAutoPerMe() { procedi=true; document.getElementById('cercaPerMe').nome.className="email03"; document.getElementById('cercaPerMe').cognome.className="email03"; document.getElementById('cercaPerMe').email.className="email03"; var valori_email=/[a-zA-Z0-9._%-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/; document.getElementById('cercaPerMe').regione.className="ricerca"; document.getElementById('cercaPerMe').provincia.className="ricerca"; if(document.getElementById('cercaPerMe').nome.value==""){ procedi=false; document.getElementById('cercaPerMe').nome.focus(); document.getElementById('cercaPerMe').nome.className="emailErrore03"; alert("Attenzione! Inserire il nome"); }else if(document.getElementById('cercaPerMe').cognome.value==""){ procedi=false; document.getElementById('cercaPerMe').cognome.focus(); document.getElementById('cercaPerMe').cognome.className="emailErrore03"; alert("Attenzione! Inserire il cognome"); }else if((document.getElementById('cercaPerMe').email.value=="")||(!document.getElementById('cercaPerMe').email.value.match(valori_email))){ procedi=false; document.getElementById('cercaPerMe').email.focus(); document.getElementById('cercaPerMe').email.className="emailErrore03"; alert("Attenzione! Inserire un indirizzo e-mail valido"); }else if(document.getElementById('cercaPerMe').regione.value==""){ procedi=false; document.getElementById('cercaPerMe').regione.focus(); document.getElementById('cercaPerMe').regione.className="emailErrore03"; alert("Attenzione! Inserire la regione"); }else if(document.getElementById('cercaPerMe').provincia.value==""){ procedi=false; document.getElementById('cercaPerMe').provincia.focus(); document.getElementById('cercaPerMe').provincia.className="emailErrore03"; alert("Attenzione! Inserire la provincia"); }else if((document.getElementById('cercaPerMe').marca.value=="")&&(document.getElementById('cercaPerMe').modello.value=="")&&(document.getElementById('cercaPerMe').carrozzeria.value=="")&&(document.getElementById('cercaPerMe').alimentazione.value=="")&&(document.getElementById('cercaPerMe').regione.value=="")){ procedi=false; alert("Scegli i valori almeno per questi parametri: Marca, Modello, Carrozzeria, Alimentazione, Regione"); }else if(document.getElementById('cercaPerMe').privacy[1].checked==true){ procedi=false; alert("Attezione! Per inviare il modulo bisogna accettare il trattamento dei dati personali"); } if(procedi==true) { document.getElementById('cercaPerMe').submit(); } } // Funzione per la verifica dei parametri inseriti nella ricerca function verificaRicercaPrezzo() { procedi=true; var carrozzeria=document.getElementById('ricercaAvanzata').carrozzeria.value; var prezzo_da=document.getElementById('ricercaAvanzata').prezzo_da.value; var prezzo_a=document.getElementById('ricercaAvanzata').prezzo_a.value; if((carrozzeria=="")&&(prezzo_da=="")&&(prezzo_a=="")) { procedi=false; alert("ATTENZIONE! Selezionare almeno un parametro di ricerca!"); } if(procedi==true) { document.getElementById('ricercaAvanzata').submit(); } } // Funzione per la verifica dei parametri inseriti nella ricerca function verificaRicerca() { procedi=true; var marca=document.getElementById('ricercaAvanzata').marca.value; var modello=document.getElementById('ricercaAvanzata').modello.value; var tipo_auto=document.getElementById('ricercaAvanzata').tipo_auto.value; var carrozzeria=document.getElementById('ricercaAvanzata').carrozzeria.value; var alimentazione=document.getElementById('ricercaAvanzata').alimentazione.value; var cambio=document.getElementById('ricercaAvanzata').cambio.value; var regione=document.getElementById('ricercaAvanzata').regione.value; var provincia=document.getElementById('ricercaAvanzata').provincia.value; var anno_da=document.getElementById('ricercaAvanzata').anno_da.value; var anno_a=document.getElementById('ricercaAvanzata').anno_a.value; var prezzo_da=document.getElementById('ricercaAvanzata').prezzo_da.value; var prezzo_a=document.getElementById('ricercaAvanzata').prezzo_a.value; var chilometraggio=document.getElementById('ricercaAvanzata').chilometraggio.value; var cilindrata=document.getElementById('ricercaAvanzata').cilindrata.value; if((marca=="")&&(modello=="")&&(tipo_auto=="")&&(carrozzeria=="")&&(alimentazione=="")&&(cambio=="")&&(regione=="")&&(provincia=="")&&(anno_da=="")&&(anno_a=="")&&(prezzo_da=="")&&(prezzo_a=="")&&(chilometraggio=="")&&(cilindrata=="")) { procedi=false; alert("ATTENZIONE! Selezionare almeno un parametro di ricerca!"); } if(procedi==true) { document.getElementById('ricercaAvanzata').submit(); } } // Funzione che svuota il form di ricerca avanzata function cancellaParametriRicerca() { var ctrls = document.getElementById('ricercaAvanzata'); for (var i = 0; i < ctrls.length; i++) { var cbox = ctrls[i]; if (cbox.type == "checkbox") { cbox.checked=false; } else if (cbox.type == "select-one") { cbox.selectedIndex="0"; } else if (cbox.type == "text") { cbox.value=""; } } } // Funzione per la select regione provincia function regioneProvincia(regione, tabindex, selezione) { var xmlHttp = getXmlHttpObject(); xmlHttp.open('GET', "./include/ajax.php?tabella=provincia®ione="+regione+"&tabindex="+tabindex+"&selezione="+selezione, true); xmlHttp.onreadystatechange = stateChanged; xmlHttp.send(null); function stateChanged() { if(xmlHttp.readyState == 4) { //Stato OK if (xmlHttp.status == 200) { var resp = xmlHttp.responseText; if(resp) { var valore=resp; document.getElementById("provincia").innerHTML=valore; } } } } } // Funzione per la select regione provincia function regioneProvinciaRicerca(regione, tabindex, selezione, contatore) { var xmlHttp = getXmlHttpObject(); xmlHttp.open('GET', "./include/ajax.php?tabella=provincia_ricerca®ione="+regione+"&tabindex="+tabindex+"&selezione="+selezione+"&contatore="+contatore, true); xmlHttp.onreadystatechange = stateChanged; xmlHttp.send(null); function stateChanged() { if(xmlHttp.readyState == 4) { //Stato OK if (xmlHttp.status == 200) { var resp = xmlHttp.responseText; if(resp) { var valore=resp; document.getElementById("provincia_ricerca").innerHTML=valore; } } } } } // Funzione per la select regione provincia function provinciaComune(provincia, tabindex, selezione, punti) { if(punti==null) { punti='.'; } var xmlHttp = getXmlHttpObject(); xmlHttp.open('GET', punti+"/include/ajax.php?tabella=comune&provincia="+provincia+"&tabindex="+tabindex+"&selezione="+selezione, true); xmlHttp.onreadystatechange = stateChanged; xmlHttp.send(null); function stateChanged() { if(xmlHttp.readyState == 4) { //Stato OK if (xmlHttp.status == 200) { var resp = xmlHttp.responseText; if(resp) { var valore=resp; document.getElementById("comune").innerHTML=valore; } } } } } // Funzione per inviare l'e-mail dalla scheda auto function inviaEmail() { procedi=true document.formEmail.nome.className="email"; document.formEmail.email.className="email"; var valori_email=/[a-zA-Z0-9._%-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/; var nome=document.formEmail.nome.value; var email=document.formEmail.email.value; var telefono=document.formEmail.telefono.value; var messaggio=document.formEmail.messaggio.value; var codice_inserzione=document.formEmail.codice_inserzione.value; var newsletter; if(document.formEmail.newsletter.checked==true) { newsletter=1; }else{ newsletter=0; } if(document.formEmail.nome.value=="") { procedi=false; document.formEmail.nome.className="emailErrore"; document.formEmail.nome.focus(); alert("Inserire il nome"); }else if((document.formEmail.email.value=="")||(!document.formEmail.email.value.match(valori_email))||(document.formEmail.email.value=="cole_david88@yahoo.com")){ procedi=false; document.formEmail.email.className="emailErrore"; document.formEmail.email.focus(); alert("Inserire un indirizzo e-mail valido"); }else if(document.formEmail.privacy.checked!=true){ procedi=false; alert("Attezione! Per inviare il modulo bisogna accettare il trattamento dei dati personali"); } if(procedi==true) { document.formEmail.submit(); /* var xmlHttp = getXmlHttpObject(); // alert("./include/ajax.php?tabella=invio_email&nome="+nome+"&email="+email+"&telefono="+telefono+"&messaggio="+messaggio+"&codice_inserzione="+codice_inserzione+"&newsletter="+newsletter); xmlHttp.open('GET', "./include/ajax.php?tabella=invio_email&nome="+nome+"&email="+email+"&telefono="+telefono+"&messaggio="+messaggio+"&codice_inserzione="+codice_inserzione+"&newsletter="+newsletter, true); xmlHttp.send(null); alert("E-mail correttamente INVIATA!"); document.formEmail.nome.value=""; document.formEmail.email.value=""; document.formEmail.telefono.value=""; document.formEmail.messaggio.value=""; */ conta_email_google(); } } // Apertura pop-up function open_pop(url, width, height) { stile=" width="+width+"px height="+height+"px status=no toolbar=no menubar=no scrollbars=no"; window.open(url, "", stile); } // switch foto scheda auto function cambia_foto(codice_inserzione, codice_cliente, numero_foto) { var xmlHttp = getXmlHttpObject(); xmlHttp.open("GET", "../../../../../include/ajax.php?tabella=foto&codice_cliente="+codice_cliente+"&codice_inserzione="+codice_inserzione+"&numero_foto="+numero_foto, true); //alert("./include/ajax.php?tabella=foto&codice_cliente="+codice_cliente+"&codice_inserzione="+codice_inserzione+"&numero_foto="+numero_foto); xmlHttp.onreadystatechange = stateChanged; xmlHttp.send(null); function stateChanged() { if(xmlHttp.readyState == 4) { //Stato OK if (xmlHttp.status == 200) { var resp = xmlHttp.responseText; testo=resp.split("#;#"); document.getElementById('foto').innerHTML=testo[0]; document.getElementById('contatoreFoto').innerHTML=testo[1]; for(i=0;i"; }else if(parametri[3]=="immagini"){ var link; link=parametri[4]; var url; url=link.replace("http://", ""); contenuto=""; } document.getElementById('elaborazione_'+id_aggiornare).style.display="none"; document.getElementById(id_aggiornare).style.display="block"; document.getElementById(id_aggiornare).innerHTML=contenuto; }else{ document.getElementById('elaborazione_'+id_aggiornare).style.display="none"; document.getElementById(id_aggiornare).style.display="none"; } } } } } // Contatore click su banner img function conta_click(banner, tipologia) { // Aggiorno il campo contatore click su banner var xmlHttp = getXmlHttpObject(); xmlHttp.open('GET', "./include/ajax.php?tabella=conta_click_banner&banner="+banner+"&tipologia="+tipologia, true); xmlHttp.send(null); } // Contatore click su link function contatore(pagina) { if(pagina!="") { // Aggiorno il campo contatore click su link var xmlHttp = getXmlHttpObject(); xmlHttp.open('GET', "./include/ajax.php?tabella=conta_click&pagina="+pagina, true); xmlHttp.send(null); } } // Nascondi telefono function nascondi_telefono() { document.getElementById('telefono_conc').style.display="none"; } // Visualizza telefono function visualizza_telefono(codice_inserzione) { document.getElementById('telefono_conc').style.display="block"; document.getElementById('visualizza_telefono').style.display="none"; // Aggiorno il campo visualizzazione_telefono tramite ajax var xmlHttp = getXmlHttpObject(); xmlHttp.open('GET', "../../../../../include/ajax.php?tabella=visualizzazione_telefono&codice_inserzione="+codice_inserzione, true); xmlHttp.send(null); } // Visualizza telefono function visualizza_telefono_conc(codice_cliente) { document.getElementById('telefono_conc').style.display="block"; document.getElementById('visualizza_telefono').style.display="none"; // Aggiorno il campo visualizzazione_telefono tramite ajax var xmlHttp = getXmlHttpObject(); xmlHttp.open('GET', "./include/ajax.php?tabella=visualizzazione_telefono_conc&codice_cliente="+codice_cliente, true); xmlHttp.send(null); } // Auto alert function autoAlert() { document.getElementById('autoAlert').nome.className="email03"; document.getElementById('autoAlert').cognome.className="email03"; document.getElementById('autoAlert').provincia.className="ricerca"; document.getElementById('autoAlert').regione.className="ricerca"; document.getElementById('autoAlert').email.className="email03"; var valori_email=/[a-zA-Z0-9._%-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/; procedi=true if(document.getElementById('autoAlert').nome.value=="") { procedi=false; document.getElementById('autoAlert').nome.className="emailErrore03"; document.getElementById('autoAlert').nome.focus(); alert("Attenzione!\nE' necessario inserire il nome"); }else if(document.getElementById('autoAlert').cognome.value==""){ procedi=false; document.getElementById('autoAlert').cognome.className="emailErrore03"; document.getElementById('autoAlert').cognome.focus(); alert("Attenzione!\nE' necessario inserire il cognome"); }else if((document.getElementById('autoAlert').email.value=="")||(!document.getElementById('autoAlert').email.value.match(valori_email))){ procedi=false; document.getElementById('autoAlert').email.className="emailErrore03"; document.getElementById('autoAlert').email.focus(); alert("Attenzione!\nE' necessario inserire un indirizzo e-mail valido"); }else if(document.getElementById('autoAlert').regione.value==""){ procedi=false; document.getElementById('autoAlert').regione.className="emailErrore03"; document.getElementById('autoAlert').regione.focus(); alert("Attenzione!\nE' necessario inserire la regione"); }else if(document.getElementById('autoAlert').provincia.value==""){ procedi=false; document.getElementById('autoAlert').provincia.className="emailErrore03"; document.getElementById('autoAlert').provincia.focus(); alert("Attenzione!\nE' necessario inserire la provincia"); }else if((document.getElementById('autoAlert').marca.value=="")&&(document.getElementById('autoAlert').modello.value=="")&&(document.getElementById('autoAlert').alimentazione.value=="")&&(document.getElementById('autoAlert').prezzo_da.value=="")&&(document.getElementById('autoAlert').prezzo_a.value=="")){ procedi=false; alert("Attenzione!\nE' necessario compilare almeno uno tra i seguenti campi: Marca, Modello, Alimentazione, Prezzo da, Prezzo a"); } if(procedi==true) { document.getElementById('autoAlert').submit(); } } // Segnala annuncio ad un amico function invia_segnalazione_amico() { procedi=true; var nome_mittente=document.getElementById('formSegnalazioneAmico').nome.value; var email_mittente=document.getElementById('formSegnalazioneAmico').email.value; var nome_destinatario=document.getElementById('formSegnalazioneAmico').nome_destinatario.value; var email_destinatario=document.getElementById('formSegnalazioneAmico').email_destinatario.value; var codice_inserzione=document.getElementById('formSegnalazioneAmico').codice_inserzione.value; if(document.getElementById('formSegnalazioneAmico').nome.value=="") { document.getElementById('formSegnalazioneAmico').nome.focus(); procedi=false; alert("Attenzione! Devi inserire il tuo nome"); }else if(document.getElementById('formSegnalazioneAmico').email.value==""){ document.getElementById('formSegnalazioneAmico').email.focus(); procedi=false; alert("Attenzione! Devi inserire la tua e-mail"); }else if(document.getElementById('formSegnalazioneAmico').nome_destinatario.value==""){ document.getElementById('formSegnalazioneAmico').nome_destinatario.focus(); procedi=false; alert("Attenzione! Devi inserire il nome del destinatario"); }else if(document.getElementById('formSegnalazioneAmico').email_destinatario.value==""){ document.getElementById('formSegnalazioneAmico').email_destinatario.focus(); procedi=false; alert("Attenzione! Devi inserire l'indirizzo e-mail del destinatario"); } if(procedi==true) { var xmlHttp = getXmlHttpObject(); xmlHttp.open('GET', "./include/ajax.php?tabella=segnalaAmico&nome="+nome_mittente+"&email="+email_mittente+"&nome_destinatario="+nome_destinatario+"&email_destinatario="+email_destinatario+"&codice_inserzione="+codice_inserzione, true); xmlHttp.send(null); alert("Il tuo messaggio è stato correttamente inviato."); $nascondi("segnalaAmico"); } } // Verifica compilazione dei campi dei commenti del blog function verifica_commenti() { procedi=true; document.commenti.nome.className="email02"; document.commenti.email.className="email02"; var valori_email=/[a-zA-Z0-9._%-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/; if(document.commenti.nome.value=="") { document.commenti.nome.focus(); procedi=false; document.commenti.nome.className="emailErrore02"; alert("Inserire il nome"); }else if((document.commenti.email.value=="")||(!document.commenti.email.value.match(valori_email))){ procedi=false; document.commenti.email.focus(); document.commenti.email.className="emailErrore02"; alert("Attenzione! Inserire un indirizzo e-mail valido\nTi ricordiamo che l'indirizzo e-mail non verrà visualizzato nel commento."); }else if(document.commenti.messaggio.value==""){ procedi=false; document.commenti.messaggio.focus(); alert("Attenzione! Inserire il testo del commento."); } if(procedi==true) { document.commenti.submit(); } } // Funzione per il check del numero di telefono nascosto - Registrazione privati function allerta_telefono(valore) { if(valore==0) { alert("Attenzione, selezionando questo checkbox il vostro numero di telefono non comparirà nella scheda dell'annuncio"); document.registrazione.tel_nascosto.value="1"; }else{ document.registrazione.tel_nascosto.value="0"; } } // Vetrina in home page function carica_vetrina(partenza) { document.getElementById('vetrina_home').innerHTML="
"; var xmlHttp = getXmlHttpObject(); xmlHttp.open('GET', "./include/ajax.php?edit=vetrina_home&partenza="+partenza, true); xmlHttp.onreadystatechange = stateChanged; xmlHttp.send(null); function stateChanged() { if(xmlHttp.readyState == 4) { //Stato OK if (xmlHttp.status == 200) { var resp = xmlHttp.responseText; document.getElementById('vetrina_home').innerHTML=resp; } } } } // Funzione per modificare lo style dello span in home page function cambiaStyle(valore) { if(valore==0) { document.getElementById('ched_auto_01').className="arancione"; document.getElementById('ched_auto_02').className="nero"; }else{ document.getElementById('ched_auto_01').className="nero"; document.getElementById('ched_auto_02').className="arancione"; } } // Funzione per verificare quanti annunci sono presenti function verifica_quanti_annunci() { var marca=document.getElementById('ricerca').marca.value; var modello=document.getElementById('ricerca').modello.value; var alimentazione=document.getElementById('ricerca').alimentazione.value; //var tipo_auto=document.getElementById('ricerca').tipo_auto.value; var provincia=document.getElementById('ricerca').provincia.value; var anno_da=document.getElementById('ricerca').anno_da.value; var prezzo_a=document.getElementById('ricerca').prezzo_a.value; var chilometraggio=document.getElementById('ricerca').chilometraggio.value; if(document.getElementById('ricerca').tipo_auto[0].checked==true) { var tipo_auto_2="Auto usata"; }else{ var tipo_auto_2="Auto nuova"; } var xmlHttp = getXmlHttpObject(); xmlHttp.open("GET", "./include/ajax.php?tabella=suggest&marca="+marca+"&modello="+modello+"&alimentazione="+alimentazione+"&tipo_auto="+tipo_auto_2+"&provincia="+provincia+"&anno_da="+anno_da+"&prezzo_a="+prezzo_a+"&chilometraggio="+chilometraggio, true); xmlHttp.onreadystatechange = stateChanged; xmlHttp.send(null); function stateChanged() { if(xmlHttp.readyState == 4) { //Stato OK if (xmlHttp.status == 200) { if((marca=="")&&(modello=="")&&(alimentazione=="")&&(provincia=="")&&(anno_da=="")&&(prezzo_a=="")&&(chilometraggio=="")) { document.getElementById('risultatoRicerca').style.display="none"; }else{ var resp = xmlHttp.responseText; document.getElementById('risultatoRicerca').innerHTML=resp; document.getElementById('risultatoRicerca').style.display="block"; } } } } } // Funzione per verificare quanti annunci sono presenti function verifica_quanti_annunci_ricerca(valore_div, contatore_ricerca) { setTimeout("", 20000); if(valore_div!="") { var nome_div=valore_div; }else{ var nome_div=""; } //marca if (document.getElementById('ricerca'+valore_div).marca) { var marca=document.getElementById('ricerca'+valore_div).marca.value; }else{ var marca=""; } //modello if (document.getElementById('ricerca'+valore_div).modello) { var modello=document.getElementById('ricerca'+valore_div).modello.value; }else{ var modello=""; } //alimentazione if (document.getElementById('ricerca'+valore_div).alimentazione) { var alimentazione=document.getElementById('ricerca'+valore_div).alimentazione.value; }else{ var alimentazione=""; } //provincia if (document.getElementById('ricerca'+valore_div).provincia) { var provincia=document.getElementById('ricerca'+valore_div).provincia.value; }else{ var provincia=""; } //regione if (document.getElementById('ricerca'+valore_div).regione) { var regione=document.getElementById('ricerca'+valore_div).regione.value; }else{ var regione=""; } //anno_da if (document.getElementById('ricerca'+valore_div).anno_da) { var anno_da=document.getElementById('ricerca'+valore_div).anno_da.value; }else{ var anno_da=""; } //anno_a if (document.getElementById('ricerca'+valore_div).anno_a) { var anno_a=document.getElementById('ricerca'+valore_div).anno_a.value; }else{ var anno_a=""; } //prezzo_da if (document.getElementById('ricerca'+valore_div).prezzo_da) { var prezzo_da=document.getElementById('ricerca'+valore_div).prezzo_da.value; }else{ var prezzo=""; } //prezzo_a if (document.getElementById('ricerca'+valore_div).prezzo_a) { var prezzo_a=document.getElementById('ricerca'+valore_div).prezzo_a.value; }else{ var prezzo_a=""; } //chilometraggio_da if (document.getElementById('ricerca'+valore_div).chilometraggio_da) { var chilometraggio_da=document.getElementById('ricerca'+valore_div).chilometraggio_da.value; }else{ var chilometraggio_da=""; } //chilometraggio_a if (document.getElementById('ricerca'+valore_div).chilometraggio_a) { var chilometraggio_a=document.getElementById('ricerca'+valore_div).chilometraggio_a.value; }else{ var chilometraggio_a=""; } //tipo_auto if (document.getElementById('ricerca'+valore_div).tipo_auto) { var tipo_auto=document.getElementById('ricerca'+valore_div).tipo_auto.value; }else{ var tipo_auto=""; } //versione if (document.getElementById('ricerca'+valore_div).versione) { var versione=document.getElementById('ricerca'+valore_div).versione.value; }else{ var versione=""; } var xmlHttp = getXmlHttpObject(); xmlHttp.open("GET", "./include/ajax.php?tabella=suggest_ricerca&marca="+marca+"&modello="+modello+"&alimentazione="+alimentazione+"&tipo_auto="+tipo_auto+"&provincia="+provincia+"®ione="+regione+"&anno_a="+anno_a+"&anno_da="+anno_da+"&prezzo_a="+prezzo_a+"&prezzo_da="+prezzo_da+"&chilometraggio_da="+chilometraggio_da+"&chilometraggio_a="+chilometraggio_a+"&contatore_ricerca="+contatore_ricerca+"&versione="+versione, true); xmlHttp.onreadystatechange = stateChanged; xmlHttp.send(null); function stateChanged() { if(xmlHttp.readyState == 4) { //Stato OK if (xmlHttp.status == 200) { if((marca=="")&&(modello=="")&&(alimentazione=="")&&(provincia=="")&&(anno_da=="")&&(prezzo_a=="")&&(chilometraggio_da=="")) { document.getElementById('risultatoRicerca').style.display="none"; }else{ var resp = xmlHttp.responseText; document.getElementById('risultatoRicerca'+nome_div).innerHTML=resp; document.getElementById('risultatoRicerca'+nome_div).style.display="block"; } } } } } // Funzione per generare il select modelli function loadList(tabella, marca_selezionata, modello_selezionato, tabindex, stile_select, div, valore_home, punti,serie) { if(punti==null) { punti=""; } else { punti="."; } var xmlHttp = getXmlHttpObject(); xmlHttp.open("GET", punti+"./include/ajax.php?tabella="+tabella+"&marca="+marca_selezionata+"&modello="+modello_selezionato+"&tabindex="+tabindex+"&style="+stile_select+"&home="+valore_home+"&serie="+serie, true); xmlHttp.onreadystatechange = stateChanged; xmlHttp.send(null); function stateChanged() { if(xmlHttp.readyState == 4) { //Stato OK if (xmlHttp.status == 200) { var resp = xmlHttp.responseText; var quale_div="select_modello"+div; document.getElementById(quale_div).innerHTML=resp; } } } } // Funzione per generare il select modelli function loadListRicerca(tabella, marca_selezionata, modello_selezionato, tabindex, div_risultato, id_select,serie) { var xmlHttp = getXmlHttpObject(); xmlHttp.open("GET", "./include/ajax.php?tabella=modelli_risultati_ricerca&marca="+marca_selezionata+"&modello="+modello_selezionato+"&tabindex="+tabindex+"&risultati_ricerca="+div_risultato+"&id_select="+id_select+"&serie="+serie, true); xmlHttp.onreadystatechange = stateChanged; xmlHttp.send(null); function stateChanged() { if(xmlHttp.readyState == 4) { //Stato OK if (xmlHttp.status == 200) { var resp = xmlHttp.responseText; var quale_div="risultatoRicerca"+div_risultato; document.getElementById('select_modello_ricerca').innerHTML=resp; } } } } // Funzione indispensabile per il funzionamento delle chiamate in ajax function getXmlHttpObject() { var xmlHttp=null; try { //Firefox e Opera xmlHttp=new XMLHttpRequest(); } catch(e) { //Internet Explorer try { xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); } catch(e) { xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); } } return xmlHttp; }