$(function(){init_carte_bases()});var search_gmap=false;var all_markers=[];var photo_markers=[];var gmap_bounds=0;var opened_marker=false;var photos_zone=false;function init_carte_bases(){if(search_gmap==false){var d=document.getElementById("search_main_gmap_tooltip");var a=new GIcon();a.image="/images/icons/gmap/icon_base.png";a.iconSize=new GSize(52,37);a.shadow="/images/icons/gmap/icon_base_shadow.png";a.shadowSize=new GSize(52,37);a.iconAnchor=new GPoint(16,37);a.infoWindowAnchor=new GPoint(35,15);a.transparent="/images/icons/gmap/icon_base.png";a.printImage="/images/icons/gmap/icon_base_print.gif";a.mozPrintImage="/images/icons/gmap/icon_base_print.gif";a.printShadow="/images/icons/gmap/icon_base_print_shadow.gif";a.imageMap=[0,0,31,0,31,32,21,32,16,37,11,32,0,32];var f=new GIcon();f.iconSize=new GSize(39,39);f.iconAnchor=new GPoint(25,25);f.infoWindowAnchor=new GPoint(25,25);if(GBrowserIsCompatible()){window.onunload=function(){GUnload()};search_gmap=new GMap2(document.getElementById("search_main_gmap_div"));search_gmap.setMapType(G_PHYSICAL_MAP);search_gmap.setCenter(new GLatLng(0,0),1);search_gmap.setUIToDefault();search_gmap.disableScrollWheelZoom();gmap_bounds=new GLatLngBounds();search_gmap.getPane(G_MAP_FLOAT_PANE).appendChild(d);d.style.visibility="hidden";$.post("/xhr/gmap/carte_zone.php",{id:id_zone_nav},function(h){if(h.success==true){for(var j=0;h.base[j];j++){c(h.base[j],j)}search_gmap.setZoom(search_gmap.getBoundsZoomLevel(gmap_bounds));search_gmap.setCenter(gmap_bounds.getCenter())}},"json")}}else{search_gmap.setZoom(search_gmap.getBoundsZoomLevel(gmap_bounds));search_gmap.setCenter(gmap_bounds.getCenter());search_gmap.closeInfoWindow()}function g(k){if(k==true){if(photos_zone==false){$("#search_main_gmap_wait_photos_zone").css({display:"block"});var j=gmap_bounds.getSouthWest().lng();var h=gmap_bounds.getSouthWest().lat();var n=gmap_bounds.getNorthEast().lng();var m=gmap_bounds.getNorthEast().lat();$.getJSON("http://www.panoramio.com/map/get_panoramas.php?order=popularity&set=public&from=0&to=15&minx="+j+"&miny="+h+"&maxx="+n+"&maxy="+m+"&size=small&callback=?",function(o){if(o.count>0){photos_zone=o;for(var p=0;o.photos[p];p++){b(o.photos[p],p)}$("#search_main_gmap_wait_photos_zone").css({display:"none"})}else{$("#search_main_gmap_wait_photos_zone").css({display:"none"})}})}else{for(var l=0;photos_zone.photos[l];l++){photo_markers[l].show()}}}else{$("#search_main_gmap_wait_photos_zone").css({display:"none"});for(var l=0;photo_markers[l];l++){search_gmap.closeInfoWindow();photo_markers[l].hide()}}}function b(h,l){var k=new GLatLng(h.latitude,h.longitude);var i=new GMarker(k,new GIcon(f,h.photo_file_url));var j='<img src="'+h.photo_file_url+'" width="'+h.width+'" height="'+h.height+'">';j+='<div class="gmap_photo_marker_html_links"><a href="'+h.photo_url+'" target="_blank">Photo</a> by <a href="'+h.owner_url+'" target="_blank">'+h.owner_name+"</a></div>";j+='<div class="gmap_photo_marker_html_infos">Photos provided by <a href="http://www.panoramio.com/" target="_blank">Panoramio</a>. Photos are under the copyright of their owners.</div>';GEvent.addListener(i,"click",function(){i.openInfoWindowHtml(j)});photo_markers[l]=i;search_gmap.addOverlay(i)}function c(i,l){var k=new GLatLng(i.coord_gps[0],i.coord_gps[1]);gmap_bounds.extend(k);var h=new GMarker(k,a);h.tooltip=i.tooltip;h.photos=false;h.current_photo=1;var j="";j='<div class="search_main_gmap_html">';j+='<div class="left" id="gmap_panoramio_photo_loading">';j+='<div id="gmap_panoramio_photo"></div>';j+='<div id="gmap_panoramio_photo_nav"><a href="#" id="gmap_prev_photo">&laquo; prev</a> | <a href="#" id="gmap_next_photo">next &raquo;</a></div>';j+="</div>";j+='<div class="right">'+i.html_tpl;j+='<div class="infos_photo">';j+='<div id="gmap_panoramio_auteur">Loading photos...</div>';j+='Photos provided by <a href="http://www.panoramio.com/" target="_blank">Panoramio</a>. Photos are under the copyright of their owners.</div>';j+="</div>";j+="</div>";GEvent.addListener(h,"click",function(){h.openInfoWindowHtml(j);opened_marker=l});GEvent.addListener(h,"infowindowopen",function(){if(h.photos==false){$("#gmap_panoramio_photo").css({background:"none"});$("#gmap_panoramio_auteur").html("Loading photos...");var o=i.coord_gps[1]-0.01;var n=i.coord_gps[0]-0.01;var r=i.coord_gps[1]+0.01;var q=i.coord_gps[0]+0.01;$.getJSON("http://www.panoramio.com/map/get_panoramas.php?order=popularity&set=public&from=0&to=10&minx="+o+"&miny="+n+"&maxx="+r+"&maxy="+q+"&size=small&callback=?",function(s){if(s.count>0){h.photos=s}else{h.photos.count=0}p()})}else{p()}function p(){if(opened_marker==l){if(h.photos.count>0){m();if(h.photos.photos.length>1){$("#gmap_panoramio_photo_nav").css({display:"block"});$("#gmap_prev_photo").click(function(){h.current_photo-=1;if(h.current_photo<1){h.current_photo=h.photos.photos.length}m();return false});$("#gmap_next_photo").click(function(){h.current_photo+=1;if(h.current_photo>h.photos.photos.length){h.current_photo=1}m();return false})}else{$("#gmap_panoramio_photo_nav").css({display:"none"})}}else{$("#gmap_panoramio_photo").css({background:"white"});$("#gmap_panoramio_photo_nav").css({display:"none"});$("#gmap_panoramio_photo").html('<center style="color:grey; padding-top:15px;">Sorry<br>No photos found</center>');$("#gmap_panoramio_auteur").html("0 photos")}}else{return 0}}function m(){var u=h.current_photo-1;$("#gmap_panoramio_photo").css({background:"white"});var s='<img src="'+h.photos.photos[u].photo_file_url+'" width="150">';var t='<a href="'+h.photos.photos[u].photo_url+'" target="_blank">Photo</a> by <a href="'+h.photos.photos[u].owner_url+'" target="_blank">'+h.photos.photos[u].owner_name+"</a>";$("#gmap_panoramio_photo").html(s);$("#gmap_panoramio_auteur").html(t)}});all_markers[l]=h;search_gmap.addOverlay(h);GEvent.addListener(h,"mouseover",function(){e(h)});GEvent.addListener(h,"mouseout",function(){d.style.visibility="hidden"})}function e(j){d.innerHTML=j.tooltip;var i=search_gmap.getCurrentMapType().getProjection().fromLatLngToPixel(search_gmap.fromDivPixelToLatLng(new GPoint(0,0),true),search_gmap.getZoom());var m=search_gmap.getCurrentMapType().getProjection().fromLatLngToPixel(j.getPoint(),search_gmap.getZoom());var k=j.getIcon().iconAnchor;var l=j.getIcon().iconSize.width;var h=d.clientHeight;var n=new GControlPosition(G_ANCHOR_TOP_LEFT,new GSize(m.x-i.x-k.x+l-15,m.y-i.y-k.y-h+55));n.apply(d);d.style.visibility="visible"}};
