﻿/// <reference path="MicrosoftAjax.js" />
/// <reference path="Country.js" />
/// <reference path="navmap.js" />

Type.registerNamespace("fdi");

fdi.Countries = function () {
    this._countries = new Array();
}

fdi.Countries.prototype = {
    Add: function (country) {
        this._countries.push(country);
    },
    GetCountryByUrlName: function (urlName) {
        for (var index in this._countries) {
            if (this._countries[index].UrlName == urlName) {
                return this._countries[index];
            }
        }
        return null;
    },
    HideAll: function () {
        for (var index in this._countries) {
            this._countries[index].Hide();
        }
    },
    ShowAll: function () {
        for (var index in this._countries) {
            this._countries[index].Show();
        }
    },
    ShowInArea: function (view) {
        var returnCountries = new Array();
        for (var index in this._countries) {
            if (this._countries[index].Layer.BoundingRect == null) this._countries[index].Layer.BoundingRect = this._countries[index].Layer.GetBoundingRectangle();
            var boundingRectangle = this._countries[index].Layer.BoundingRect;
            if (fdi.ShapeUtils.DoBoundingBoxesIntersect(boundingRectangle, view)) {
                //this._countries[index].Show();
                Array.add(returnCountries, this._countries[index]);
            }
            else {
                //this._countries[index].Hide();
            }
        }
        return returnCountries;
    }
}

fdi.Countries.registerClass('fdi.Countries', null, Sys.IDisposable);
