function ExtInfoWindow(c,d,a,b){this.html_=a;this.marker_=c;this.infoWindowId_=d;this.options_=b==null?{}:b;this.ajaxUrl_=this.options_.ajaxUrl==null?null:this.options_.ajaxUrl;this.callback_=this.options_.ajaxCallback==null?null:this.options_.ajaxCallback;this.borderSize_=this.options_.beakOffset==null?0:this.options_.beakOffset;this.paddingX_=this.options_.paddingX==null?0+this.borderSize_:this.options_.paddingX+this.borderSize_;this.paddingY_=this.options_.paddingY==null?0+this.borderSize_:this.options_.paddingY+this.borderSize_;this.map_=null;this.container_=document.createElement("div");this.container_.style.position="relative";this.container_.style.display="none";this.contentDiv_=document.createElement("div");this.contentDiv_.id=this.infoWindowId_+"_contents";this.contentDiv_.innerHTML=this.html_;this.contentDiv_.style.display="block";this.contentDiv_.style.visibility="hidden";this.wrapperDiv_=document.createElement("div")}ExtInfoWindow.prototype=new GOverlay();ExtInfoWindow.prototype.initialize=function(map){this.map_=map;this.defaultStyles={containerWidth:this.map_.getSize().width/2,borderSize:1};this.wrapperParts={tl:{t:0,l:0,w:0,h:0,domElement:null},t:{t:0,l:0,w:0,h:0,domElement:null},tr:{t:0,l:0,w:0,h:0,domElement:null},l:{t:0,l:0,w:0,h:0,domElement:null},r:{t:0,l:0,w:0,h:0,domElement:null},bl:{t:0,l:0,w:0,h:0,domElement:null},b:{t:0,l:0,w:0,h:0,domElement:null},br:{t:0,l:0,w:0,h:0,domElement:null},beak:{t:0,l:0,w:0,h:0,domElement:null},close:{t:0,l:0,w:0,h:0,domElement:null}};for(var i in this.wrapperParts){var tempElement=document.createElement("div");tempElement.id=this.infoWindowId_+"_"+i;tempElement.style.visibility="hidden";document.body.appendChild(tempElement);tempElement=document.getElementById(this.infoWindowId_+"_"+i);var tempWrapperPart=eval("this.wrapperParts."+i);tempWrapperPart.w=parseInt(this.getStyle_(tempElement,"width"));tempWrapperPart.h=parseInt(this.getStyle_(tempElement,"height"));document.body.removeChild(tempElement)}for(var i in this.wrapperParts){if(i=="close"){this.wrapperDiv_.appendChild(this.contentDiv_)}var wrapperPartsDiv=null;if(this.wrapperParts[i].domElement==null){wrapperPartsDiv=document.createElement("div");this.wrapperDiv_.appendChild(wrapperPartsDiv)}else{wrapperPartsDiv=this.wrapperParts[i].domElement}wrapperPartsDiv.id=this.infoWindowId_+"_"+i;wrapperPartsDiv.style.position="absolute";wrapperPartsDiv.style.width=this.wrapperParts[i].w+"px";wrapperPartsDiv.style.height=this.wrapperParts[i].h+"px";wrapperPartsDiv.style.top=this.wrapperParts[i].t+"px";wrapperPartsDiv.style.left=this.wrapperParts[i].l+"px";this.wrapperParts[i].domElement=wrapperPartsDiv}this.map_.getPane(G_MAP_FLOAT_PANE).appendChild(this.container_);this.container_.id=this.infoWindowId_;var containerWidth=this.getStyle_(document.getElementById(this.infoWindowId_),"width");this.container_.style.width=(containerWidth==null?this.defaultStyles.containerWidth:containerWidth);this.map_.getContainer().appendChild(this.contentDiv_);this.contentWidth=this.getDimensions_(this.container_).width;this.contentDiv_.style.width=this.contentWidth+"px";this.contentDiv_.style.position="absolute";this.container_.appendChild(this.wrapperDiv_);GEvent.bindDom(this.container_,"mousedown",this,this.onClick_);GEvent.bindDom(this.container_,"dblclick",this,this.onClick_);GEvent.bindDom(this.container_,"DOMMouseScroll",this,this.onClick_);GEvent.trigger(this.map_,"extinfowindowopen");if(this.ajaxUrl_!=null){this.ajaxRequest_(this.ajaxUrl_)}};ExtInfoWindow.prototype.onClick_=function(a){if(navigator.userAgent.toLowerCase().indexOf("msie")!=-1&&document.all){window.event.cancelBubble=true;window.event.returnValue=false}else{a.stopPropagation()}};ExtInfoWindow.prototype.remove=function(){if(this.map_.getExtInfoWindow()!=null){GEvent.trigger(this.map_,"extinfowindowbeforeclose");GEvent.clearInstanceListeners(this.container_);if(this.container_.outerHTML){this.container_.outerHTML=""}if(this.container_.parentNode){this.container_.parentNode.removeChild(this.container_)}this.container_=null;GEvent.trigger(this.map_,"extinfowindowclose");this.map_.setExtInfoWindow_(null)}};ExtInfoWindow.prototype.copy=function(){return new ExtInfoWindow(this.marker_,this.infoWindowId_,this.html_,this.options_)};ExtInfoWindow.prototype.redraw=function(a){if(!a||this.container_==null){return}var h=this.contentDiv_.offsetHeight;this.contentDiv_.style.height=h+"px";this.contentDiv_.style.left=this.wrapperParts.l.w+"px";this.contentDiv_.style.top=this.wrapperParts.tl.h+"px";this.contentDiv_.style.visibility="visible";this.wrapperParts.tl.t=0;this.wrapperParts.tl.l=0;this.wrapperParts.t.l=this.wrapperParts.tl.w;this.wrapperParts.t.w=(this.wrapperParts.l.w+this.contentWidth+this.wrapperParts.r.w)-this.wrapperParts.tl.w-this.wrapperParts.tr.w;this.wrapperParts.t.h=this.wrapperParts.tl.h;this.wrapperParts.tr.l=this.wrapperParts.t.w+this.wrapperParts.tl.w;this.wrapperParts.l.t=this.wrapperParts.tl.h;this.wrapperParts.l.h=h;this.wrapperParts.r.l=this.contentWidth+this.wrapperParts.l.w;this.wrapperParts.r.t=this.wrapperParts.tr.h;this.wrapperParts.r.h=h;this.wrapperParts.bl.t=h+this.wrapperParts.tl.h;this.wrapperParts.b.l=this.wrapperParts.bl.w;this.wrapperParts.b.t=h+this.wrapperParts.tl.h;this.wrapperParts.b.w=(this.wrapperParts.l.w+this.contentWidth+this.wrapperParts.r.w)-this.wrapperParts.bl.w-this.wrapperParts.br.w;this.wrapperParts.b.h=this.wrapperParts.bl.h;this.wrapperParts.br.l=this.wrapperParts.b.w+this.wrapperParts.bl.w;this.wrapperParts.br.t=h+this.wrapperParts.tr.h;this.wrapperParts.close.l=this.wrapperParts.tr.l+this.wrapperParts.tr.w-this.wrapperParts.close.w-this.borderSize_;this.wrapperParts.close.t=this.borderSize_;this.wrapperParts.beak.l=this.borderSize_+(this.contentWidth/2)-(this.wrapperParts.beak.w/2);this.wrapperParts.beak.t=this.wrapperParts.bl.t+this.wrapperParts.bl.h-this.borderSize_;for(var g in this.wrapperParts){if(g=="close"){this.wrapperDiv_.insertBefore(this.contentDiv_,this.wrapperParts[g].domElement)}var f=null;if(this.wrapperParts[g].domElement==null){f=document.createElement("div");this.wrapperDiv_.appendChild(f)}else{f=this.wrapperParts[g].domElement}f.id=this.infoWindowId_+"_"+g;f.style.position="absolute";f.style.width=this.wrapperParts[g].w+"px";f.style.height=this.wrapperParts[g].h+"px";f.style.top=this.wrapperParts[g].t+"px";f.style.left=this.wrapperParts[g].l+"px";this.wrapperParts[g].domElement=f}var c=this.marker_;var b=this.map_;GEvent.addDomListener(this.wrapperParts.close.domElement,"click",function(){b.closeExtInfoWindow()});var e=this.map_.fromLatLngToDivPixel(this.marker_.getPoint());this.container_.style.position="absolute";var d=this.marker_.getIcon();this.container_.style.left=(e.x-(this.contentWidth/2)-d.iconAnchor.x+d.infoWindowAnchor.x)+"px";this.container_.style.top=(e.y-this.wrapperParts.bl.h-h-this.wrapperParts.tl.h-this.wrapperParts.beak.h-d.iconAnchor.y+d.infoWindowAnchor.y+this.borderSize_)+"px";this.container_.style.display="block";if(this.map_.getExtInfoWindow()!=null){this.repositionMap_()}};ExtInfoWindow.prototype.resize=function(){var e=this.contentDiv_.cloneNode(true);e.id=this.infoWindowId_+"_tempContents";e.style.visibility="hidden";e.style.height="auto";document.body.appendChild(e);e=document.getElementById(this.infoWindowId_+"_tempContents");var b=e.offsetHeight;document.body.removeChild(e);this.contentDiv_.style.height=b+"px";var f=this.contentDiv_.offsetWidth;var a=this.map_.fromLatLngToDivPixel(this.marker_.getPoint());var g=this.wrapperParts.t.domElement.offsetHeight+this.wrapperParts.l.domElement.offsetHeight+this.wrapperParts.b.domElement.offsetHeight;var d=this.wrapperParts.t.domElement.offsetTop;this.wrapperParts.l.domElement.style.height=b+"px";this.wrapperParts.r.domElement.style.height=b+"px";var c=this.wrapperParts.b.domElement.offsetTop-b;this.wrapperParts.l.domElement.style.top=c+"px";this.wrapperParts.r.domElement.style.top=c+"px";this.contentDiv_.style.top=c+"px";windowTHeight=parseInt(this.wrapperParts.t.domElement.style.height);c-=windowTHeight;this.wrapperParts.close.domElement.style.top=c+this.borderSize_+"px";this.wrapperParts.tl.domElement.style.top=c+"px";this.wrapperParts.t.domElement.style.top=c+"px";this.wrapperParts.tr.domElement.style.top=c+"px";this.repositionMap_()};ExtInfoWindow.prototype.repositionMap_=function(){var r=this.map_.fromLatLngToDivPixel(this.map_.getBounds().getNorthEast());var b=this.map_.fromLatLngToDivPixel(this.map_.getBounds().getSouthWest());var p=this.map_.fromLatLngToDivPixel(this.marker_.getPoint());var k=0;var g=0;var c=this.paddingX_;var a=this.paddingY_;var h=this.marker_.getIcon().infoWindowAnchor;var f=this.marker_.getIcon().iconAnchor;var l=this.wrapperParts.t.domElement;var q=this.wrapperParts.l.domElement;var m=this.wrapperParts.b.domElement;var o=this.wrapperParts.r.domElement;var d=this.wrapperParts.beak.domElement;var e=p.y-(-h.y+f.y+this.getDimensions_(d).height+this.getDimensions_(m).height+this.getDimensions_(q).height+this.getDimensions_(l).height+this.paddingY_);if(e<r.y){g=r.y-e}else{var n=p.y+this.paddingY_;if(n>=b.y){g=-(n-b.y)}}var i=Math.round(p.x+this.getDimensions_(this.container_).width/2+this.getDimensions_(o).width+this.paddingX_+h.x-f.x);if(i>r.x){k=-(i-r.x)}else{var j=-(Math.round((this.getDimensions_(this.container_).width/2-this.marker_.getIcon().iconSize.width/2)+this.getDimensions_(q).width+this.borderSize_+this.paddingX_)-p.x-h.x+f.x);if(j<b.x){k=b.x-j}}if(k!=0||g!=0&&this.map_.getExtInfoWindow()!=null){this.map_.panBy(new GSize(k,g))}};ExtInfoWindow.prototype.ajaxRequest_=function(b){var a=this.map_;var c=this.callback_;GDownloadUrl(b,function(d,f){var e=document.getElementById(a.getExtInfoWindow().infoWindowId_+"_contents");if(d==null||f==-1){e.innerHTML='<span class="error">ERROR: The Ajax request failed to get HTML content from "'+b+'"</span>'}else{e.innerHTML=d}if(c!=null){c()}a.getExtInfoWindow().resize();GEvent.trigger(a,"extinfowindowupdate")})};ExtInfoWindow.prototype.getDimensions_=function(f){var b=this.getStyle_(f,"display");if(b!="none"&&b!=null){return{width:f.offsetWidth,height:f.offsetHeight}}var e=f.style;var a=e.visibility;var g=e.position;var d=e.display;e.visibility="hidden";e.position="absolute";e.display="block";var c=f.clientWidth;var h=f.clientHeight;e.display=d;e.position=g;e.visibility=a;return{width:c,height:h}};ExtInfoWindow.prototype.getStyle_=function(e,a){var c=false;a=this.camelize_(a);var b=e.style[a];if(!b){if(document.defaultView&&document.defaultView.getComputedStyle){var d=document.defaultView.getComputedStyle(e,null);b=d?d[a]:null}else{if(e.currentStyle){b=e.currentStyle[a]}}}if((b=="auto")&&(a=="width"||a=="height")&&(this.getStyle_(e,"display")!="none")){if(a=="width"){b=e.offsetWidth}else{b=e.offsetHeight}}return(b=="auto")?null:b};ExtInfoWindow.prototype.camelize_=function(a){var c=a.split("-"),d=c.length;if(d==1){return c[0]}var b=a.charAt(0)=="-"?c[0].charAt(0).toUpperCase()+c[0].substring(1):c[0];for(var e=1;e<d;e++){b+=c[e].charAt(0).toUpperCase()+c[e].substring(1)}return b};GMap.prototype.ExtInfoWindowInstance_=null;GMap.prototype.ClickListener_=null;GMap.prototype.InfoWindowListener_=null;GMarker.prototype.openExtInfoWindow=function(d,b,c,a){if(d==null){throw"Error in GMarker.openExtInfoWindow: map cannot be null";return false}if(b==null||b==""){throw"Error in GMarker.openExtInfoWindow: must specify a cssId";return false}d.closeInfoWindow();if(d.getExtInfoWindow()!=null){d.closeExtInfoWindow()}if(d.getExtInfoWindow()==null){d.setExtInfoWindow_(new ExtInfoWindow(this,b,c,a));if(d.ClickListener_==null){d.ClickListener_=GEvent.addListener(d,"click",function(e){if(!e&&d.getExtInfoWindow()!=null){d.closeExtInfoWindow()}})}if(d.InfoWindowListener_==null){d.InfoWindowListener_=GEvent.addListener(d,"infowindowopen",function(e){if(d.getExtInfoWindow()!=null){d.closeExtInfoWindow()}})}d.addOverlay(d.getExtInfoWindow())}};GMarker.prototype.closeExtInfoWindow=function(a){if(a.getExtInfWindow()!=null){a.closeExtInfoWindow()}};GMap2.prototype.getExtInfoWindow=function(){return this.ExtInfoWindowInstance_};GMap2.prototype.setExtInfoWindow_=function(a){this.ExtInfoWindowInstance_=a};GMap2.prototype.closeExtInfoWindow=function(){if(this.getExtInfoWindow()!=null){this.ExtInfoWindowInstance_.remove()}};
