;$.fn.extend({find_pos:function(){if(!this.tagName&&this.length){obj=this[0]}else{return[0,0]}
var a=curtop=0;if(obj.offsetParent){a=obj.offsetLeft;curtop=obj.offsetTop;while(obj=obj.offsetParent){a+=obj.offsetLeft;curtop+=obj.offsetTop}}
return[a,curtop]}});function MapTips(o){var p=this;var q=o;this.add_tooltip=function(a,b){a.tooltip=b;GEvent.addListener(a,"mouseover",p.show_tooltip);GEvent.addListener(a,"mouseout",p.hide_tooltip)};this.show_tooltip=function(a){var b=q.fromLatLngToContainerPixel(this.getLatLng());$("body").append('<p id="maptip" style="visibility: hidden;">'+this.tooltip+'</p>');var c=$(q.getContainer()).find_pos();var d=c[0];var e=c[0]+$(q.getContainer()).width();var f=c[1];var g=this.getIcon().iconSize;c[0]+=b.x;c[1]+=b.y-g.height;var h=$("#maptip")[0].offsetWidth/2;var i=$("#maptip")[0].offsetHeight+3;var j=c[0]-h;var k=c[1]-i;var l=c[0]-h;var m=c[0]-h+$("#maptip")[0].offsetWidth;var n=c[1]-i;if(d>=l){j+=d-l+3}else if(e<=m){j-=m-e+3}
if(f>=n){k+=$("#maptip")[0].offsetHeight+g.height+6}
$("#maptip").css("left",j).css("top",k).css("visibility","visible");$("#maptip").fadeIn("medium")};this.hide_tooltip=function(){$("#maptip").remove()}};function GMPoint(){this.latitude=0.0;this.longitude=0.0;this.toolTipHTML='';this.detailsHTML='';this.icon='';this.redirectURL='';this.redirectInNewWindow=false};function GoogleMap(){this.map=null;this.points=new Array();this.coordinates=new Array();this.gmap_div_id='';this.gmap_loader_div='';this.loadedTo=0;this.tooltip='';var h=this;var j=null;this.initGMap=function(a,b,c,d){c=typeof(c)!='undefined'?c:0;d=typeof(d)!='undefined'?d:0;if(GBrowserIsCompatible()){this.gmap_div_id=a;this.gmap_loader_div=b;document.getElementById(this.gmap_loader_div).style.display='block';document.getElementById(this.gmap_div_id).style.display='block';this.map=new GMap2(document.getElementById(this.gmap_div_id));this.map.setCenter(new GLatLng(c,d),10);this.maptips=new MapTips(this.map)}else{this.map=false}};this.addPoint=function(a,b,c,d,e,f,g){var p=new GMPoint();this.points.push(new GLatLng(a,b));d=typeof(d)!='undefined'?d:'';e=typeof(e)!='undefined'?e:'';onClickRedirect=typeof(onClickRedirect)!='undefined'?onClickRedirect:false;f=typeof(f)!='undefined'?f:'';g=typeof(g)!='undefined'?g:false;if(e.length)f='';p.latitude=a;p.longitude=b;p.toolTipHTML=d;p.detailsHTML=e;p.icon=c;p.redirectURL=f;p.redirectInNewWindow=g;this.coordinates.push(p)};this.modalOpen=function(a){a.overlay.fadeIn('fast',function(){a.container.fadeIn('fast',function(){a.data.hide().slideDown('slow')})})};this.createMarker=function(a,b,c){var d=new GMarker(a,b);var e=document.createElement("div");if(c.detailsHTML.length){GEvent.addListener(d,"click",function(){$(c.detailsHTML).modal({onOpen:h.modalOpen})})}else if(c.redirectURL.length){if(c.redirectInNewWindow){GEvent.addListener(d,"click",function(){window.open(c.redirectURL)})}else{GEvent.addListener(d,"click",function(){window.location=c.redirectURL})}};return d};this.plotMap=function(){if(!this.map)return false;var a=null;var b=null;var c='Name';var d=null;var e=this.map.getCurrentMapType().getProjection().fromLatLngToPixel(this.map.getBounds().getSouthWest(),this.map.getZoom());var f=this.map.getDefaultUI();f.controls.scalecontrol=true;f.controls.largemapcontrol3d=true;f.maptypes.hybrid=false;f.maptypes.physical=false;this.map.setUI(f);for(var i=0;i<this.coordinates.length;i++){d=this.coordinates[i];a=new GLatLng(d.latitude,d.longitude);b=new GIcon(G_DEFAULT_ICON);if(d.icon.length)b.image=d.icon;var g=this.createMarker(a,b,d);this.map.addOverlay(g);this.maptips.add_tooltip(g,d.toolTipHTML)};this.fitMap();this.loadedTo=setTimeout(function(){h.checkLoaded()},2500)};this.checkLoaded=function(){if(!this.map){clearTimeout(this.loadedTo);return false};if(this.map.isLoaded()){clearTimeout(this.loadedTo);document.getElementById(this.gmap_loader_div).style.display='none';var a=document.getElementById(this.gmap_div_id).style;a.opacity=1;a.MozOpacity=1;a.KhtmlOpacity=1;a.filter="alpha(opacity="+100+")";a.position='relative';if(typeof onMapLoaded=='function'){onMapLoaded();}}};this.fitMap=function(){if(!this.map)return false;var a=new GLatLngBounds();for(var i=0;i<this.points.length;i++){a.extend(this.points[i])}
this.map.setZoom(this.map.getBoundsZoomLevel(a));this.map.setCenter(a.getCenter())};this.clearOverlays=function(){if(!this.map)return false;while(this.coordinates.length){this.coordinates.pop()}
while(this.points.length){this.points.pop()}
this.map.clearOverlays();return true};this.removeMapType=function(a){if(!this.map)return false;this.map.removeMapType(a)};this.dispose=function(){this.selfObj=null;map=null;GUnload()}};