function InfoBox(a){a=a||{},google.maps.OverlayView.apply(this,arguments),this.parentObject=a.parentObject,this.content_=a.content||"",this.disableAutoPan_=a.disableAutoPan||!1,this.maxWidth_=a.maxWidth||0,this.pixelOffset_=a.pixelOffset||new google.maps.Size(0,0),this.position_=a.position||new google.maps.LatLng(0,0),this.zIndex_=a.zIndex||null,this.boxClass_=a.boxClass||"infoBox",this.boxStyle_=a.boxStyle||{},this.closeBoxMargin_=a.closeBoxMargin||"2px",this.closeBoxURL_=a.closeBoxURL||"http://www.google.com/intl/en_us/mapfiles/close.gif",a.closeBoxURL===""&&(this.closeBoxURL_=""),this.infoBoxClearance_=a.infoBoxClearance||new google.maps.Size(1,1),this.isHidden_=a.isHidden||!1,this.alignBottom_=a.alignBottom||!1,this.pane_=a.pane||"floatPane",this.enableEventPropagation_=a.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 a,b=this,c=this.parentObject,d=function(a){a.cancelBubble=!0,a.stopPropagation&&a.stopPropagation()},e=function(a){a.returnValue=!1,a.preventDefault&&a.preventDefault(),b.enableEventPropagation_||d(a)};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):(a=this.getBoxWidths_(),this.div_.style.width=this.div_.offsetWidth-a.left-a.right+"px",this.fixedWidthSet_=!1),this.panBox_(this.disableAutoPan_),this.enableEventPropagation_||(this.eventListener1_=google.maps.event.addDomListener($("#infowindow .innertab")[0],"mousedown",d),this.eventListener2_=google.maps.event.addDomListener($("#infowindow .innertab")[0],"click",d),this.eventListener3_=google.maps.event.addDomListener($("#infowindow .innertab")[0],"dblclick",d),this.eventListener4_=google.maps.event.addDomListener($("#infowindow .innertab")[0],"mouseover",function(a){this.style.cursor="default"}),this.eventListener1_=google.maps.event.addDomListener($("#infowindow .innertab")[1],"mousedown",d),this.eventListener2_=google.maps.event.addDomListener($("#infowindow .innertab")[1],"click",d),this.eventListener3_=google.maps.event.addDomListener($("#infowindow .innertab")[1],"dblclick",d),this.eventListener4_=google.maps.event.addDomListener($("#infowindow .innertab")[1],"mouseover",function(a){this.style.cursor="default"}),$("#start-city").keypress(function(a){a.which===13&&c.calcRoute()}),google.maps.event.addDomListener(document.getElementById("getdirections"),"click",function(){c.calcRoute()})),this.contextListener_=google.maps.event.addDomListener(this.div_,"contextmenu",e),google.maps.event.trigger(this,"domready"))},InfoBox.prototype.getCloseBoxImg_=function(){var a="";return this.closeBoxURL_!==""&&(a="<img",a+=" src='"+this.closeBoxURL_+"'",a+=" align=right",a+=" style='",a+=" position: relative;",a+=" cursor: pointer;",a+=" margin: "+this.closeBoxMargin_+";",a+="'>"),a},InfoBox.prototype.addClickHandler_=function(){var a;a=$("#infowindow .close")[0],google.maps.event.addDomListener(a,"touchstart",this.getCloseClickHandler_()),google.maps.event.addDomListener(a,"touchmove",this.getCloseClickHandler_()),google.maps.event.addDomListener(a,"touchend",this.getCloseClickHandler_()),this.closeListener_=google.maps.event.addDomListener(a,"click",this.getCloseClickHandler_())},InfoBox.prototype.getCloseClickHandler_=function(){var a=this,b=this.parentObject;return function(c){c.cancelBubble=!0,c.stopPropagation&&c.stopPropagation(),a.close(),b.selected=!1,google.maps.event.trigger(a,"closeclick")}},InfoBox.prototype.panBox_=function(a){var b,c,d=0,e=0;if(!a){b=this.getMap();if(b instanceof google.maps.Map){b.getBounds().contains(this.position_)||b.setCenter(this.position_),c=b.getBounds();var f=b.getDiv(),g=f.offsetWidth,h=f.offsetHeight,i=this.pixelOffset_.width,j=this.pixelOffset_.height,k=this.div_.offsetWidth,l=this.div_.offsetHeight,m=this.infoBoxClearance_.width,n=this.infoBoxClearance_.height,o=this.getProjection().fromLatLngToContainerPixel(this.position_);o.x<-i+m?d=o.x+i-m:o.x+k+i+m>g&&(d=o.x+k+i+m-g),this.alignBottom_?o.y<-j+n+l?e=o.y+j-n-l:o.y+j+n>h&&(e=o.y+j+n-h):o.y<-j+n?e=o.y+j-n:o.y+l+j+n>h&&(e=o.y+l+j+n-h);if(d!==0||e!==0){var p=b.getCenter();b.panBy(d,e)}}}},InfoBox.prototype.setBoxStyle_=function(){var a,b;if(this.div_){this.div_.className=this.boxClass_,this.div_.style.cssText="",b=this.boxStyle_;for(a in b)b.hasOwnProperty(a)&&(this.div_.style[a]=b[a]);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 a,b={top:0,bottom:0,left:0,right:0},c=this.div_;return document.defaultView&&document.defaultView.getComputedStyle?(a=c.ownerDocument.defaultView.getComputedStyle(c,""),a&&(b.top=parseInt(a.borderTopWidth,10)||0,b.bottom=parseInt(a.borderBottomWidth,10)||0,b.left=parseInt(a.borderLeftWidth,10)||0,b.right=parseInt(a.borderRightWidth,10)||0)):document.documentElement.currentStyle&&c.currentStyle&&(b.top=parseInt(c.currentStyle.borderTopWidth,10)||0,b.bottom=parseInt(c.currentStyle.borderBottomWidth,10)||0,b.left=parseInt(c.currentStyle.borderLeftWidth,10)||0,b.right=parseInt(c.currentStyle.borderRightWidth,10)||0),b},InfoBox.prototype.onRemove=function(){this.div_&&(this.div_.parentNode.removeChild(this.div_),this.div_=null)},InfoBox.prototype.draw=function(){this.createInfoBoxDiv_();var a=this.getProjection().fromLatLngToDivPixel(this.position_);this.div_.style.left=a.x+this.pixelOffset_.width+"px",this.alignBottom_?this.div_.style.bottom=-(a.y+this.pixelOffset_.height)+"px":this.div_.style.top=a.y+this.pixelOffset_.height+"px",this.isHidden_?this.div_.style.visibility="hidden":this.div_.style.visibility="visible"},InfoBox.prototype.setOptions=function(a){typeof a.boxClass!="undefined"&&(this.boxClass_=a.boxClass,this.setBoxStyle_()),typeof a.boxStyle!="undefined"&&(this.boxStyle_=a.boxStyle,this.setBoxStyle_()),typeof a.content!="undefined"&&this.setContent(a.content),typeof a.disableAutoPan!="undefined"&&(this.disableAutoPan_=a.disableAutoPan),typeof a.maxWidth!="undefined"&&(this.maxWidth_=a.maxWidth),typeof a.pixelOffset!="undefined"&&(this.pixelOffset_=a.pixelOffset),typeof a.alignBottom!="undefined"&&(this.alignBottom_=a.alignBottom),typeof a.position!="undefined"&&this.setPosition(a.position),typeof a.zIndex!="undefined"&&this.setZIndex(a.zIndex),typeof a.closeBoxMargin!="undefined"&&(this.closeBoxMargin_=a.closeBoxMargin),typeof a.closeBoxURL!="undefined"&&(this.closeBoxURL_=a.closeBoxURL),typeof a.infoBoxClearance!="undefined"&&(this.infoBoxClearance_=a.infoBoxClearance),typeof a.isHidden!="undefined"&&(this.isHidden_=a.isHidden),typeof a.enableEventPropagation!="undefined"&&(this.enableEventPropagation_=a.enableEventPropagation),this.div_&&this.draw()},InfoBox.prototype.setContent=function(a){this.content_=a,this.div_&&(this.closeListener_&&(google.maps.event.removeListener(this.closeListener_),this.closeListener_=null),this.fixedWidthSet_||(this.div_.style.width=""),typeof a.nodeType=="undefined"?this.div_.innerHTML=this.getCloseBoxImg_()+a:(this.div_.innerHTML=this.getCloseBoxImg_(),this.div_.appendChild(a)),this.fixedWidthSet_||(this.div_.style.width=this.div_.offsetWidth+"px",typeof a.nodeType=="undefined"?this.div_.innerHTML=this.getCloseBoxImg_()+a:this.div_.innerHTML=this.getCloseBoxImg_()),this.addClickHandler_()),google.maps.event.trigger(this,"content_changed")},InfoBox.prototype.setPosition=function(a){this.position_=a,this.div_&&this.draw(),google.maps.event.trigger(this,"position_changed")},InfoBox.prototype.setZIndex=function(a){this.zIndex_=a,this.div_&&(this.div_.style.zIndex=a),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(a,b){var c=this;b&&(this.position_=b.getPosition(),this.moveListener_=google.maps.event.addListener(b,"position_changed",function(){c.setPosition(this.getPosition())})),this.setMap(a),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)}
