
var Control = new ClassControl()
Control.Initialize()

function ClassControl()
{
    this.Initialize = function()
    {
        this.Areal = false
	    this.CurrentLink = false
        this.MarkerMarge = 0
    }
	
	this.MouseWheel = function(event)
	{
		var zoomfactor
		if ( event.wheelDelta < 0 ) zoomfactor = -1
		if ( event.wheelDelta > 0 ) zoomfactor = 1
		var x = event.clientX - document.getElementById("Googlemap").offsetLeft
		var y = event.clientY - document.getElementById("Googlemap").offsetTop
		var point = new GPoint(x, y)
		GoogleMap.setCenter(GoogleMap.fromDivPixelToLatLng(point), GoogleMap.getZoom() + zoomfactor);

	}
	
	this.Click = function(event)
	{
	}

	this.MouseoverImage = function(oImg)
	{
		oImg.src = oImg.src.replace('-n.gif', '-h.gif')
	}

	this.MouseoutImage = function(oImg)
	{
		oImg.src = oImg.src.replace('-h.gif', '-n.gif')
	}
	
	this.Dummy = function()
	{
	    
	}

	this.KlikKaartType = function(linkje, type)
	{
		if (this.CurrentLink == false)
		{
			this.CurrentLink = document.getElementById('CurrentTab')
			this.CurrentLink.id = ''
			this.CurrentClass = this.CurrentLink.className
		}
		if (type == G_NORMAL_MAP)
		{
		    this.MarkerMarge = 0
		    this.Areal = false
		    document.getElementById('ControlDiv').className = 'Control'
		}
		else
		{
		    this.Areal = true
		    this.MarkerMarge = 14
		    document.getElementById('ControlDiv').className = 'ControlAreal'
		}
		this.onZoom()
		this.CurrentLink.className = this.CurrentClass
		this.CurrentLink = linkje
		
		this.CurrentClass = this.CurrentLink.className
		
		this.CurrentLink.className = this.CurrentClass + ' CurrentTab'
		
	    GoogleMap.setMapType(eval('G_' + type + '_MAP'))
		document.getElementById('Kaart_Type').value = type
	}
	
	this.Slide = function(event)
	{
		if (!this.Sliding) return
		y = event.clientY - this.DeltaY
		this.SetSliderPixels(y)
	}
	
	this.StartSlide = function(event)
	{
	    this.DeltaY = event.clientY - document.getElementById('Slider').offsetTop
		this.Sliding = true
	}
	
	this.StopSlide = function()
	{
		if (!this.Sliding) return
		this.Sliding = false
		y = this.SliderPx - this.MarkerMarge
		if (y < 2 - this.MarkerMarge) y = 2 - this.MarkerMarge
		if (y > 72) y = 72
		z = 17 - Math.round((y - 3) / 7)
		GoogleMap.setZoom(z)
	}
	
	this.ClickSlider = function(event)
	{
		y = event.offsetY - 4 - this.MarkerMarge
		if (y < 2 - this.MarkerMarge) y = 2 - this.MarkerMarge
		if (y > 72) y = 72
		this.SetSliderPixels(y)
		z = 17 - Math.round((y - 3) / 7)
		GoogleMap.setZoom(z)
	}
	
	this.SetSliderPixels = function(y)
	{
		if (y < 2) y = 2
		if (y > 72+this.MarkerMarge) y = 72+this.MarkerMarge
	    this.SliderPx = y
		document.getElementById('Slider').style.top = y + 'px'
	}

	this.SetSliderZoomlevel = function(z)
	{
		this.SliderPx = 72+this.MarkerMarge - (z-7) * 7
		document.getElementById('Slider').style.top = this.SliderPx + 'px'
	}
	
	this.ZoomEnd = function()
	{
		this.onZoom()
		if (window.Markers) Markers.Refresh()
		if (window.Banner) Banner.AfterZoom()
		if (window.GeoData)
		{
    		center = GoogleMap.getCenter()
		    GeoData.Set(center.lng(), center.lat(), GoogleMap.getZoom())
		}
		if (GoogleMap.getZoom() <= 6) this.ZoomIn()
		document.getElementById('Kaart_Z').value = GoogleMap.getZoom()
	}

	this.MoveEnd = function()
	{
		if (window.Markers) Markers.Refresh()
		if (window.Banner) Banner.AfterMove()
   		center = GoogleMap.getCenter()
		if (window.GeoData)
		{
		    GeoData.Set(center.lng(), center.lat(), GoogleMap.getZoom())
		}
		document.getElementById('Kaart_X').value = center.lng()
		document.getElementById('Kaart_Y').value = center.lat()
	}

	this.onZoom = function()
	{
		z = GoogleMap.getZoom()
		this.SetSliderZoomlevel(z)
		Tooltip.Close()
	}

	this.ZoomIn = function()
	{
		z = GoogleMap.getZoom()
		if (z >= 19) return
		GoogleMap.zoomIn()
	}

	this.ZoomOut = function()
	{
		z = GoogleMap.getZoom()
		if (z <= 7) return
		GoogleMap.zoomOut()
	}
	
	this.ClickCenter = function()
	{
	    GoogleMap.setCenter(new GLatLng(Settings.y, Settings.x), Settings.z)
	}

	this.wheelZoom = function(event)
	{
		if (event.detail) // Firefox
		{
			if (event.detail < 0)
			{
				this.ZoomIn()
			}
			else if (event.detail > 0)
			{
				this.ZoomOut()
			}
		}
		else if (event.wheelDelta) // IE
		{
			if (event.wheelDelta > 0)
			{
				this.ZoomIn()
			}
			else if (event.wheelDelta < 0)
			{
				this.ZoomOut()
			}
		}
	}
}

function StopSlide()
{
    Control.StopSlide()
}

document.onmouseup = StopSlide

