
var tipo_ordinamento="recenti";var durata_ordinamento="settimana";var event_tipo_ordinamento="recenti";var icona_emoczioni=0;var originalZoom;var originalCenter;var zoomin=15;var zoomout=5;var zoomed=false;var newTempMarker;var id_cat=0;var actualPopupId=0;var geocodeAddress=new Array();function addressType(zindirizzoCompleto,zlat,zlng){this.indirizzoCompleto=zindirizzoCompleto;this.lat=zlat;this.lng=zlng;}
function typeMarker(zlatzlng,zid_contenuto,zhtml,zcat,ztooltip){this.latlng=zlatzlng;this.id_contenuto=zid_contenuto;this.html=zhtml;this.cat=zcat;this.tooltip=ztooltip;}
function LoadNewData(){xajax_loadDinamicMarkers(getNorthEast(),getSouthWest(),tipo_ordinamento,durata_ordinamento,0,0);}
function LoadNewDataHP(){xajax_loadDinamicMarkersHP(getNorthEast(),getSouthWest(),tipo_ordinamento,event_tipo_ordinamento,durata_ordinamento,0,0)}
function vediancheLoadNewData(id_categoria,id_contenuto){if(id_categoria)
id_cat=id_categoria;xajax_vediAnche(getNorthEast(),getSouthWest(),id_cat,id_contenuto,0);}
function cambiaOrdinamentoHPContenuti(tipologia,evento,durata){durata_ordinamento=durata;tipo_ordinamento=tipologia;event_tipo_ordinamento=evento;LoadNewDataHP();}
function cambiaOrdinamento(tipologia,durata){var migliori=document.getElementById("label_migliori");var letti=document.getElementById("label_letti");var commentati=document.getElementById("label_commentati");var recenti=document.getElementById("label_recenti");var passati=document.getElementById("label_passati");var inprogramma=document.getElementById("label_inprogramma");var oggi=document.getElementById("label_oggi");var prossimi=document.getElementById("label_prossimi");document.getElementById("durata_settimana").style.display="";document.getElementById("durata_mese").style.display="";document.getElementById("durata_sempre").style.display="";document.getElementById("durata_id_settimana").style.display="none";document.getElementById("durata_id_mese").style.display="none";document.getElementById("durata_id_sempre").style.display="none";if(commentati){commentati.className="";if(tipologia=="commentati"){document.getElementById('durata_ordinamento').style.display='';commentati.className="bluBold";}}
if(passati){passati.className="";if(tipologia=="passati"){document.getElementById('durata_ordinamento').style.display='none';passati.className="bluBold";}}
if(inprogramma){inprogramma.className="";if(tipologia=="inprogramma"){document.getElementById('durata_ordinamento').style.display='none';inprogramma.className="bluBold";}}
if(oggi){oggi.className="";if(tipologia=="oggi"){document.getElementById('durata_ordinamento').style.display='none';oggi.className="bluBold";}}
if(prossimi){prossimi.className="";if(tipologia=="prossimi"){document.getElementById('durata_ordinamento').style.display='none';prossimi.className="bluBold";}}
if(migliori){migliori.className="";if(tipologia=="migliori"){document.getElementById('durata_ordinamento').style.display='none';migliori.className="bluBold";}}
if(recenti){recenti.className="";if(tipologia=="recenti"){document.getElementById('durata_ordinamento').style.display='none';recenti.className="bluBold";}}
if(letti){letti.className="";if(tipologia=="letti"){document.getElementById('durata_ordinamento').style.display='';letti.className="bluBold";}}
if(durata=="settimana"){document.getElementById("durata_id_settimana").style.display="";document.getElementById("durata_settimana").style.display="none";}
if(durata=="mese"){document.getElementById("durata_id_mese").style.display="";document.getElementById("durata_mese").style.display="none";}
if(durata=="sempre"){document.getElementById("durata_id_sempre").style.display="";document.getElementById("durata_sempre").style.display="none";}
durata_ordinamento=durata;tipo_ordinamento=tipologia;LoadNewData();}
function resetMarkers(){map.clearOverlays();markers=[];markers_id=[];points=[];counter=0;marker_infoDB=[];for(var property in marker_staticinfoDB){if(String(property>>>0)==property&&property>>>0!=0xffffffff){marker_infoDB[property]=marker_staticinfoDB[property].html;createMarker(marker_staticinfoDB[property].latlng,marker_staticinfoDB[property].id_posto,marker_staticinfoDB[property].html,marker_staticinfoDB[property].cat,marker_staticinfoDB[property].tooltip);}}}
function resetContents(){map.clearOverlays();var temp_markers=[];var temp_counter=0;var temp_markers_id=[];var temp_points=[];for(i=0;i<markers_id.length;i++){if(isNaN(markers_id[i])==true){temp_points[temp_counter]=points[i];temp_markers[temp_counter]=markers[i];temp_markers_id[temp_counter]=markers_id[i];temp_counter++;}}
markers=temp_markers;markers_id=temp_markers_id;points=temp_points;counter=temp_counter;}
function resetEmoczioni(){map.clearOverlays();var temp_markers=[];var temp_counter=0;var temp_markers_id=[];var temp_points=[];for(i=0;i<markers_id.length;i++){if(isNaN(markers_id[i])==false){temp_points[temp_counter]=points[i];temp_markers[temp_counter]=markers[i];temp_markers_id[temp_counter]=markers_id[i];temp_counter++;}}
markers=temp_markers;markers_id=temp_markers_id;points=temp_points;counter=temp_counter;}
function orderOfCreation(marker,b){return 1;}
function inverseOrder(marker,b){return-GOverlay.getZIndex(marker.getPoint().lat());}
function redrawMarkers(direction){if(typeof direction=='undefined')direction=1;if(direction==1){for(var i=markers.length-1;i>=0;i--){map.addOverlay(markers[i]);}}
else{for(var i=0;i<markers.length;i++){map.addOverlay(markers[i]);}}
drawRoute();}
function drawRoute(){}
var lastZoomedOn=-1;function zoomOnMarker(idx){for(i=0;i<markers_id.length;i++){if(markers_id[i]==idx){idx=i;marker=markers[i];}}
if(newTempMarker){map.removeOverlay(newTempMarker);}
closePopup();if(zoomed==false||(lastZoomedOn!=-1&&lastZoomedOn!=idx)){if(lastZoomedOn==-1){originalZoom=map.getZoom();originalCenter=map.getCenter();}
map.setCenter(points[idx],zoomin,map.getCurrentMapType());zoomed=true;lastZoomedOn=idx;}
else{restoreZoom();zoomed=false;lastZoomedOn=-1;}
clearTimeout(datatimeout);}
function zoomOnLatLng(lat,lng){if(zoomed==false){originalZoom=map.getZoom();originalCenter=map.getCenter();map.setCenter(new GLatLng(lat,lng),zoomin,map.getCurrentMapType());zoomed=true;}
else{restoreZoom();zoomed=false;}
clearTimeout(datatimeout);closePopup();}
function restoreZoom(){map.setCenter(originalCenter,originalZoom,map.getCurrentMapType());zoomed=false;clearTimeout(datatimeout);closePopup();}
function makeVisible(element){element.style.visibility='visible';element.style.display='block';}
function makeHidden(element){element.style.visibility='hidden';element.style.display='none';}
function getOffset(element){if(!element||!element.tagName||element.tagName.toLowerCase()=="body")
return{x:0,y:0};parentOffset=getOffset(element.offsetParent);return{x:parentOffset.x+element.offsetLeft,y:parentOffset.y+element.offsetTop};}
function preparePopup(id_posto,categoria,sottocategoria,nome,indirizzo,nrecensioni,nick_recensione,data_recensione,nfoto,nvideo,media_soddisfazione,media_euro,immagine){var html="";html=html+"<div id=\"gmap_popup\">";html=html+"<div id=\"gmap_corpo\">";html=html+"<div id=\"gmap_path\"><a href=\"#\" onclick=\"closePopup();\" style=\"float:right\" class=\"blu\" title=\"chiudi\">[x]</a>"+categoria+" > "+sottocategoria+"</div>";html=html+"<h1><a href=\"http://www.myopencity.it/posto/view/"+id_posto+"\" class=\"bluB\">"+nome+"</a></h1>";html=html+"";html=html+"<div  id=\"gmap_foto\">";if(immagine)
html=html+" <img src=\"http://www.myopencity.it/upload/content/48_"+immagine+"\" width=\"48\" height=\"48\"/><br />";else
html=html+" <img src=\"http://www.myopencity.it/img/icona_generica_48.gif\" width=\"48\" height=\"48\"/><br />";if(nfoto)
html=html+" <img src=\"http://www.myopencity.it/images/ico_morefoto.gif\" />";if(nvideo)
html=html+" <img src=\"http://www.myopencity.it/images/ico_morevideo.gif\" />";html=html+"</div>";html=html+"<p  class=\"minuscolo\">"+indirizzo+"</p>";html=html+"<p><img src=\"http://www.myopencity.it/images/"+media_soddisfazione+"faccie_mini.png\" /></p>";html=html+"<p><img src=\"http://www.myopencity.it/images/"+media_euro+"euro_mini.png\" /></p>";if(nick_recensione){html=html+"<p>"+nrecensioni+" opinioni</p>";html=html+"<p>Ultima opinione <br />";html=html+"  <a href=\"http://www.myopencity.it/profile/"+escape(escape(nick_recensione))+"\" class=\"bluB\">"+nick_recensione+"</a> "+data_recensione+"</p>";}
html=html+"</div>";html=html+"<div id=\"gmap_bottom\"></div>";html=html+"</div>";return html;}
function preparePopupMocpiazza(categoria,titolo,immagine,testo,indirizzo,id_user,username,data_last,id_mocpiazza){var html="";html=html+"<div id=\"gmap_popup_hp\">";html=html+"<div id=\"gmap_corpo\">";html=html+"<div id=\"gmap_path\"><a href=\"#\" onclick=\"closePopup();\" style=\"float:right\" class=\"blu\" title=\"chiudi\">[x]</a>"+categoria+"</div>";html=html+"<h1><a href=\"http://www.myopencity.it/mocpiazza/"+id_mocpiazza+"\" class=\"bluB\">"+titolo+"</a></h1>";html=html+"";html=html+"<div  id=\"gmap_foto\">";if(immagine)
html=html+" <img src=\"http://www.myopencity.it/upload/content/48_"+immagine+"\" width=\"48\" height=\"48\"/><br />";else
html=html+" <img src=\"http://www.myopencity.it/img/icona_generica_48.gif\" width=\"48\" height=\"48\"/><br />";html=html+"</div>";html=html+"<p >&#8220;"+testo+"&#8221;</p>";html=html+"<p  class=\"minuscolo\">"+indirizzo+"</p>";html=html+"<p >inviato da: <a href=\"/profile/"+id_user+"\" class=\"bluB\">"+username+"</a> il "+data_last+"</p>";html=html+"</div>";html=html+"<div id=\"gmap_bottom\"></div>";html=html+"</div>";return html;}
function preparePopupPeople(id_user,foto,username,ponderazione,via,data_last,titolo,id_contenuto,registrato){var html="";html=html+"<div id=\"gmap_popup\">";html=html+"<div id=\"gmap_corpo\">";html=html+"<div id=\"gmap_path\"><a href=\"#\" onclick=\"closePopup();\" style=\"float:right\" class=\"blu\" title=\"chiudi\">[x]</a>&nbsp;</div>";html=html+"<div  id=\"gmap_foto\">";html=html+"<img src=\"http://www.myopencity.it/"+foto+"\" class=\"floatsx\" alt=\"foto\" title=\"foto\" />";html=html+"<p><strong><a href=\"/profile/"+id_user+"\" class=\"bluB\">"+username+"</a></strong></p>";html=html+"<p><b>Dove: </b> <span class=\"minuscolo\">"+via+"</span></p>";if(data_last)
html=html+"<p><b>Ultima opinione: </b> "+data_last+"</p>";html=html+"<p><a href=\"/view/"+id_contenuto+"\">"+titolo+"</a></p>";html=html+"<p><b>Registrato il: </b> "+registrato+"</p><p>";if(user_id!=id_user){html=html+"<a href=\"http://www.myopencity.it/manage/pm/send/"+escape(escape(username))+"\"><img src=\"http://www.myopencity.it/img/invia_messaggio_privato.gif\" class=\"blu\" alt=\"Invia messaggio privato\" /></a>";if(user_id)
html=html+"<a href=\"javascript:void(0);\" onclick=\"javascript:xajax_popupAggiungiAmico("+id_user+")\"><img src=\"http://www.myopencity.it/img/aggiungi_ad_amici.gif\" class=\"blu\" alt=\"Aggiungi ad amici\" /></a>";else
html=html+"<a href=\"/profile/"+id_user+"/login\"><img src=\"http://www.myopencity.it/img/aggiungi_ad_amici.gif\" class=\"blu\" alt=\"Aggiungi ad amici\" /></a>";html=html+"<a href=\"/publish/emoczioniprivate/"+id_user+"\"><img src=\"http://www.myopencity.it/img/invia_emoczione.gif\" class=\"blu\" alt=\"Invia eMOCzione\" /></a>";}
html=html+"</div></div>";html=html+"<div id=\"gmap_bottom\"></div>";html=html+"</div>";return html;}
function preparePopupGroup(id_gruppo,foto,nomegruppo,via,totmembri,categoria,sottocategoria,fondato){var html="";html=html+"<div id=\"gmap_popup_min\">";html=html+"<div id=\"gmap_corpo\">";html=html+"<div id=\"gmap_path\"><a href=\"#\" onclick=\"closePopup();\" style=\"float:right\" class=\"blu\" title=\"chiudi\">[x]</a>"+categoria+" > "+sottocategoria+"</div>";html=html+"<h1><a href=\"http://www.myopencity.it/groupfile/"+id_gruppo+"\" class=\"bluB\">"+nomegruppo+"</a></h1>";html=html+"<div  id=\"gmap_foto\">";if(foto){html=html+"       <img src=\"http://www.myopencity.it/upload/content/48_"+foto+"\" class=\"floatsx\" alt=\"foto\" title=\"foto\" />";}
else{html=html+"       <img src=\"http://www.myopencity.it/img/caricatura_gruppo.gif\" class=\"floatsx\" alt=\"foto\" title=\"foto\" height=\"48px\" width=\"48px\" />";}
html=html+"</div>";html=html+"<p><b>Dove: </b><span class=\"minuscolo\"> "+via+"</span></p>";html=html+"<p><b>Fondato il:</b> "+fondato+"</p>";html=html+"</div>";html=html+"<div id=\"gmap_bottom\"></div>";html=html+"</div>";return html;}
function preparePopupEmoczioni(id_emoczione,id_user,username,indirizzo,icona,testo,data,sesso,filename){var html="";html=html+"<div id=\"gmap_popup_emoc\">";html=html+"<div id=\"emoc_corpo\">";html=html+"<div id=\"emoc_path\"><a href=\"#\" onclick=\"closePopup();\" style=\"float:right\" class=\"blu\" title=\"chiudi\">[x]</a><span  class=\"minuscolo\">"+indirizzo+"</span> </div>";html=html+"<div  id=\"emoc_foto\">";if(filename){html=html+"       <img src=\"http://www.myopencity.it/upload/content/48_"+filename+"\" class=\"floatsx\" alt=\"foto\" title=\"foto\" />";}
else{if(sesso=='m'){html=html+"       <img src=\"http://www.myopencity.it/img/caricatura_uomo.gif\" class=\"floatsx\" alt=\"foto\" title=\"foto\" />";}
else{html=html+"       <img src=\"http://www.myopencity.it/img/caricatura_donna.gif\" class=\"floatsx\" alt=\"foto\" title=\"foto\" />";}}
html=html+"</div>";html=html+"<p>"+testo+"</p>";html=html+"<p>Inviata da <span class=\"bluB\">"+username+"</span> "+data+"</p>";html=html+"</div>";html=html+"<div id=\"emoc_bottom\"></div>";html=html+"</div>";return html;}
function showMapPopup(map,marker,html,id_contenuto,centra){if(zoomed==false){for(i=0;i<markers_id.length;i++){if(markers_id[i]==id_contenuto){marker=markers[i];}}
document.getElementById('servicePopup').innerHTML='';if(centra==true)
map.setCenter(marker.getPoint());var TlcLatLng=map.fromContainerPixelToLatLng(new GPoint(0,0),true);var TlcDivPixel=map.fromLatLngToDivPixel(TlcLatLng);var pointDivPixel=map.fromLatLngToDivPixel(marker.getPoint());var popup=document.getElementById("mapPopup");var mappina=document.getElementById("map");var result=getOffset(mappina);var x=0;var y=0;x=pointDivPixel.x-TlcDivPixel.x;y=pointDivPixel.y-TlcDivPixel.y;x+=result.x-140;y+=result.y-215;popup.style.left=x+'px';popup.style.top=y+'px';if(marker.getIcon().image){var iconTemp=marker.getIcon().image;var iconNumber=iconTemp.substr(iconTemp.lastIndexOf('/')+1);}
else{var iconNumber=marker.getIcon();}
iconNumber=iconNumber.substr(0,iconNumber.indexOf('.'));iconNumber=parseInt(iconNumber)
if(isNaN(iconNumber)==false){if(iconNumber<=16)
iconNumber=iconNumber+16}
if(newTempMarker)
map.removeOverlay(newTempMarker);if(isNaN(iconNumber)==false){newTempMarker=new GMarker(marker.getPoint(),{'icon':icon[iconNumber],zIndexProcess:importanceOrder});map.addOverlay(newTempMarker);}
else{newTempMarker=new GMarker(marker.getPoint(),{'icon':marker.getIcon(),zIndexProcess:importanceOrder});map.addOverlay(newTempMarker);}
GEvent.addListener(newTempMarker,"mouseout",function(){closePopup();restoreHighlight();});highlightContenuto(id_contenuto);popup.innerHTML=html;makeVisible(popup);}}
function importanceOrder(marker,b){return GOverlay.getZIndex(marker.getPoint().lat())+1000;}
function closePopup(){var popup=document.getElementById("mapPopup");if(newTempMarker){setTimeout("map.removeOverlay(newTempMarker);newTempMarker='';",10)
restoreHighlight();makeHidden(popup);}
popup.innerHTML="";}
function testMouseOut(){if(!event.fromElement.contains(event.toElement)&&!document.getElementById('mapPopup').contains(event.toElement)){closePopup();}}
function mouseLeaves(element,evt){if(typeof evt.toElement!='undefined'&&typeof element.contains!='undefined'){return!element.contains(evt.toElement);}
else if(typeof evt.relatedTarget!='undefined'&&evt.relatedTarget){return!contains(element,evt.relatedTarget);}}
function contains(container,containee){while(containee){if(container==containee){return true;}
containee=containee.parentNode;}
return false;}
function highlightContenuto(id_contenuto){var contenuto=document.getElementById("contenuto_"+id_contenuto);if(contenuto){contenuto.className="scheda2bordi popUpHighlight";if(actualPopupId!=id_contenuto){var contenutoOld=document.getElementById("contenuto_"+actualPopupId);if(contenutoOld)
contenutoOld.className="scheda2bordi";actualPopupId=id_contenuto;}}}
function restoreHighlight(){var contenuto=document.getElementById("contenuto_"+actualPopupId);if(contenuto){contenuto.className="scheda2bordi";}
actualPopupId=0;}
function IsNumeric(sText)
{var ValidChars="0123456789.";var IsNumber=true;var Char;for(i=0;i<sText.length&&IsNumber==true;i++)
{Char=sText.charAt(i);if(ValidChars.indexOf(Char)==-1)
{IsNumber=false;}}
return IsNumber;}
function impostaMappa(point,zoom,id_activate,id_deactivate){var objactiv=document.getElementById(id_activate);var objdeativ=document.getElementById(id_deactivate);map.setCenter(point,zoom,map.getCurrentMapType());objactiv.className="";objdeativ.className="blu strong";xajax_salvaMappa(point.lat(),point.lng(),zoom);}
function impostaMappaNew(point,zoom){map.setCenter(point,zoom,map.getCurrentMapType());document.getElementById('cittasottomappa').style.display="none";}
function zindex(src,index){var x=document.body.getElementsByTagName('img');for(y=0;y<x.length;y++){if(x[y].src==src){x[y].style.zIndex=index;return true;}}
return false;}