/* --------- /javascripts/ClusterMarker.js --------- */ 

function ClusterMarker($map,$options){this._map=$map;this._mapMarkers=[];this._iconBounds=[];this._clusterMarkers=[];this._eventListeners=[];if(typeof($options)==='undefined'){$options={};}
this.borderPadding=($options.borderPadding)?$options.borderPadding:256;this.clusteringEnabled=($options.clusteringEnabled===false)?false:true;if($options.clusterMarkerClick){this.clusterMarkerClick=$options.clusterMarkerClick;}
if($options.clusterMarkerIcon){this.clusterMarkerIcon=$options.clusterMarkerIcon;}else{this.clusterMarkerIcon=new GIcon();this.clusterMarkerIcon.image='http://maps.google.com/mapfiles/arrow.png';this.clusterMarkerIcon.iconSize=new GSize(39,34);this.clusterMarkerIcon.iconAnchor=new GPoint(9,31);this.clusterMarkerIcon.infoWindowAnchor=new GPoint(9,31);this.clusterMarkerIcon.shadow='http://www.google.com/intl/en_us/mapfiles/arrowshadow.png';this.clusterMarkerIcon.shadowSize=new GSize(39,34);}
this.clusterMarkerTitle=($options.clusterMarkerTitle)?$options.clusterMarkerTitle:'Click to zoom in and see %count markers';if($options.fitMapMaxZoom){this.fitMapMaxZoom=$options.fitMapMaxZoom;}
this.intersectPadding=($options.intersectPadding)?$options.intersectPadding:0;if($options.markers){this.addMarkers($options.markers);}
GEvent.bind(this._map,'moveend',this,this._moveEnd);GEvent.bind(this._map,'zoomend',this,this._zoomEnd);GEvent.bind(this._map,'maptypechanged',this,this._mapTypeChanged);}
ClusterMarker.prototype.addMarkers=function($markers){var i;for(i=$markers.length-1;i>=0;i--){$markers[i]._isVisible=false;$markers[i]._isActive=false;$markers[i]._makeVisible=false;}
this._mapMarkers=this._mapMarkers.concat($markers);};ClusterMarker.prototype._clusterMarker=function($clusterGroupIndexes){function $newClusterMarker($location,$icon,$title){return new GMarker($location,{icon:$icon,title:$title});}
var $clusterGroupBounds=new GLatLngBounds(),i,$clusterMarker,$clusteredMarkers=[],$marker,$this=this,$mapMarkers=this._mapMarkers;for(i=$clusterGroupIndexes.length-1;i>=0;i--){$marker=$mapMarkers[$clusterGroupIndexes[i]];$marker.index=$clusterGroupIndexes[i];$clusterGroupBounds.extend($marker.getLatLng());$clusteredMarkers.push($marker);}
var myIcon=new GIcon(this.clusterMarkerIcon);var markerCount=$clusteredMarkers.length;myIcon.image="/images/gmaps/"+markerCount+".png"
$clusterMarker=$newClusterMarker($clusterGroupBounds.getCenter(),myIcon,this.clusterMarkerTitle.replace(/%count/gi,$clusterGroupIndexes.length));$clusterMarker.clusterGroupBounds=$clusterGroupBounds;this._eventListeners.push(GEvent.addListener($clusterMarker,'click',function(){$this.clusterMarkerClick({clusterMarker:$clusterMarker,clusteredMarkers:$clusteredMarkers});}));$clusterMarker._childIndexes=$clusterGroupIndexes;for(i=$clusterGroupIndexes.length-1;i>=0;i--){$mapMarkers[$clusterGroupIndexes[i]]._parentCluster=$clusterMarker;}
return $clusterMarker;};ClusterMarker.prototype.clusterMarkerClick=function($args){this._map.setCenter($args.clusterMarker.getLatLng(),this._map.getBoundsZoomLevel($args.clusterMarker.clusterGroupBounds));};ClusterMarker.prototype._filterActiveMapMarkers=function(){var $borderPadding=this.borderPadding,$mapZoomLevel=this._map.getZoom(),$mapProjection=this._map.getCurrentMapType().getProjection(),$mapPointSw,$activeAreaPointSw,$activeAreaLatLngSw,$mapPointNe,$activeAreaPointNe,$activeAreaLatLngNe,$activeAreaBounds=this._map.getBounds(),i,$marker,$uncachedIconBoundsIndexes=[],$oldState,$mapMarkers=this._mapMarkers,$iconBounds=this._iconBounds;if($borderPadding){$mapPointSw=$mapProjection.fromLatLngToPixel($activeAreaBounds.getSouthWest(),$mapZoomLevel);$activeAreaPointSw=new GPoint($mapPointSw.x-$borderPadding,$mapPointSw.y+$borderPadding);$activeAreaLatLngSw=$mapProjection.fromPixelToLatLng($activeAreaPointSw,$mapZoomLevel);$mapPointNe=$mapProjection.fromLatLngToPixel($activeAreaBounds.getNorthEast(),$mapZoomLevel);$activeAreaPointNe=new GPoint($mapPointNe.x+$borderPadding,$mapPointNe.y-$borderPadding);$activeAreaLatLngNe=$mapProjection.fromPixelToLatLng($activeAreaPointNe,$mapZoomLevel);$activeAreaBounds.extend($activeAreaLatLngSw);$activeAreaBounds.extend($activeAreaLatLngNe);}
this._activeMarkersChanged=false;if(typeof($iconBounds[$mapZoomLevel])==='undefined'){this._iconBounds[$mapZoomLevel]=[];this._activeMarkersChanged=true;for(i=$mapMarkers.length-1;i>=0;i--){$marker=$mapMarkers[i];$marker._isActive=$activeAreaBounds.containsLatLng($marker.getLatLng())?true:false;$marker._makeVisible=$marker._isActive;if($marker._isActive){$uncachedIconBoundsIndexes.push(i);}}}else{for(i=$mapMarkers.length-1;i>=0;i--){$marker=$mapMarkers[i];$oldState=$marker._isActive;$marker._isActive=$activeAreaBounds.containsLatLng($marker.getLatLng())?true:false;$marker._makeVisible=$marker._isActive;if(!this._activeMarkersChanged&&$oldState!==$marker._isActive){this._activeMarkersChanged=true;}
if($marker._isActive&&typeof($iconBounds[$mapZoomLevel][i])==='undefined'){$uncachedIconBoundsIndexes.push(i);}}}
return $uncachedIconBoundsIndexes;};ClusterMarker.prototype._filterIntersectingMapMarkers=function(){var $clusterGroup,i,j,$mapZoomLevel=this._map.getZoom(),$mapMarkers=this._mapMarkers,$iconBounds=this._iconBounds;for(i=$mapMarkers.length-1;i>0;i--)
{if($mapMarkers[i]._makeVisible){$clusterGroup=[];for(j=i-1;j>=0;j--){if($mapMarkers[j]._makeVisible&&$iconBounds[$mapZoomLevel][i].intersects($iconBounds[$mapZoomLevel][j])){$clusterGroup.push(j);}}
if($clusterGroup.length!==0){$clusterGroup.push(i);for(j=$clusterGroup.length-1;j>=0;j--){$mapMarkers[$clusterGroup[j]]._makeVisible=false;}
this._clusterMarkers.push(this._clusterMarker($clusterGroup));}}}};ClusterMarker.prototype.fitMapToMarkers=function(){var $mapMarkers=this._mapMarkers,$markersBounds=new GLatLngBounds(),i;if($mapMarkers.length===0){return;}
for(i=$mapMarkers.length-1;i>=0;i--){$markersBounds.extend($mapMarkers[i].getLatLng());}
var $fitMapToMarkersZoom=this._map.getBoundsZoomLevel($markersBounds);if(this.fitMapMaxZoom&&$fitMapToMarkersZoom>this.fitMapMaxZoom){$fitMapToMarkersZoom=this.fitMapMaxZoom;}
this._map.setCenter($markersBounds.getCenter(),$fitMapToMarkersZoom);this.refresh();};ClusterMarker.prototype._mapTypeChanged=function(){this.refresh(true);};ClusterMarker.prototype._moveEnd=function(){if(!this._cancelMoveEnd){this.refresh();}else{this._cancelMoveEnd=false;}};ClusterMarker.prototype._preCacheIconBounds=function($indexes,$mapZoomLevel){var $mapProjection=this._map.getCurrentMapType().getProjection(),i,$marker,$iconSize,$iconAnchorPoint,$iconAnchorPointOffset,$iconBoundsPointSw,$iconBoundsPointNe,$iconBoundsLatLngSw,$iconBoundsLatLngNe,$intersectPadding=this.intersectPadding,$mapMarkers=this._mapMarkers;for(i=$indexes.length-1;i>=0;i--){$marker=$mapMarkers[$indexes[i]];$iconSize=$marker.getIcon().iconSize;$iconAnchorPoint=$mapProjection.fromLatLngToPixel($marker.getLatLng(),$mapZoomLevel);$iconAnchorPointOffset=$marker.getIcon().iconAnchor;$iconBoundsPointSw=new GPoint($iconAnchorPoint.x-$iconAnchorPointOffset.x-$intersectPadding,$iconAnchorPoint.y-$iconAnchorPointOffset.y+$iconSize.height+$intersectPadding);$iconBoundsPointNe=new GPoint($iconAnchorPoint.x-$iconAnchorPointOffset.x+$iconSize.width+$intersectPadding,$iconAnchorPoint.y-$iconAnchorPointOffset.y-$intersectPadding);$iconBoundsLatLngSw=$mapProjection.fromPixelToLatLng($iconBoundsPointSw,$mapZoomLevel);$iconBoundsLatLngNe=$mapProjection.fromPixelToLatLng($iconBoundsPointNe,$mapZoomLevel);this._iconBounds[$mapZoomLevel][$indexes[i]]=new GLatLngBounds($iconBoundsLatLngSw,$iconBoundsLatLngNe);}};ClusterMarker.prototype.refresh=function($forceFullRefresh){var i,$marker,$zoomLevel=this._map.getZoom(),$uncachedIconBoundsIndexes=this._filterActiveMapMarkers();if(this._activeMarkersChanged||$forceFullRefresh){this._removeClusterMarkers();if(this.clusteringEnabled&&$zoomLevel<this._map.getCurrentMapType().getMaximumResolution()){if($uncachedIconBoundsIndexes.length>0){this._preCacheIconBounds($uncachedIconBoundsIndexes,$zoomLevel);}
this._filterIntersectingMapMarkers();}
for(i=this._clusterMarkers.length-1;i>=0;i--){this._map.addOverlay(this._clusterMarkers[i]);}
for(i=this._mapMarkers.length-1;i>=0;i--){$marker=this._mapMarkers[i];if(!$marker._isVisible&&$marker._makeVisible){this._map.addOverlay($marker);$marker._isVisible=true;if($marker.data&&$marker.data.length&&$marker.data.length>1){$marker.setImage('/images/gmaps/'+$marker.data.length+'.png');}}
if($marker._isVisible&&!$marker._makeVisible){this._map.removeOverlay($marker);$marker._isVisible=false;}}}};ClusterMarker.prototype._removeClusterMarkers=function(){var i,j,$map=this._map,$eventListeners=this._eventListeners,$clusterMarkers=this._clusterMarkers,$childIndexes,$mapMarkers=this._mapMarkers;for(i=$clusterMarkers.length-1;i>=0;i--){$childIndexes=$clusterMarkers[i]._childIndexes;for(j=$childIndexes.length-1;j>=0;j--){delete $mapMarkers[$childIndexes[j]]._parentCluster;}
$map.removeOverlay($clusterMarkers[i]);}
for(i=$eventListeners.length-1;i>=0;i--){GEvent.removeListener($eventListeners[i]);}
this._clusterMarkers=[];this._eventListeners=[];};ClusterMarker.prototype.removeMarkers=function(){var i,$mapMarkers=this._mapMarkers,$map=this._map;for(i=$mapMarkers.length-1;i>=0;i--){if($mapMarkers[i]._isVisible){$map.removeOverlay($mapMarkers[i]);}
delete $mapMarkers[i]._isVisible;delete $mapMarkers[i]._isActive;delete $mapMarkers[i]._makeVisible;}
this._removeClusterMarkers();this._mapMarkers=[];this._iconBounds=[];};ClusterMarker.prototype.triggerClick=function($index){var $marker=this._mapMarkers[$index];if($marker._isVisible){GEvent.trigger($marker,'click');}
else if($marker._isActive){var $clusteredMarkersIndexes=$marker._parentCluster._childIndexes,$intersectDetected=true,$uncachedIconBoundsIndexes,i,$mapZoomLevel=this._map.getZoom(),$clusteredMarkerIndex,$iconBounds=this._iconBounds,$mapMaxZoomLevel=this._map.getCurrentMapType().getMaximumResolution();while($intersectDetected&&$mapZoomLevel<$mapMaxZoomLevel){$intersectDetected=false;$mapZoomLevel++;if(typeof($iconBounds[$mapZoomLevel])==='undefined'){$iconBounds[$mapZoomLevel]=[];this._preCacheIconBounds($clusteredMarkersIndexes,$mapZoomLevel);}else{$uncachedIconBoundsIndexes=[];for(i=$clusteredMarkersIndexes.length-1;i>=0;i--){if(typeof($iconBounds[$mapZoomLevel][$clusteredMarkersIndexes[i]])==='undefined'){$uncachedIconBoundsIndexes.push($clusteredMarkersIndexes[i]);}}
if($uncachedIconBoundsIndexes.length>=1){this._preCacheIconBounds($uncachedIconBoundsIndexes,$mapZoomLevel);}}
for(i=$clusteredMarkersIndexes.length-1;i>=0;i--){$clusteredMarkerIndex=$clusteredMarkersIndexes[i];if($clusteredMarkerIndex!==$index&&$iconBounds[$mapZoomLevel][$clusteredMarkerIndex].intersects($iconBounds[$mapZoomLevel][$index])){$intersectDetected=true;break;}}};this._map.setCenter($marker.getLatLng(),$mapZoomLevel);this.triggerClick($index);}else{this._map.setCenter($marker.getLatLng());this.triggerClick($index);}};ClusterMarker.prototype._zoomEnd=function(){this._cancelMoveEnd=true;this.refresh(true);};/* --------- /javascripts/map_actions.js --------- */ 

