function RouteMarker(point, route) {
	this.marker = null;
	this.highlighted = false;
	this.route = route;
	
	this.init_(point);
}

RouteMarker.prototype.init_ = function(point) {

	var icon = this.createIcon_();
	this.marker = new GMarker(point, {icon: icon, draggable: true});
	
	var thisroute = this.route;
	GEvent.addListener(this.marker, "drag", function() { thisroute.draw();});
	
	var thismarker = this;
	GEvent.addListener(this.marker, "click", function() { thisroute.highlightMarker(thismarker);});	
	
	//handled by map
	//GEvent.addListener(this.marker, "singlerightclick", function() { alert('rightclick'); thisroute.deleteMarker(thismarker);});	
	
	//GEvent.bind(this.marker, "drag", this, function() { this.route.draw(); });
	
	//GEvent.bind(this.marker, "click", this, GEvent.callbackArgs(this, this.highlightMarker, marker));
}

RouteMarker.prototype.getMarker = function() { 
	return this.marker;
}

RouteMarker.prototype.getPoint = function() {
	return this.marker.getLatLng();
}

RouteMarker.prototype.highlight = function(highlighted) {
	this.highlighted = highlighted;	
	GEvent.clearInstanceListeners(this.marker);
	this.init_(this.marker.getLatLng());
}

RouteMarker.prototype.createIcon_ = function() {

	var icon = new GIcon();
	var color = null;

	if(this.highlighted) {
		color = "yellow";
	}
	else {
		color = "green";
	}
	
	icon.image = "http://labs.google.com/ridefinder/images/mm_20_" + color + ".png";
  	icon.shadow = "http://labs.google.com/ridefinder/images/mm_20_shadow.png";
  	icon.iconSize = new GSize(12,20);
  	icon.shadowSize = new GSize(22,20);
  	icon.iconAnchor = new GPoint(6,20);
  	icon.infoWindowAnchor = new GPoint(6,1);
  	icon.infoShadowAnchor = new GPoint(13,13);
  	return icon;
}