/*!
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
if(typeof google!="undefined"){function InfoBox(n){n=n||{},google.maps.OverlayView.apply(this,arguments),this.content_=n.content||"",this.disableAutoPan_=n.disableAutoPan||!1,this.maxWidth_=n.maxWidth||0,this.pixelOffset_=n.pixelOffset||new google.maps.Size(0,0),this.position_=n.position||new google.maps.LatLng(0,0),this.zIndex_=n.zIndex||null,this.boxClass_=n.boxClass||"infoBox",this.boxStyle_=n.boxStyle||{},this.closeBoxMargin_=n.closeBoxMargin||"2px",this.closeBoxURL_=n.closeBoxURL||"http://www.google.com/intl/en_us/mapfiles/close.gif",n.closeBoxURL===""&&(this.closeBoxURL_=""),this.infoBoxClearance_=n.infoBoxClearance||new google.maps.Size(1,1),this.isHidden_=n.isHidden||!1,this.alignBottom_=n.alignBottom||!1,this.pane_=n.pane||"floatPane",this.enableEventPropagation_=n.enableEventPropagation||!1,this.div_=null,this.closeListener_=null,this.eventListener1_=null,this.eventListener2_=null,this.eventListener3_=null,this.moveListener_=null,this.contextListener_=null,this.fixedWidthSet_=null}InfoBox.prototype=new google.maps.OverlayView,InfoBox.prototype.createInfoBoxDiv_=function(){var t,i=this,n=function(n){n.cancelBubble=!0,n.stopPropagation&&n.stopPropagation()},r=function(t){t.returnValue=!1,t.preventDefault&&t.preventDefault(),i.enableEventPropagation_||n(t)};this.div_||(this.div_=document.createElement("div"),this.setBoxStyle_(),typeof this.content_.nodeType=="undefined"?this.div_.innerHTML=this.getCloseBoxImg_()+this.content_:(this.div_.innerHTML=this.getCloseBoxImg_(),this.div_.appendChild(this.content_)),this.getPanes()[this.pane_].appendChild(this.div_),this.addClickHandler_(),this.div_.style.width?this.fixedWidthSet_=!0:this.maxWidth_!==0&&this.div_.offsetWidth>this.maxWidth_?(this.div_.style.width=this.maxWidth_,this.div_.style.overflow="auto",this.fixedWidthSet_=!0):(t=this.getBoxWidths_(),this.div_.style.width=this.div_.offsetWidth-t.left-t.right+"px",this.fixedWidthSet_=!1),this.panBox_(this.disableAutoPan_),this.enableEventPropagation_||(this.eventListener1_=google.maps.event.addDomListener(this.div_,"mousedown",n),this.eventListener2_=google.maps.event.addDomListener(this.div_,"click",n),this.eventListener3_=google.maps.event.addDomListener(this.div_,"dblclick",n),this.eventListener4_=google.maps.event.addDomListener(this.div_,"mouseover",function(){this.style.cursor="default"})),this.contextListener_=google.maps.event.addDomListener(this.div_,"contextmenu",r),google.maps.event.trigger(this,"domready"))},InfoBox.prototype.getCloseBoxImg_=function(){var n="";return this.closeBoxURL_!==""&&(n="<img",n+=" src='"+this.closeBoxURL_+"'",n+=" align=right",n+=" style='",n+=" position: relative;",n+=" cursor: pointer;",n+=" margin: "+this.closeBoxMargin_+";",n+="'>"),n},InfoBox.prototype.addClickHandler_=function(){var n;this.closeBoxURL_!==""?(n=this.div_.firstChild,this.closeListener_=google.maps.event.addDomListener(n,"click",this.getCloseClickHandler_())):this.closeListener_=null},InfoBox.prototype.getCloseClickHandler_=function(){var n=this;return function(t){t.cancelBubble=!0,t.stopPropagation&&t.stopPropagation(),n.close(),google.maps.event.trigger(n,"closeclick")}},InfoBox.prototype.panBox_=function(n){var i,y,e=0,f=0,p;if(!n&&(i=this.getMap(),i instanceof google.maps.Map)){i.getBounds().contains(this.position_)||i.setCenter(this.position_),y=i.getBounds();var l=i.getDiv(),a=l.offsetWidth,o=l.offsetHeight,s=this.pixelOffset_.width,r=this.pixelOffset_.height,v=this.div_.offsetWidth,h=this.div_.offsetHeight,c=this.infoBoxClearance_.width,u=this.infoBoxClearance_.height,t=this.getProjection().fromLatLngToContainerPixel(this.position_);t.x<-s+c?e=t.x+s-c:t.x+v+s+c>a&&(e=t.x+v+s+c-a),this.alignBottom_?t.y<-r+u+h?f=t.y+r-u-h:t.y+r+u>o&&(f=t.y+r+u-o):t.y<-r+u?f=t.y+r-u:t.y+h+r+u>o&&(f=t.y+h+r+u-o),e===0&&f===0||(p=i.getCenter(),i.panBy(e,f))}},InfoBox.prototype.setBoxStyle_=function(){var n,t;if(this.div_){this.div_.className=this.boxClass_,this.div_.style.cssText="",t=this.boxStyle_;for(n in t)t.hasOwnProperty(n)&&(this.div_.style[n]=t[n]);typeof this.div_.style.opacity!="undefined"&&this.div_.style.opacity!==""&&(this.div_.style.filter="alpha(opacity="+this.div_.style.opacity*100+")"),this.div_.style.position="absolute",this.div_.style.visibility="hidden",this.zIndex_!==null&&(this.div_.style.zIndex=this.zIndex_)}},InfoBox.prototype.getBoxWidths_=function(){var i,n={top:0,bottom:0,left:0,right:0},t=this.div_;return document.defaultView&&document.defaultView.getComputedStyle?(i=t.ownerDocument.defaultView.getComputedStyle(t,""),i&&(n.top=parseInt(i.borderTopWidth,10)||0,n.bottom=parseInt(i.borderBottomWidth,10)||0,n.left=parseInt(i.borderLeftWidth,10)||0,n.right=parseInt(i.borderRightWidth,10)||0)):document.documentElement.currentStyle&&t.currentStyle&&(n.top=parseInt(t.currentStyle.borderTopWidth,10)||0,n.bottom=parseInt(t.currentStyle.borderBottomWidth,10)||0,n.left=parseInt(t.currentStyle.borderLeftWidth,10)||0,n.right=parseInt(t.currentStyle.borderRightWidth,10)||0),n},InfoBox.prototype.onRemove=function(){this.div_&&(this.div_.parentNode.removeChild(this.div_),this.div_=null)},InfoBox.prototype.draw=function(){this.createInfoBoxDiv_();var n=this.getProjection().fromLatLngToDivPixel(this.position_);this.div_.style.left=n.x+this.pixelOffset_.width+"px",this.alignBottom_?this.div_.style.bottom=-(n.y+this.pixelOffset_.height)+"px":this.div_.style.top=n.y+this.pixelOffset_.height+"px",this.div_.style.visibility=this.isHidden_?"hidden":"visible"},InfoBox.prototype.setOptions=function(n){typeof n.boxClass!="undefined"&&(this.boxClass_=n.boxClass,this.setBoxStyle_()),typeof n.boxStyle!="undefined"&&(this.boxStyle_=n.boxStyle,this.setBoxStyle_()),typeof n.content!="undefined"&&this.setContent(n.content),typeof n.disableAutoPan!="undefined"&&(this.disableAutoPan_=n.disableAutoPan),typeof n.maxWidth!="undefined"&&(this.maxWidth_=n.maxWidth),typeof n.pixelOffset!="undefined"&&(this.pixelOffset_=n.pixelOffset),typeof n.alignBottom!="undefined"&&(this.alignBottom_=n.alignBottom),typeof n.position!="undefined"&&this.setPosition(n.position),typeof n.zIndex!="undefined"&&this.setZIndex(n.zIndex),typeof n.closeBoxMargin!="undefined"&&(this.closeBoxMargin_=n.closeBoxMargin),typeof n.closeBoxURL!="undefined"&&(this.closeBoxURL_=n.closeBoxURL),typeof n.infoBoxClearance!="undefined"&&(this.infoBoxClearance_=n.infoBoxClearance),typeof n.isHidden!="undefined"&&(this.isHidden_=n.isHidden),typeof n.enableEventPropagation!="undefined"&&(this.enableEventPropagation_=n.enableEventPropagation),this.div_&&this.draw()},InfoBox.prototype.setContent=function(n){this.content_=n,this.div_&&(this.closeListener_&&(google.maps.event.removeListener(this.closeListener_),this.closeListener_=null),this.fixedWidthSet_||(this.div_.style.width=""),typeof n.nodeType=="undefined"?this.div_.innerHTML=this.getCloseBoxImg_()+n:(this.div_.innerHTML=this.getCloseBoxImg_(),this.div_.appendChild(n)),this.fixedWidthSet_||(this.div_.style.width=this.div_.offsetWidth+"px",typeof n.nodeType=="undefined"?this.div_.innerHTML=this.getCloseBoxImg_()+n:(this.div_.innerHTML=this.getCloseBoxImg_(),this.div_.appendChild(n))),this.addClickHandler_()),google.maps.event.trigger(this,"content_changed")},InfoBox.prototype.setPosition=function(n){this.position_=n,this.div_&&this.draw(),google.maps.event.trigger(this,"position_changed")},InfoBox.prototype.setZIndex=function(n){this.zIndex_=n,this.div_&&(this.div_.style.zIndex=n),google.maps.event.trigger(this,"zindex_changed")},InfoBox.prototype.getContent=function(){return this.content_},InfoBox.prototype.getPosition=function(){return this.position_},InfoBox.prototype.getZIndex=function(){return this.zIndex_},InfoBox.prototype.show=function(){this.isHidden_=!1,this.div_&&(this.div_.style.visibility="visible")},InfoBox.prototype.hide=function(){this.isHidden_=!0,this.div_&&(this.div_.style.visibility="hidden")},InfoBox.prototype.open=function(n,t){var i=this;t&&(this.position_=t.getPosition(),this.moveListener_=google.maps.event.addListener(t,"position_changed",function(){i.setPosition(this.getPosition())})),this.setMap(n),this.div_&&this.panBox_()},InfoBox.prototype.close=function(){this.closeListener_&&(google.maps.event.removeListener(this.closeListener_),this.closeListener_=null),this.eventListener1_&&(google.maps.event.removeListener(this.eventListener1_),google.maps.event.removeListener(this.eventListener2_),google.maps.event.removeListener(this.eventListener3_),google.maps.event.removeListener(this.eventListener4_),this.eventListener1_=null,this.eventListener2_=null,this.eventListener3_=null,this.eventListener4_=null),this.moveListener_&&(google.maps.event.removeListener(this.moveListener_),this.moveListener_=null),this.contextListener_&&(google.maps.event.removeListener(this.contextListener_),this.contextListener_=null),this.setMap(null)}}