var baseIcon=false;var markerPoints=0;var selected_marker=null;var latlngbounds=null;var map_markers={};function drawAndSetListMapEvents(properties){var map_top=$('map_area').positionedOffset().top;$$('tr.item').each(function(elem){addListMapObservers(elem)})
plotSearchListMap($('list_map'),properties);if(!Prototype.Browser.IE6){Event.observe(window,'scroll',function(){if(document.viewport.getScrollOffsets().top>map_top){$('map_area').addClassName('fixed');}else{$('map_area').removeClassName('fixed');}})}}
function plotSearchListMap(container,properties){if(GBrowserIsCompatible()){map=new GMap2(container);latlngbounds=new GLatLngBounds()
properties.each(function(p){var marker=createSearchListMarker(p);map.addOverlay(marker);});map.setCenter(latlngbounds.getCenter(),map.getBoundsZoomLevel(latlngbounds));map.addControl(new GSmallZoomControl3D());map.addControl(new GMenuMapTypeControl());return map;}}
function createSearchListMarker(data){if(!baseIcon){baseIcon=new GIcon();baseIcon.image="/images/gmaps/pin-propiedades.gif";baseIcon.iconSize=new GSize(30,45);baseIcon.iconAnchor=new GPoint(15,45);baseIcon.infoWindowAnchor=new GPoint(9,2);}
var latlng=new GLatLng(data.lat,data.lon);var marker=new GMarker(latlng,{icon:baseIcon});marker.hash_id='itp'+data.id;GEvent.addListener(marker,"click",function(){toggleSearchMapIcons(marker)});map_markers[marker.hash_id]=marker;latlngbounds.extend(latlng);return marker;}
function toggleSearchMapIcons(marker){resetSearchMapIcons();window.location.hash=marker.hash_id;$(marker.hash_id).addClassName('highlighted');setMarker(marker);}
function setMarker(marker){marker.setImage('/images/gmaps/pin-prop-selected.gif');selected_marker=marker;}
function resetSearchMapIcons(){$$('.item.highlighted').each(function(e){e.removeClassName('highlighted')});selected_marker&&selected_marker.setImage('/images/gmaps/pin-propiedades.gif');selected_marker=null;}
function addListMapObservers(elem){elem.observe('mouseover',function(e){resetSearchMapIcons();this.addClassName('highlighted');var mark=map_markers[elem.id];if(mark){setMarker(mark);}});elem.observe('mouseout',function(e){resetSearchMapIcons();})}
function createMarker(data,previousMarkers){if(!baseIcon){baseIcon=new GIcon();baseIcon.image='/images/gmaps/pin-propiedades.gif';baseIcon.iconSize=new GSize(30,45);baseIcon.iconAnchor=new GPoint(15,45);baseIcon.infoWindowAnchor=new GPoint(9,2);}
var letteredIcon=new GIcon(baseIcon);var lat=data.lat,lon=data.lon;var point=new GLatLng(lat,lon);markerOptions={icon:letteredIcon};var marker=null;if(previousMarkers&&previousMarkers[point.toString()]){marker=previousMarkers[point.toString()];if(data.featured_rank){marker.data.unshift(data);}
else{marker.data.push(data);}}
else{marker=new GMarker(point,markerOptions);marker.data=[data];marker.SAInfoWindow=function(){var form=$('property_sideform');if(form){form.select('.prop_ids').invoke('remove');form.appendChild(new Element('input',{'type':'hidden','name':'search[prop_ids]','value':this.data.map(function(e){return e.id}).join(','),'class':'prop_ids'}));searchControl.hashSerializeForm();}
var title='',window_height=150;if(this.data.length>1){window_height=170;title="<h4>Se han encontrado "+this.data.length+" propiedades</h4>";}
var listing=new Element('div',{'class':'map_listing','style':'width:490px;height:150px;overflow:auto;'}).update("<img src='/images/spinner.gif' />");var window_info=new Element('div',{'style':'width:500px;height:'+window_height+'px;'}).update(title).insert(listing);this.openInfoWindow(window_info);new Ajax.Request('/data/realestate',{method:'get',parameters:this.data.map(function(e){return'ids[]='+e.id}).join('&'),onSuccess:function(transport){listing.update();var response=transport.responseJSON;for(var j=0;j<response.length;++j){var data=response[j];var link_url=data.get_url;var html="<div class='map_info_window"+(data.featured_rank?(' featured_'+j):'')+"' style='overflow:auto;'><div class='image slideshow'></div><div class='details'><h1><a href='"+(link_url)+"'>"+data.title+"</a></h1>";if(data.price&&data.priceUnit){html+="<div class='price'>"+data.priceUnit+" "+number_with_delimiter(data.price)+"</div>";}
if(data.address_html){html+="<address>"+data.address_html+"</address>";}
if(data.features){html+="<p>"+data.features.truncate(80)+"</p>";}
if(data.description){html+="<p>"+data.description.truncate(80)+"</p>";}
html+="<a class='more' href='"+(link_url)+"'>Ver +</a>";html+="<a class='source'>Publicado en "+data.source_name+" el "+data.publish_date+"</a>";html+="</div><br class='clearfix' /></div>";var o=new Element('div',{'class':'map_listing_item'}).update(html);var images_container=o.select("div.image")[0];if(data.images){images_to_slideshow(data.images.map(function(i){return i.url}),images_container);}else if(data.first_image){images_container.update("<img src='"+data.first_image.url+"' />");images_container.removeClassName("slideshow");}else{images_container.removeClassName("slideshow");images_container.addClassName("default");images_container.update("<img src='http://a0.sumavisos.com/images/realestate100px.png' />");}
listing.appendChild(o);}}})}
GEvent.addListener(marker,"click",marker.SAInfoWindow);if(previousMarkers){previousMarkers[point.toString()]=marker;}}
return marker;}
var circle_radius=500;var map=null;function plotMap(container,center,properties,no_search,translations_text,fixed_size){if(GBrowserIsCompatible()){var map_options={}
if(fixed_size){map_options['size']=fixed_size}
map=new GMap2(container,map_options);var mapCenter=(center)?center:{"lat":-34.600433,"lon":-58.466492};map.setCenter(new GLatLng(mapCenter.lat,mapCenter.lon),12);map.addControl(new GLargeMapControl3D(map));map.addControl(new GMapTypeControl(map));map.addControl(new GScaleControl());map.addControl(new GOverviewMapControl());map.addControl(new PanoMapTypeControl(map));var markers=[];var previousMarkers={};for(var i=0;i<properties.length;++i){var marker=createMarker(properties[i],previousMarkers);markers.push(marker);}
var numericIcon=new GIcon();numericIcon.iconSize=new GSize(37,51);numericIcon.iconAnchor=new GPoint(19,51);numericIcon.infoWindowAnchor=new GPoint(9,2);var cluster=new ClusterMarker(map,{markers:markers,clusterMarkerIcon:numericIcon,intersectPadding:8});cluster.fitMapToMarkers();if(!no_search){searchControl=new SearchControl(map);searchControl.translations=translations_text.search_control;searchControl._clusterMarker=cluster;var statusControl=new StatusControl(map);statusControl.translations=translations_text.status_control;searchControl._statusControl=statusControl;var howToControl=new HowToControl(map);howToControl.translations=translations_text.how_to_control;searchControl._howToControl=howToControl;map.addControl(statusControl);map.addControl(searchControl);map.addControl(howToControl);GEvent.addListener(map,"click",function(overlay,point){if(point){singleClick=!singleClick;setTimeout(function(){if(singleClick)createCircle(new GLatLng(point.lat(),point.lng()),circle_radius)},300);}});}}
return map;}
function drawPOI(poi){if(poi){opts={title:poi.title};if(poi.icon){opts.icon=new GIcon(G_DEFAULT_ICON,poi.icon);opts.icon.iconSize=new GSize(32,32);}
var poi_marker=new GMarker(new GLatLng(poi.lat,poi.lon),opts);map.addOverlay(poi_marker);}}/* --------- /javascripts/mapsearch.js --------- */ 

