function restrictinput(maxlength,e,placeholder) { if (window.event&&event.srcElement.value.length>=maxlength) return false else if (e.target&&e.target==eval(placeholder)&&e.target.value.length>=maxlength) { var pressedkey=/[a-zA-Z0-9\.\,\/]/ //detect alphanumeric keys if (pressedkey.test(String.fromCharCode(e.which))) e.stopPropagation() } } function ContoMaiuscole(testo,etichetta_campo) { var contatore=0; var percentuale=parseInt(testo.length*0.1); for (var i = 0 ; ipercentuale) { alert ("ATTENZIONE:Inserire il campo "+etichetta_campo+" rigorosamente in minuscolo."); return false; } else { var contatore1=0; for (var i = 0 ; i2) { alert ("ATTENZIONE:Inserire il campo "+etichetta_campo+" rigorosamente in minuscolo."); return false; } } return true; } } function sistema_maiuscole(testo) { var xmlHttp = getXmlHttpObject(); xmlHttp.open('GET', 'include/ajax.php?edit=sistema_maiuscole&testo='+testo.value, 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) { testo.value=resp; } } else { alert(xmlHttp.responseText); } } } } function displaylimit(thename, theid, thelimit) { var theform=theid!=""? document.getElementById(theid) : thename var numero_caratteri; //alert(eval(thename).value.length); if(eval(thename).value.length==0) { numero_caratteri=thelimit; } else { numero_caratteri=thelimit-(eval(thename).value.length); } var limit_text='Hai ancora '+numero_caratteri+' caratteri disponibili' if (document.all||ns6) document.write(limit_text) if (document.all) { eval(theform).onkeypress=function() { return restrictinput(thelimit,event,theform) } eval(theform).onkeyup=function() { countlimit(thelimit,event,theform) } } else if (ns6) { document.body.addEventListener('keypress', function(event) { restrictinput(thelimit,event,theform) }, true); document.body.addEventListener('keyup', function(event) { countlimit(thelimit,event,theform) }, true); } } function countlimit(maxlength,e,placeholder) { var theform=eval(placeholder) var lengthleft=maxlength-theform.value.length var placeholderobj=document.all? document.all[placeholder] : document.getElementById(placeholder) if (window.event||e.target&&e.target==eval(placeholder)) { if(lengthleft<0) { theform.value=theform.value.substring(0,maxlength); } placeholderobj.innerHTML=lengthleft if (lengthleft<0) { alert ("ATTENZIONE:E' stato raggiunto il massimo dei caratteri consentiti."); } } } // Verifico che sia compilato almeno un campo per la ricerca immobile function verificaRicerca(riviste) { // Riviste indica se l'utente ha o meno la pubblicazione // In base a questo parametro gestisco la verifica if(riviste==0) { if((document.ricerca.codice_inserzione.value=="")&&(document.ricerca.rif_agenzia.value=="")&&(document.ricerca.tipo_immobile.value=="")&&(document.ricerca.provincia.value=="")&&(document.ricerca.citta.value=="")) { alert("Selezionare almeno un parametro per la ricerca"); }else{ document.ricerca.submit(); } }else{ if((document.ricerca.codice_inserzione.value=="")&&(document.ricerca.rif_agenzia.value=="")&&(document.ricerca.tipo_immobile.value=="")&&(document.ricerca.provincia.value=="")&&(document.ricerca.citta.value=="")&&(document.ricerca.pubblicato_su.value=="")) { alert("Selezionare almeno un parametro per la ricerca"); }else{ document.ricerca.submit(); } } } // Verifico la correttezza dei dati inseriti. function verificaAnnuncio() { procedi=true; document.formAnnuncio.provincia.className="evidenza02"; document.formAnnuncio.citta.className="evidenza02"; document.formAnnuncio.tipo_immobile.className="evidenza02"; document.formAnnuncio.prezzo.className="evidenza02"; if(document.formAnnuncio.provincia.value=="") { procedi=false; alert("Selezionare la provincia"); document.formAnnuncio.provincia.className="evidenza"; document.formAnnuncio.provincia.focus(); }else if(document.formAnnuncio.citta.value==""){ procedi=false; alert("Selezionare il comune"); document.formAnnuncio.citta.className="evidenza"; document.formAnnuncio.citta.focus(); /*}else if(document.formAnnuncio.prezzo.value==""){ procedi=false; alert("Inserire il prezzo"); document.formAnnuncio.prezzo.className="evidenza"; document.formAnnuncio.prezzo.focus(); */ }else if(document.formAnnuncio.tipo_immobile.value==""){ procedi=false; alert("Selezionare la tipologia"); document.formAnnuncio.tipo_immobile.className="evidenza"; document.formAnnuncio.tipo_immobile.focus(); } if(procedi==true) { document.formAnnuncio.submit(); } } // Visualizza la tabella con gli optional function optional() { if(document.formAnnuncio.optional_valore.value==0){ $visualizza("div_optional"); $update("optional_valore", 1, true); }else{ $nascondi("div_optional"); $update("optional_valore", 0, true); } } function select_tipologie(tipo_proposta, tipologia_immobile, tabindex) { var xmlHttp = getXmlHttpObject(); xmlHttp.open('GET', './include/ajax.php?edit=select_tipologia&tipo_proposta='+tipo_proposta+'&tipologia='+tipologia_immobile+'&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; // Creo il div con dentro il select della tipologia var option = document.createElement("div"); option.value = resp; $update("div_select", option.value); } } } } function select_order_direction(order_by,order_direction) { var xmlHttp = getXmlHttpObject(); xmlHttp.open('GET', 'include/ajax.php?edit=select_order_direction&order_by='+order_by+'&order_direction='+order_direction, true); xmlHttp.onreadystatechange = stateChanged; xmlHttp.send(null); function stateChanged() { if(xmlHttp.readyState == 4) { //Stato OK if (xmlHttp.status == 200) { var resp = xmlHttp.responseText; // Creo il div con dentro il select dell'order_direction if(resp) { var option = document.createElement("div"); option.value = resp; $update("div_select_order_direction", option.value); } } else { alert(xmlHttp.responseText); } } } } // Funzione per la cancellazione delle foto function editPics(codice_utente, codice_inserzione, edit) { var a=confirm("Cancellare la foto?"); if(a) { var xmlHttp = getXmlHttpObject(); xmlHttp.open('GET', './include/ajax.php?action=delete_pics&codice_utente='+codice_utente+'&codice_inserzione='+codice_inserzione+'&edit='+edit, true); xmlHttp.send(null); $nascondi('immagine_foto_'+edit); $nascondi('bottone_foto_'+edit); $visualizza('cancellata_'+edit); } } // Visualizza il form di login nella pagina login.php function visualizza_form() { $visualizza('visualizza_form_login'); } // ACCESSO AREA RISERVATA // Funzione per la verifica della login richiamata da verifica_login() function avvia_login(usr, password) { var xmlHttp = getXmlHttpObject(); password=password.replace("+", "XXXX"); xmlHttp.open('GET', './include/ajax.php?tabella=utenti&username='+usr+'&password='+password, true); xmlHttp.onreadystatechange = stateChanged; xmlHttp.send(null); function stateChanged() { if(xmlHttp.readyState == 4) { //Stato OK if (xmlHttp.status == 200) { var res = xmlHttp.responseText; if(res) { // se feedback = 0 login + sessione + redirect var feedback=res; if(feedback==0) { location.href = "../area_clienti/index.php"; }else if(feedback==1){ // feedback = 1 - Dati errati alert("ATTENZIONE!! Verificare i dati inseriti"); }else if(feedback==2){ // feedback = 2 - Account scaduto alert("ATTENZIONE! Account scaduto. Contattare l'assistenza"); }else{ alert("ATTENZIONE! Account non attivo. Contattare l'assistenza"); } } } } } } function verifica_login() { var procedi=true; document.formLogin.username.className="invia"; document.formLogin.pwd.className="invia"; var usr=document.formLogin.username.value; var password=document.formLogin.pwd.value; if(document.formLogin.username.value=="") { procedi=false; document.formLogin.username.focus(); document.formLogin.username.className="inviaErrore"; alert("ATTENZIONE! Inserire l'username"); }else if(document.formLogin.pwd.value==""){ procedi=false; document.formLogin.pwd.focus(); document.formLogin.pwd.className="inviaErrore"; alert("ATTENZIONE! Inserire la password"); } if(procedi==true) { avvia_login(usr, password); } } // Controllo campi prima di invio e-mail ad assistenza function richiesta_assistenza() { procedi=true; document.assistenza.oggetto.className="evidenza02"; document.assistenza.messaggio.style.background="#ffffff"; if(document.assistenza.oggetto.value=="") { document.assistenza.oggetto.focus(); document.assistenza.oggetto.className="evidenza"; alert("Inserire l'oggetto del messaggio"); procedi=false; }else if(document.assistenza.messaggio.value==""){ document.assistenza.messaggio.focus(); document.assistenza.messaggio.style.background="#caf0ff"; alert("Inserire il testo del messaggio"); procedi=false; } if(procedi==true) { document.assistenza.submit(); } } // Verifica la correttezza dei campi impostati nel profilo prima di salvarli function verificaProfilo() { var procedi; procedi=true; // Setto il valore di default dalle classe degli input document.formProfilo.nome.className="evidenza02"; document.formProfilo.via.className="evidenza02"; document.formProfilo.cap.className="evidenza02"; document.formProfilo.tel.className="evidenza02"; document.formProfilo.email.className="evidenza02"; document.formProfilo.pwd.className="evidenza02"; document.formProfilo.provincia.className="evidenza02"; document.formProfilo.citta.className="evidenza02"; // Verifico la corretta compilazione dei campi. if(document.formProfilo.InserzionistaPrivato.value==0) { if(document.formProfilo.FirmaSms.value.length>25) { alert("ATTENZIONE : il campo FIRMA PER RIVISTA deve essere lungo al massimo 25 caratteri."); procedi=false; }else if(document.formProfilo.tel.value.length>27){ alert("ATTENZIONE : il campo TELEFONO deve essere lungo al massimo 27 caratteri."); procedi=false; } } if(document.formProfilo.nome.value==""){ document.formProfilo.nome.focus(); document.formProfilo.nome.className="evidenza"; alert("Inserire il nome!"); procedi=false; } else if(document.formProfilo.via.value==""){ document.formProfilo.via.focus(); document.formProfilo.via.className="evidenza"; alert("Inserire la via!"); procedi=false; } else if(document.formProfilo.cap.value==""){ document.formProfilo.cap.focus(); document.formProfilo.cap.className="evidenza"; alert("Inserire il CAP!"); procedi=false; } else if(document.formProfilo.tel.value==""){ document.formProfilo.tel.focus(); document.formProfilo.tel.className="evidenza"; alert("INserire il numero di telefono!"); procedi=false; } else if(document.formProfilo.email.value==""){ document.formProfilo.email.focus(); document.formProfilo.email.className="evidenza"; alert("Inserire l'e-mail!"); procedi=false; } else if(document.formProfilo.pwd.value==""){ document.formProfilo.pwd.focus(); document.formProfilo.pwd.className="evidenza"; alert("Inserire la password"); procedi=false; } else if(document.formProfilo.provincia.value==""){ document.formProfilo.provincia.focus(); document.formProfilo.provincia.className="evidenza"; alert("Inserire la provincia"); procedi=false; }else if(document.formProfilo.citta.value==""){ document.formProfilo.citta.focus(); document.formProfilo.citta.className="evidenza"; alert("Inserire la città"); procedi=false; } // Se tutti i campi son compilati correttamente invio il modulo if(procedi==true) { document.formProfilo.submit(); } } // Carica provincia e comuni function loadList(tabella, select_1_sel, select_2_sel, tabindex) { var xmlHttp = getXmlHttpObject(); //alert('./include/ajax.php?tabella='+tabella+'&select_1='+select_1_sel+'&select_2='+select_2_sel+"&tabindex="+tabindex); xmlHttp.open('GET', './include/ajax.php?tabella='+tabella+'&select_1='+select_1_sel+'&select_2='+select_2_sel+"&tabindex="+tabindex, true); xmlHttp.onreadystatechange = stateChanged; xmlHttp.send(null); function stateChanged() { if(xmlHttp.readyState == 4) { //Stato OK if (xmlHttp.status == 200) { var res = xmlHttp.responseText; // Creo il div con l'elenco delle province var valore=res; valore=valore.replace("AX", "à"); valore=valore.replace("EX", "è"); valore=valore.replace("IX", "ì"); valore=valore.replace("OX", "ò"); valore=valore.replace("UX", "ù"); $update("select_comune", valore); } } } } // FUNZIONE PER AJAX IN BASE AL BROWSER 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; } // Apre il popup function open_scroll(url,w,h) { var zoom; if(zoom) { zoom.close(); } zoom=window.open(url,'pop','height='+h+',width='+w+'location=no,resizable=no,scrollbars=no'); } // Questa funzione apre il div che contiene i campi per la galleria fotografica function galleriaFotografica(){ if(document.formAnnuncio.galleria_valore.value==0){ $visualizza("galleria"); document.formAnnuncio.galleria_valore.value=1; }else{ $nascondi("galleria"); document.formAnnuncio.galleria_valore.value=0; } } // Controlla i campi nel profilo Firma Sms function controlla_campi() { } function confermaeliminatutti() { if (confirm("Confermi l'operazione?Verranno eliminati tutti gli annunci.")) { document.elimina_tutti.submit(); }; } function confermadeseleziona(nomeform) { if (confirm("Confermi l'operazione?Verranno deselezionati tutti gli annunci della testata selezionata.")) { eval('document.'+nomeform+'.submit()'); }; } function confermaseleziona(nomeform) { if (confirm("Confermi l'operazione?Verranno pubblicati tutti gli annunci disponibili sulla testata selezionata.")) { eval('document.'+nomeform+'.submit()'); }; } var horizontal_offset="9px" //horizontal offset of hint box from anchor link var vertical_offset="0" //horizontal offset of hint box from anchor link. No need to change. var ie=document.all var ns6=document.getElementById&&!document.all function getposOffset(what, offsettype) { var totaloffset=(offsettype=="left")? what.offsetLeft : what.offsetTop; var parentEl=what.offsetParent; while (parentEl!=null) { totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop; parentEl=parentEl.offsetParent; } return totaloffset; } function iecompattest() { return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body } function clearbrowseredge(obj, whichedge) { var edgeoffset=(whichedge=="rightedge")? parseInt(horizontal_offset)*-1 : parseInt(vertical_offset)*-1 if (whichedge=="rightedge") { var windowedge=ie && !window.opera? iecompattest().scrollLeft+iecompattest().clientWidth-30 : window.pageXOffset+window.innerWidth-40 dropmenuobj.contentmeasure=dropmenuobj.offsetWidth if (windowedge-dropmenuobj.x < dropmenuobj.contentmeasure) edgeoffset=dropmenuobj.contentmeasure+obj.offsetWidth+parseInt(horizontal_offset) } else { var windowedge=ie && !window.opera? iecompattest().scrollTop+iecompattest().clientHeight-15 : window.pageYOffset+window.innerHeight-18 dropmenuobj.contentmeasure=dropmenuobj.offsetHeight if (windowedge-dropmenuobj.y < dropmenuobj.contentmeasure) edgeoffset=dropmenuobj.contentmeasure-obj.offsetHeight } return edgeoffset } function showhint(menucontents, obj, e, tipwidth) { if ((ie||ns6) && document.getElementById("hintbox")) { dropmenuobj=document.getElementById("hintbox") dropmenuobj.innerHTML=menucontents dropmenuobj.style.left=dropmenuobj.style.top=-500 if (tipwidth!="") { dropmenuobj.widthobj=dropmenuobj.style dropmenuobj.widthobj.width=tipwidth } dropmenuobj.x=getposOffset(obj, "left") dropmenuobj.y=getposOffset(obj, "top") dropmenuobj.style.left=dropmenuobj.x-clearbrowseredge(obj, "rightedge")+obj.offsetWidth+"px" dropmenuobj.style.top=dropmenuobj.y-clearbrowseredge(obj, "bottomedge")+"px" dropmenuobj.style.visibility="visible" obj.onmouseout=hidetip } } function hidetip(e) { dropmenuobj.style.visibility="hidden" dropmenuobj.style.left="-500px" } function createhintbox() { var divblock=document.createElement("div") divblock.setAttribute("id", "hintbox") document.body.appendChild(divblock) } if (window.addEventListener) window.addEventListener("load", createhintbox, false) else if (window.attachEvent) window.attachEvent("onload", createhintbox) else if (document.getElementById) window.onload=createhintbox