(function(){
/*
 OverlappingMarkerSpiderfier
https://github.com/jawj/OverlappingMarkerSpiderfier
Copyright (c) 2011 George MacKerron
Released under the MIT licence: http://opensource.org/licenses/mit-license
*/
var l=null;
(function(){
  function n(j,h){
    return function(){
      return j.apply(h,arguments)
    }
  }
  var p=Array.prototype.slice;
  this.OverlappingMarkerSpiderfier=function(){
    function j(b){
      var c,f,d;
      this.map=b;
      this.i=new this.constructor.b(this.map);
      this.d=[];
      this.f={};
      d=["click","zoom_changed","maptypeid_changed"];
      c=0;
      for(f=d.length;c<f;c++)b=d[c],h.event.addListener(this.map,b,n(function(){return this.m()},this))}
      var h,k,m,i,a,o;
      a=j.prototype;
      a.VERSION="0.1";
      h=google.maps;
      i=h.MapTypeId;
      o=Math.PI*2;
      a.nearbyDistance=20;
      a.circleSpiralSwitchover=9;
      a.circleFootSeparation=23;
      a.circleStartAngle=o/12;
      a.spiralFootSeparation=26;
      a.spiralLengthStart=11;
      a.spiralLengthFactor=4;
      a.usualZIndex=10;
      a.spiderfiedZIndex=1E4;
      a.usualLegZIndex=9;
      a.highlightedLegZIndex=9999;
      a.legWeight=1.5;
      a.legColors={usual:{},highlighted:{}};
      m=a.legColors.usual;
      k=a.legColors.highlighted;
      m[i.HYBRID]=m[i.SATELLITE]="#fff";
      k[i.HYBRID]=k[i.SATELLITE]="#f00";
      m[i.TERRAIN]=m[i.ROADMAP]="#444";
      k[i.TERRAIN]=k[i.ROADMAP]="#f00";
      a.addMarker=function(b){
        h.event.addListener(b,"click",n(function(){return this.w(b)},
this));
        b.setZIndex(this.usualZIndex);
        this.d.push(b);
      return this};
a.addListener=function(b,c){
var f,d;
((d=(f=this.f)[b])!=l?d:f[b]=[]).push(c);
return this};
a.trigger=function(){var q;var b,c,f,d,g,e;
c=arguments[0];
b=2<=arguments.length?p.call(arguments,1):[];
q=(f=this.f[c])!=l?f:[],c=q;
e=[];
d=0;
for(g=c.length;d<g;d++)
f=c[d],e.push(f.apply(l,b));
return e
};
a.t=function(b,c){var f,d,g,e,a,h,i,j;
e=[];
a=c*c;
g=this.g(b.position);
j=this.d;
h=0;
for(i=j.length;h<i;h++)f=j[h],d=this.g(f.position),this.j(d,g)<
a&&e.push({r:f,h:d});return e};
a.n=function(b,c){var f,d,g,e,a;e=this.circleFootSeparation*(2+b)/o;
d=o/b;
a=[];
for(g=0;0<=b?g<b:g>b;0<=b?g++:g--)f=this.circleStartAngle+g*d,a.push(new h.Point(c.x+e*Math.cos(f),c.y+e*Math.sin(f)));return a};
a.o=function(b,c){var f,d,a,e,i;
a=this.spiralLengthStart;
f=0;
i=[];
for(d=0;0<=b?d<b:d>b;0<=b?d++:d--)f+=this.spiralFootSeparation/a+d*5.0E-4,e=new h.Point(c.x+a*Math.cos(f),c.y+a*Math.sin(f)),a+=o*this.spiralLengthFactor/f,i.push(e);return i};
a.w=function(b){var c;
c=b.a!=l;
this.m();
return c?this.trigger("click",b):(c=this.t(b,this.nearbyDistance),c.length===1?this.trigger("click",b):this.z(c))};
a.q=function(b){
return{e:n(function(){return b.a.c.setOptions({strokeColor:this.legColors.highlighted[this.map.mapTypeId],zIndex:this.highlightedLegZIndex})},this),l:n(function(){return b.a.c.setOptions({strokeColor:this.legColors.usual[this.map.mapTypeId],zIndex:this.usualLegZIndex})},this)}};
a.z=function(b){var c,f,d,a,e,i,j,k,m;
this.k=!0;
d=b.length;
c=this.u(function(){var c,
a,d;d=[];c=0;for(a=b.length;c<a;c++)i=b[c],d.push(i.h);return d}());d=d>=this.circleSpiralSwitchover?this.o(d,c).reverse():this.n(d,c);j=[];k=0;
for(m=d.length;k<m;k++){
f=d[k];
c=this.v(f);
e=this.s(b,n(function(b){return this.j(b.h,f)},this));
e=e.r;
a=new h.Polyline({map:this.map,path:[e.position,c],strokeColor:this.legColors.usual[this.map.mapTypeId],strokeWeight:this.legWeight,zIndex:this.usualLegZIndex});
e.a={A:e.position,c:a};
if(this.legColors.highlighted[this.map.mapTypeId]!==this.legColors.usual[this.map.mapTypeId])a=
this.q(e),h.event.addListener(e,"mouseover",a.e),h.event.addListener(e,"mouseout",a.l),e.a.p=a;
e.setZIndex(this.spiderfiedZIndex+f.y);
e.setPosition(c);
j.push(e)}return this.trigger("spiderfy",j)};
a.m=function(){var b,c,a,d,g,e;if(this.k!=l){delete this.k;
a=[];
e=this.d;
d=0;
for(g=e.length;d<g;d++)
if(c=e[d],c.a!=l)c.a.c.setMap(l),c.setZIndex(this.usualZIndex),c.setPosition(c.a.A),b=c.a.p,b!=l&&(h.event.clearListeners(c,"mouseover",b.e),h.event.clearListeners(c,"mouseout",b.l)),delete c.a,a.push(c);return this.trigger("unspiderfy",
a)}};a.j=function(b,c){var a,d;a=b.x-c.x;d=b.y-c.y;return a*a+d*d};
a.u=function(b){var a,f,d,g,e;
g=f=d=0;
for(e=b.length;g<e;g++)a=b[g],f+=a.x,d+=a.y;
b=b.length;
return new h.Point(f/b,d/b)};
a.g=function(b){
  return this.i.getProjection().fromLatLngToDivPixel(b)};
  a.v=function(b){
    return this.i.getProjection().fromDivPixelToLatLng(b)};
    a.s=function(b,a){
      var f,d,g,e,h;
      g=0;
      for(h=b.length;g<h;g++)if(e=b[g],e=a(e),!(typeof f!=="undefined"&&f!==l)||e<d)d=e,f=g;
      return b.splice(f,1)[0]};
    j.b=function(a){return this.setMap(a)};
    j.b.prototype=new h.OverlayView;
    j.b.prototype.draw=function(){};
    return j
}()}).call(this);
}).call(this);
/* Wed 15 Jun 2011 11:00:16 BST */
