function pageSize() { var size = { height : 0, width : 0 } ; if (document.documentElement && document.documentElement.scrollHeight) { size.width = document.documentElement.scrollWidth; size.height = document.documentElement.scrollHeight; } else if (document.body) // other Explorers { size.width = document.body.scrollWidth; size.height = document.body.scrollHeight; } return size; } function jumpScrollEndOfPage() { size = pageSize(); window.scroll(0,size.height); // horizontal and vertical scroll targets } function caricaTerritorio() { var oTextbox = new AutoSuggestControl(document.getElementById("territorio"), new StateSuggestions()); } function trim2(stringa) { while (stringa.substring(0,1) == ' ') { stringa = stringa.substring(1, stringa.length); } while (stringa.substring(stringa.length-1, stringa.length) == ' ') { stringa = stringa.substring(0,stringa.length-1); } return stringa; } function controlloTipologiaCap(){ var attivazioneCaptcha="NO"; if(document.form1.attivazioneCaptcha != null) attivazioneCaptcha = document.form1.attivazioneCaptcha.value; if('SI' == attivazioneCaptcha){ var base = document.form1.baseForm.value; if(document.getElementById("controllo")!= null) document.getElementById("controllo").style.display="none"; if(document.getElementById("controlloMappe")!= null) document.getElementById("controlloMappe").style.display="none"; // ricerca per cap if( (trim(document.getElementById("territorio").value)).length == 5) { if(!isNaN(document.getElementById("territorio").value)){ rigeneraCaptcha(base); document.getElementById("cerca3").style.display="none"; document.getElementById("cerca3captcha").style.display="block"; }else{ document.getElementById("cerca3captcha").style.display="none"; document.getElementById("cerca3").style.display="block"; } }else{ document.getElementById("cerca3captcha").style.display="none"; document.getElementById("cerca3").style.display="block"; } } } function paginazione(attivazioneCaptcha,tipo,occorrenzeLibere,inizio,massimo) { if( "SI" == attivazioneCaptcha){ // se chiamo la pagina numero (occorrenzeLibere/10) o se pagino la ricerca per cap, mostro il captcha document.getElementById("cerca3captcha").style.display="none"; document.getElementById("ricerca").value=""; document.getElementById("territorio").value=""; var base = document.ricaricaPagina.base.value; rigeneraCaptcha(base); if(tipo.toLowerCase() == "cap"){ document.getElementById("controllo").style.display="block"; document.ricaricaPagina.start.value= inizio; document.ricaricaPagina.max.value= massimo; jumpScrollEndOfPage(); }else{ if(inizio >=occorrenzeLibere){ document.getElementById("controllo").style.display="block"; document.ricaricaPagina.start.value= inizio; document.ricaricaPagina.max.value= massimo; }else{ document.getElementById("controllo").style.display="none"; document.ricaricaPagina.start.value= inizio; document.ricaricaPagina.max.value= massimo; document.ricaricaPagina.submit(); } } }else{ document.getElementById("cerca3captcha").style.display="none"; document.getElementById("ricerca").value=""; document.getElementById("territorio").value=""; document.getElementById("controllo").style.display="none"; document.ricaricaPagina.start.value= inizio; document.ricaricaPagina.max.value= massimo; document.ricaricaPagina.submit(); } } function VerificaCaptchaPaginazione(){ var fieldcaptcha = document.form_controllo.fieldcaptcha.value; var cod = trim2(fieldcaptcha); ElaboraDato.checkCaptcha(cod,controllaCaptcha ); } function controllaCaptcha(data){ if(data == "errore"){ jumpScrollEndOfPage(); alert("Codice di sicurezza errato."); var base = document.ricaricaPagina.base.value; rigeneraCaptchaDaPaginazione(base); document.form_controllo.fieldcaptcha.value=""; document.form_controllo.fieldcaptcha.style.backgroundColor="#FFFFCC"; }else{ document.ricaricaPagina.textfieldcaptcha.value=document.form_controllo.fieldcaptcha.value; document.ricaricaPagina.submit(); } } function VerificaCaptchaPaginazioneMappe(){ var fieldcaptcha = document.form_controllo.fieldcaptcha.value; var cod = trim2(fieldcaptcha); ElaboraDato.checkCaptcha(cod, controllaCaptchaMappe ); } function controllaCaptchaMappe(data){ if(data == "errore"){ jumpScrollEndOfPage(); alert("Codice di sicurezza errato."); var base = document.refreshPageMultiMap.base.value; rigeneraCaptchaDaPaginazione(base); document.form_controllo.fieldcaptcha.value =""; document.form_controllo.fieldcaptcha.style.backgroundColor="#FFFFCC"; }else{ document.refreshPageMultiMap.textfieldcaptcha.value=document.form_controllo.fieldcaptcha.value; document.refreshPageMultiMap.submit(); } } function VerificaCaptchaRicerca(codiceCaptcha){ cod=trim2(codiceCaptcha); ElaboraDato.checkCaptcha(cod,controllaCampiConCaptcha ); } function controllaCampi(){ pageTrack(); document.form1.ricerca.style.backgroundColor="#FFFFFF"; document.form1.territorio.style.backgroundColor="#FFFFFF"; error =""; if(document.form1.ricerca.value == '' || (trim(document.form1.ricerca.value)).length <= 2){ error = error + " - Specifica la ricerca che desideri effettuare (almeno 3 caratteri)\n"; document.form1.ricerca.style.backgroundColor="#FFFFCC"; } if( (trim(document.form1.territorio.value)).length == 1){ error = error + " - Specifica una Regione, una Provincia, un Comune o un CAP valido\n"; document.form1.territorio.style.backgroundColor="#FFFFCC"; } if((document.form1.select1SEL.value == ": ") && (document.getElementById("tipoForm").value=="nazione") ){ error = error + " - Seleziona la nazione \n"; document.form1.select1SEL.style.backgroundColor="#FFFFCC"; } if(error != ""){ alert(error); }else{ document.form1.submit(); } } function controllaCampiConCaptcha(data){ pageTrack(); var from = document.getElementById("from").value; document.form1.ricerca.style.backgroundColor="#FFFFFF"; document.form1.territorio.style.backgroundColor="#FFFFFF"; document.form1.textfieldcaptcha.style.backgroundColor="#FFFFFF"; var base = document.form1.baseForm.value; error =""; if(document.form1.ricerca.value == '' || (trim(document.form1.ricerca.value)).length <= 2){ error = error + " - Specifica la ricerca che desideri effettuare (almeno 3 caratteri)\n"; document.form1.ricerca.style.backgroundColor="#FFFFCC"; } if( (trim(document.form1.territorio.value)).length == 1){ error = error + " - Specifica una Regione, una Provincia, un Comune o un CAP valido\n"; document.form1.territorio.style.backgroundColor="#FFFFCC"; } if(data == 'errore'){ error = error + " - Codice di sicurezza errato\n"; document.form1.textfieldcaptcha.style.backgroundColor="#FFFFCC"; document.form1.textfieldcaptcha.value=""; } if(error != ""){ alert(error); if(from == '') rigeneraCaptcha(base); else rigeneraCaptchaDaLista(base); }else{ document.form1.submit(); } } function controllaFormContatti(){ document.getElementById('problema').style.backgroundColor="#FFFFFF"; document.getElementById('argomento').style.backgroundColor="#FFFFFF"; document.getElementById('messaggio').style.backgroundColor="#FFFFFF"; document.getElementById('email').style.backgroundColor="#FFFFFF"; document.getElementById('nome').style.backgroundColor="#FFFFFF"; document.getElementById('cognome').style.backgroundColor="#FFFFFF"; //document.getElementById('telefono').style.backgroundColor="#FFFFFF"; var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/; errore =""; if(document.getElementById("problema").value == ""){ errore = errore + " - Specificare la tipologia del problema\n"; document.getElementById('problema').style.backgroundColor="#FFFFCC"; } if(document.getElementById("argomento").value == "" && document.getElementById("fields_comunica").style.display == 'block'){ errore = errore + " - Please choose argoment type\n"; document.getElementById('argomento').style.backgroundColor="#FFFFCC"; } if(document.getElementById("messaggio").value == ""){ errore = errore + " - Scrivi un breve messaggio\n"; document.getElementById('messaggio').style.backgroundColor="#FFFFCC"; } if(document.getElementById("email").value == ""){ errore = errore + " - Specificare indirizzo email\n"; document.getElementById('email').style.backgroundColor="#FFFFCC"; } if(document.getElementById("nome").value == ""){ errore = errore + " - Specificare il tuo nome\n"; document.getElementById('nome').style.backgroundColor="#FFFFCC"; } if(document.getElementById("cognome").value == ""){ errore = errore + " - Specificare il tuo cognome\n"; document.getElementById('cognome').style.backgroundColor="#FFFFCC"; } if(document.getElementById("email").value != "" && filter.test(document.getElementById("email").value) == false){ errore = errore + " - Email non valida\n"; document.getElementById('email').style.backgroundColor="#FFFFCC"; } /*if(document.getElementById("telefono").value != "" && isNaN(document.getElementById("telefono").value)){ errore = errore + " - Numero di telefono non valido\n"; document.getElementById('telefono').style.backgroundColor="#FFFFCC"; }*/ if(errore != ""){ alert(errore); return false; } return true; } function controllaFormContattiEL(){ document.getElementById('messaggio').style.backgroundColor="#FFFFFF"; document.getElementById('email').style.backgroundColor="#FFFFFF"; document.getElementById('nome').style.backgroundColor="#FFFFFF"; document.getElementById('cognome').style.backgroundColor="#FFFFFF"; var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/; errore =""; if(document.getElementById("nome").value == ""){ errore = errore + " - Specificare il tuo nome\n"; document.getElementById('nome').style.backgroundColor="#FFFFCC"; } if(document.getElementById("cognome").value == ""){ errore = errore + " - Specificare il tuo cognome\n"; document.getElementById('cognome').style.backgroundColor="#FFFFCC"; } if(document.getElementById("email").value == ""){ errore = errore + " - Specificare indirizzo email\n"; document.getElementById('email').style.backgroundColor="#FFFFCC"; } if(document.getElementById("email").value != "" && filter.test(document.getElementById("email").value) == false){ errore = errore + " - Email non valida\n"; document.getElementById('email').style.backgroundColor="#FFFFCC"; } if(document.getElementById("telefono").value != "" && isNaN(document.getElementById("telefono").value)){ errore = errore + " - Numero di telefono non valido\n"; document.getElementById('telefono').style.backgroundColor="#FFFFCC"; } if(document.getElementById("fax").value != "" && isNaN(document.getElementById("fax").value)){ errore = errore + " - Numero di fax non valido\n"; document.getElementById('fax').style.backgroundColor="#FFFFCC"; } if(document.getElementById("messaggio").value == ""){ errore = errore + " - Scrivi un breve messaggio\n"; document.getElementById('messaggio').style.backgroundColor="#FFFFCC"; } if(errore != ""){ alert(errore); return false; } return true; } function go2() { if(document.forms[0].oldUser != null && document.forms[0].oldUser.value != "") { if(document.forms[0].user.value != document.forms[0].oldUser.value) { if(document.forms[0].force != null) document.forms[0].force.value = "no"; } } } function go(){ go2(); document.forms[0].action="<%=urlTelemaco%>"; document.forms[0].submit; return true; } function carica(){ if(document.forms[0].oldUser != null && document.forms[0].oldUser.value != "") document.forms[0].user.value = document.forms[0].oldUser.value; } function goSmart(){ document.forms[0].user.value=""; document.forms[0].pass.value=""; document.forms[0].action="<%=urlTelemacoSM%>"; document.forms[0].method="GET"; document.forms[0].submit; } function goPageSmart(url) { location.href=url +"/asia/pageSmart.jsp?appCallFrom=comc"; } function trim(value) { return value.replace(/^\s+/,"").replace(/\s+$/,""); } function tolgoSpazi(stringa){ var splitted = stringa.split(" "); var stringatmp =""; for (i in splitted) { stringatmp = stringatmp + splitted[i]; } return stringatmp; } function rigeneraCaptcha(base){ if(document.getElementById("frameCaptcha") != null){ if(document.getElementById("numero").value ==""){ document.getElementById("numero").value="2"; document.getElementById("frameCaptcha").src=base + "/ricerca/codiceCaptcha.jsp"; } else{ document.getElementById("numero").value=""; document.getElementById("frameCaptcha").src=base + "/ricerca/codiceCaptcha2.jsp"; } } if(document.getElementById("frameCaptcha2") != null){ if(document.getElementById("numero2").value ==""){ document.getElementById("numero2").value="2"; document.getElementById("frameCaptcha2").src=base + "/ricerca/codiceCaptcha2.jsp"; } else{ document.getElementById("numero2").value=""; document.getElementById("frameCaptcha2").src=base + "/ricerca/codiceCaptcha.jsp"; } } } function rigeneraCaptchaDaLista(base){ if(document.getElementById("controllo")!= null) document.getElementById("controllo").style.display="none"; if(document.getElementById("controlloMappe")!= null) document.getElementById("controlloMappe").style.display="none"; rigeneraCaptcha(base); } function rigeneraCaptchaDaPaginazione(base){ document.getElementById("cerca3captcha").style.display = "none"; rigeneraCaptcha(base); } function mostraCaptcha(){ document.getElementById("cerca3").style.display="none"; document.getElementById("cerca3captcha").style.display="block"; } function nascondiCaptcha(){ document.getElementById("cerca3").style.display="block"; document.getElementById("cerca3captcha").style.display="none"; } function submitenter(myfield,e) {//fix enter key on submit if (document.getElementById("cerca3captcha") == null || document.getElementById("cerca3captcha").style.display == "none") { var keycode; if (window.event) keycode = window.event.keyCode; else if (e) keycode = e.which; else return true; if (keycode == 13) {controllaCampi(); //myfield.form.submit(); return false; } else return true; } else { var keycode2; if (window.event) keycode2 = window.event.keyCode; else if (e) keycode2 = e.which; else return true; if (keycode2 == 13) {VerificaCaptchaRicerca(document.form1.textfieldcaptcha.value); return false; } else return true; } }