﻿function Region() {
    var point;
    var nazwa;
    var marker;
    var kto;  
    this.Visible = false;
    this.miasta = [];
    
}


Region.prototype.AddMarker = function(icon) {
    this.marker = new GMarker(this.point, {icon:icon});
    map.addOverlay(this.marker);
    this.marker.self = this;
    GEvent.addListener(this.marker, "click", this.onClick);
}

Region.prototype.AddMarkerSwiat = function(icon) {
    this.marker = new GMarker(this.point, { icon: icon });
    map.addOverlay(this.marker);
    this.marker.self = this;
    GEvent.addListener(this.marker, "click", function() {
    this.openInfoWindowHtml(this.self.nazwa + "<br/>" + this.self.kto);
    });
}

Region.prototype.onClick = function() {
    var _miasta = this.self.miasta;
    var count = _miasta.length;

    if (!this.self.Visible) {
        for (var i = 0; i < count; i++) {
            map.addOverlay(_miasta[i].polyline);
            map.addOverlay(_miasta[i].marker);
        }
        this.self.Visible = true;
    }
    else {
        for (var i = 0; i < count; i++) {
            map.removeOverlay(_miasta[i].polyline);
            map.removeOverlay(_miasta[i].marker);   
        }
        this.self.Visible = false;
    }
}

function Miasto(region) {
    var point;
    var nazwa;
    var polyline; 
    var marker;
    this.region = region;
}

Miasto.prototype.BuildPolyline = function(x, y) {
    this.polyline = new GPolyline([x, y], "#000000", 2);
}

Miasto.prototype.BuildMarker = function(icon) {
    this.marker = new GMarker(this.point, { icon: icon });
    this.marker.self = this;   
    GEvent.addListener(this.marker, "click", this.onClick);
}

Miasto.prototype.onClick = function() {
    this.openInfoWindowHtml(this.self.nazwa);
}



