var Pfizer = Pfizer || {};
Pfizer.GMap = (function($, google) {
    'use strict';
    var isa = II.GMap;

    var categories = [
        "Programs by region",
        "Skills-based employee investments",
        "Eliminating blinding trachoma",
        "Mobilizing against malaria",
        "Addressing chronic non-communicable diseases",
        "Preventing and treating HIV-related infections",
        "Preventing HIV/AIDS in the U.S.",
        "Caring for and preventing infectious diseases",
        "Responding to natural disasters",
        "Patient Assistance in the U.S."
    ];

    var marker_positions = [
        [
            [  44.04,  -99.14],
            [  23.48, -102.52],
            [   3.69,  -72.42],
            [  53.54,   13.71],
            [  39.50,   70.66],
            [  14.94,   16.44]
        ],
        [
            [  43.39,  -74.27],
            [  31.73,  -95.27],
            [  36.00,  -76.82],
            [  18.90,  -98.96],
            [   7.89,  -62.49],
            [  52.05,   21.27],
            [  50.96,    8.79],
            [  38.41,   29.71],
            [  27.22,   17.05],
            [  28.15,  -10.02],
            [   5.88,   38.06],
            [   2.90,   31.38],
            [  -0.48,   39.20],
            [  17.31,   -8.39],
            [   6.01,   -1.32],
            [  13.75,  -16.57],
            [ -21.94,   17.71],
            [  31.99,  102.30],
            [  22.59,  100.20],
            [  17.81,   75.59]
        ],
        [
            [  33.28,   -4.57],
            [   8.41,   22.68],
            [   8.41,   31.46],
            [   2.90,   34.10],
            [  15.79,  -14.59],
            [ -18.98,   25.00],
            [  46.80,  107.40],
            [  22.92,   84.55]
        ],
        [
            [   2.02,   39.02],
            [  10.19,   -1.19],
            [  14.43,  -13.05]
        ],
        [
            [  42.29,  -77.78],
            [  20.30,  -88.68],
            [ -11.44,  -46.85],
            [  38.96,   41.84],
            [  35.03,  116.41],
            [  34.99,  133.90],
            [  47.28,   86.66]
        ],
        [
            [  14.09,  -85.25],
            [  26.27,    3.16],
            [   7.71,   43.77],
            [  -0.35,   30.41],
            [  -0.88,   36.04],
            [ -25.01,   29.09],
            [ -30.52,   22.85],
            [  33.58,   60.12]
        ],
        [
            [  30.56, -101.34],
            [  35.68,  -81.17]
        ],
        [
            [   0.40,   33.09]
        ],
        [
            [  27.99, -106.88],
            [  -5.79,  -75.06],
            [  28.46,  112.06],
            [  49.95,   72.25],
            [  37.53,  -93.67],
            [  37.93,  140.14]
        ],
        [
            [  38.64, -105.12]
        ]
    ];

    var marker_colors = [
        '#0093d0',
        '#cc292b',
        '#00a950',
        '#de8703',
        '#75d1e0',
        '#4a245e',
        '#f7d417',
        '#d95f60',
        '#7dba00',
        '#d6006e'
    ];

    var GMap = function (id, options, initial_active) {
        options = options || {};
        options.mapTypeControl = options.mapTypeControl || false;
        options.zoomControlOptions = options.zoomControlOptions || {
            style : google.maps.ZoomControlStyle.SMALL
        };
        isa.apply(this, [id, options]);

        this.marker_overlay = new Pfizer.GMap.MarkerOverlay(
            marker_positions, marker_colors
        );
        this.menu_control = new Pfizer.GMap.MenuControl(
            categories,
            this.map_id + "_menu_control",
            this.marker_overlay,
            initial_active
        );

    };

    GMap.prototype = new isa();

    GMap.prototype.create_map = function () {
        isa.prototype.create_map.apply(this, arguments);

        this.marker_overlay.add_to_map(this.map);
        this.menu_control.add_to_map(this.map);
    };

    return GMap;
})(jQuery, google);
