function PopupMarker(e,b){this.latlng_=e;b=b||{};this.text_=b.text||"";if(b.text){b.text=undefined}this.opts_=b;this.popupStyle_=b.style||"normal";this.chart_=b.chart||{};var c=navigator.userAgent.toLowerCase();var d=((c.indexOf("msie")!==-1)&&(c.indexOf("opera")===-1));var a=0;this.popupImgSrc_="http://maps.google.com/mapfiles/transit/markers/1280.png";this.popupTbl={};this.popupTbl.leftTop={left:0,top:a,width:19,height:7};this.popupTbl.leftTopFill={left:16,top:3,width:4,height:4};this.popupTbl.rightTop={left:19,top:a,width:10,height:7};this.popupTbl.rightTopImg={left:-125,top:0,width:10,height:7};this.popupTbl.centerTopFill={left:19,top:a,width:0,height:7};a+=this.popupTbl.leftTop.height;this.popupTbl.leftBody={left:11,top:a,width:8,height:0};this.popupTbl.centerBodyFill={left:19,top:a,width:40,height:15};this.popupTbl.rightBody={left:19,top:a,width:9,height:0};this.popupTbl.leftBottom={left:0,top:a,width:20,height:21};this.popupTbl.leftBottomImg={left:0,top:-13,width:20,height:21};this.popupTbl.leftBottomFill={left:16,top:0,width:4,height:6};this.popupTbl.rightBottom={left:19,top:a,width:10,height:7};this.popupTbl.rightBottomImg={left:-125,top:-13,width:10,height:7};this.popupTbl.centerBottomFill={left:19,top:(a+(d?-1:0)),width:0,height:(6+(d?1:0))};GMarker.apply(this,arguments)}PopupMarker.prototype=new GMarker(new GLatLng(0,0));PopupMarker.prototype.initialize=function(a){GMarker.prototype.initialize.apply(this,arguments);this.map_=a;this.container_=document.createElement("div");a.getPane(G_MAP_MARKER_PANE).appendChild(this.container_);this.container_.style.zIndex=GOverlay.getZIndex(this.latlng_.lat());this.container_.style.position="absolute";this.container_.style.visibility="hidden";if(this.popupStyle_==="chart"){this.makeChartPopup_()}else{this.makeNormalPopup_()}var b=this;GEvent.bindDom(this.container_,"mousedown",this,function(){return GEvent.trigger(b,"mousedown")});GEvent.bindDom(this.container_,"dragstart",this,function(){return GEvent.trigger(b,"dragstart")});GEvent.bindDom(this.container_,"mouseup",this,function(){return GEvent.trigger(b,"mouseup")});GEvent.bindDom(this.container_,"mouseover",this,function(){return GEvent.trigger(b,"mouseover")});GEvent.bindDom(this.container_,"mouseout",this,function(){return GEvent.trigger(b,"mouseout")})};PopupMarker.prototype.makeNormalPopup_=function(){this.leftTop_=this.makeImgDiv_(this.popupImgSrc_,this.popupTbl.leftTop);this.leftTop_.appendChild(this.fillDiv_(this.popupTbl.leftTopFill));this.container_.appendChild(this.leftTop_);this.leftBody_=this.fillDiv_(this.popupTbl.leftBody);this.leftBody_.style.borderWidth="0 0 0 1px";this.leftBody_.style.borderStyle="none none none solid";this.leftBody_.style.borderColor="#000000";this.container_.appendChild(this.leftBody_);this.leftBottom_=this.makeImgDiv_(this.popupImgSrc_,this.popupTbl.leftBottomImg);this.leftBottom_.style.left=this.popupTbl.leftBottom.left+"px";this.leftBottom_.style.top=this.popupTbl.leftBottom.top+"px";this.leftBottom_.style.width=this.popupTbl.leftBottom.width+"px";this.leftBottom_.style.height=this.popupTbl.leftBottom.height+"px";this.leftBottom_.appendChild(this.fillDiv_(this.popupTbl.leftBottomFill));this.container_.appendChild(this.leftBottom_);this.bodyContainer_=document.createElement("div");this.bodyContainer_.style.position="absolute";this.bodyContainer_.style.backgroundColor="#CCCCFF";this.bodyContainer_.style.overflow="hidden";this.bodyContainer_.style.left=this.popupTbl.centerBodyFill.left+"px";this.bodyContainer_.style.top=this.popupTbl.centerBodyFill.top+"px";this.bodyContainer_.style.width=this.popupTbl.centerBodyFill.width+"px";this.bodyContainer_.style.height=this.popupTbl.centerBodyFill.height+"px";this.container_.appendChild(this.bodyContainer_);this.rightTop_=this.makeImgDiv_(this.popupImgSrc_,this.popupTbl.rightTopImg);this.rightTop_.style.left=this.popupTbl.rightTop.left+"px";this.rightTop_.style.top=this.popupTbl.rightTop.top+"px";this.rightTop_.style.width=this.popupTbl.rightTop.width+"px";this.rightTop_.style.height=this.popupTbl.rightTop.height+"px";this.container_.appendChild(this.rightTop_);this.rightBottom_=this.makeImgDiv_(this.popupImgSrc_,this.popupTbl.rightBottomImg);this.rightBottom_.style.left=this.popupTbl.rightBottom.left+"px";this.rightBottom_.style.top=this.popupTbl.rightBottom.top+"px";this.rightBottom_.style.width=this.popupTbl.rightBottom.width+"px";this.rightBottom_.style.height=this.popupTbl.rightBottom.height+"px";this.container_.appendChild(this.rightBottom_);this.rightBody_=this.fillDiv_(this.popupTbl.rightBody);this.rightBody_.style.borderWidth="0 1px 0 0";this.rightBody_.style.borderStyle="none solid none none";this.rightBody_.style.borderColor="#000000";this.container_.appendChild(this.rightBody_);this.centerBottom_=this.fillDiv_(this.popupTbl.centerBottomFill);this.centerBottom_.style.borderWidth="0 0 1px 0";this.centerBottom_.style.borderStyle="none none solid none";this.centerBottom_.style.borderColor="#000000";this.container_.appendChild(this.centerBottom_);this.centerTop_=this.fillDiv_(this.popupTbl.centerTopFill);this.centerTop_.style.borderColor="#000000";this.centerTop_.style.borderWidth="1px 0 0 0";this.centerTop_.style.borderStyle="solid none none none";this.container_.appendChild(this.centerTop_)};PopupMarker.prototype.makeChartPopup_=function(){this.chartImg_=this.makeImgDiv_("http://www.google.com/mapfiles/transparent.png",{left:0,top:0,width:0,height:0});this.chartImg_.firstChild.style.MozUserSelect="none";this.chartImg_.firstChild.style.KhtmlUserSelect="none";this.chartImg_.firstChild.style.WebkitUserSelect="none";this.chartImg_.firstChild.style.userSelect="none";this.container_.appendChild(this.chartImg_)};PopupMarker.prototype.redraw=function(a){GMarker.prototype.redraw.apply(this,arguments);if(a){this.showPopup();this.latlng_=this.getLatLng();this.container_.style.zIndex=GOverlay.getZIndex(this.latlng_.lat())}};PopupMarker.prototype.copy=function(){this.opts_.text=this.text_;return new PopupMarker(this.latlng_,this.opts_)};PopupMarker.prototype.hide=function(){GMarker.prototype.hide.apply(this,arguments);this.container_.style.visibility="hidden"};PopupMarker.prototype.show=function(){GMarker.prototype.show.apply(this,arguments)};PopupMarker.prototype.showPopup=function(){this.show();if(this.popupStyle_==="chart"){this.redrawChartImg_(this.text_)}else{this.redrawNormalPopup_(this.text_)}var a=this.map_.getInfoWindow();if(!a.isHidden()||this.isNull(this.text_)){return}this.container_.style.visibility="visible"};PopupMarker.prototype.hidePopup=function(){this.container_.style.visibility="hidden"};PopupMarker.prototype.remove=function(){GEvent.clearInstanceListeners(this.container_);while(this.container_.firstChild){this.container_.removeChild(this.container_.firstChild)}this.container_.parentNode.removeChild(this.container_);GMarker.prototype.remove.apply(this,arguments);delete arguments.callee};PopupMarker.prototype.setText=function(a){this.text_=a};PopupMarker.prototype.redrawNormalPopup_=function(d){if(this.beforeNormalPopupText_!==d){while(this.bodyContainer_.firstChild){this.bodyContainer_.removeChild(this.bodyContainer_.firstChild)}this.bodyContainer_.innerHTML=d;if(this.isIE_()===false&&this.bodyContainer_.hasChildNodes){if(this.bodyContainer_.firstChild.nodeType===1){this.bodyContainer_.firstChild.style.margin=0}}var c=this.isIE_()?2:0;var a=this.getHtmlSize_(d);var b=this.popupTbl.leftTop.width+a.width;this.leftBottom_.style.top=(a.height+this.popupTbl.leftBody.top)+"px";this.leftBody_.style.height=a.height+"px";this.bodyContainer_.style.width=a.width+"px";this.bodyContainer_.style.height=a.height+"px";this.bodyContainer_.style.top=this.popupTbl.leftBody.top;this.rightTop_.style.left=b+"px";this.rightBottom_.style.left=this.rightTop_.style.left;this.rightBottom_.style.top=this.leftBottom_.style.top;this.rightBody_.style.left=b+"px";this.rightBody_.style.height=this.leftBody_.style.height;this.centerBottom_.style.top=this.leftBottom_.style.top;this.centerBottom_.style.width=a.width+"px";this.centerTop_.style.width=a.width+"px";this.size_={width:(b+this.popupTbl.rightTop.width),height:(a.height+this.popupTbl.leftTop.height+this.popupTbl.leftBottom.height)};this.container_.style.width=this.size_.width+"px";this.container_.style.height=this.size_.height+"px"}var e=this.map_.fromLatLngToDivPixel(this.latlng_);this.container_.style.left=e.x+"px";this.container_.style.top=(e.y-this.size_.height)+"px";this.beforeNormalPopupText_=d};PopupMarker.prototype.setChartStyle=function(a){this.chart_.chartStyle=a};PopupMarker.prototype.setChartIcon=function(a){this.chart_.icon=a};PopupMarker.prototype.setChartTextColor=function(a){this.chart_.textColor=a};PopupMarker.prototype.setChartBgColor=function(a){this.chart_.bgColor=a};PopupMarker.prototype.redrawChartImg_=function(g){this.chart_.shapeStyle="bb";this.chart_.textColor=this.chart_.textColor||"000000";this.chart_.bgColor=this.chart_.bgColor||"FFFFFF";this.chart_.textColor=this.chart_.textColor.replace("#","");this.chart_.bgColor=this.chart_.bgColor.replace("#","");var a="chst="+this.chart_.chartStyle;switch(this.chart_.chartStyle){case"d_bubble_icon_text_small":case"d_bubble_icon_text_big":a=a+"&chld="+this.chart_.icon+"|"+this.chart_.shapeStyle+"|"+g+"|"+this.chart_.bgColor+"|"+this.chart_.textColor;break;case"d_bubble_icon_texts_big":g=g.replace(/[\r]/,"");g=g.replace(/[\n]/,"|");a=a+"&chld="+this.chart_.icon+"|"+this.chart_.shapeStyle+"|"+this.chart_.bgColor+"|"+this.chart_.textColor+"|"+g;break;case"d_bubble_texts_big":g=g.replace(/[\r]/,"");g=g.replace(/[\n]/,"|");a=a+"&chld="+this.chart_.shapeStyle+"|"+this.chart_.bgColor+"|"+this.chart_.textColor+"|"+g;break}var d=this.map_.fromLatLngToDivPixel(this.latlng_);if(this.beforeParams===a){var e=parseInt(this.chartImg_.firstChild.offsetHeight,10);this.container_.style.left=d.x+"px";this.container_.style.top=(d.y-e)+"px";return}var c=new Image();c.src="http://chart.apis.google.com/chart?"+a;var b=this;var i=this.isIE_();var f=100;var h=function(){f--;if(f===0){return}if(c.complete===true){b.size_={width:c.width,height:c.height};if(i===true){b.chartImg_.firstChild.style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='http://chart.apis.google.com/chart?"+a+"')"}else{b.chartImg_.removeChild(b.chartImg_.firstChild);b.chartImg_.appendChild(c)}b.chartImg_.firstChild.style.width=b.size_.width+"px";b.chartImg_.firstChild.style.height=b.size_.height+"px";b.container_.style.left=d.x+"px";b.container_.style.top=(d.y-b.size_.height)+"px";b.container_.style.width=b.size_.width+"px";b.container_.style.height=b.size_.height+"px"}else{var j=arguments.callee;setTimeout(j,10)}};this.beforeParams=a;h()};PopupMarker.prototype.isNull=function(a){if(!a&&a!==0||a===undefined||a===""||a===null||typeof a==="undefined"){return true}return false};PopupMarker.prototype.getHtmlSize_=function(f){var g=this.map_.getContainer();var c=function(j){var i=document.createElement("span");i.innerHTML=j;i.style.display="inline";g.appendChild(i);var h={};h.width=i.offsetWidth;h.height=i.offsetHeight;g.removeChild(i);return h};var d;var b=f.split(/\n/i);var a=new GSize(1,1);for(var e=0;e<b.length;e++){d=c(b[e]);a.width+=d.width;a.height+=d.height}return a};PopupMarker.prototype.makeImgDiv_=function(b,d){var c=document.createElement("div");c.style.position="absolute";c.style.overflow="hidden";if(d.width){c.style.width=d.width+"px"}if(d.height){c.style.height=d.height+"px"}var a=null;if(this.isIE_()===false){a=new Image();a.src=b}else{a=document.createElement("div");if(d.width){a.style.width=d.width+"px"}if(d.height){a.style.height=d.height+"px"}}a.style.position="relative";a.style.left=d.left+"px";a.style.top=d.top+"px";a.style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+b+"')";c.appendChild(a);return c};PopupMarker.prototype.fillDiv_=function(a){var b=document.createElement("div");b.style.position="absolute";b.style.backgroundColor="#CCCCFF";b.style.fontSize="1px";b.style.lineHeight="1px";b.style.overflow="hidden";b.style.left=a.left+"px";b.style.top=a.top+"px";b.style.width=a.width+"px";b.style.height=a.height+"px";return b};PopupMarker.prototype.isIE_=function(){return(navigator.userAgent.toLowerCase().indexOf("msie")!==-1)?true:false};
