/* ======================================================================
 * MarkerLabel, klasa główna
 * ====================================================================== */
function MarkerLabel(color,name){
    this.surface_ = new RysownikSurface(60,13);
	this.label_ = new RysownikLabel(this.surface_);
    this.setColor(color);
	this.setLabel(new String(name).substr(0, 9));
}
MarkerLabel.prototype = new GOverlay();

MarkerLabel.prototype.initialize = function(map){
	this.surface_.attach(map.getPane(G_MAP_MARKER_PANE));
}

/* ----------------------------------------------------------------------
 * @spec
 * ---------------------------------------------------------------------- */
MarkerLabel.prototype.setColor = function(color){
    color = color.replace(" ","","g");
	this.label_.setColor({color:color});
	this.label_.setStroke({color:color});
};

/* ----------------------------------------------------------------------
 * @spec
 * ---------------------------------------------------------------------- */
MarkerLabel.prototype.setLabel = function(label){
    this.label_.setLabel(new String(label).substr(0, 9));
};

/* ----------------------------------------------------------------------
 * @spec
 * ---------------------------------------------------------------------- */
MarkerLabel.prototype.move_ = function(glatlng){
    this.position_ = glatlng;
    if (!this.drawn_){
        Wiking.getMap().addOverlay(this);
        this.drawn_=true;
    }
    this.redraw(true);
};

MarkerLabel.prototype.hide = function(){
	this.surface_.hide();
}

MarkerLabel.prototype.show = function(){
	this.surface_.show();
}

MarkerLabel.prototype.redraw = function(force){
    if (!force) return;
    var point = Wiking.getMap().fromLatLngToDivPixel(this.position_);

	this.surface_.moveTo(point.x + 20, point.y - 40);
}

MarkerLabel.prototype.getPosition = function(){
    return Wiking.getMap().fromLatLngToDivPixel(this.position_);
}

MarkerLabel.prototype.setPosition = function(pos){
	this.position_ = Wiking.getMap().fromDivPixelToLatLng(pos);
	this.redraw(true);
}

MarkerLabel.prototype.getWidth = function(){
	return this.surface_.width;
}

MarkerLabel.prototype.getHeight = function(){
	return this.surface_.height;
}

MarkerLabel.prototype.remove = function(){
    var node = this.surface_.getNode();
    node.parentNode.removeChild(node);
}

/* ----------------------------------------------------------------------
 * @doc zwraca node surface'a czyli główny node tego obiektu (w DOM)
 * @spec
 * ---------------------------------------------------------------------- */
MarkerLabel.prototype.getNode = function(){
    return this.surface_.getNode();
};

/* ----------------------------------------------------------------------
 * @doc zwraca node patha, czyli sam marker
 * @spec
 * ---------------------------------------------------------------------- */
MarkerLabel.prototype.getLabelNode = function(){
    return this.label_.getNode();
};
