//
// コメントマーカー
//
function CommentMarker(latlng, opt_opts) {
  this.seq_ = opt_opts.seq || 0;
  this.bgcolor_ = opt_opts.bgcolor == "" ? "#ffffff" : "#"+opt_opts.bgcolor;
  this.size_ = opt_opts.size || "";
  this.id_ = opt_opts.id || "";
  LabeledMarker.apply(this, arguments);
}



CommentMarker.prototype = new LabeledMarker(new GLatLng(0, 0), {labelText:""});



CommentMarker.prototype.initialize = function(map) {
  LabeledMarker.prototype.initialize.apply(this, arguments);
  this.div_.style.border = "1px solid black";
  this.div_.style.padding = "2px";
  this.div_.style.backgroundColor = this.bgcolor_;
  this.div_.style.fontWeight = "normal";
  this.div_.style.fontSize = this.size_;
  this.div_.style.whiteSpace = "nowrap";
  this.div_.setAttribute("id", this.id_);
  
  this.div_.innerHTML = this.convertLinkTag( this.div_.innerHTML );

  this.div_.marker = this;
  GEvent.addDomListener(this.div_, "click", function(){map.removeOverlay(this.marker)});
}



CommentMarker.prototype.redraw = function(force) {
  LabeledMarker.prototype.redraw.apply(this, arguments);
  this.div_.style.zIndex = this.seq_;
}



CommentMarker.prototype.convertLinkTag = function ( str )
{
    var reg = new RegExp( '(https?://[0-9a-zA-Z#$/%&?.+\~\-]+)', 'g' );
    var result = str.replace( reg, function( Str, P1 )
                                   {
                                       return '<a href="'+P1+'" target="_blank">'+P1+'</a>'
                                   });
    return result;
}

