﻿function BingMap()
{
    this._map = null;
    var bmap;
}

BingMap.prototype = {

    createMap: function()
    {
        this._map = new VEMap('mMap');
        this._map.LoadMap(new VELatLong(0, 0), 0, 'o', false);
        bmap = this._map;
        bmap.SetDashboardSize(VEDashboardSize.Normal);
        bmap.HideDashboard();

    },

    destroyMap: function()
    {
        bmap.Dispose();
        bmap = null;
    },

    checkBirdEye: function()
    {
        var windowResize = new WindowResizer();

        var dialogframe = windowResize.dialogFrame();
        var myString = dialogframe.split(",");
        var dwidth = parseFloat(myString[0]);
        var dheight = parseFloat(myString[1]);

        bmap.SetCenterAndZoom(new VELatLong(entity.Latitude, entity.Longitude), 15 /*, 'o', false*/);

        setTimeout(function()
        {

            if (bmap.IsBirdseyeAvailable())
            {
                var mydialog = new Dialogs("#birdseye", entity.Name + " Birds Eye")
                mydialog.setDialog();
                bmap.SetMapStyle(VEMapStyle.Birdseye);

                var compwidth = $("#birdseye").width();
                var compheight = $("#birdseye").height();

                bmap.Resize(compwidth, compheight);
            }
            else
            {
                var windowResize = new WindowResizer();

                if (currentMap == 'Google')
                {
                    windowResize.hide3D_Map();
                }

                windowResize.hide2DMap();

                $("#birdeyePopup").dialog({
                    draggable: false,
                    resizable: false,
                    modal: true,
                    width: 300,
                    height: 100,
                    autoOpen: true,

                    close: function(ev, ui)
                    {
                        $("#birdeyePopup").dialog("destroy");

                        if (currentMap == 'Google')
                        {
                            windowResize.show3D_Map();
                        }
                        windowResize.show2DMap();
                        dialog = false;
                    }
                });
            }
        }, 2000);
    }
};

