var _mFlags = {doContinuousZoom:true, doDoubleClickZoom:true}

var detailMarker
var GoogleMap
var Markers
var Resultaatlijst

function load2()
{
	// google map initialiseren
	GoogleMap = new GMap2(document.getElementById("Googlemap"));
	
	if (!GBrowserIsCompatible()) return

    if (window.Control)
    {
    	// blok rechtsonderin:
    	GoogleMap.addControl(new GOverviewMapControl());
    }

	// Schaal
	GoogleMap.addControl(new GScaleControl());
	
	// Locatie
	x = Settings.x
	y = Settings.y
	z = Settings.z

    type = 'NORMAL'	
    if (document.getElementById('Kaart_X') && document.getElementById('Kaart_Y') && document.getElementById('Kaart_Z') && document.getElementById('Kaart_Type'))
    {
	    if (document.getElementById('Kaart_X').value != '') x = document.getElementById('Kaart_X').value
	    if (document.getElementById('Kaart_Y').value != '') y = document.getElementById('Kaart_Y').value
	    if (document.getElementById('Kaart_Z').value != '') z = parseInt(document.getElementById('Kaart_Z').value)
	    if (document.getElementById('Kaart_Type').value != '') type = document.getElementById('Kaart_Type').value
	}
	
	if (document.getElementById('Tab'+type))
	    document.getElementById('Tab'+type).id = 'CurrentTab'
	
	GoogleMap.setCenter(new GLatLng(y, x), z);
	if (type != 'NORMAL')
	{
	    if (document.getElementById('CurrentTab')) Control.KlikKaartType(document.getElementById('CurrentTab'), type)
	}

	// Zoom
    if (window.Control)
    {
	    GoogleMap.enableContinuousZoom()
	    GoogleMap.enableDoubleClickZoom()
	    //GEvent.addDomListener(document.getElementById("Googlemap"), "DOMMouseScroll", function(event) { Control.wheelZoom(event) }); // Firefox
	    //GEvent.addDomListener(document.getElementById("Googlemap"), "mousewheel",     function(event) { Control.wheelZoom(event) }); // IE
	    GEvent.addListener(GoogleMap, "zoomend", function(event) { Control.ZoomEnd(event) })
	    GEvent.addListener(GoogleMap, "moveend", function(event) { Control.MoveEnd(event) })
	    GEvent.addListener(GoogleMap, "movestart", function(event) { Tooltip.Close() })
	    GEvent.addListener(GoogleMap, "dragstart", function(event) { Tooltip.Close() })
	    
	    document.getElementById("Googlemap").oncontextmenu = new Function("return false")
	}
	
    if (Settings.bResultaatlijst)
    {
        if (window.ClassResultaatlijst)
        {
            Resultaatlijst = new ClassResultaatlijst()
            Resultaatlijst.Initialize()
        }
        if (window.GeoDataClass)
        {
            GeoData = new GeoDataClass()
            GeoData.Initialize()
        }
    }
    if (Settings.bWoningen && window.ClassMarkers)
    {
        Markers = new ClassMarkers()
        Markers.Initialize()
    }

    if (Settings.bDetailObject)
    {
		var icon = new GIcon();
		switch(Settings.Website)
		{
		    case 'funda': icon.image = "/img/kaart/marker/punaise.gif"; break;
		    case 'fib': icon.image = "/img/kaart/marker_fib/punaise.gif"; break;
		    default: icon.image = "/img/kaart/marker/punaise.gif"; break;
		}
		icon.iconSize = new GSize(29, 60);
		icon.iconAnchor = new GPoint(14, 60);
		icon.infoWindowAnchor = new GPoint(0, 0);
		detailMarker = new GMarker(new GLatLng(Settings.y, Settings.x), icon)

    	GoogleMap.addOverlay(detailMarker);
    }
    if (window.Control)
    {
        Control.SetSliderZoomlevel(GoogleMap.getZoom())
    }
	if (window.GeoData)
	{
		center = GoogleMap.getCenter()
	    GeoData.Set(center.lng(), center.lat(), GoogleMap.getZoom())
	}
    //Preload()
	addeptStyle()
	if (window.Markers) Markers.Refresh()
}

function GetLinkById(s)
{
    links = document.getElementsByTagName('a')
    for(i=0;i<links.length;i++)
    {
        if (links[i].id != '')
        {
            alert(links[i].id + ' - ' + s + ' ; ' + (links[i].id == s))
            if (links[i].id == s) return links[i]
        }
    }
}

function Preload()
{
    if (!document.getElementById('Preload')) return
    images = new Array('m.gif', 'r.gif', 'b-n.gif', 'b-no.gif', 'b-nw.gif', 'b-zw.gif', 'b-zo.gif', 'b-z.gif', 'b-w.gif', 'b-o.gif')
	html = ''
	switch(Settings.Website)
	{
	    case 'funda': map = '/img/kaart/marker/'; break;
	    case 'fib': map = '/img/kaart/marker_fib/'; break;
	}
	for(i=0; i<images.length; i++)
	{
		html += '<img src="' + map + images[i] + '" />'
	}
	document.getElementById('Preload').innerHTML = html
}

function addeptStyle()
{
	// Blok rechtsonderin ietsje verplaatsen
    if (!document.getElementById('Googlemap_overview')) return
	document.getElementById('Googlemap_overview').style.marginLeft = '1px'
	document.getElementById('Googlemap_overview').style.marginTop = '1px'
}

