﻿
Gen.prototype.m_initMap = function()
{        
    var l_mapDiv = eID("mapDiv");
    map = new GMap2(l_mapDiv, {draggableCursor:"crosshair"});

    map.setCenter(this.m_defaultCentre, this.m_defaultZoom);
    
    map.setMapType(G_HYBRID_MAP);
    
    map.addControl(new GSmallZoomControl3D());
    map.addControl(new GHierarchicalMapTypeControl());
    map.addControl(new GScaleControl());
    
	
    map.enableDoubleClickZoom();
    map.enableContinuousZoom();
    map.enableScrollWheelZoom();
    
    GEvent.addListener(map, "moveend", function() 
    {
        if (!gen.m_gridOn && gen.m_overlaysOn)
        {
            gen.m_displayRoutes(true);
        }
    });   
    
    GEvent.addListener(map, "zoomend", function() 
    {
        gen.m_zoomEnd();
    });     

    GEvent.addListener(map, "click", function() 
    {
        if (eID("panDiv2").style.display != "none")
        {
			document.getElementById("panDiv2").innerHTML = "";
            eID("panDiv2").style.display = "none";
            eID("indexFrame").style.display = "block";
        }
    });   

}



Gen.prototype.m_zoomEnd = function()
{ 
    var z = map.getZoom();
    
    if (z < gen.m_minRouteZoom)
    {
        eID("showOverlaysCheck").checked = false;
        this.m_overlaysOn = false;

        var l_categorySelect = eID("categorySelect");

        
        this.m_displayGrid(this.m_overlaysOn);
        this.m_displayRoutes(false);
    }    
    else  if (z < this.m_midRouteZoom)
    {
        if (this.m_gridOn != true)
        {
            this.m_gridOn = true;
        }

        this.m_displayGrid(this.m_overlaysOn);
        this.m_displayRoutes(false);
    }
    else
    {
        eID("showOverlaysCheck").checked = true;
        this.m_overlaysOn = true;
        
        var l_categorySelect = eID("categorySelect");
        
        if (l_categorySelect.value != "poi")
        {
            l_categorySelect.value = "poi";
            categorySelectChange(l_categorySelect)
        }
        if (this.m_gridOn != false)
        {
            this.m_gridOn = false;
        }

        this.m_displayGrid(false);
        this.m_displayRoutes(this.m_overlaysOn);
    }
    
    gen.m_displayPlaces();  // _NEW

}


