﻿

function GlobeDot(newsEvent) {

    // TOPEVENT => Create GlobeDot: We need only one GlobeDot per location on the map (MapPoint)

        this.Globe = null;
        this.Id = "GlobeDot" + newsEvent.NodeId;
        this.NewsEventId = newsEvent.NewsEventId;
        this.IsUnicefEvent = newsEvent.IsUnicefEvent;
        this.MapPoint = newsEvent.MapPoint;
        this.ObjectX = (newsEvent.MapPoint.X * 6) - 6;

        this.Element = $(document.createElement('div'));
        this.Element.attr("id", this.Id);
        this.Element.css("left", this.ObjectX + "px");
        this.Element.css("top", ((newsEvent.MapPoint.Y * 6) + 12) + "px");

        if (this.IsUnicefEvent) this.Element.addClass('globeDot blue');
        else this.Element.addClass('globeDot red');

        $('#globeMap').append(this.Element);

        this.GlobePanel = new GlobePanel(this, newsEvent);
}

GlobeDot.prototype.AddEvent = function (newsEvent) {
    // NO TOPEVENT => Add Event to GlobePanel!
    this.GlobePanel.AddEvent(this, newsEvent);
}



GlobeDot.prototype.Update = function () {

    var positionX = this.Globe.MapX + this.ObjectX;
    if (positionX < 0) positionX = this.Globe.MapWidth + positionX;
    else if (positionX > this.Globe.MapWidth) positionX = positionX - this.Globe.MapWidth;

    this.Element.css("left", positionX + "px");

    this.GlobePanel.Update();
}
