﻿
hs.showCredits = 0;
hs.graphicsDir = '/highslide/graphics/';
hs.outlineType = 'rounded-light-brown'; //rounded-white
hs.wrapperClassName = 'draggable-header no-footer';
hs.allowSizeReduction = true;
hs.preserveContent = true;
hs.align = 'center';
hs.dimmingOpacity = 0.50;
hs.dimmingDuration = 0;

var e = []; function ce(id) { if (!e[id]) { e[id] = $(id); } return e[id]; }

e['document'] = $(document);
e['document'].ready(function() { app.init(); });


var app = {

    map: null,
    slat: 46.191625784561026,
    slng: 6.161870956420898,
    szoom: 16,

    /* Max and mon coords and zoom factor for Geneva region */
    minZoom: 12,
    maxZoom: 16,
    minLat: 46.320,            //north
    maxLat: 46.120,            //south
    minLng: 5.921,             //west
    maxLng: 6.320,             //east
    arrMarkers: new Array(),
    allowedBounds: null,
    isTotoVisible: false,
    isToStay: false,
    winId: 'infoWin',
    totoX: 0,
    totoY: 0,
    boxX: 0,
    boxY: 0,
    totoWidth: 221,
    totoHeight: 221,
    curType: '',

    init: function() {

        $(window).bind('unload', function(event) { app.unLoad(); });
        $().mousemove(function(e) { app.totoX = e.pageX; app.totoY = e.pageY; });
        $('#infoWin').hide();

        app.initMap();

    },

    unLoad: function() { GUnload(); },

    initMap: function() {
        if (!this.map) {
            if (GBrowserIsCompatible()) {

                this.map = new GMap2($('#venue-map').get(0));
                this.allowedBounds = new GLatLngBounds(new GLatLng(this.maxLat, this.minLng), new GLatLng(this.minLat, this.maxLng));

                /* Limits the zoom factors */
                var mapTypes = this.map.getMapTypes();
                for (var i = 0; i < mapTypes.length; i++) { mapTypes[i].getMinimumResolution = function() { return app.minZoom; }; mapTypes[i].getMaximumResolution = function() { return app.maxZoom; }; }

                var point = new GLatLng(this.slat, this.slng);
                this.map.setCenter(point, this.szoom);
                this.map.addControl(new GLargeMapControl3D(), new GControlPosition(G_ANCHOR_TOP_LEFT, new GSize(240, 10)));
                this.map.addControl(new GScaleControl(), new GControlPosition(G_ANCHOR_BOTTOM_LEFT, new GSize(240, 10)));
                this.map.clearOverlays();

                var marker = new GMarker(point, { draggable: false });
                this.map.addOverlay(marker);
                marker.openInfoWindowHtml($('#infoWin').html(), { maxWidth: 500, noCloseOnClick: true });
                //this.map.setCenter(point, 16);

            }
        }
    }

};


