function GMarkerControl(myMap) {
	this.myMap = myMap;
	this.initVars();
}

GMarkerControl.prototype = new GControl();

GMarkerControl.prototype.initVars = function() {
	this.marker = null;
	this.monitored = true;
	this.clicked = false;
	this.clickHandler = null;
}

GMarkerControl.prototype.initialize = function(map) {
	this.button = document.createElement("div");
	this.setButtonStyle_(this.button, this.clicked);
	map.getContainer().appendChild(this.button);
	
	var callBack = GEvent.callback(this, this.doClick);
	GEvent.addDomListener(this.button, "click", callBack);
	
	return this.button;
}

GMarkerControl.prototype.getDefaultPosition = function() {
	return new GControlPosition(G_ANCHOR_TOP_LEFT, new GSize(142, 7));
}

GMarkerControl.prototype.setButtonStyle_ = function(button, clicked) {
	if (clicked)
		button.style.backgroundImage = "url(\"images/Bmd.png\")";
	else button.style.backgroundImage = "url(\"images/Bmu.png\")";
	button.style.width = "31px";
	button.style.height = "31px";
}

/*************
	Actions
**************/
GMarkerControl.prototype.doClick = function(overlay, point){
	this.clicked = !this.clicked;
	this.setButtonStyle_(this.button, this.clicked);
	
	if (this.clicked == false){
		GEvent.removeListener(this.clickHandler);
		this.initVars();
	}
	else {
		this.myMap.deactivateControls(this);
		this.clickHandler = GEvent.bind(this.myMap.map, "click", this, this.createMarker);
	}
}

GMarkerControl.prototype.createMarker = function(overlay, point){
	if (point != null){
		this.marker = this.myMap.createMarker(point.lat(), point.lng());
		//this.myMap.addMarker(this.marker);
		this.myMap.addManagedMarker(this.marker, 0, 17);
		this.marker.addInfoWindowTabsHtml({'adresse' : '', 'coordonnees' : '<script>$("div-coordonnees").innerHTML = marker.getCoordinates();</script>'}, 1);
	}
}
