// 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"; } } // Questa funzione identifica i banner spot per la ricerca avanzata function banner_spot(url) { // Invio i dati alla pagina in ajax var xmlHttp = getXmlHttpObject(); xmlHttp.open('GET', "./include/ajax.php?funzione=banner_spot&"+url, true); xmlHttp.onreadystatechange = stateChanged; xmlHttp.send(null); function stateChanged() { if(xmlHttp.readyState == 4) { //Stato OK if (xmlHttp.status == 200) { var resp = xmlHttp.responseText; var parametri=resp.split("#;#"); if(parametri[0]!="") { contenuto=""; $nascondi('elaborazione_Banner_laterale_spot_1'); $visualizza('Banner_laterale_spot_1'); $update('Banner_laterale_spot_1', contenuto); }else{ $nascondi('elaborazione_Banner_laterale_spot_1'); //$nascondi('Banner_laterale_spot_1'); } } } } } // 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"; document.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; 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.regione.value==""){ procedi=false; document.registrazione.regione.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.citta.value==""){ procedi=false; document.registrazione.citta.focus(); document.registrazione.citta.className="emailErrore04"; alert("Attenzione! Inserire la cittā"); }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').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; 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="emailErrore04"; alert("Attenzione! Inserire il nome"); }else if(document.getElementById('registrazione').cognome.value==""){ procedi=false; document.getElementById('registrazione').cognome.focus(); document.getElementById('registrazione').cognome.className="emailErrore04"; 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="emailErrore04"; 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="emailErrore04"; 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="emailErrore04"; 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="emailErrore04"; 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="emailErrore04"; 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(); } } } } } } // Cerca auto per me - controllo campi function cercaAutoPerMe() { procedi=true; document.cercaPerMe.nome.className="email03"; document.cercaPerMe.cognome.className="email03"; document.cercaPerMe.email.className="email03"; var valori_email=/[a-zA-Z0-9._%-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/; document.cercaPerMe.provincia.className="email03"; if((document.cercaPerMe.marca.value=="")&&(document.cercaPerMe.modello.value=="")&&(document.cercaPerMe.carrozzeria.value=="")&&(document.cercaPerMe.alimentazione.value=="")&&(document.cercaPerMe.regione.value=="")) { procedi=false; alert("Scegli almeno uno tra questo parametri: Marca, Modello, Carrozzeria, Alimentazione, Regione"); }else if(document.cercaPerMe.nome.value==""){ procedi=false; document.cercaPerMe.nome.focus(); document.cercaPerMe.nome.className="emailErrore04"; alert("Attenzione! Inserire il nome"); }else if(document.cercaPerMe.cognome.value==""){ procedi=false; document.cercaPerMe.cognome.focus(); document.cercaPerMe.cognome.className="emailErrore04"; alert("Attenzione! Inserire il cognome"); }else if((document.cercaPerMe.email.value=="")||(!document.cercaPerMe.email.value.match(valori_email))){ procedi=false; document.cercaPerMe.email.focus(); document.cercaPerMe.email.className="emailErrore04"; alert("Attenzione! Inserire un indirizzo e-mail valido"); }else if(document.cercaPerMe.provincia.value==""){ procedi=false; document.cercaPerMe.provincia.focus(); document.cercaPerMe.provincia.className="emailErrore04"; alert("Attenzione! Inserire la provincia"); }else if(document.cercaPerMe.privacy[1].checked==true){ procedi=false; alert("Attezione! Per inviare il modulo bisogna accettare il trattamento dei dati personali"); } if(procedi==true) { document.cercaPerMe.submit(); } } // Registrazione alla newsletter function registrazioneNewsletter() { procedi=true; document.newsletter.nome.className="email02"; document.newsletter.email.className="email02"; var valori_email=/[a-zA-Z0-9._%-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/; if(document.newsletter.nome.value=="") { procedi=false; document.newsletter.nome.focus(); document.newsletter.nome.className="emailErrore02"; alert("Inserire il nome"); }else if((document.newsletter.email.value=="")||(!document.newsletter.email.value.match(valori_email))){ procedi=false; document.newsletter.email.focus(); document.newsletter.email.className="emailErrore02"; alert("Inserire un indirizzo e-mail valido"); }else if(document.newsletter.privacy[1].checked==true){ procedi=false; alert("Per registrarsi alla newsletter bisogna accettare il trattamento dei dati personali"); } if(procedi==true){ document.newsletter.submit(); } } // Ricerca parola chiave function ricercaKeyword() { if(document.ricercaAvanzata.keyword.value=="") { alert("Specificare le parole chiave per la ricerca"); }else{ document.ricercaAvanzata.submit(); } } // Ricerca prezzo controllo campi function ricercaPrezzo() { procedi=true; if((document.ricercaAvanzata.prezzo_da.value=="")&&(document.ricercaAvanzata.prezzo_a.value=="")&&(document.ricercaAvanzata.carrozzeria.value=="")) { procedi=false; alert("Selezionare almeno un parametro per la ricerca"); } if(procedi==true) { document.ricercaAvanzata.submit(); } } // Funzione conttati dal form altre occasioni function contattaConc() { procedi=true; var nome=document.getElementById('contattiConc').nome.value; document.getElementById('contattiConc').nome.className="email"; var email=document.getElementById('contattiConc').email.value; document.getElementById('contattiConc').email.className="email"; 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').nome.style.background="#ffffff"; 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="emailErrore03"; alert("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="emailErrore03"; alert("Inserisci un indirizzo e-mail valido"); }else if(messaggio==""){ procedi=false; document.getElementById('contattiConc').messaggio.focus(); document.getElementById('contattiConc').messaggio.style.background="#ec6a00"; alert("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); $visualizza("feedback"); alert("Messaggio inviato correttamente"); document.getElementById('contattiConc').nome.value=""; document.getElementById('contattiConc').email.value=""; document.getElementById('contattiConc').telefono.value=""; document.getElementById('contattiConc').messaggio.value=""; } } // Funzione per la ricerca concessionario function trovaConcessionario(numero_form) { $visualizza("elaborazione"); $nascondi("risultato"); // 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.formRicercaConcessionario.nome.value; regione=document.formRicercaConcessionario.regione.value; provincia=document.formRicercaConcessionario.provincia.value; var pagina=document.formRicercaConcessionario.pagina.value; }else{ var nome; var regione; var provincia; nome=document.formRicercaConcessionario.nome.value; regione=document.formRicercaConcessionario.regione.value; provincia=document.formRicercaConcessionario.provincia.value; var pagina=eval("document.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 $visualizza("risultato"); var valore = resp; $update("risultato", valore); $nascondi("elaborazione"); } } } } // Funzione per la select regione provincia function regioneProvincia(regione, tabindex) { var xmlHttp = getXmlHttpObject(); xmlHttp.open('GET', "./include/ajax.php?tabella=provincia®ione="+regione+"&tabindex="+tabindex, 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; $update("provincia", valore); } } } } } // Funzione invio e-mail modulo contatti function inviaEmailContatti() { procedi=true; var codice_inserzione=document.contatti.codice_inserzione.value; var nome=document.contatti.nome.value; document.contatti.nome.className="email02"; var email=document.contatti.email.value; document.contatti.email.className="email02"; var indirizzo=document.contatti.indirizzo.value; var cap=document.contatti.cap.value; var comune=document.contatti.comune.value; document.contatti.comune.className="email02"; var provincia=document.contatti.provincia.value; document.contatti.provincia.className="email02"; var telefono=document.contatti.telefono.value; var messaggio=document.contatti.messaggio.value; document.contatti.nome.style.background="#ffffff"; var valori_email=/[a-zA-Z0-9._%-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/; if(nome=="") { procedi=false; document.contatti.nome.focus(); document.contatti.nome.className="emailErrore02"; alert("Inserisci il nome"); }else if((email=="")||(!document.contatti.email.value.match(valori_email))){ procedi=false; document.contatti.email.focus(); document.contatti.email.className="emailErrore02"; alert("Inserisci un indirizzo e-mail valido"); }else if(comune==""){ procedi=false; document.contatti.comune.focus(); document.contatti.comune.className="emailErrore02"; alert("Inserisci il comune"); }else if(provincia==""){ procedi=false; document.contatti.provincia.focus(); document.contatti.provincia.className="emailErrore02"; alert("Inserisci la provincia"); }else if(messaggio==""){ procedi=false; document.contatti.messaggio.focus(); document.contatti.messaggio.style.background="#ec6a00"; alert("Inserisci il testo del messaggio"); }else if(document.contatti.privacy[1].checked==true){ procedi=false; document.contatti.privacy[0].checked=true; alert("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+"&email="+email+"&indirizzo="+indirizzo+"&cap="+cap+"&comune="+comune+"&provincia="+provincia+"&telefono="+telefono+"&messaggio="+messaggio, true); xmlHttp.send(null); $visualizza("feedback"); alert("Messaggio inviato correttamente"); } } // Funzione per il caricamento delle foto pop function startImg(quale, codice_cliente, codice_inserzione) { $nascondi("ingrandimentoImg"); $visualizza("elaborazione"); var xmlHttp = getXmlHttpObject(); xmlHttp.open('GET', "./include/ajax.php?tabella=ingrandimento_immagini&immagini="+quale+"&codice_inserzione="+codice_inserzione+"&codice_cliente="+codice_cliente, 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; $update("ingrandimentoImg", valore); $visualizza("ingrandimentoImg"); $nascondi("elaborazione"); } } } } } // Funzione segnalazione errore function invia_segnalazione_errore() { var nome_mittente=document.formSegnalazioneErrore.nome.value; var email_mittente=document.formSegnalazioneErrore.email.value; var valori_email=/[a-zA-Z0-9._%-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/; var messaggio_mittente=document.formSegnalazioneErrore.messaggio.value; var codice_inserzione=document.formSegnalazioneErrore.codice_inserzione.value; document.formSegnalazioneErrore.nome.className="email"; document.formSegnalazioneErrore.email.className="email"; procedi=true; if(document.formSegnalazioneErrore.nome.value=="") { document.formSegnalazioneErrore.nome.focus(); document.formSegnalazioneErrore.nome.className="emailErrore"; procedi=false; alert("ATTENZIONE! Inserire il nome"); }else if((document.formSegnalazioneErrore.email.value=="")||(!document.formSegnalazioneErrore.email.value.match(valori_email))){ document.formSegnalazioneErrore.email.focus(); document.formSegnalazioneErrore.email.className="emailErrore"; procedi=false; alert("ATTENZIONE! Inserire un indirizzo e-mail valido"); }else if(document.formSegnalazioneErrore.messaggio.value==""){ document.formSegnalazioneErrore.messaggio.focus(); document.formSegnalazioneErrore.messaggio.style.background="#ec6a00"; procedi=false; alert("ATTENZIONE! Inserire il testo"); } if(procedi==true) { var xmlHttp = getXmlHttpObject(); xmlHttp.open('GET', "./include/ajax.php?tabella=annunci_errori&nome="+nome_mittente+"&email="+email_mittente+"&messaggio="+messaggio_mittente+"&codice_inserzione="+codice_inserzione, true); xmlHttp.send(null); alert("Ti ringraziamo per la segnalazione inviataci.\nSarā nostra cura verificare l'annuncio."); document.formSegnalazioneErrore.nome.value=""; document.formSegnalazioneErrore.email.value=""; document.formSegnalazioneErrore.messaggio.value=""; $nascondi("segnalaErrori"); } } // 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))){ procedi=false; document.formEmail.email.className="emailErrore"; document.formEmail.email.focus(); alert("Inserire un indirizzo e-mail valido"); } if(procedi==true) { var xmlHttp = getXmlHttpObject(); 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=""; } } // Funzione confronta auto function listaConfronto(azione, codice_annuncio, codice_utente, id) { var xmlHttp = getXmlHttpObject(); if(azione=='aggiungi') { xmlHttp.open('GET', "./include/ajax.php?tabella=confronto&codice_annuncio="+codice_annuncio+"&codice_utente="+codice_utente+"&azione=aggiungi", true); xmlHttp.send(null); $visualizza("noListaConfronto_"+id); $nascondi("listaConfronto_"+id); alert("Auto correttamente INSERITA nella lista confronto"); }else{ xmlHttp.open('GET', "./include/ajax.php?tabella=confronto&codice_annuncio="+codice_annuncio+"&codice_utente="+codice_utente+"&azione=elimina", true); xmlHttp.send(null); $nascondi("noListaConfronto_"+id); $visualizza("listaConfronto_"+id); alert("Auto correttamente ELIMINATA dalla lista confronto"); } } // Funzione visualizzazione immagini scheda auto function anteprimaImg(valore, codice_inserzione, codice_cliente) { $nascondi("anteprimaImg"); $visualizza("elaborazioneAnteprima"); var xmlHttp = getXmlHttpObject(); xmlHttp.open('GET', "./include/ajax.php?tabella=immagini&immagini="+valore+"&codice_inserzione="+codice_inserzione+"&codice_cliente="+codice_cliente, 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; $update("anteprimaImg", valore); $visualizza("anteprimaImg"); $nascondi("elaborazioneAnteprima"); } } } } } // Motore di ricerca annunci dei concessionari function motoreRicercaConcessionario(codice_cliente, pagina) { $nascondi("risultatiRicerca"); $visualizza("elaborazione"); 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("#;#"); $update("risultatiRicerca", contenuti[0]); $update("ordinamentoPagina", contenuti[1]); $nascondi("elaborazione"); $visualizza("risultatiRicerca"); } } } } // Motore di ricerca cambio pagina/ordinamento annunci in ajax function motoreRicercaInterno(url, order_by, order_direction, annunci_pagina, pagina) { $nascondi("risultatiRicerca"); $visualizza("elaborazione"); var xmlHttp = getXmlHttpObject(); xmlHttp.open("GET", "./include/ajax.php?tabella=ricerca&"+url+"&order_by="+order_by+"&order_direction="+order_direction+"&annunci_pagina="+annunci_pagina+"&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("#;#"); $update("risultatiRicerca", contenuti[0]); $update("quanti_annunci", contenuti[1]); $update("ordinamentoPagina02", contenuti[2]); $update("ordinamentoPagina", contenuti[2]); $nascondi("elaborazione"); $visualizza("risultatiRicerca"); } } } } // Motore di ricerca annunci in ajax function motoreRicerca(url, pagina) { $nascondi("risultatiRicerca"); $visualizza("elaborazione"); var xmlHttp = getXmlHttpObject(); xmlHttp.open("GET", "./include/ajax.php?tabella=ricerca&"+url+"&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("#;#"); $update("risultatiRicerca", contenuti[0]); $update("quanti_annunci", contenuti[1]); $update("ordinamentoPagina02", contenuti[2]); $update("ordinamentoPagina", contenuti[2]); $nascondi("elaborazione"); $visualizza("risultatiRicerca"); } } } } // Funzione per la login function verificaLogin(punti) { procedi=true; 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(); alert("Inserire l'username!"); }else if(document.getElementById('login').password.value==""){ procedi=false; document.getElementById('login').password.focus(); 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")) { if(resp=="clienti") { location.href=punti+'area_clienti/index.php'; }else if(resp=="privati"){ 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"); } } } } } // Funzione per la visualizzazione dei banner function banner(banner, tabella, keyword) { // creo gli id da aggiornare nei div var id_aggiornare; id_aggiornare=banner.replace("sponsor_", ""); // visualizzo la scritta loading...e nascondi lo spazio del banner $visualizza('elaborazione_'+id_aggiornare); $nascondi(id_aggiornare); var xmlHttp = getXmlHttpObject(); xmlHttp.open("GET", "./include/ajax.php?tabella="+tabella+"&banner="+banner+"&"+keyword, true); xmlHttp.onreadystatechange = stateChanged; xmlHttp.send(null); function stateChanged() { if(xmlHttp.readyState == 4) { //Stato OK if (xmlHttp.status == 200) { var resp = xmlHttp.responseText; var parametri=resp.split("#;#"); if(parametri[0]!="") { contenuto=""; $nascondi('elaborazione_'+id_aggiornare); $visualizza(id_aggiornare); $update(id_aggiornare, contenuto); }else{ $nascondi('elaborazione_'+id_aggiornare); $nascondi(id_aggiornare); } } } } } // Funzione per generare il select modelli function loadList(tabella, marca_selezionata, modello_selezionato, tabindex, stile_select, div) { var xmlHttp = getXmlHttpObject(); xmlHttp.open("GET", "./include/ajax.php?tabella="+tabella+"&marca="+marca_selezionata+"&modello="+modello_selezionato+"&tabindex="+tabindex+"&style="+stile_select, 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; $update(quale_div, resp); } } } } // Funzione per generare la vetrina di autoaffari function elencoVetrina(start) { $nascondi("elenco_vetrina"); $visualizza("elaborazione"); var xmlHttp = getXmlHttpObject(); xmlHttp.open("GET", "./include/ajax.php?tabella=vetrina&start="+start, true); xmlHttp.onreadystatechange = stateChanged; xmlHttp.send(null); function stateChanged() { if(xmlHttp.readyState == 4) { //Stato OK if (xmlHttp.status == 200) { var resp = xmlHttp.responseText; $update('elenco_vetrina', resp); $nascondi("elaborazione"); $visualizza("elenco_vetrina"); } } } } // Funzione per contare il click sui link sponsorizzati function updateClick(id, tabella) { var xmlHttp = getXmlHttpObject(); xmlHttp.open("GET", "./include/ajax.php?tabella="+tabella+"&id="+id, true); xmlHttp.send(null); } // Funzione per inserire il sito tra i preferiti function addbookmark() { var bookmarkurl="http://www.autoaffari.com"; var bookmarktitle="Autoaffari.com - Migliaia di annunci di vendita auto usate, nuove, km0 ed aziendali."; window.external.AddFavorite(bookmarkurl,bookmarktitle); } // Funzione per verificare la compilazione di almeno un campo di ricerca function verificaCampi() { procedi=true; if((document.getElementById('ricerca').marca.value=="")&&(document.getElementById('ricerca').tipo_auto.value=="")&&(document.getElementById('ricerca').anno_da.value=="")&&(document.getElementById('ricerca').anno_a.value=="")&&(document.getElementById('ricerca').alimentazione.value=="")&&(document.getElementById('ricerca').prezzo_da.value=="")&&(document.getElementById('ricerca').prezzo_a.value=="")&&(document.getElementById('ricerca').regione.value=="")) { procedi=false; alert("Inserire almeno un parametro per la ricerca!"); } if(procedi==true) { document.getElementById('ricerca').submit(); } } // 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; } // Script per avere il banner laterale che segue lo scroll della pagina window.onerror = null; var topMargin = 10; var slideTime = 1200; var ns6 = (!document.all && document.getElementById); var ie4 = (document.all); var ns4 = (document.layers); function layerObject(id,left) { if(ns6) { this.obj = document.getElementById(id).style; this.obj.left = left; return this.obj; }else if(ie4){ this.obj = document.all[id].style; this.obj.left = left; return this.obj; }else if(ns4){ this.obj = document.layers[id]; this.obj.left = left; return this.obj; } } function layerSetup() { floatLyr = new layerObject('floatLayer', 780); window.setInterval("main()", 10) } function floatObject() { if(ns4 || ns6) { findHt = window.innerHeight; }else if(ie4){ findHt = document.body.clientHeight; } } function main() { if(ns4) { this.currentY = document.layers["floatLayer"].top; this.scrollTop = window.pageYOffset; mainTrigger(); }else if(ns6){ this.currentY = parseInt(document.getElementById('floatLayer').style.top); this.scrollTop = scrollY; mainTrigger(); }else if(ie4){ this.currentY = floatLayer.style.pixelTop; this.scrollTop = document.body.scrollTop; mainTrigger(); } } function mainTrigger() { var newTargetY = this.scrollTop + this.topMargin; if ( this.currentY != newTargetY ) { if ( newTargetY != this.targetY ) { this.targetY = newTargetY; floatStart(); } animator(); } } function floatStart() { var now = new Date(); this.A = this.targetY - this.currentY; this.B = Math.PI / ( 2 * this.slideTime ); this.C = now.getTime(); if (Math.abs(this.A) > this.findHt) { this.D = this.A > 0 ? this.targetY - this.findHt : this.targetY + this.findHt; this.A = this.A > 0 ? this.findHt : -this.findHt; }else{ this.D = this.currentY; } } function animator() { var now = new Date(); var newY = this.A * Math.sin( this.B * ( now.getTime() - this.C ) ) + this.D; newY = Math.round(newY); if (( this.A > 0 && newY > this.currentY ) || ( this.A < 0 && newY < this.currentY )) { if ( ie4 )document.all.floatLayer.style.pixelTop = newY; if ( ns4 )document.layers["floatLayer"].top = newY; if ( ns6 )document.getElementById('floatLayer').style.top = newY + "px"; } } function start() { if(ns6||ns4) { pageWidth = innerWidth; pageHeight = innerHeight; layerSetup(); floatObject(); }else if(ie4){ pageWidth = document.body.clientWidth; pageHeight = document.body.clientHeight; layerSetup(); floatObject(); } } function visualizza() { $nascondi('schedaAuto'); $visualizza('immaginiAuto'); }