Daedalus.Flag = OpenLayers.Class.create();
Daedalus.Flag.prototype = 
    OpenLayers.Class.inherit( Daedalus.Base, OpenLayers.Marker, {

        data: null,

        initialize: function(lonlat, data) {
            OpenLayers.Marker.prototype.initialize.apply(this, [lonlat, data.icon]);
            this.data = data;
            this.setComment('');
        },

        setCursor: function(name) {
            this.icon.imageDiv.style.cursor = name;
        },
        
        move: function(dx, dy) {
            var curPos = this.map.getLayerPxFromLonLat(this.lonlat);
            this.moveTo(curPos.add(dx, dy));
        },
        
        setComment: function(text) {
            this.data.text = text;
        },
        
        getComment: function() {
            return this.data.text;
        },
        
        toString: function() {
            var rep = [ this.data.id ];
            if (this.data.text && this.data.text.length) {
                rep.push(this.data.text);
            }
            return '[' + rep.join(', ') + ']';
        },
        
        getData: function() {
            return {
                id:          this.data.id,
                e:           this.lonlat.lon,
                n:           this.lonlat.lat,
                comment:     this.getComment(),
                icontype_id: this.data.type 
            };
        }
    }
);
