var mapIconClass = Class.create({
    initialize: function(obj){
       Object.extend(this,obj);
       this.markerSmall = null;
       this.markerMed = null;
       this.markerLarge = null;
       this.listeners = new Array();
    },
    update: function(newObj){
       if(newObj.title != this.title){ 
           this.deleteMarkers();
           this.createMarkers();
       }
    },
    remove: function(){
        this.deleteMarkers();
        for (var j=this.listeners.length-1; j>=0; j--)
        {
           GEvent.removeListener(this.listeners[j]);
        }

    },
    createMarkers: function () {
        var point = new GLatLng(this.lat, this.lng);
        var iconObj = this;
        this.markerSmall = new GMarker(point, {title: unescape(this.title), icon:this.iconSmall, zIndexProcess:importanceOrder});
        this.markerSmall.importance = this.zIndex;
        var markerSmall = this.markerSmall;
        var listener1 = GEvent.addListener(markerSmall, "click", function() {
           markerSmall.openInfoWindowHtml(iconObj.getMarkerText(markerSmall));
        });
        listeners.push(listener1);
        map.addOverlay(this.markerSmall);
        this.markerSmall.hide();
        this.markerMed = new GMarker(point, {title: unescape(this.title), icon:this.iconMedium, zIndexProcess:importanceOrder});
        this.markerMed.importance = this.zIndex;
        var markerMed = this.markerMed;
        var listener2 = GEvent.addListener(markerMed, "click", function() {
           markerMed.openInfoWindowHtml(iconObj.getMarkerText(markerMed));
        });
        listeners.push(listener2);
        map.addOverlay(this.markerMed);
        this.markerMed.hide();
        this.markerLarge = new GMarker(point, {title: unescape(this.title), icon:this.iconLarge, zIndexProcess:importanceOrder});
        this.markerLarge.importance = this.zIndex;
        var markerLarge = this.markerLarge;
        var listener3 = GEvent.addListener(markerLarge, "click", function() {
           markerLarge.openInfoWindowHtml(iconObj.getMarkerText(markerLarge));
        });
        listeners.push(listener3);
        map.addOverlay(this.markerLarge);
        this.markerLarge.hide();
        determineIconVisibility(this);
   }, 
   getMarkerText: function (marker) {
      return unescape( this.prefix + " " + this.advisoryText + " " + this.suffix);
   },
   deleteMarkers: function () {
        map.removeOverlay(this.markerSmall);
        map.removeOverlay(this.markerMed);
        map.removeOverlay(this.markerLarge);
   },
   getImpactText: function () {
       var text = "";
       if (this.impact == 0) text = "None";
       else if (this.impact == 1) text = "Low";
       else if (this.impact == 2) text = "Medium";
       else if (this.impact == 3) text = "High";
       else if (this.impact == 4) text = "Closed";
       return "<b>Traffic Impact:</b> " + text + "<br><br>"; 
   }
});

