function PlazeMap(container,options){if(!(typeof GBrowserIsCompatible=='function'&&GBrowserIsCompatible()))
return;if(!options.bounds&&(isNaN(options.center.lat)&&isNaN(options.center.lng)))
return;options=options||{};options.center.lat=parseFloat(options.center.lat);options.center.lng=parseFloat(options.center.lng);options.zoom=typeof options.zoom=='number'?options.zoom:17;var ICON_BASE_PATH='/images/pins/single/';var baseIcon=new GIcon();baseIcon.iconSize=new GSize(36,46);baseIcon.iconAnchor=new GPoint(0,46);var userIcon=new GIcon();userIcon.image=ICON_BASE_PATH+'user.png';userIcon.iconSize=new GSize(31,38);userIcon.iconAnchor=new GPoint(0,38);var map,center,marker,overlays=[],controls=[new GSmallMapControl(),new GMapTypeControl()];if(document.namespaces)
document.namespaces.add('v','urn:schemas-microsoft-com:vml');var PlazesInfoWindow=function(marker,target,type){this.marker=marker;this.$target=target;this.type=type||'small';};PlazesInfoWindow.prototype=new GOverlay();PlazesInfoWindow.prototype.initialize=function(map){this.container=$('<div id="plazes-info-window" class="'+this.type+'"></div>')[0];this.yield=$('<div class="yield"></div>').appendTo(this.container)[0];this.$target.appendTo(this.yield);map.getPane(G_MAP_FLOAT_PANE).appendChild(this.container);var fromLatLngToDivPixel=map.fromLatLngToDivPixel(center);this.container.style.top=fromLatLngToDivPixel.y-this.container.offsetHeight+3+'px';this.container.style.left=fromLatLngToDivPixel.x+1+'px';var a=document.createElement('a');a.className='remove';a.href='#';a.title=_('Show on map');a.innerHTML='[x]';this.container.appendChild(a);a.onclick=enableMap;};PlazesInfoWindow.prototype.remove=function(){this.container.parentNode.removeChild(this.container);};PlazesInfoWindow.prototype.redraw=function(){};function disableMap(){for(var i=0,overlay;overlay=overlays[i];i++)
map.removeOverlay(overlay);marker.hide();map.setMapType(G_SATELLITE_MAP);map.setZoom(options.zoom);if(options.moveBy)
map.panTo(options.moveBy);for(var k=0,control;control=controls[k];k++)
map.removeControl(control);map.disableDragging();}
function enableMap(){$('#actions').hide();map.removeOverlay(marker.overlay);map.setMapType(G_NORMAL_MAP);map.panTo(center);marker.show();for(var i=0,control;control=controls[i];i++)
map.addControl(control);map.enableDragging();for(var k=0,overlay;overlay=overlays[k];k++)
map.addOverlay(overlay);return false;}
map=new GMap2(container);if(options.bounds){center=new GLatLngBounds(new GLatLng(options.bounds.swLat,options.bounds.swLng),new GLatLng(options.bounds.neLat,options.bounds.neLng)).getCenter();map.setCenter(center,options.zoom,G_SATELLITE_MAP);map.setZoom(map.getBoundsZoomLevel(bounds));}
else{center=new GLatLng(options.center.lat,options.center.lng);map.setCenter(center,options.zoom,G_SATELLITE_MAP);}
if(options.moveBy)
map.setCenter((options.moveBy=map.fromContainerPixelToLatLng(new GPoint(map.getSize().width/2-options.moveBy.x,map.getSize().height/2+options.moveBy.y))));var user=options.user&&(options.user.lat=parseFloat(options.user.lat))&&(options.user.lng=parseFloat(options.user.lng))&&new GLatLng(options.user.lat,options.user.lng)||null;if(user&&!user.equals(center)){overlays.push(new GMarker(user,{clickable:false,icon:new GIcon(userIcon,options.user.pin),title:_('You are here')}));overlays.push(new GPolyline([center,user],'#6ebdf1',1,1));}
marker=new GMarker(center,{icon:new GIcon(user&&user.equals(center)?userIcon:baseIcon,user&&user.equals(center)?options.user.pin:ICON_BASE_PATH+options.category+'.png'),title:options.markerTitle});map.addOverlay(marker);marker.hide();GEvent.addListener(marker,'click',function(){if(typeof PlazesInfoWindow!='undefined'){if(!this.overlay)
this.overlay=new PlazesInfoWindow(this,$('#data'),'large');map.addOverlay(this.overlay);disableMap();}
else
map.openInfoWindow(center,$('#data')[0]);});GEvent.addListener(map,'moveend',function(){if(marker.isHidden())
$('#actions').show();});GEvent.trigger(marker,'click');GEvent.addDomListener(window,'unload',GUnload);$('#do-map a').bind('click',function(){return enableMap();});};