var singleClick=false;var searchCenterOptions=new Object();var searchBorderOptions=new Object();searchCenterOptions.icon=new GIcon();searchCenterOptions.icon.image="/images/gmaps/centerArrow.png";searchCenterOptions.icon.iconSize=new GSize(16,16);searchCenterOptions.icon.iconAnchor=new GPoint(8,8);searchCenterOptions.draggable=true;searchCenterOptions.bouncy=true;searchCenterOptions.zIndexProcess=function(){return 250000000;};searchBorderOptions.icon=new GIcon();searchBorderOptions.icon.image="/images/gmaps/resizeArrow.png";searchBorderOptions.icon.iconSize=new GSize(25,20);searchBorderOptions.icon.iconAnchor=new GPoint(12,10);searchBorderOptions.draggable=true;searchBorderOptions.bouncy=true;searchBorderOptions.zIndexProcess=function(){return 250000000;};function createCircle(point,radius,fit_map,only_render){singleClick=false;searchArea=new SearchArea();searchArea.initializeCircle(radius,point,map);searchControl.addSearchArea(searchArea);searchArea.render(fit_map,only_render);}
function destination(orig,hdng,dist){var R=6371;var oX,oY;var x,y;var d=dist/R;hdng=hdng*Math.PI/180;oX=orig.x*Math.PI/180;oY=orig.y*Math.PI/180;y=Math.asin(Math.sin(oY)*Math.cos(d)+Math.cos(oY)*Math.sin(d)*Math.cos(hdng));x=oX+Math.atan2(Math.sin(hdng)*Math.sin(d)*Math.cos(oY),Math.cos(d)-Math.sin(oY)*Math.sin(y));y=y*180/Math.PI;x=x*180/Math.PI;return new GLatLng(y,x);}
function distance(point1,point2){var R=6371;var lon1=point1.lng()*Math.PI/180;var lat1=point1.lat()*Math.PI/180;var lon2=point2.lng()*Math.PI/180;var lat2=point2.lat()*Math.PI/180;var deltaLat=lat1-lat2;var deltaLon=lon1-lon2;var step1=Math.pow(Math.sin(deltaLat/2),2)+Math.cos(lat2)*Math.cos(lat1)*Math.pow(Math.sin(deltaLon/2),2);var step2=2*Math.atan2(Math.sqrt(step1),Math.sqrt(1-step1));return step2*R;}
function SearchArea(){}
SearchArea.prototype.COLOR="#FF0000";SearchArea.prototype._map;SearchArea.prototype._radius;SearchArea.prototype._dragHandle;SearchArea.prototype._centerHandle;SearchArea.prototype._polygon;SearchArea.prototype._control;SearchArea.prototype._points;SearchArea.prototype._dragHandlePosition;SearchArea.prototype._centerHandlePosition;SearchArea.prototype._centerField;SearchArea.prototype._radiusField;SearchArea.prototype.initializeCircle=function(radius,point,map){this._radius=radius;this._map=map;this._points=[];this._dragHandlePosition=destination(point,90,this._radius/1000);this._dragHandle=new GMarker(this._dragHandlePosition,searchBorderOptions);this._centerHandlePosition=point;this._centerHandle=new GMarker(this._centerHandlePosition,searchCenterOptions);this._map.addOverlay(this._dragHandle);this._map.addOverlay(this._centerHandle);this._centerField=$('search_point');this._radiusField=$('search_radius');var that=this;GEvent.addListener(this._dragHandle,"dragend",function(){that.updateCircle('border');});GEvent.addListener(this._centerHandle,"dragend",function(){that.updateCircle('center');});}
SearchArea.prototype.updateCircle=function(type){this._map.removeOverlay(this._polygon);if(type=='border'){this._dragHandlePosition=this._dragHandle.getPoint();this._radius=distance(this._centerHandlePosition,this._dragHandlePosition)*1000;this.render();}else if(type=='center'){this._centerHandlePosition=this._centerHandle.getPoint();this.render();this._dragHandle.setPoint(this.getEast());}}
SearchArea.prototype.updateFields=function(){this._centerField.value=this.getCenterLatLng();this._radiusField.value=this.getKMRadius();}
SearchArea.prototype.clearFields=function(){this._centerField.value="";this._radiusField.value="";window.location.hash="#.";}
SearchArea.prototype.render=function(fit_map,only_render){this.updateFields();circle_radius=this._radius;if(!only_render){this._control.updateMarkers(fit_map);}
this._points.clear();var distance=this._radius/1000;for(var i=0;i<72;++i){this._points.push(destination(this._centerHandlePosition,i*360/72,distance));}
this._points.push(destination(this._centerHandlePosition,0,distance));this._polygon=new GPolygon(this._points,this.COLOR,2,1,this.COLOR,0.1);this._control.render();this._map.addOverlay(this._polygon);}
SearchArea.prototype.remove=function(){this.clearFields();this._map.removeOverlay(this._polygon);GEvent.clearListeners(this._dragHandle);GEvent.clearListeners(this._centerHandle);this._map.removeOverlay(this._dragHandle);this._map.removeOverlay(this._centerHandle);this._searchPoint=null;this._searchRadius=null;this._control=null;}
SearchArea.prototype.getKMRadius=function(){return(this._radius/1000).toFixed(2);}
SearchArea.prototype.getCenterLatLng=function(){return this._centerHandle.getPoint().toUrlValue();}
SearchArea.prototype.getHTML=function(){result="<a title='"+this._control.translations.remove+"' onClick='searchControl.removeSearchArea(true); return false;' ><img src='/images/transparent.gif' class='sprite sprite-close'/></a>"+this._control.translations.searching+"<span class='radius'> "+this._control.translations.radius+" ";if(this._radius<1000){result+=this._radius.toFixed(1)+'m';}else{result+=(this._radius/1000).toFixed(1)+'km';}
result+="</span>";if(this._polygon){result+="<span class='area'>"+this._control.translations.area+" "+(this._polygon.getArea()/1000000).toFixed(1)+"km&sup2;</span>";}
return result;}
SearchArea.prototype.getNorth=function(){return this._points[0];}
SearchArea.prototype.getSouth=function(){return this._points[(72/2)];}
SearchArea.prototype.getEast=function(){return this._points[(72/4)];}
SearchArea.prototype.getWest=function(){return this._points[(72/4*3)];}
function SearchControl(){}
SearchControl.prototype=new GControl();SearchControl.prototype._searchArea;SearchControl.prototype._searchDiv;SearchControl.prototype._searchForm;SearchControl.prototype._statusControl;SearchControl.prototype.preloaded_markers=[];SearchControl.prototype.translations;SearchControl.prototype.show_info_window=true;SearchControl.prototype.initialize=function(map){this._map=map;this._searchDiv=new Element("div",{'id':"searchControl",'class':'invisible map_control'});this._map.getContainer().appendChild(this._searchDiv);this._searchForm=$('property_sideform');this._results_counter=$('map_results_count');this._results_title=$('map_results_title');this.title_suffix=document.title.replace(/.+?\|/,' |');this._poi_markers=[];var preloaded_data=window.location.hash.replace(/#/,'').toQueryParams();if(preloaded_data.prop_ids){this.preloaded_markers=preloaded_data.prop_ids.split(',');}
var that=this;$('property_search_operation').observe('change',function(){that.togglePriceOperationFilter(this.value);that.filterBy({operation:this.value});})
$('property_search_property_type').observe('change',function(){that.filterBy({property_type:this.value});})
return this._searchDiv;}
SearchControl.prototype.getDefaultPosition=function(){return new GControlPosition(G_ANCHOR_TOP_LEFT,new GSize(70,10));}
SearchControl.prototype.addSearchArea=function(searchArea){if(this._searchArea){this.removeSearchArea();}
this._searchArea=searchArea;searchArea._control=this;this._searchDiv.innerHTML=searchArea.getHTML();}
SearchControl.prototype.render=function(){if(this._searchArea){this._searchDiv.removeClassName('invisible');this._searchDiv.innerHTML=this._searchArea.getHTML();}else{this._searchDiv.innerHTML='';this._searchDiv.addClassName('invisible');}}
SearchControl.prototype.togglePriceOperationFilter=function(operation){$('price_sell_menu').toggle();$('search_sell_currency').disabled=!$('search_sell_currency').disabled
$('price_sell_currency').toggle();$('price_rent_menu').toggle();$('search_rent_currency').disabled=!$('search_rent_currency').disabled
$('price_rent_currency').toggle();$('search_price_from').value=''
$('search_price_to').value=''}
SearchControl.prototype.updatePlaces=function(places_arr){var place_ids=places_arr.map(function(e){return e.select('select').map(function(f){return f.value}).reject(function(f){return!f||f.empty()}).last()}).compact().uniq()
this._searchForm.select('.place_ids').each(function(e){e.remove()});for(var i=0;i<place_ids.length;++i){this._searchForm.appendChild(new Element('input',{'type':'hidden','name':'search[place_ids]['+i+']','value':place_ids[i],'class':'place_ids'}));}
this.updateMarkers();}
SearchControl.prototype.filterBy=function(filters,clicked,parent_id,fit_map){if(clicked){$$('#'+parent_id+' a').each(function(e){e.removeClassName('current')});clicked.addClassName('current');clicked.blur();}
$H(filters).each(function(e){var filter=$('search_'+e.key)
if(filter){filter.value=e.value;}});this.updateMarkers(fit_map);}
SearchControl.prototype.hashSerializeForm=function(){var values=[];$H(Form.serialize(this._searchForm,true)).each(function(h){if(!h.value.toString().empty()){values.push(h.key.replace(/search\[(.+?)\]/,'$1')+'='+h.value);}});window.location.hash=values.join('&');}
var request_counter=0;SearchControl.prototype.updateMarkers=function(fit_map){this.hashSerializeForm();if(update_markers){var that=this;this.setLoading();var this_request=++request_counter;new Ajax.Request(this._searchForm.action,{parameters:Form.serialize(this._searchForm)+'&ajax=1',method:'get',onSuccess:function(transport){if(this_request===request_counter){var new_properties=transport.responseJSON.properties;var new_title=transport.responseJSON.title;var new_win_title=transport.responseJSON.win_title
var new_markers=[];var previousMarkers={};var click=false;for(var i=0;i<new_properties.length;++i){new_markers.push(createMarker(new_properties[i],previousMarkers));if(click===false&&that.show_info_window&&that.preloaded_markers.include(new_properties[i].id)){click=i;}}
if(that._results_counter){that._results_counter.update(new_properties.length.toString());}
if(that._results_title&&new_title){that._results_title.update(new_title);}
if(new_win_title){document.title=new_win_title+that.title_suffix;}
that._clusterMarker.removeMarkers();that._clusterMarker.addMarkers(new_markers);that._clusterMarker.refresh();if(that.show_info_window&&click!==false){that._clusterMarker.triggerClick(click);that.show_info_window=false;}else if(fit_map){that._clusterMarker.fitMapToMarkers();}
that.drawPOIs(transport.responseJSON.pois);}},onComplete:function(transport){if(this_request===request_counter)that.endLoading();}});}else{update_markers=true;}}
SearchControl.prototype.drawPOIs=function(pois){if(this._poi_markers.length>0){this._poi_markers.each(function(e){this._map.removeOverlay(e);});this._poi_markers.clear();}
if(pois){var that=this;pois.each(function(poi){var opts={title:poi.title};if(poi.icon){opts.icon=new GIcon(G_DEFAULT_ICON,poi.icon);opts.icon.iconSize=new GSize(32,32);}
var marker=new GMarker(new GLatLng(poi.lat,poi.lon),opts);GEvent.addListener(marker,"click",function(){this.openInfoWindow("<h3>"+poi.title+"</h3><p>"+
poi.description+"</p>")});that._map.addOverlay(marker);that._poi_markers.push(marker);})}}
SearchControl.prototype.setLoading=function(){this._statusControl.show();}
SearchControl.prototype.endLoading=function(){this._statusControl.hide();}
SearchControl.prototype.removeSearchArea=function(update_markers){this._searchArea.remove();this._searchArea=null;this.render();if(update_markers){this.updateMarkers();}}
SearchControl.prototype.closeHowTo=function(){this._howToControl.hide();}
function StatusControl(){}
StatusControl.prototype=new GControl();StatusControl.prototype._statusDiv;StatusControl.prototype.translations;StatusControl.prototype.initialize=function(map){this._map=map;this._statusDiv=new Element("div",{'id':"statusControl",'class':'map_control'}).update("<img src='/images/spinner.gif' class='spinner'/>"+this.translations.loading_text);this._statusDiv.hide();this._map.getContainer().appendChild(this._statusDiv);return this._statusDiv;}
StatusControl.prototype.getDefaultPosition=function(){var left_distance=(this._map.getSize().width/3).round();return new GControlPosition(G_ANCHOR_TOP_LEFT,new GSize(left_distance,30));}
StatusControl.prototype.show=function(){this._statusDiv.show();}
StatusControl.prototype.hide=function(){this._statusDiv.hide();}
function followIfCompatible(text,button_text){if(GBrowserIsCompatible()&&navigator.geolocation){var b=new Element("button",{"id":"follow"}).update(button_text)
b.observe("click",follow);$$(".map_search_instructions").first().insert(text).appendChild(b)}}
function follow(){searchControl.setLoading()
positionId=navigator.geolocation.watchPosition(function(position){currentLocation=new GLatLng(position.coords.latitude,position.coords.longitude);createCircle(currentLocation,1000,true);});}
function HowToControl(){}
HowToControl.prototype=new GControl();HowToControl.prototype._statusDiv;HowToControl.prototype.translations;HowToControl.prototype.initialize=function(map){this._map=map;this._statusDiv=new Element('div',{'id':'howToControl','class':'map_control map_search_instructions'}).update("<img src='/images/transparent.gif' class='sprite sprite-close close' onclick='searchControl.closeHowTo();return false;'/>"+(this.translations));this._map.getContainer().appendChild(this._statusDiv);return this._statusDiv;}
HowToControl.prototype.getDefaultPosition=function(){return new GControlPosition(G_ANCHOR_TOP_RIGHT,new GSize(20,50));}
HowToControl.prototype.hide=function(){this._statusDiv.hide();}/* --------- /javascripts/gmaps/gfslideshow.js --------- */ 

function GFslideShow(photoFeed,container,options){this.feedUrl=null;this.directEntries=null;if(typeof photoFeed=='string'){this.feedUrl=photoFeed;}else if(photoFeed&&photoFeed.length&&photoFeed.length>1){this.directEntries=photoFeed;}else{throw"invalid argument: photoFeed";}
if(typeof container=="string"){container=document.getElementById(container);}
this.container=container;this.parseOptions(options);this.setup();}
GFslideShow.THUMBNAILS_SMALL="small";GFslideShow.THUMBNAILS_MEDIUM="medium";GFslideShow.THUMBNAILS_LARGE="large";GFslideShow.MRSS_THUMBNAIL_TAG="thumbnail";GFslideShow.MRSS_THUMBNAIL_NS="http://search.yahoo.com/mrss/";GFslideShow.ITMS_THUMBNAIL_TAG="coverArt";GFslideShow.ITMS_THUMBNAIL_NS="http://phobos.apple.com/rss/1.0/modules/itms/";GFslideShow.DEFAULT_THUMBNAIL_TAG=GFslideShow.MRSS_THUMBNAIL_TAG;GFslideShow.DEFAULT_THUMBNAIL_NS=GFslideShow.MRSS_THUMBNAIL_NS;GFslideShow.DEFAULT_DISPLAY_TIME=3000;GFslideShow.DEFAULT_TRANSISTION_TIME=1000;GFslideShow.DEFAULT_TRANSISTION_STEP=40;GFslideShow.DEFAULT_PAUSE_PNG=google.loader.ServiceBase+"/solutions/slideshow/pause.png";GFslideShow.DEFAULT_PLAY_PNG=google.loader.ServiceBase+"/solutions/slideshow/play.png";GFslideShow.FC_PAUSE_PNG={small:google.loader.ServiceBase+"/solutions/slideshow/btn_pause_small.png",big:google.loader.ServiceBase+"/solutions/slideshow/btn_pause.png"};GFslideShow.FC_PLAY_PNG={small:google.loader.ServiceBase+"/solutions/slideshow/btn_play_small.png",big:google.loader.ServiceBase+"/solutions/slideshow/btn_play.png"};GFslideShow.FC_PREV_PNG={small:google.loader.ServiceBase+"/solutions/slideshow/btn_prev_small.png",big:google.loader.ServiceBase+"/solutions/slideshow/btn_prev.png"};GFslideShow.FC_NEXT_PNG={small:google.loader.ServiceBase+"/solutions/slideshow/btn_next_small.png",big:google.loader.ServiceBase+"/solutions/slideshow/btn_next.png"};GFslideShow.DEFAULT_FC_FADEOUT_TIME=5000;GFslideShow.DEFAULT_FC_OPACITY=0.65;GFslideShow.prototype.parseOptions=function(options){var maxEntries;if(google!=undefined&&google.feeds!=undefined){maxEntries=google.feeds.Feed.MAX_ENTRIES;}else{maxEntries=20;}
this.options={numResults:maxEntries,scaleImages:false,thumbnailTag:GFslideShow.DEFAULT_THUMBNAIL_TAG,thumbnailNamespace:GFslideShow.DEFAULT_THUMBNAIL_NS,thumbnailSize:GFslideShow.THUMBNAILS_LARGE,linkTarget:null,displayTime:GFslideShow.DEFAULT_DISPLAY_TIME,transitionTime:GFslideShow.DEFAULT_TRANSISTION_TIME,transitionStep:GFslideShow.DEFAULT_TRANSISTION_STEP,pauseOnHover:true,pauseImage:GFslideShow.DEFAULT_PAUSE_PNG,pauseStateCallback:null,scalePauseImage:true,autoCleanup:true,thumbnailUrlResolver:null,transitionCallback:null,transitionAnimationCallback:null,feedLoadCallback:null,feedProcessedCallback:null,imageClickCallback:null,centerBias:{topBias:0,leftBias:0},pauseCenterBias:{topBias:0,leftBias:0},fullControlPanel:false,fullControlPanelCursor:false,fullControlPanelFadeOutTime:GFslideShow.DEFAULT_FC_FADEOUT_TIME,fullControlPanelPlayCallback:null,fullControlPanelSmallIcons:false,maintainAspectRatio:true};if(options){for(o in this.options){if(typeof options[o]!="undefined"){this.options[o]=options[o];}}}
if(this.options.displayTime<100){this.options.displayTime=100;}
var ts=(this.options.transitionTime/this.options.transitionStep);this.delta=Math.min(1,(1.0/ts));this.started=false;};GFslideShow.prototype.setup=function(){if(this.container==null)return;if(window.ActiveXObject){this.ie=this[window.XMLHttpRequest?'ie7':'ie6']=true;}else if(window.opera){this.opera=true;}else if(document.childNodes&&!document.all&&!navigator.taintEnabled){this.safari=true;if(navigator.userAgent.indexOf('iPhone')>0){this.iphone=true;}}else if(document.getBoxObjectFor!=null){this.gecko=true;}
if(this.feedUrl){this.feed=new google.feeds.Feed(this.feedUrl);this.feed.setResultFormat(google.feeds.Feed.MIXED_FORMAT);this.feed.setNumEntries(this.options.numResults);this.feed.load(this.bind(this.feedLoaded));}else if(this.directEntries){this.feedLoaded(this.directEntries);}};GFslideShow.prototype.addEntries=function(newEntries){this.processEntries(newEntries);if(!this.thumb_timer){this.processThumbs();}};GFslideShow.prototype.bind=function(method){var self=this;var opt_args=[].slice.call(arguments,1);return function(){var args=opt_args.concat([].slice.call(arguments));return method.apply(self,args);}};GFslideShow.prototype.mouseOver=function(e){var event=e||window.event;var relatedTarget=event.relatedTarget||event.fromElement;while(relatedTarget!=null){if(relatedTarget==this.container){return;}
relatedTarget=relatedTarget.parentNode;}
if(this.options.fullControlPanel){if(this.options.pauseOnHover&&!this.display_paused){this.pauseOrPlayFullControl();}
this.fadeInFullControl();}else{this.display_paused=true;if(this.pauseImage){this.pauseImage.style.visibility="visible";}}
if(this.options.pauseStateCallback){this.options.pauseStateCallback(this.display_paused);}};GFslideShow.prototype.mouseOut=function(e){var event=e||window.event;var relatedTarget=event.relatedTarget||event.toElement;while(relatedTarget!=null){if(relatedTarget==this.container){return;}
relatedTarget=relatedTarget.parentNode;}
if(this.options.fullControlPanel){this.fadeOutFullControl();this.container.onmousemove=null;if(this.options.pauseOnHover&&this.display_paused){this.pauseOrPlayFullControl();}}else{this.display_paused=false;if(this.pauseImage){this.pauseImage.style.visibility="hidden";}}
if(this.options.pauseStateCallback){this.options.pauseStateCallback(this.display_paused);}
if(this.display_timer==null&&this.transition_timer==null){this.displayNextPhoto();}};GFslideShow.prototype.operaClickAndCallout=function(){var entry=this.entries[this.photo_index];var tmpLink=this.createLink(entry.link);tmpLink.click();};GFslideShow.prototype.pause=function(opt_suppressPauseImage){var pi=this.pauseImage;if(opt_suppressPauseImage){this.pauseImage=null;}
this.pauseAndCallout();this.pauseImage=pi;};GFslideShow.prototype.resume=function(){this.resumeSlideShow();};GFslideShow.prototype.pauseAndCallout=function(){this.display_paused=true;if(this.pauseImage){this.pauseImage.style.visibility="visible";}
this.container.onmouseout=null;if(this.options.imageClickCallback){this.options.imageClickCallback(this.entries[this.photo_index]);}};GFslideShow.prototype.resumeSlideShow=function(){if(this.options.pauseOnHover||this.options.fullControlPanel){this.container.onmouseover=this.bind(this.mouseOver);this.container.onmouseout=this.bind(this.mouseOut);}
this.display_paused=false;if(this.pauseImage){this.pauseImage.style.visibility="hidden";}
if(this.display_timer==null&&this.transition_timer==null){this.displayNextPhoto();}};GFslideShow.prototype.clearNode=function(node){if(node==null)return;var child;while(child=node.firstChild){node.removeChild(child);}};GFslideShow.prototype.createSubContainer=function(){var div=document.createElement("div");div.style.width="100%";div.style.height="100%";div.style.position="relative";div.style.overflow="hidden";this.clearNode(this.container);this.container.appendChild(div);this.container=div;};GFslideShow.prototype.grabThumb=function(thumbNodes){var ti=0;if(thumbNodes.length>1){if(this.options.thumbnailSize==GFslideShow.THUMBNAILS_LARGE){ti=thumbNodes.length-1;}else if(this.options.thumbnailSize==GFslideShow.THUMBNAILS_MEDIUM){ti=Math.floor(thumbNodes.length/2);}}
var node=thumbNodes[ti];var thumb=null;var thumb=node.getAttribute("url");if(!thumb){thumb=node.firstChild.nodeValue;}
return thumb;};GFslideShow.prototype.processThumbs=function(opt_chunk,opt_timeout){this.thumb_timer=null;var start=this.thumbs_index;var num=this.entries.length;var chunk=opt_chunk||4;if(num>(start+chunk)){num=(start+chunk);var cb=this.bind(this.processThumbs);var to=opt_timeout||Math.round(this.options.displayTime/4);this.thumb_timer=window.setTimeout(cb,to);}
for(var i=start;i<num;i++){var thumbUrl=this.entries[i].thumbUrl;var image=this.createImage(thumbUrl);this.images.push(image);if(this.options.linkTarget){if(!this.opera){var link=this.createLink(this.entries[i].link);link.appendChild(image);this.container.appendChild(link);}else{image.onclick=this.bind(this.operaClickAndCallout);image.style.cursor='pointer';this.container.appendChild(image);}}else{this.container.appendChild(image);}
if(image.complete){this.imageLoaded(image);}else{image.onerror=this.bind(this.imageError,image);image.onload=this.bind(this.imageLoaded,image);}
this.thumbs_index++;}};GFslideShow.prototype.processEntries=function(entries){for(var i=0;i<entries.length;i++){var thumbUrl=null;if(this.options.thumbnailUrlResolver){thumbUrl=this.options.thumbnailUrlResolver(entries[i]);}else{var thumbNodes=google.feeds.getElementsByTagNameNS(entries[i].xmlNode,this.options.thumbnailNamespace,this.options.thumbnailTag);if(thumbNodes&&thumbNodes.length>0){thumbUrl=this.grabThumb(thumbNodes);}}
if(thumbUrl){entries[i].thumbUrl=thumbUrl;this.entries.push(entries[i]);}}};GFslideShow.prototype.feedLoaded=function(result){if(this.options.feedLoadCallback){this.options.feedLoadCallback(result);}
if((this.feedUrl&&result.error)||(this.directEntries&&this.directEntries.length==0)){if(!this.options.feedLoadCallback){this.container.innerHTML="<center>feed could not be loaded.</center>";}
return;}
this.createSubContainer();if(this.container.offsetWidth){this.width=this.container.offsetWidth;this.height=this.container.offsetHeight;}
this.createPauseImage();this.images=[];this.entries=[];this.thumbs_index=0;var entries;if(this.feedUrl){entries=result.feed.entries;}else{entries=this.directEntries;}
this.processEntries(entries);if(this.options.feedProcessedCallback){this.options.feedProcessedCallback(result);}
if(this.options.fullControlPanel&&this.entries.length>0){this.createFullControlPanel();}
if((this.options.pauseOnHover||this.options.fullControlPanel)&&this.entries.length>0){this.container.onmouseover=this.bind(this.mouseOver);this.container.onmouseout=this.bind(this.mouseOut);}
if(this.options.imageClickCallback){this.container.onclick=this.bind(this.pauseAndCallout);}
this.processThumbs(1,100+(Math.random()*100));};GFslideShow.prototype.imageLoaded=function(image){image.__gfloaded=true;this.adjustImage(image);if(!this.started){for(var i=0;i<this.images.length;i++){if(image==this.images[i]){this.beginSlideShow(i);}
break;}}};GFslideShow.prototype.imageError=function(image){image.__gferror=true;};GFslideShow.prototype.adjustImage=function(image){if(this.options.scaleImages){if(this.options.maintainAspectRatio){this.scaleImage(image);}else{image.style.height=this.height+"px";image.style.width=this.width+"px";}}
this.centerImage(image);};GFslideShow.prototype.scaleImage=function(image,opt_width,opt_height){var width=opt_width||this.width;var height=opt_height||this.height;var imgW=image.offsetWidth;var imgH=image.offsetHeight;if(imgW<=0||imgH<=0)return;var scaleH=height/imgH;var scaleW=width/imgW;if(scaleH<scaleW){image.style.height=height+"px";image.style.width=Math.round(imgW*scaleH)+"px";}else{image.style.width=width+"px";image.style.height=Math.round(imgH*scaleW)+"px";}};GFslideShow.prototype.centerImage=function(image){var oh=this.height-image.offsetHeight;var ow=this.width-image.offsetWidth;image.style.top="0px";image.style.left="0px";if(oh>0){var ah=Math.round(oh/2);image.style.top=image.offsetTop+ah+
this.options.centerBias.topBias+"px";}
if(ow>0){var aw=Math.round(ow/2);image.style.left=image.offsetLeft+aw+
this.options.centerBias.leftBias+"px";}};GFslideShow.prototype.createLink=function(href){var link=document.createElement('a');link.setAttribute('href',href);if(this.options.linkTarget){link.setAttribute('target',this.options.linkTarget);}
return link;};GFslideShow.prototype.createImage=function(src){var image=document.createElement("img");image.style.position="absolute";image.setAttribute("src",src);this.setOpacity(image,0);return image;};GFslideShow.prototype.adjustPauseImage=function(image){if(this.options.scalePauseImage){var height=Math.round(this.height*0.33);var width=Math.round(this.width*0.33);this.scaleImage(image,width,height);}
this.placePauseImage(image);};GFslideShow.prototype.placePauseImage=function(image){var oh=this.height-image.offsetHeight;var ow=this.width-image.offsetWidth;image.style.top="0px";image.style.left="0px";if(oh>0){var off=Math.round(this.height*0.10);if(off<15)off=10;var ah=this.height-(image.offsetHeight+off);if(ah<0)ah=0;image.style.top=image.offsetTop+ah+
this.options.pauseCenterBias.topBias+"px";}
if(ow>0){var aw=Math.round(ow/2);image.style.left=image.offsetLeft+aw+
this.options.pauseCenterBias.leftBias+"px";}};GFslideShow.prototype.createAlphaPauseImage=function(image){this.adjustPauseImage(image);var imgW=image.offsetWidth;var imgH=image.offsetHeight;var imgT=image.style.top;var imgL=image.style.left;var element=null;if(this.ie){var src=this.options.pauseImage;element=document.createElement("div");element.style.filter="progid:DXImageTransform.Microsoft."+"AlphaImageLoader(src='"+src+"', sizingMethod='scale')";element.style.position="absolute";element.style.width=imgW+"px";element.style.height=imgH+"px";element.style.left=imgL;element.style.top=imgT;}else{element=image;element.style.opacity="";}
element.style.visibility="hidden";element.style.zIndex=222;if(element!=image){this.container.appendChild(element);this.container.removeChild(image);}
this.pauseImage=element;};GFslideShow.prototype.pauseImageLoaded=function(image){this.createAlphaPauseImage(image);};GFslideShow.prototype.createPauseImage=function(src){if(!this.options.pauseOnHover)return;var pauseOff=this.createImage(this.options.pauseImage);this.container.appendChild(pauseOff);if(pauseOff.complete){this.createAlphaPauseImage(pauseOff);}else{pauseOff.onload=this.bind(this.pauseImageLoaded,pauseOff);}};GFslideShow.prototype.createFullControlPanel=function(){var h=(this.options.fullControlPanelSmallIcons?25:45);if(this.options.fullControlPanelCursor)h+=10;var padTop=(this.options.fullControlPanelSmallIcons?5:10);var padBottom=5;var div=document.createElement('div');div.style.backgroundColor='#000000';div.style.height=h+'px';div.style.top=(this.height-(h+padBottom+padTop))+'px';div.style.width='100%';div.style.zIndex='222';div.style.position='relative';div.style.textAlign='center';div.style.direction='ltr';div.style.paddingTop=padTop+'px';div.style.paddingBottom=padBottom+'px';var iconSize=this.options.fullControlPanelSmallIcons?'small':'big';var handCursor=this.ie?'hand':'pointer';var pause=document.createElement("img");pause.src=GFslideShow.FC_PAUSE_PNG[iconSize];pause.style.cursor=handCursor;var next=document.createElement("img");next.src=GFslideShow.FC_NEXT_PNG[iconSize];next.style.cursor=handCursor;var prev=document.createElement("img");prev.src=GFslideShow.FC_PREV_PNG[iconSize];prev.style.cursor=handCursor;pause.style.marginLeft='5px';pause.style.marginRight='5px';div.appendChild(prev);div.appendChild(pause);div.appendChild(next);var cursor=null;if(this.options.fullControlPanelCursor){cursor=document.createElement('div');cursor.style.height='1.3em';cursor.style.fontSize='11px';cursor.style.color='#bbbbbb';div.appendChild(cursor);}
this.fc={};this.fc.container=div;this.fc.pause=pause;this.fc.next=next;this.fc.prev=prev;this.fc.cursor=cursor;next.onclick=this.bind(this.goForward);prev.onclick=this.bind(this.goBackward);pause.onclick=this.bind(this.pauseOrPlayClick);this.fc.container.style.visibility="hidden";this.container.appendChild(div);};GFslideShow.prototype.clearTransitionTimer=function(){if(this.transition_timer){clearInterval(this.transition_timer);this.transition_timer=null;}};GFslideShow.prototype.setTransitionTimer=function(){this.clearTransitionTimer();this.lastTick=GFslideShow.timeNow();var cb=this.bind(this.transitionAnimation);this.transition_timer=window.setInterval(cb,this.options.transitionStep);};GFslideShow.prototype.clearDisplayTimer=function(){if(this.display_timer){clearTimeout(this.display_timer);this.display_timer=null;}};GFslideShow.prototype.setDisplayTimer=function(){if(this.display_timer)return;var cb=this.bind(this.displayNextPhoto);this.display_timer=window.setTimeout(cb,this.options.displayTime);};GFslideShow.prototype.clearThumbTimer=function(){if(this.thumb_timer){clearTimeout(this.thumb_timer);this.thumb_timer=null;}};GFslideShow.prototype.beginSlideShow=function(index){this.photo_index=index;this.next=this.images[this.photo_index];this.snapToNextPhoto();this.started=true;};GFslideShow.timeNow=function(){var d=new Date();return d.getTime();};GFslideShow.prototype.goForward=function(){this.finishTransition();this.setNextPhoto();this.snapToNextPhoto();this.clearFullControlTimeoutTimer();};GFslideShow.prototype.goBackward=function(){this.finishTransition();this.setPreviousPhoto();this.snapToNextPhoto();this.clearFullControlTimeoutTimer();};GFslideShow.prototype.gotoIndex=function(index){if(index==this.photo_index){return;}
this.clearTransitionTimer();this.setPhotoIndex(index);this.snapToNextPhoto();this.clearFullControlTimeoutTimer();}
GFslideShow.prototype.pauseOrPlayClick=function(){if(this.options.fullControlPanelPlayCallback&&this.display_paused){this.container.onmouseover=null;this.container.onmouseout=null;this.options.fullControlPanelPlayCallback(this.entries[this.photo_index]);this.fadeOutFullControl();}else{this.pauseOrPlayFullControl();}}
GFslideShow.prototype.pauseOrPlayFullControl=function(){var iconSize=this.options.fullControlPanelSmallIcons?'small':'big';if(this.display_paused){this.display_paused=false;this.fc.pause.src=GFslideShow.FC_PAUSE_PNG[iconSize];if(this.display_timer==null&&this.transition_timer==null){this.displayNextPhoto();}}else{this.display_paused=true;this.fc.pause.src=GFslideShow.FC_PLAY_PNG[iconSize];}};GFslideShow.prototype.fullControlMotion=function(){var op=this.fc.container.opacity;if(op<GFslideShow.DEFAULT_FC_OPACITY){this.container.onmousemove=null;this.clearFullControlTimeoutTimer();this.fadeInFullControl();}else{this.setFullControlTimeoutTimer();}}
GFslideShow.prototype.clearFullControlTimeoutTimer=function(){if(!this.fc){return;}
if(this.fc.timeout){clearTimeout(this.fc.timeout);this.fc.timeout=null;}}
GFslideShow.prototype.setFullControlTimeoutTimer=function(){if(this.fc.timeout){clearTimeout(this.fc.timeout);this.fc.timeout=null;}
if(this.options.fullControlPanelFadeOutTime>0){var cb=this.bind(this.fadeOutFullControl);this.fc.timeout=setTimeout(cb,this.options.fullControlPanelFadeOutTime);}}
GFslideShow.prototype.setFullControlTimeout=function(){this.container.onmousemove=this.bind(this.fullControlMotion);this.setFullControlTimeoutTimer();}
GFslideShow.prototype.fadeInFullControl=function(){this.setOpacity(this.fc.container,0);var cb=this.bind(this.fadeInFullControlAnimation);this.setFullControlFadeTimer(cb);}
GFslideShow.prototype.fadeInFullControlAnimation=function(){var op=this.fc.container.opacity;op+=0.075;op=Math.min(GFslideShow.DEFAULT_FC_OPACITY,op);this.setOpacity(this.fc.container,op);if(op>=GFslideShow.DEFAULT_FC_OPACITY){this.setFullControlFadeTimer();this.setFullControlTimeout();}}
GFslideShow.prototype.fadeOutFullControl=function(){var cb=this.bind(this.fadeOutFullControlAnimation);this.setFullControlFadeTimer(cb);}
GFslideShow.prototype.fadeOutFullControlAnimation=function(){var op=this.fc.container.opacity;op-=0.075;this.setOpacity(this.fc.container,op);if(op<=0){this.setFullControlFadeTimer();}}
GFslideShow.prototype.setFullControlFadeTimer=function(opt_callback){if(this.fc.fade_timer){clearInterval(this.fc.fade_timer);this.fc.fade_timer=null;}
if(opt_callback){this.fc.fade_timer=window.setInterval(opt_callback,40);}}
GFslideShow.prototype.transitionAnimation=function(){if(this.current&&this.next){var delta=this.delta;var ts=this.options.transitionStep;var now=GFslideShow.timeNow();var tick=now-this.lastTick;this.lastTick=now;delta*=(tick/ts);if(delta<0)return;var cur_op=this.current.opacity-delta;var next_op=this.next.opacity+delta;this.setOpacity(this.current,cur_op);this.setOpacity(this.next,next_op);if(this.options.transitionAnimationCallback){this.options.transitionAnimationCallback(this.next.opacity);}
if(cur_op>0){return;}}
this.finishTransition();};GFslideShow.prototype.setNextPhoto=function(){if(this.images.length==0){return;}
var ci=this.photo_index;var done=false;while(!done){if(++this.photo_index>=this.images.length){this.photo_index=0;}
var image=this.images[this.photo_index];if(image&&image.__gfloaded){this.next=image;done=true;}else{if(this.photo_index==ci){this.next=this.images[0];done=true;}}}};GFslideShow.prototype.setPreviousPhoto=function(){var ci=this.photo_index;var done=false;while(!done&&this.images.length!=0){if(--this.photo_index<0){this.photo_index=this.images.length-1;}
var image=this.images[this.photo_index];if(image&&image.__gfloaded){this.next=image;done=true;}else{if(this.photo_index==ci){this.next=this.images[0];done=true;}}}};GFslideShow.prototype.setPhotoIndex=function(index){if(index<0||index>=this.images.length){return;}
var image=this.images[index];if(image&&image.__gfloaded){this.next=image;this.photo_index=index;}};GFslideShow.prototype.clearPauseEvents=function(){this.container.onmouseover=null;this.container.onmouseout=null;};GFslideShow.prototype.cleanup=function(){this.clearTransitionTimer();this.clearDisplayTimer();this.clearThumbTimer();this.clearPauseEvents();this.clearNode(this.container);this.container=null;};GFslideShow.prototype.displayNextPhoto=function(){this.display_timer=null;if(!this.started){return false;}
if(this.display_paused)return;if((!this.container||!this.container.parentNode)&&this.options.autoCleanup){this.cleanup();return;}
this.setNextPhoto();this.beginTransition();};GFslideShow.prototype.snapToNextPhoto=function(){this.setOpacity(this.next,1);this.setOpacity(this.current,0);this.current=this.next;this.setDisplayTimer();if(this.options.transitionCallback){this.options.transitionCallback(this.entries[this.photo_index],this.options.transitionTime);}
if(this.options.fullControlPanel&&this.options.fullControlPanelCursor){var index=(this.photo_index+1)+' / '+this.images.length;this.fc.cursor.innerHTML=index;}}
GFslideShow.prototype.beginTransition=function(){if(!this.current||!this.next||(this.current==this.next)){this.setDisplayTimer();return;}
if(this.options.transitionTime>=this.options.transitionStep){this.setTransitionTimer();}else{this.snapToNextPhoto();}};GFslideShow.prototype.finishTransition=function(){this.clearTransitionTimer();this.snapToNextPhoto();};GFslideShow.prototype.setOpacity=function(image,opacity){if(image==null)return;opacity=Math.max(0,Math.min(1,opacity));if(opacity==0){if(image.style.visibility!="hidden"){image.style.visibility="hidden";}}else{if(image.style.visibility!="visible"){image.style.visibility="visible";}}
if(this.ie)image.style.filter="alpha(opacity="+opacity*100+")";image.style.opacity=image.opacity=opacity;};/* --------- /javascripts/gmaps/markermanager.js --------- */ 

function MarkerManager(map,opt_opts){var me=this;me.map_=map;me.mapZoom_=map.getZoom();me.projection_=map.getCurrentMapType().getProjection();opt_opts=opt_opts||{};me.tileSize_=MarkerManager.DEFAULT_TILE_SIZE_;var maxZoom=MarkerManager.DEFAULT_MAX_ZOOM_;if(opt_opts.maxZoom!=undefined){maxZoom=opt_opts.maxZoom;}
me.maxZoom_=maxZoom;me.trackMarkers_=opt_opts.trackMarkers;var padding;if(typeof opt_opts.borderPadding=="number"){padding=opt_opts.borderPadding;}else{padding=MarkerManager.DEFAULT_BORDER_PADDING_;}
me.swPadding_=new GSize(-padding,padding);me.nePadding_=new GSize(padding,-padding);me.borderPadding_=padding;me.gridWidth_=[];me.grid_=[];me.grid_[maxZoom]=[];me.numMarkers_=[];me.numMarkers_[maxZoom]=0;GEvent.bind(map,"moveend",me,me.onMapMoveEnd_);me.removeOverlay_=function(marker){map.removeOverlay(marker);me.shownMarkers_--;};me.addOverlay_=function(marker){map.addOverlay(marker);me.shownMarkers_++;};me.resetManager_();me.shownMarkers_=0;me.shownBounds_=me.getMapGridBounds_();};MarkerManager.DEFAULT_TILE_SIZE_=1024;MarkerManager.DEFAULT_MAX_ZOOM_=17;MarkerManager.DEFAULT_BORDER_PADDING_=100;MarkerManager.MERCATOR_ZOOM_LEVEL_ZERO_RANGE=256;MarkerManager.prototype.resetManager_=function(){var me=this;var mapWidth=MarkerManager.MERCATOR_ZOOM_LEVEL_ZERO_RANGE;for(var zoom=0;zoom<=me.maxZoom_;++zoom){me.grid_[zoom]=[];me.numMarkers_[zoom]=0;me.gridWidth_[zoom]=Math.ceil(mapWidth/me.tileSize_);mapWidth<<=1;}};MarkerManager.prototype.clearMarkers=function(){var me=this;me.processAll_(me.shownBounds_,me.removeOverlay_);me.resetManager_();};MarkerManager.prototype.getTilePoint_=function(latlng,zoom,padding){var pixelPoint=this.projection_.fromLatLngToPixel(latlng,zoom);return new GPoint(Math.floor((pixelPoint.x+padding.width)/this.tileSize_),Math.floor((pixelPoint.y+padding.height)/this.tileSize_));};MarkerManager.prototype.addMarkerBatch_=function(marker,minZoom,maxZoom){var mPoint=marker.getPoint();if(this.trackMarkers_){GEvent.bind(marker,"changed",this,this.onMarkerMoved_);}
var gridPoint=this.getTilePoint_(mPoint,maxZoom,GSize.ZERO);for(var zoom=maxZoom;zoom>=minZoom;zoom--){var cell=this.getGridCellCreate_(gridPoint.x,gridPoint.y,zoom);cell.push(marker);gridPoint.x=gridPoint.x>>1;gridPoint.y=gridPoint.y>>1;}};MarkerManager.prototype.isGridPointVisible_=function(point){var me=this;var vertical=me.shownBounds_.minY<=point.y&&point.y<=me.shownBounds_.maxY;var minX=me.shownBounds_.minX;var horizontal=minX<=point.x&&point.x<=me.shownBounds_.maxX;if(!horizontal&&minX<0){var width=me.gridWidth_[me.shownBounds_.z];horizontal=minX+width<=point.x&&point.x<=width-1;}
return vertical&&horizontal;}
MarkerManager.prototype.onMarkerMoved_=function(marker,oldPoint,newPoint){var me=this;var zoom=me.maxZoom_;var changed=false;var oldGrid=me.getTilePoint_(oldPoint,zoom,GSize.ZERO);var newGrid=me.getTilePoint_(newPoint,zoom,GSize.ZERO);while(zoom>=0&&(oldGrid.x!=newGrid.x||oldGrid.y!=newGrid.y)){var cell=me.getGridCellNoCreate_(oldGrid.x,oldGrid.y,zoom);if(cell){if(me.removeFromArray(cell,marker)){me.getGridCellCreate_(newGrid.x,newGrid.y,zoom).push(marker);}}
if(zoom==me.mapZoom_){if(me.isGridPointVisible_(oldGrid)){if(!me.isGridPointVisible_(newGrid)){me.removeOverlay_(marker);changed=true;}}else{if(me.isGridPointVisible_(newGrid)){me.addOverlay_(marker);changed=true;}}}
oldGrid.x=oldGrid.x>>1;oldGrid.y=oldGrid.y>>1;newGrid.x=newGrid.x>>1;newGrid.y=newGrid.y>>1;--zoom;}
if(changed){me.notifyListeners_();}};MarkerManager.prototype.removeMarker=function(marker){var me=this;var zoom=me.maxZoom_;var changed=false;var point=marker.getPoint();var grid=me.getTilePoint_(point,zoom,GSize.ZERO);while(zoom>=0){var cell=me.getGridCellNoCreate_(grid.x,grid.y,zoom);if(cell){me.removeFromArray(cell,marker);}
if(zoom==me.mapZoom_){if(me.isGridPointVisible_(grid)){me.removeOverlay_(marker);changed=true;}}
grid.x=grid.x>>1;grid.y=grid.y>>1;--zoom;}
if(changed){me.notifyListeners_();}};MarkerManager.prototype.addMarkers=function(markers,minZoom,opt_maxZoom){var maxZoom=this.getOptMaxZoom_(opt_maxZoom);for(var i=markers.length-1;i>=0;i--){this.addMarkerBatch_(markers[i],minZoom,maxZoom);}
this.numMarkers_[minZoom]+=markers.length;};MarkerManager.prototype.getOptMaxZoom_=function(opt_maxZoom){return opt_maxZoom!=undefined?opt_maxZoom:this.maxZoom_;}
MarkerManager.prototype.getMarkerCount=function(zoom){var total=0;for(var z=0;z<=zoom;z++){total+=this.numMarkers_[z];}
return total;};MarkerManager.prototype.addMarker=function(marker,minZoom,opt_maxZoom){var me=this;var maxZoom=this.getOptMaxZoom_(opt_maxZoom);me.addMarkerBatch_(marker,minZoom,maxZoom);var gridPoint=me.getTilePoint_(marker.getPoint(),me.mapZoom_,GSize.ZERO);if(me.isGridPointVisible_(gridPoint)&&minZoom<=me.shownBounds_.z&&me.shownBounds_.z<=maxZoom){me.addOverlay_(marker);me.notifyListeners_();}
this.numMarkers_[minZoom]++;};GBounds.prototype.containsPoint=function(point){var outer=this;return(outer.minX<=point.x&&outer.maxX>=point.x&&outer.minY<=point.y&&outer.maxY>=point.y);}
MarkerManager.prototype.getGridCellCreate_=function(x,y,z){var grid=this.grid_[z];if(x<0){x+=this.gridWidth_[z];}
var gridCol=grid[x];if(!gridCol){gridCol=grid[x]=[];return gridCol[y]=[];}
var gridCell=gridCol[y];if(!gridCell){return gridCol[y]=[];}
return gridCell;};MarkerManager.prototype.getGridCellNoCreate_=function(x,y,z){var grid=this.grid_[z];if(x<0){x+=this.gridWidth_[z];}
var gridCol=grid[x];return gridCol?gridCol[y]:undefined;};MarkerManager.prototype.getGridBounds_=function(bounds,zoom,swPadding,nePadding){zoom=Math.min(zoom,this.maxZoom_);var bl=bounds.getSouthWest();var tr=bounds.getNorthEast();var sw=this.getTilePoint_(bl,zoom,swPadding);var ne=this.getTilePoint_(tr,zoom,nePadding);var gw=this.gridWidth_[zoom];if(tr.lng()<bl.lng()||ne.x<sw.x){sw.x-=gw;}
if(ne.x-sw.x+1>=gw){sw.x=0;ne.x=gw-1;}
var gridBounds=new GBounds([sw,ne]);gridBounds.z=zoom;return gridBounds;};MarkerManager.prototype.getMapGridBounds_=function(){var me=this;return me.getGridBounds_(me.map_.getBounds(),me.mapZoom_,me.swPadding_,me.nePadding_);};MarkerManager.prototype.onMapMoveEnd_=function(){var me=this;me.objectSetTimeout_(this,this.updateMarkers_,0);};MarkerManager.prototype.objectSetTimeout_=function(object,command,milliseconds){return window.setTimeout(function(){command.call(object);},milliseconds);};MarkerManager.prototype.refresh=function(){var me=this;if(me.shownMarkers_>0){me.processAll_(me.shownBounds_,me.removeOverlay_);}
me.processAll_(me.shownBounds_,me.addOverlay_);me.notifyListeners_();};MarkerManager.prototype.updateMarkers_=function(){var me=this;me.mapZoom_=this.map_.getZoom();var newBounds=me.getMapGridBounds_();if(newBounds.equals(me.shownBounds_)&&newBounds.z==me.shownBounds_.z){return;}
if(newBounds.z!=me.shownBounds_.z){me.processAll_(me.shownBounds_,me.removeOverlay_);me.processAll_(newBounds,me.addOverlay_);}else{me.rectangleDiff_(me.shownBounds_,newBounds,me.removeCellMarkers_);me.rectangleDiff_(newBounds,me.shownBounds_,me.addCellMarkers_);}
me.shownBounds_=newBounds;me.notifyListeners_();};MarkerManager.prototype.notifyListeners_=function(){GEvent.trigger(this,"changed",this.shownBounds_,this.shownMarkers_);};MarkerManager.prototype.processAll_=function(bounds,callback){for(var x=bounds.minX;x<=bounds.maxX;x++){for(var y=bounds.minY;y<=bounds.maxY;y++){this.processCellMarkers_(x,y,bounds.z,callback);}}};MarkerManager.prototype.processCellMarkers_=function(x,y,z,callback){var cell=this.getGridCellNoCreate_(x,y,z);if(cell){for(var i=cell.length-1;i>=0;i--){callback(cell[i]);}}};MarkerManager.prototype.removeCellMarkers_=function(x,y,z){this.processCellMarkers_(x,y,z,this.removeOverlay_);};MarkerManager.prototype.addCellMarkers_=function(x,y,z){this.processCellMarkers_(x,y,z,this.addOverlay_);};MarkerManager.prototype.rectangleDiff_=function(bounds1,bounds2,callback){var me=this;me.rectangleDiffCoords(bounds1,bounds2,function(x,y){callback.apply(me,[x,y,bounds1.z]);});};MarkerManager.prototype.rectangleDiffCoords=function(bounds1,bounds2,callback){var minX1=bounds1.minX;var minY1=bounds1.minY;var maxX1=bounds1.maxX;var maxY1=bounds1.maxY;var minX2=bounds2.minX;var minY2=bounds2.minY;var maxX2=bounds2.maxX;var maxY2=bounds2.maxY;for(var x=minX1;x<=maxX1;x++){for(var y=minY1;y<=maxY1&&y<minY2;y++){callback(x,y);}
for(var y=Math.max(maxY2+1,minY1);y<=maxY1;y++){callback(x,y);}}
for(var y=Math.max(minY1,minY2);y<=Math.min(maxY1,maxY2);y++){for(var x=Math.min(maxX1+1,minX2)-1;x>=minX1;x--){callback(x,y);}
for(var x=Math.max(minX1,maxX2+1);x<=maxX1;x++){callback(x,y);}}};MarkerManager.prototype.removeFromArray=function(array,value,opt_notype){var shift=0;for(var i=0;i<array.length;++i){if(array[i]===value||(opt_notype&&array[i]==value)){array.splice(i--,1);shift++;}}
return shift;};/* --------- /javascripts/gmaps/pano_layer.js --------- */ 

function PanoramioLayerCallback(json,panoLayer){this.panoLayer=panoLayer;for(var i=0;i<json.photos.length;i++){var photo=json.photos[i];if(!panoLayer.ids[photo.photo_id]){var marker=this.createMarker(photo,panoLayer.markerIcon);panoLayer.mgr.addMarker(marker,0);panoLayer.ids[photo.photo_id]="exists";panoLayer.mgr.addMarker(marker,panoLayer.map.getZoom());}}}
PanoramioLayerCallback.prototype.formImgUrl=function(photoId,imgType){return'http://www.panoramio.com/photos/'+imgType+'/'+photoId+'.jpg';}
PanoramioLayerCallback.prototype.formPageUrl=function(photoId){return'http://www.panoramio.com/photo/'+photoId;}
PanoramioLayerCallback.prototype.createMarker=function(photo,baseIcon){var me=this;var markerIcon=new GIcon(baseIcon);markerIcon.image=this.formImgUrl(photo.photo_id,"mini_square");var marker=new GMarker(new GLatLng(photo.latitude,photo.longitude),{icon:markerIcon,title:photo.photo_title});if(photo.photo_title.length>33){photo.photo_title=photo.photo_title.substring(0,33)+"&#8230;";}
var html="<div id='infowin' style='height:320px; width:240px;'>"+"<p><a href='http://www.panoramio.com/' target='_blank'>"+"<img src='http://www.panoramio.com/img/logo-small.gif' border='0' width='119px' height='25px' alt='Panoramio logo' /><\/a></p>"+"<a id='photo_infowin' target='_blank' href='"+photo.photo_url+"'>"+"<img border='0' width='"+photo.width+"' height='"+photo.height+"' src='"+photo.photo_file_url+"'/><\/a>"+"<div style='overflow: hidden; width: 240px;'>"+"<p><a target='_blank' class='photo_title' href='"+photo.photo_url+"'><strong>"+photo.photo_title+"<\/strong><\/a></p>"+"<p>Posted by <a target='_blank' href='"+photo.owner_url+"'>"+
photo.owner_name+"<\/a></p><\/div>"+"<\/div>";marker.html=html;GEvent.addListener(marker,"click",function(){me.panoLayer.map.openInfoWindow(marker.getLatLng(),marker.html,{noCloseOnClick:true});});return marker;}
function PanoramioLayer(map,opt_opts){var me=this;me.map=map;me.ids={};me.mgr=new MarkerManager(map,{maxZoom:19});var icon=new GIcon();icon.image="http://www.panoramio.com/img/panoramio-marker.png";icon.shadow="";icon.iconSize=new GSize(24,24);icon.shadowSize=new GSize(22,22);icon.iconAnchor=new GPoint(9,9);icon.infoWindowAnchor=new GPoint(9,0);me.markerIcon=icon;me.enabled=false;GEvent.addListener(map,"moveend",function(){if(me.enabled){var bounds=map.getBounds();var southWest=bounds.getSouthWest();var northEast=bounds.getNorthEast();me.load(me,{maxy:northEast.lat(),miny:southWest.lat(),maxx:northEast.lng(),minx:southWest.lng()});}});}
PanoramioLayer.prototype.enable=function(){this.enabled=true;GEvent.trigger(this.map,"moveend");}
PanoramioLayer.prototype.disable=function(){this.enabled=false;this.mgr.clearMarkers();this.ids={};}
PanoramioLayer.prototype.getEnabled=function(){return this.enabled;}
PanoramioLayer.prototype.load=function(panoLayer,userOptions){var options={order:"popularity",set:"public",from:"0",to:"10",minx:"-180",miny:"-90",maxx:"180",maxy:"90",size:"small"};for(optionName in userOptions){if(userOptions.hasOwnProperty(optionName)){options[optionName]=userOptions[optionName];}}
var url="http://www.panoramio.com/map/get_panoramas.php?";var uniqueID="";for(optionName in options){if(options.hasOwnProperty(optionName)){var optionVal=""+options[optionName]+"";url+=optionName+"="+optionVal+"&";uniqueID+=optionVal.replace(/[^\w]+/g,"");}}
var callbackName="PanoramioLayerCallback.loader"+uniqueID;eval(callbackName+" = function(json) { var pa = new PanoramioLayerCallback(json, panoLayer);}");var script=document.createElement('script');script.setAttribute('src',url+'callback='+callbackName);script.setAttribute('id','jsonScript');script.setAttribute('type','text/javascript');document.documentElement.firstChild.appendChild(script);}/* --------- /javascripts/gmaps/pano_maptypecontrol.js --------- */ 

function PanoMapTypeControl(opt_opts){this.options=opt_opts||{};}
PanoMapTypeControl.prototype=new GControl();PanoMapTypeControl.prototype.initialize=function(map){var container=document.createElement("div");var me=this;var panoDiv=me.createButton_("Panoramio");panoDiv.style.marginRight="8px";GEvent.addDomListener(panoDiv,"click",function(){if(me.panoLayer){if(me.panoLayer.getEnabled()){me.panoLayer.disable();}else{me.panoLayer.enable();}}else{me.panoLayer=new PanoramioLayer(map);me.panoLayer.enable();}
me.toggleButton_(panoDiv.firstChild,me.panoLayer.getEnabled());});me.toggleButton_(panoDiv.firstChild,false);container.appendChild(panoDiv);map.getContainer().appendChild(container);GEvent.trigger(map,"maptypechanged");return container;}
PanoMapTypeControl.prototype.createButton_=function(text){var buttonDiv=document.createElement("div");this.setButtonStyle_(buttonDiv);buttonDiv.style.cssFloat="left";buttonDiv.style.styleFloat="left";var textDiv=document.createElement("div");textDiv.appendChild(document.createTextNode(text));textDiv.style.width="6em";buttonDiv.appendChild(textDiv);return buttonDiv;}
PanoMapTypeControl.prototype.assignButtonEvent_=function(div,map,mapType,otherDivs){var me=this;GEvent.addDomListener(div,"click",function(){for(var i=0;i<otherDivs.length;i++){me.toggleButton_(otherDivs[i].firstChild,false);}
me.toggleButton_(div.firstChild,true);map.setMapType(mapType);});}
PanoMapTypeControl.prototype.toggleButton_=function(div,boolCheck){div.style.fontWeight=boolCheck?"bold":"";div.style.border="1px solid white";var shadows=boolCheck?["Top","Left"]:["Bottom","Right"];for(var j=0;j<shadows.length;j++){div.style["border"+shadows[j]]="1px solid #b0b0b0";}}
PanoMapTypeControl.prototype.getDefaultPosition=function(){return new GControlPosition(G_ANCHOR_TOP_RIGHT,new GSize(150,7));}
PanoMapTypeControl.prototype.setButtonStyle_=function(button){button.style.color="#000000";button.style.backgroundColor="white";button.style.font="small Arial";button.style.border="1px solid black";button.style.padding="0px";button.style.margin="0px";button.style.textAlign="center";button.style.fontSize="12px";button.style.cursor="pointer";}
