function ExtInfoWindow(marker,windowId,html,opt_opts){this.html_=html;this.marker_=marker;this.infoWindowId_=windowId;this.options_=opt_opts==null?{}:opt_opts;this.ajaxUrl_=this.options_.ajaxUrl==null?null:this.options_.ajaxUrl;this.callback_=this.options_.ajaxCallback==null?null:this.options_.ajaxCallback;this.maxContent_=this.options_.maxContent==null?null:this.options_.maxContent;this.maximizeEnabled_=this.maxContent_==null?false:true;this.isMaximized_=false;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;if(this.maximizeEnabled_){this.maxWidth_=this.map_.getSize().width*0.9;this.maxHeight_=this.map_.getSize().height*0.9}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}};if(this.maximizeEnabled_){this.wrapperParts.max={t:0,l:0,w:0,h:0,domElement:null};this.wrapperParts.min={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=this.wrapperParts[i];tempWrapperPart.w=parseInt(this.getStyle_(tempElement,'width'),10);tempWrapperPart.h=parseInt(this.getStyle_(tempElement,'height'),10);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_);if(this.maximizeEnabled_){this.minWidth_=this.getDimensions_(this.container_).width;console.log(this.minWidth_)}if(this.maximizeEnabled_){thisMap=this.map_;thisMaxWidth=this.maxWidth_;thisMaxHeight=this.maxHeight_;thisContainer=this.container_;thisMaxContent=this.maxContent_;thisMinWidth=this.container_.style.width;thisMinHeight=this.container_.style.height;GEvent.addDomListener(this.wrapperParts.max.domElement,'click',function(){var infoWindow=thisMap.getExtInfoWindow();infoWindow.container_.style.width=thisMaxWidth+'px';infoWindow.ajaxRequest_(thisMaxContent);infoWindow.isMaximized_=true;infoWindow.redraw(true);infoWindow.toggleMaxMin_()});GEvent.addDomListener(this.wrapperParts.min.domElement,'click',function(){var infoWindow=thisMap.getExtInfoWindow();infoWindow.container_.style.width=thisMinWidth;infoWindow.container_.style.height=thisMinHeight;if(infoWindow.ajaxUrl_!=null){infoWindow.ajaxRequest_(this.ajaxUrl_)}else{infoWindow.contentDiv_.innerHTML=infoWindow.html_}infoWindow.isMaximized_=false;infoWindow.redraw(true);infoWindow.resize();infoWindow.toggleMaxMin_()});this.toggleMaxMin_()}var stealEvents=['mousedown','dblclick','DOMMouseScroll'];for(i=0;i<stealEvents.length;i++){GEvent.bindDom(this.container_,stealEvents[i],this,this.onClick_)}GEvent.trigger(this.map_,'extinfowindowopen');if(this.ajaxUrl_!=null){this.ajaxRequest_(this.ajaxUrl_)}};ExtInfoWindow.prototype.onClick_=function(e){if(navigator.userAgent.toLowerCase().indexOf('msie')!=-1&&document.all){window.event.cancelBubble=true;window.event.returnValue=false}else{e.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(force){if(!force||this.container_==null)return;var contentHeight=this.contentDiv_.offsetHeight;this.contentDiv_.style.height=contentHeight+'px';this.contentWidth=this.getDimensions_(this.container_).width;this.contentDiv_.style.width=this.container_.style.width;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=contentHeight;this.wrapperParts.r.l=this.contentWidth+this.wrapperParts.l.w;this.wrapperParts.r.t=this.wrapperParts.tr.h;this.wrapperParts.r.h=contentHeight;this.wrapperParts.bl.t=contentHeight+this.wrapperParts.tl.h;this.wrapperParts.b.l=this.wrapperParts.bl.w;this.wrapperParts.b.t=contentHeight+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=contentHeight+this.wrapperParts.tr.h;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_;this.wrapperParts.close.l=this.wrapperParts.tr.l+this.wrapperParts.tr.w-this.wrapperParts.close.w-this.borderSize_;this.wrapperParts.close.t=this.borderSize_;if(this.maximizeEnabled_){this.wrapperParts.max.l=this.wrapperParts.close.l-this.wrapperParts.max.w-5;this.wrapperParts.max.t=this.wrapperParts.close.t;this.wrapperParts.min.l=this.wrapperParts.max.l;this.wrapperParts.min.t=this.wrapperParts.max.t}for(var i in this.wrapperParts){if(i=='close'){this.wrapperDiv_.insertBefore(this.contentDiv_,this.wrapperParts[i].domElement)}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}var currentMarker=this.marker_;var thisMap=this.map_;GEvent.addDomListener(this.wrapperParts.close.domElement,'click',function(){thisMap.closeExtInfoWindow()});var pixelLocation=this.map_.fromLatLngToDivPixel(this.marker_.getPoint());this.container_.style.position='absolute';var markerIcon=this.marker_.getIcon();this.container_.style.left=(pixelLocation.x-(this.contentWidth/2)-markerIcon.iconAnchor.x+markerIcon.infoWindowAnchor.x)+'px';this.container_.style.top=(pixelLocation.y-this.wrapperParts.bl.h-contentHeight-this.wrapperParts.tl.h-this.wrapperParts.beak.h-markerIcon.iconAnchor.y+markerIcon.infoWindowAnchor.y+this.borderSize_)+'px';this.container_.style.display='block';if(this.map_.getExtInfoWindow()!=null){this.repositionMap_()}};ExtInfoWindow.prototype.toggleMaxMin_=function(){if(this.wrapperParts.max.domElement!=null&&this.wrapperParts.min.domElement!=null){if(this.isMaximized_){this.wrapperParts.max.domElement.style.display='none';this.wrapperParts.min.domElement.style.display='block'}else{this.wrapperParts.max.domElement.style.display='block';this.wrapperParts.min.domElement.style.display='none'}}}

ExtInfoWindow.prototype.resize=function(){var tempElement=this.contentDiv_.cloneNode(true);tempElement.id=this.infoWindowId_+'_tempContents';tempElement.style.visibility='hidden';tempElement.style.height='auto';document.body.appendChild(tempElement);tempElement=document.getElementById(this.infoWindowId_+'_tempContents');var contentHeight=tempElement.offsetHeight;document.body.removeChild(tempElement);this.contentDiv_.style.height=contentHeight+'px';var contentWidth=this.container_.offsetWidth;var pixelLocation=this.map_.fromLatLngToDivPixel(this.marker_.getPoint());var oldWindowHeight=this.wrapperParts.t.domElement.offsetHeight+this.wrapperParts.l.domElement.offsetHeight+this.wrapperParts.b.domElement.offsetHeight;var oldWindowPosTop=this.wrapperParts.t.domElement.offsetTop;this.wrapperParts.l.domElement.style.height=contentHeight+'px';this.wrapperParts.r.domElement.style.height=contentHeight+'px';var newPosTop=this.wrapperParts.b.domElement.offsetTop-contentHeight;this.wrapperParts.l.domElement.style.top=newPosTop+'px';this.wrapperParts.r.domElement.style.top=newPosTop+'px';this.contentDiv_.style.top=newPosTop+'px';windowTHeight=parseInt(this.wrapperParts.t.domElement.style.height,10);newPosTop-=windowTHeight;this.wrapperParts.close.domElement.style.top=newPosTop+this.borderSize_+'px';this.wrapperParts.tl.domElement.style.top=newPosTop+'px';this.wrapperParts.t.domElement.style.top=newPosTop+'px';this.wrapperParts.tr.domElement.style.top=newPosTop+'px';this.repositionMap_()};

ExtInfoWindow.prototype.repositionMap_=function(){var mapNE=this.map_.fromLatLngToDivPixel(this.map_.getBounds().getNorthEast());var mapSW=this.map_.fromLatLngToDivPixel(this.map_.getBounds().getSouthWest());var markerPosition=this.map_.fromLatLngToDivPixel(this.marker_.getPoint());var panX=0;var panY=0;var paddingX=this.paddingX_;var paddingY=this.paddingY_;var infoWindowAnchor=this.marker_.getIcon().infoWindowAnchor;var iconAnchor=this.marker_.getIcon().iconAnchor;var windowT=this.wrapperParts.t.domElement;var windowL=this.wrapperParts.l.domElement;var windowB=this.wrapperParts.b.domElement;var windowR=this.wrapperParts.r.domElement;var windowBeak=this.wrapperParts.beak.domElement;var offsetTop=markerPosition.y-(-infoWindowAnchor.y+iconAnchor.y+this.getDimensions_(windowBeak).height+this.getDimensions_(windowB).height+this.getDimensions_(windowL).height+this.getDimensions_(windowT).height+this.paddingY_);if(offsetTop<mapNE.y){panY=mapNE.y-offsetTop}else{var offsetBottom=markerPosition.y+this.paddingY_;if(offsetBottom>=mapSW.y){panY=-(offsetBottom-mapSW.y)}}var offsetRight=Math.round(markerPosition.x+this.getDimensions_(this.container_).width/2+this.getDimensions_(windowR).width+this.paddingX_+infoWindowAnchor.x-iconAnchor.x);if(offsetRight>mapNE.x){panX=-(offsetRight-mapNE.x)}else{var offsetLeft=-(Math.round((this.getDimensions_(this.container_).width/2-this.marker_.getIcon().iconSize.width/2)+this.getDimensions_(windowL).width+this.borderSize_+this.paddingX_)-markerPosition.x-infoWindowAnchor.x+iconAnchor.x);if(offsetLeft<mapSW.x){panX=mapSW.x-offsetLeft}}if(panX!=0||panY!=0&&this.map_.getExtInfoWindow()!=null){this.map_.panBy(new GSize(panX,panY))}};

ExtInfoWindow.prototype.ajaxRequest_=function(url){var thisMap=this.map_;var thisCallback=this.callback_;GDownloadUrl(url,function(response,status){if(thisMap.getExtInfoWindow()!==null){var infoWindow=document.getElementById(thisMap.getExtInfoWindow().infoWindowId_+'_contents');if(response==null||status==-1){infoWindow.innerHTML='<span class="error">ERROR: The Ajax request failed to get HTML content from "'+url+'"</span>'}else{infoWindow.innerHTML=response}if(thisCallback!=null){thisCallback()}thisMap.getExtInfoWindow().resize()}GEvent.trigger(thisMap,'extinfowindowupdate')})};ExtInfoWindow.prototype.getDimensions_=function(element){var display=this.getStyle_(element,'display');if(display!='none'&&display!=null){return{width:element.offsetWidth,height:element.offsetHeight}}var els=element.style;var originalVisibility=els.visibility;var originalPosition=els.position;var originalDisplay=els.display;els.visibility='hidden';els.position='absolute';els.display='block';var originalWidth=element.clientWidth;var originalHeight=element.clientHeight;els.display=originalDisplay;els.position=originalPosition;els.visibility=originalVisibility;return{width:originalWidth,height:originalHeight}};ExtInfoWindow.prototype.getStyle_=function(element,style){var found=false;style=this.camelize_(style);if(element.id==this.infoWindowId_&&style=='width'&&element.style.display=='none'){element.style.visibility='hidden';element.style.display=''}var value=element.style[style];if(!value){if(document.defaultView&&document.defaultView.getComputedStyle){var css=document.defaultView.getComputedStyle(element,null);value=css?css[style]:null}else if(element.currentStyle){value=element.currentStyle[style]}}if((value=='auto')&&(style=='width'||style=='height')&&(this.getStyle_(element,'display')!='none')){if(style=='width'){value=element.offsetWidth}else{value=element.offsetHeight}}if(element.id==this.infoWindowId_&&style=='width'&&element.style.display!='none'){element.style.display='none';element.style.visibility='visible'}return(value=='auto')?null:value};

ExtInfoWindow.prototype.camelize_=function(element){var parts=element.split('-'),len=parts.length;if(len==1)return parts[0];var camelized=element.charAt(0)=='-'?parts[0].charAt(0).toUpperCase()+parts[0].substring(1):parts[0];for(var i=1;i<len;i++){camelized+=parts[i].charAt(0).toUpperCase()+parts[i].substring(1)}return camelized};GMap.prototype.ExtInfoWindowInstance_=null;GMap.prototype.ClickListener_=null;GMap.prototype.InfoWindowListener_=null;GMarker.prototype.openExtInfoWindow=function(map,cssId,html,opt_opts){if(map==null){throw'Error in GMarker.openExtInfoWindow: map cannot be null';return false}if(cssId==null||cssId==''){throw'Error in GMarker.openExtInfoWindow: must specify a cssId';return false}map.closeInfoWindow();if(map.getExtInfoWindow()!=null){map.closeExtInfoWindow()}if(map.getExtInfoWindow()==null){map.setExtInfoWindow_(new ExtInfoWindow(this,cssId,html,opt_opts));if(map.ClickListener_==null){map.ClickListener_=GEvent.addListener(map,'click',function(event){if(!event&&map.getExtInfoWindow()!=null){map.closeExtInfoWindow()}})}if(map.InfoWindowListener_==null){map.InfoWindowListener_=GEvent.addListener(map,'infowindowopen',function(event){if(map.getExtInfoWindow()!=null){map.closeExtInfoWindow()}})}map.addOverlay(map.getExtInfoWindow())}};
GMarker.prototype.closeExtInfoWindow=function(map){if(map.getExtInfWindow()!=null){map.closeExtInfoWindow()}};GMap2.prototype.getExtInfoWindow=function(){return this.ExtInfoWindowInstance_};GMap2.prototype.setExtInfoWindow_=function(extInfoWindow){this.ExtInfoWindowInstance_=extInfoWindow};GMap2.prototype.closeExtInfoWindow=function(){if(this.getExtInfoWindow()!=null){this.ExtInfoWindowInstance_.remove()}};

