OpenLayers.Control.Esborra = OpenLayers.Class(OpenLayers.Control.SelectFeature, {
	title: "Esborrar",
	dialegHTML: 'Fes clic sobre lâ€™element que vols esborrar',
    type: OpenLayers.Control.TYPE_TOOL,
	
	activate: function() {
		OpenLayers.Control.SelectFeature.prototype.activate.apply(this);
		this.updateDialeg();
	},
	
	updateDialeg: function() {
		var numElements = this.layer.features.length;
		// Control "Esborra". Crido a l'actualitzaciÃ³ del diÃ leg.
		var controlTexte = this.map.getControlsByClass("OpenLayers.Control.Texte")[0];
		if (controlTexte) {
			numElements += controlTexte.numEtiquetes();
		}
		if (numElements == 0) {
			/*var noElements = 'No hi ha elements per a esborrar';
			this.dialeg.contentDiv.innerHTML = noElements;*/
			// afegit per a desactivar la funció de posar una marca
		
        	mapa.seleccionaIcon(2);
       		mapa.seleccionaIcon(2);
       		mapa.mostraMissatge(6,false);
		}		
	},
	
	onSelect: function(feature) {
		this.layer.removeFeatures(feature);
		this.updateDialeg();
	},
	
	deactivate: function() {
		this.unselectAll();
		OpenLayers.Control.SelectFeature.prototype.deactivate.apply(this);
	},
	
	CLASS_NAME: "OpenLayers.Control.Esborra"
});
