(function(){var images='/skin/frontend/prologislive/default/images/',markerClusterer=null,markerImage,shadowImage,map=null,large=window.large||false,styles=[{url:images+'cluster.png',height:35,width:35,textColor:'#fff',textSize:12}],locationLength=null,infoWindows=[],latLng=null;function refreshMap(){if(markerClusterer){markerClusterer.clearMarkers();}
var markers=[],i=0,marker=null;for(;i<locationLength;i++){var content='<li><a href="'+LOCATION[i].url+'"><img src="'+LOCATION[i].image+'" width="60" /></a><a href="'+LOCATION[i].url+'">'+LOCATION[i].address+'</a><br /><br /><a class="atp" href="/wishlist/index/add/product/'+LOCATION[i].id+'/">Add to \'My Properties\'</a></li>';latLng=new google.maps.LatLng(LOCATION[i].position.lat,LOCATION[i].position.long);marker=new google.maps.Marker({animation:google.maps.Animation.DROP,content:content,icon:markerImage,position:latLng,shadow:shadowImage});markers.push(marker);}
markerClusterer=new MarkerClusterer(map,markers,{styles:styles,zoomOnClick:false});}
function centerMap(){var bounds=new google.maps.LatLngBounds(),i=0,latLng=null;for(;i<locationLength;i++){latLng=new google.maps.LatLng(LOCATION[i].position.lat,LOCATION[i].position.long);bounds.extend(latLng);}
map.fitBounds(bounds);}
function addListeners(){var infoWindow=null,markers=markerClusterer.getMarkers();google.maps.event.addListener(markerClusterer,'clustermouseover',function(e){var markersLength=e.getMarkers().length,content=['<div class="block block-infobox">','<div class="block-title"><strong>'+markersLength+' Properties</strong></div>','<div class="block-content">','<ul>'],i=0;for(;i<markersLength;i++){content.push(e.markers_[i].content);}
content.push('</ul>','</div>','</div>');content=content.join('');infoWindow=new InfoBox({boxStyle:{background:'#fff',border:'1px solid #ccc',padding:'5px',width:'200px'},content:content,position:e.getCenter()});infoWindows.push(infoWindow);infoWindow.open(map);});for(i=0;i<markers.length;i++){google.maps.event.addListener(markers[i],'click',function(){var content=['<div class="block block-infobox">','<div class="block-title"><strong>Property</strong></div>','<div class="block-content">','<ul>',this.content,'</ul>','</div>','</div>','</div>'];content=content.join('');new InfoBox({boxStyle:{background:'#fff',border:'1px solid #ccc',padding:'5px',width:'200px'},content:content,position:this.position}).open(map);});}}
var initialize=function(id){if(large){markerImage=new google.maps.MarkerImage(images+'marker_lrg.png',new google.maps.Size(20,34),new google.maps.Point(0,0),new google.maps.Point(10,34));shadowImage=new google.maps.MarkerImage(images+'shadow_lrg.png',new google.maps.Size(40,34),new google.maps.Point(0,0),new google.maps.Point(10,34));}else{markerImage=new google.maps.MarkerImage(images+'marker.png',new google.maps.Size(10,17),new google.maps.Point(0,0),new google.maps.Point(5,17));shadowImage=new google.maps.MarkerImage(images+'shadow.png',new google.maps.Size(22,17),new google.maps.Point(0,0),new google.maps.Point(5,17));}
map=new google.maps.Map(document.getElementById(id),{mapTypeId:google.maps.MapTypeId.ROADMAP});locationLength=LOCATION.length;refreshMap();centerMap();if(LOCATION[0].radius>0){var geocoder=new google.maps.Geocoder();geocoder.geocode({address:LOCATION[0].postcode},function(results,status){if(status==google.maps.GeocoderStatus.OK){var circle=new google.maps.Circle({center:results[0].geometry.location,fillColor:'#0E3A19',fillOpacity:.15,map:map,radius:LOCATION[0].radius*1609.344,strokeColor:'#0E3A19',strokeWeight:1});map.fitBounds(circle.getBounds());map.setCenter(results[0].geometry.location);}});}
if(id==='bigmap'||large){addListeners();}
google.maps.event.addListener(map,'zoom_changed',function(){var i=0;for(;i<infoWindows.length;i++){infoWindows[i].close();}});}
google.setOnLoadCallback(function(){initialize('map');setTimeout(function(){if(large){map.setZoom(17);map.setMapTypeId(google.maps.MapTypeId.HYBRID);}},100);});window.initialize=initialize;}());
