/*
	window.controls.js
	loads the controls window
*/

var stateControls = true;
var offsetControls = 78;

function initControls ()
{
	// init buttons
	initButtonsZoom ();
	initButtonsMove ();
	
	// events
	$('controlsButton').onclick = function () 
	{
		toggleControls ();
	}

	if (BrowserDetect.browser == 'Explorer' && BrowserDetect.version == 6)
	{
		// no IE6 hover
	}
	else
	{	
		$('controlsButton').onmouseover = function () 
		{
			if(stateControls)
			{
				$('controlsButton').style.background = 'url(img/layers/button.maptype.hover.png)';

				iePng (this);			
			}
			else
			{
				$('controlsButton').style.background = 'url(img/layers/button.maptype.off.hover.png)';

				iePng (this);
			}
		}

		$('controlsButton').onmouseout = function () 
		{
			if(stateControls)
			{
				$('controlsButton').style.background = 'url(img/layers/button.maptype.png)';

				iePng (this);			
			}
			else
			{
				$('controlsButton').style.background = 'url(img/layers/button.maptype.off.png)';

				iePng (this);			
			}
		}
	}
}

function toggleControls ()
{
	if (stateControls)
	{
		// close
				
		new Effect.Move ($('controlsEvent'),{ queue: 'end', x: 0, y: offsetControls, mode: 'relative', duration: 0.7});
		
		$('controlsButton').src = 'img/layers/button.maptype.off.png';
		$('controlsButton').title = 'Uitklappen';
		
		stateControls = false;
	}
	else
	{
		// open
		
		new Effect.Move ($('controlsEvent'),{ queue: 'end', x: 0, y: -(offsetControls), mode: 'relative', duration: 0.7});
		
		$('controlsButton').src = 'img/layers/button.maptype.png';
		$('controlsButton').title = 'Inklappen';
		
		stateControls = true;
	}
}

function initButtonsZoom ()
{
	// zoom in
	
	$('controlsButtonZoomin').onmouseover = function ()
	{
		this.className = 'hover';
	}
	
	$('controlsButtonZoomin').onmouseout = function ()
	{
		this.className = '';		
	}
	
	$('controlsButtonZoomin').onclick = function ()
	{
		map.zoomIn();
	}
	
	// zoom out
	
	$('controlsButtonZoomout').onmouseover = function ()
	{
		this.className = 'hover';	
	}
	
	$('controlsButtonZoomout').onmouseout = function ()
	{
		this.className = '';	
	}
	
	$('controlsButtonZoomout').onclick = function ()
	{
		map.zoomOut();
	}
}

function initButtonsMove ()
{
	// up
	
	$('controlsButtonMoveUp').onmouseover = function ()
	{
		this.className = 'hover';	
	}
	
	$('controlsButtonMoveUp').onmouseout = function ()
	{
		this.className = '';	
	}
	
	$('controlsButtonMoveUp').onclick = function ()
	{
		map.panDirection(0, 0.5);
	}
	
	// right
	
	$('controlsButtonMoveRight').onmouseover = function ()
	{
		this.className = 'hover';		
	}
	
	$('controlsButtonMoveRight').onmouseout = function ()
	{
		this.className = '';	
	}
	
	$('controlsButtonMoveRight').onclick = function ()
	{
		map.panDirection(-0.5, 0);
	}
	
	// down
	
	$('controlsButtonMoveDown').onmouseover = function ()
	{
		this.className = 'hover';	
	}
	
	$('controlsButtonMoveDown').onmouseout = function ()
	{
		this.className = '';	
	}
	
	$('controlsButtonMoveDown').onclick = function ()
	{
		map.panDirection(0, -0.5);
	}
	
	// left
	
	$('controlsButtonMoveLeft').onmouseover = function ()
	{
		this.className = 'hover';		
	}
	
	$('controlsButtonMoveLeft').onmouseout = function ()
	{
		this.className = '';		
	}
	
	$('controlsButtonMoveLeft').onclick = function ()
	{
		map.panDirection(0.5, 0);
	}
}/*
	window.controls.js
	loads the controls window
*/

var stateMenu = true;
var offsetMenu = 274;

function initMenu ()
{
	resizeMenu ();
	
	// events
	$('menuButton').onclick = function () 
	{
		toggleMenu ();
	}	
	
	$('menuButton').onmouseover = function () 
	{
		if(stateMenu)
		{
			$('menuButton').style.background = 'url(img/layers/button.controls.hover.png)';
		}
		else
		{
			$('menuButton').style.background = 'url(img/layers/button.controls.off.hover.png)';
		}
		
		iePng(this);
	}
	
	$('menuButton').onmouseout = function () 
	{
		if(stateMenu)
		{
			$('menuButton').style.background = 'url(img/layers/button.controls.png)';
		}
		else
		{
			$('menuButton').style.background = 'url(img/layers/button.controls.off.png)';
		}
		
		iePng(this);
	}	
}

function toggleMenu ()
{
	if (stateMenu)
	{
		// close
				
		new Effect.Move ($('menuEvent'),{ queue: 'end', x: offsetMenu, y: 0, mode: 'relative', duration: 0.7});
		
		$('menuButton').title = 'Uitklappen';
		
		stateMenu = false;
	}
	else
	{
		// open
		
		new Effect.Move ($('menuEvent'),{ queue: 'end', x: -(offsetMenu), y: 0, mode: 'relative', duration: 0.7});
		
		$('menuButton').title = 'Inklappen';
		
		stateMenu = true;
	}
}

function resizeMenu ()
{
	$('menu').style.height = (document.body.clientHeight - 79)+"px";
	$('menuBackground').style.height = (document.body.clientHeight - 132)+"px";
	$('contentCategory').style.height = (document.body.clientHeight - 132)+"px";
	$('contentInfo').style.height = (document.body.clientHeight - 132)+"px";
}/*
	window.maptype.js
	loads the maptype window
*/

var stateMaptype = true;
var offsetMaptype = 78;

function initMaptype ()
{
	// events
	$('maptypeButton').onclick = function () 
	{
		toggleMaptype ();
	}	
	
	if (BrowserDetect.browser == 'Explorer' && BrowserDetect.version == 6)
	{
		// no IE6 hover
	}
	else
	{	
		$('maptypeButton').onmouseover = function () 
		{
			if(stateMaptype)
			{
				$('maptypeButton').style.background = 'url(img/layers/button.maptype.hover.png)';
			}
			else
			{
				$('maptypeButton').style.background = 'url(img/layers/button.maptype.off.hover.png)';
			}

			//iePng (this);
		}

		$('maptypeButton').onmouseout = function () 
		{
			if(stateMaptype)
			{
				$('maptypeButton').style.background = 'url(img/layers/button.maptype.png)';
			}
			else
			{
				$('maptypeButton').style.background = 'url(img/layers/button.maptype.off.png)';
			}

			//iePng (this);
		}
	}
	
	//setTimeout("toggleMaptype ()", 2000);
}

function toggleMaptype ()
{
	if (stateMaptype)
	{
		// close
				
		new Effect.Move ($('maptypeEvent'),{ queue: 'end', x: 0, y: offsetMaptype, mode: 'relative', duration: 0.7});
		
		$('maptypeButton').src = 'img/layers/button.maptype.off.png';
		$('maptypeButton').title = 'Uitklappen';
		
		stateMaptype = false;
	}
	else
	{
		// open
		
		new Effect.Move ($('maptypeEvent'),{ queue: 'end', x: 0, y: -(offsetMaptype), mode: 'relative', duration: 0.7});
		
		$('maptypeButton').src = 'img/layers/button.maptype.png';
		$('maptypeButton').title = 'Inklappen';
		
		stateMaptype = true;
	}
}

function setMaptype (type)
{
	if (type == 'normal')
	{
		$('setMaptypeNormal').className 	= 'active';
		$('setMaptypeSatellite').className 	= '';
		$('setMaptypeBoth').className 		= '';
		
		map.setMapType (G_NORMAL_MAP);
	}
	
	if (type == 'satellite')
	{
		$('setMaptypeNormal').className 	= '';
		$('setMaptypeSatellite').className 	= 'active';
		$('setMaptypeBoth').className 		= '';	
		
		map.setMapType (G_SATELLITE_MAP);
	}
	
	if (type == 'both')
	{
		$('setMaptypeNormal').className 	= '';
		$('setMaptypeSatellite').className 	= '';
		$('setMaptypeBoth').className 		= 'active';
		
		map.setMapType (G_HYBRID_MAP);
	}
	
	//blur();
}function positionMinimap() 
{
	/*var omap = $('map_overview');
	omap.style.left = "0px";
	omap.style.bottom = "0px";

	// map restyle 
	omap.firstChild.style.borderRight = "2px solid gray";

	omap.firstChild.firstChild.style.left="0px";
	omap.firstChild.firstChild.style.top="0px";
	omap.firstChild.firstChild.style.width="190px";
	omap.firstChild.firstChild.style.height="190px";*/
}var exitFunctionGlobal;

function positionOverlay ()
{
	$('overlayContent').style.left = ((document.body.clientWidth / 2)-284)+ 'px';
}

function initOverlay ()
{
	$('overlayBackground').onclick = hideOverlay;
}

function showOverlay (contentFile, exitFunction)
{
	exitFunctionGlobal = exitFunction;
	
	/* load data */
	new Ajax.Request('/content.'+contentFile+'.php',
  	{
    		method:'get',
    		    		
    		onSuccess: function(d)
    		{
      			var response = d.responseText;
      
			/* set content */
			$('overlayContentAjax').innerHTML = response;
			
			/* clear settings */
			$('overlay').style.display = 'block';

			/* add effects / show */
			new Effect.Appear($('overlayBackground'), {from: 0, to: 0.8, queue: 'end'});
			setTimeout(function () { new Effect.Appear($('overlayContent'), {from: 0, to: 1, queue: 'end'}); }, 1000);
			if (BrowserDetect.browser == 'Explorer' && BrowserDetect.version == 6) $('cities').style.visibility = "hidden";
			
			/* trigger added function */
			if (eval(contentFile+'OverlayAdded')) eval(contentFile+'OverlayAdded')();
    		},
    		
    		onFailure: function()
    		{ 
    			alert('Something went wrong...') 
    		}
  	});
}

function hideOverlay ()
{
	if(exitFunctionGlobal) eval(exitFunctionGlobal)();
	new Effect.Fade($('overlayContent'), { queue: 'end'});
	setTimeout(function () { new Effect.Fade($('overlayBackground'), { queue: 'end'}); }, 1000);	
	setTimeout(function () { $('overlay').style.display = 'none'; }, 1500);
	if (BrowserDetect.browser == 'Explorer' && BrowserDetect.version == 6) $('cities').style.visibility = "visible";
}/*
	menu.tabs.js
	tab menu lib
*/

stateCategory = null;
stateInfo = null;
stateSearch = null;

function initTabMenu ()
{
	/* set default active tab */
	contentTabMenu('category');
	
	/* load events */
	
	// category
	$('tabCategory').onclick = function () 
	{
		contentTabMenu('category');
	}	
	
	$('tabCategory').onmouseover = function () 
	{
		this.className = 'active';
	}
	
	$('tabCategory').onmouseout = function () 
	{
		this.className = stateCategory;
	}
	
	/*
	// info
	$('tabInfo').onclick = function () 
	{
		$('contentInfoLoading').style.display = 'block';
		getAddressOverview();
		contentTabMenu('info');
	}	
	
	$('tabInfo').onmouseover = function () 
	{
		this.className = 'active';
	}
	
	$('tabInfo').onmouseout = function () 
	{
		this.className = stateInfo;
	} */
	
	/*
	// search
	$('tabSearch').onclick = function () 
	{
		contentTabMenu('search');
	}	
	
	$('tabSearch').onmouseover = function () 
	{
		this.className = 'active';
	}
	
	$('tabSearch').onmouseout = function () 
	{
		this.className = stateSearch;
	} */	
}

function contentTabMenu (type)
{

	if(type == 'category')
	{
		$('tabCategory').className 	= "active";
		stateCategory 			= "active";
		
		/*$('tabInfo').className 		= null;
		stateInfo 			= null;		
		
		
		$('tabSearch').className 	= null;
		stateSearch 			= null;	
		*/
		
		showContent (type);
	}
	
	if(type == 'info')
	{
		$('tabCategory').className 	= null;
		stateCategory 			= null;
		
		/*$('tabInfo').className 		= "active";
		stateInfo 			= "active";		

		
		$('tabSearch').className 	= null;
		stateSearch 			= null;	
		*/
		
		showContent (type);
	}
	
	if(type == 'search')
	{
		$('tabCategory').className 	= null;
		stateCategory 			= null;
		
		/*
		$('tabCity').className 		= null;
		stateCity 			= null;		

		$('tabSearch').className 	= "active";
		stateSearch 			= "active";
		
		showContent (type);
		*/
	}	

}

function showContent (type)
{
	if(type == 'category')
	{
		$('contentCategory').style.display 	= "block";
		$('contentInfo').style.display 		= "none";
		$('contentSearch').style.display 	= "none";
	}
	
	if(type == 'info')
	{
		$('contentCategory').style.display 	= "none";
		$('contentInfo').style.display 		= "block";
		$('contentSearch').style.display 	= "none";	
	}
	
	if(type == 'search')
	{
		$('contentCategory').style.display 	= "none";
		$('contentInfo').style.display 		= "none";
		$('contentSearch').style.display 	= "block";
	}
}/*
	select.city.js
	inits city select
*/

function initSelectCity ()
{
	// events
	if ($('cities'))
	{
		if ($('cities'))
		{
			$('cities').onchange = function () 
			{
				changeCity (this.value);
			}
		}
	}
}

function changeCity (city)
{
	if (routeEdit)
	{
		if (confirm("De huidige route gaat verloren, doorgaan?"))
		{
			stopRouteManual ();
			changeCityAndClear (city);
		}
	}
	else
	{
		changeCityAndClear (city);
	}
}

function changeCityAndClear (city)
{
	city_id = city;

	if (city_id == 1)
	{
		if($('h1_nikecityrun'))
		{		
			showNikeRun = true;
			$('h1_nikecityrun').style.display = 'block';
			$('ul_nikecityrun').style.display = 'block';
			$('li_nikecityrun_18').style.display = 'block';
			$('category_nikecityrun_18').checked = false;
			stateNike = false;
		}
	}
	else
	{
		if($('h1_nikecityrun'))
		{
			showNikeRun = false;
			$('h1_nikecityrun').style.display = 'none';
			$('ul_nikecityrun').style.display = 'none';
			$('li_nikecityrun_18').style.display = 'none';	
		}
	}

	map.clearOverlays();

	$('ajaxLoad').style.display = 'block';
	markersAjaxLoaded = 0;
	markersAjaxLoadedDone = 0;	
	ajaxLoadingCheck();

	/* add hover marker */
	hovermarker = new GMarker(offmap, icons['hover']);
	map.addOverlay(hovermarker);	

	clearAdresses();
	initMarkers();
	gotoCity (city);
}

function gotoCity (city)
{
	new Ajax.Request('/load.city.php',
  	{
    		method:'get',
    		parameters: 'city_id='+ city,
    		    		
    		onSuccess: function(d)
    		{
      			var response = d.responseText;
      
			var xml = GXml.parse(response);
			var point = xml.documentElement.getElementsByTagName("point");
			for (var i = 0; i < point.length; i++) 
			{
				var gotoPoint = new GLatLng(parseFloat(point[i].getAttribute("lat")), parseFloat(point[i].getAttribute("long")));
			}
						
			map.setCenter(gotoPoint);
    		},
    		
    		onFailure: function()
    		{ 
    			alert('Something went wrong...') 
    		}
  	});
}var currentRoute = Array();
var currentRoutePol;

var routeMarkers = Array();

var routeEdit;

var routeMarkersConfig = Array("green", "grey", "yellow", "red");
var routeMarkersIcons = Array();

var routeMarkers = Array(); // stores routemarkers
var routeMarkersList = Array(); // stores routemarkers and shows list

var yellowTitles = Array();

var routeMarkerActive;

var routeEnd;
var stateRouteButton;

var routeMarkersNames = {green: "Beginpunt", red: "Eindpunt", grey: "Normaal punt", yellow: "Speciaal punt"};

var kmBuffer = 0;

var offsetRoute = 257;

var actualZoomlevel;

var routeDirections;
var routeDirectionsPolyline;

function initRoute ()
{
	/* default vars */
	routeEnd 		= false;
	stateRouteButton 	= true;
	routeDirections		= new GDirections ();
	GEvent.addListener(routeDirections, "load", onGDirectionsLoad);
	
	/* resize route markers layer */
	setTimeout("resizeRouteMarkers ()", 1000);
	
	/* init marker icons */
	initRouteMarkers ();	
	
	/* init events */
	GEvent.addDomListener(map, "click", mapClick);
	GEvent.addDomListener(map, "mousemove", mapMove);
	GEvent.addDomListener(map, "mouseout", mapMoveOut);
	
	/* pull menu */
	$('routeButton').onclick = function () {
		toggleRouteMenu ();
	}
	
	/* set active buttons */
	$('routeButtonStart').className 	= '';
	$('routeButtonHelp').className 		= '';

	/* button events */
	$('routeButtonStart').onclick 		= startRoute;
	$('routeButtonClose').onclick 		= stopRoute;
	$('routeButtonHelp').onclick 		= showHelp;
	$('routeButtonProperties').onclick 	= showProperties;
	$('routeButtonShare').onclick 		= showShare;
	$('routeButtonPreview').onclick 	= showPreview;
	
	/* pull button */
	$('routeButton').onmouseover = function () 
	{
		if(stateRouteButton)
		{
			$('routeButton').style.background = 'url(img/layers/button.route.hover.png)';
		}
		else
		{
			$('routeButton').style.background = 'url(img/layers/button.route.off.hover.png)';
		}
		
		iePng(this);
	}
	
	$('routeButton').onmouseout = function () 
	{
		if(stateRouteButton)
		{
			$('routeButton').style.background = 'url(img/layers/button.route.png)';
		}
		else
		{
			$('routeButton').style.background = 'url(img/layers/button.route.off.png)';
		}
		
		iePng(this);
	}	

	/* zoom level detection */
	actualZoomlevel = map.getZoom();
	
	GEvent.addListener(map, 'zoomend',
		function (oldzoomlevel,newzoomlevel) 
		{
			actualZoomlevel = newzoomlevel;
		}
	);
	
	/* onsubmit print route */
	$('printRouteForm').onSubmit = function ()
	{
		return false;
	}
}

function onGDirectionsLoad ()
{
	if (routeDirections.getStatus().code == 200)
	{		
		/* add to map */
		map.removeOverlay (routeDirectionsPolyline);
		routeDirectionsPolyline = routeDirections.getPolyline();
		map.addOverlay(routeDirectionsPolyline);
		
		/* add info to list */
		var hours = (routeDirections.getDuration().seconds/3600);
		if (hours < 1)
		{
			hours = Math.round((routeDirections.getDuration().seconds/60));
			hours = hours + ' minuten';
		}
		else
		{
			hours = Math.floor(hours);

			var tempHours = routeDirections.getDuration().seconds/3600;	
			var tempMin = tempHours - hours;
			var tempMin = 60 * tempMin;
						
			hours = hours + ' uur en ' + Math.round(tempMin) + ' minuten';
		}
		
		$('routeMarkersTotal').innerHTML = Math.round(routeDirections.getDistance().meters/1000) + ' km - ' + hours;
		
	}
	else
	{
		alert (routeDirections.getStatus().code + ' - fout bij toevoegen marker');
		routeUndo();
	}
}

function getDirectionsOverview ()
{
	var kmBuffer = 0;
	var secBuffer = 0;
	var html = "";
	
	var routesTotal = routeDirections.getNumRoutes();
	
	html += "<h1>Routebeschrijving</h1>";
	
	html += "<table class=\"directionsOverview\" cellspacing=\"0\">";
	
	for (var i = 0; i < routeMarkersList.length; i++)
	{
		var type = routeMarkersList[i][0];
		var specialtype = routeMarkersList[i][1];
		var specialtitle = routeMarkersList[i][2];
		
		html += "<tr>";
		
			if (specialtype && specialtype != "null")
			{
				specialtype = specialtype.split("_");
				specialtype = specialtype[0];				
				
				html += "<td colspan=\"3\"><img src=\"img/icons/routeSmall/"+encodeURI(specialtype)+".gif\" alt=\"\" /> <b>"+specialtitle+"</b></td>";
			}
			else
			{
				html += "<td colspan=\"3\"><img src=\"img/icons/routeSmall/"+encodeURI(type)+".gif\" alt=\"\" /> <b>"+routeMarkersNames[type]+"</b></td>";
			}
		
		html += "</tr>";
	}
	
	html += "<tr class=\"special\"><td colspan=\"3\"></td></tr>";
	
	i=0;
	
	html += "<tr><th class=\"meters\"></th><th>Omschrijving</th><th class=\"time\">Tijd</th></tr>";
	
	//alert ('routes: '+routesTotal);
	
	for (var i = 0; i < routesTotal; i++)
	{
		var routesStepsTotal = routeDirections.getRoute(i).getNumSteps();
		
		//alert ('steps: '+routesStepsTotal);
		
		for (var j = 0; j < routesStepsTotal; j++)
		{
			var routesSteps = routeDirections.getRoute(i).getStep(j);
			
			secBuffer = secBuffer + routesSteps.getDuration().seconds;
			
			//alert ('html: '+routeDirections.getRoute(i).getStep(j).getDescriptionHtml());
			
			html += "<tr>";
				html += "<td class=\"meters\">na "+formatMeters(kmBuffer)+"</td>";
				
				html += "<td>";
					html += routesSteps.getDescriptionHtml();
				html += "</td>";
				
				html += "<td class=\"time\">"+formatSeconds (secBuffer)+"</td>";
			html += "</tr>";
			
			kmBuffer = routesSteps.getDistance().meters;
		}
		
		var type = routeMarkersList[i+1][0];
		var specialtype = routeMarkersList[i+1][1];
		var specialtitle = routeMarkersList[i+1][2];
				
		html += "<tr class=\"special\">";
		
			if (specialtype && specialtype != 'null')
			{
				specialtype = specialtype.split("_");
				specialtype = specialtype[0];				
				
				html += "<td colspan=\"3\"><img src=\"img/icons/routeSmall/"+encodeURI(specialtype)+".gif\" alt=\"\" /> Aankomst <b>"+specialtitle+"</b></td>";
			}
			else
			{
				html += "<td colspan=\"3\"><img src=\"img/icons/routeSmall/"+encodeURI(type)+".gif\" alt=\"\" /> Aankomst <b>"+routeMarkersNames[type]+"</b></td>";
			}
		
		html += "</tr>";
	}
	
	html += "</table>";
	
	//showOverlay('route_print');
	//setTimeout(function () { $('routeOverviewHtml').innerHTML = html }, 1000);
	
	$('printRouteData').value = html;
	$('printRouteForm').submit();
}

function formatMeters (met)
{
	var meters;
	
	if (met >= 1000)
	{
		meters = met / 1000;
		
		meters = Math.round(meters * 100) / 100;
		
		meters = meters + "km";
	}
	else
	{
		meters = met + "m";
	}
	
	return meters;
}

function formatSeconds (sec)
{
	var hours = (sec/3600);
	if (hours < 1)
	{
		hours = Math.round((sec/60));
		hours = hours + ' minuten';
	}
	else
	{
		hours = Math.floor(hours);

		var tempHours = sec/3600;	
		var tempMin = tempHours - hours;
		var tempMin = 60 * tempMin;

		hours = hours + ' uur en ' + Math.round(tempMin) + ' minuten';
	}
	
	return hours;
}

var moveLine;
var moveMarker;

function mapMove (latlng)
{
	if (routeEdit && !routeEnd)
	{
		if (currentRoute[0])
		{
			// line
			if($('showPolygon').checked)
			{
				map.removeOverlay(moveLine);
				var lastpoint = currentRoute[currentRoute.length-1];
				var arr = Array();
				arr.push(lastpoint);
				arr.push(latlng);
				moveLine = new GPolyline(arr, '#0E3152',3,0.4);
				map.addOverlay(moveLine);
			}
			
			// marker
			map.removeOverlay(moveMarker);
			
			var active_trans = routeMarkerActive+"_trans";
			
			moveMarker = new GMarker(latlng, routeMarkersIcons[active_trans], {clickable: false});
							
				/*GEvent.addListener(moveMarker, "click", function() 
				{
					mapClick(null, latlng);
				});*/
				
			map.addOverlay(moveMarker);
		}
	}
}

function mapMoveOut ()
{
	map.removeOverlay(moveMarker);
	map.removeOverlay(moveLine);
}

function toggleRouteMenu ()
{
	if (stateRouteButton)
	{
		// close
				
		new Effect.Move ($('routeEvent'),{ queue: 'end', x: -(offsetRoute), y: 0, mode: 'relative', duration: 0.7});
		new Effect.Move ($('routeMarkersEvent'),{ queue: 'end', x: -(offsetRoute), y: 0, mode: 'relative', duration: 0.7});
		
		$('routeButton').title = 'Uitklappen';
		
		stateRouteButton = false;
	}
	else
	{
		// open
		
		new Effect.Move ($('routeEvent'),{ queue: 'end', x: offsetRoute, y: 0, mode: 'relative', duration: 0.7});
		new Effect.Move ($('routeMarkersEvent'),{ queue: 'end', x: offsetRoute, y: 0, mode: 'relative', duration: 0.7});
		
		$('routeButton').title = 'Inklappen';
		
		stateRouteButton = true;
	}
}

function showHelp ()
{
	if (this.className != "inactive")
	{
		showOverlay ('help');
	}
}

function startRoute ()
{
	if (this.className != "inactive")
	{
		/* init data vars */
		currentRoutePol = new GPolyline(currentRoute);
		map.addOverlay(currentRoutePol);

		/* enable route editting */
		routeEdit = true;

		/* update navigation */
		checkRouteMarkersNavigation ();

		/* do button activity */
		$('routeButtonStart').className = 'inactive';
		$('routeButtonClose').className = '';
		//$('routeButtonImport').className = '';
		$('routeButtonProperties').className = '';
		$('routeButtonHelp').className = '';

		/* show workset */
		$('routeWorkset').style.display = 'block';
		new Effect.Fade($('routeWorkset'), {from:0, to:1.0, queue: 'end'});
		
		$('routeMarkers').style.display = 'block';
		new Effect.Fade($('routeMarkers'), {from:0, to:1.0, queue: 'end'});
		
		/* update route markers layer size */
		resizeRouteMarkers ();
		
		/* clear viewable route */
		map.removeOverlay(viewRoutePointsPol);
		viewRouteClear ();
	}
}

function stopRoute ()
{
	if (this.className != "inactive")
	{
		if (confirm("De huidige route gaat verloren, doorgaan?"))
		{
			/* clear functions call */
			routeEdit = false;
			clearRoute ();
			routeNavigationClearAll ();
			mapMoveOut ();
			
			/* clear input */
			routeGlobalTitle = "";
			routeGlobalDescription = "";			

			/* show stop/start button */
			$('routeButtonStart').className = '';
			$('routeButtonClose').className = 'inactive';	
			//$('routeButtonOpen').className = 'inactive';	
			//$('routeButtonSave').className = 'inactive';	
			//$('routeButtonImport').className = 'inactive';	
			$('routeButtonProperties').className = 'inactive';
			$('routeButtonPreview').className = 'inactive';
			$('routeButtonShare').className = 'inactive';
			$('routeButtonHelp').className = '';
			
			/* update route markers layer size */
			resizeRouteMarkers ();	
			
			/* hide layers */
			new Effect.Fade($('routeMarkers'), {queue: 'end'});
			new Effect.Fade($('routeWorkset'), {queue: 'end'});
			
			/* empty total */
			$('routeMarkersTotal').innerHTML = 0;
			kmBuffer = 0;
		}
	}
}

function stopRouteManual ()
{
	/* clear functions call */
	routeEdit = false;
	clearRoute ();
	routeNavigationClearAll ();
	mapMoveOut ();
	
	/* clear input */
	routeGlobalTitle = "";
	routeGlobalDescription = "";

	/* show stop/start button */
	$('routeButtonStart').className = '';
	$('routeButtonClose').className = 'inactive';	
	//$('routeButtonOpen').className = 'inactive';	
	//$('routeButtonSave').className = 'inactive';	
	//$('routeButtonImport').className = 'inactive';	
	$('routeButtonProperties').className = 'inactive';	
	$('routeButtonShare').className = 'inactive';
	$('routeButtonPreview').className = 'inactive';
	$('routeButtonHelp').className = '';

	/* update route markers layer size */
	resizeRouteMarkers ();	

	/* hide layers */
	new Effect.Fade($('routeMarkers'), {queue: 'end'});
	new Effect.Fade($('routeWorkset'), {queue: 'end'});

	/* empty total */
	$('routeMarkersTotal').innerHTML = 0;
	kmBuffer = 0;
}

function mapClick (marker, point)
{
	map.removeOverlay(moveLine);
		
	if (!routeEnd && routeEdit)
	{
		if(marker && marker.getIcon)
		{
			var point = marker.getPoint();
						
			if(routeMarkers[routeMarkers.length-1]) var km = point.distanceFrom(routeMarkers[routeMarkers.length-1].getPoint());
			
			var type = marker.getIcon().image;
			type = type.split("/");
			type = type[type.length-1];
			type = type.split(".");
			
			if(type[0] == 'marker')
			{
				type = type[1];
				var isRouteMarker = false;
			}
			else
			{
				type = type[0];
				var isRouteMarker = true;
			}
			
			if (isRouteMarker)
			{
			
			}
			else
			{
				// add the normal marker to the route
				
				currentRoute.push(point);

				if (currentRoute.length > 1)
				{
					map.removeOverlay(currentRoutePol);

					//currentRoutePol = new GPolyline(currentRoute,'#0E3152',3,1);

					if($('showPolygon').checked)
					{
						//map.addOverlay(currentRoutePol);
						routeDirections.loadFromWaypoints(currentRoute, {getPolyline: true, getSteps: true, locale: 'nl'});
					}
				}
				
				/* store in marker list */
				markerlistAdd(routeMarkerActive, type, marker.title, km, point);				
			}
			
		}
		else
		{	
			currentRoute.push(point);

			if (currentRoute.length > 1)
			{
				map.removeOverlay(currentRoutePol);

				//currentRoutePol = new GPolyline(currentRoute,'#0E3152',3,1);
				
				if($('showPolygon').checked)
				{
					//map.addOverlay(currentRoutePol);
					routeDirections.loadFromWaypoints(currentRoute, {getPolyline: true, getSteps: true, locale: 'nl'});
				}
			}
			else
			{
				/* first point */
				$('routeButtonPreview').className = '';
			}

			/* build marker */
			var marker = new GMarker(point, routeMarkersIcons[routeMarkerActive]);

			/* add event */
			if(routeMarkerActive == 'yellow')
			{
				GEvent.addListener(marker, "click", function() 
				{
					if (routeEnd)
					{
						var html = "<strong>Wijzig titel</strong>";
						html 	+= "<p>";
						html	+= "<input type=\"text\" id=\"markerTitle_"+this.listId+"\"><input type=\"submit\" value=\"Wijzigen\" onclick=\"editTitle($('markerTitle_"+this.listId+"').value, "+this.listId+");\" value=\"Wijzigen\" />";
						html	+= "</p>";
	
						marker.openInfoWindowHtml(html);

						$('markerTitle_'+this.listId).value = (marker.title ? marker.title : "");
					}
				});
			}
			
			/* store marker */
			marker.listId = routeMarkers.length;
			routeMarkers.push(marker);
			map.addOverlay(marker);
			
			/* get km */
			if(routeMarkers[marker.listId-1]) var km = point.distanceFrom(routeMarkers[marker.listId-1].getPoint());
			
			/* store in marker list */
			markerlistAdd(routeMarkerActive, null, null, km, point);

			/* check for last point */
			if (routeMarkerActive == 'red')
			{
				// we've got the last marker
				routeEnd = true;
				$('routeButtonShare').className = '';
				//$('routeButtonSave').className = '';
			}
		}
	
		checkRouteMarkersNavigation ();
	}
}

function toggleShowPolygon()
{
	if($('showPolygon').checked)
	{
		map.addOverlay(currentRoutePol);
	}
	else
	{
		map.removeOverlay(currentRoutePol);
		map.removeOverlay(moveLine);
	}
}

function editTitle (title, id)
{
	routeMarkersList[id][2] = title; 
	routeMarkers[id].title = title;
	
	updateMarkerlist ();
	map.closeInfoWindow();
}

function markerlistAdd (type, specialtype, specialtitle, km, point)
{
	routeMarkersList.push(Array(type, specialtype, specialtitle, km, point));
	
	updateMarkerlist ();
	
	$('routeMarkersList').scrollTop = $('routeMarkersList').scrollHeight;	
}

function routeMarkerHover (i)
{
	hovermarker.setPoint(routeMarkersList[i][4]);
}

function routeMarkerHoverOut ()
{
	hovermarker.setPoint(offmap);	
}

function updateMarkerlist ()
{
	$('routeMarkersList').innerHTML = '';
	
	var html = "";
	var undoHtml = "";
	
	kmBuffer = 0;
	
	for (var i = 0; i < routeMarkersList.length; i++)
	{
		var type = routeMarkersList[i][0];
		var specialtype = routeMarkersList[i][1];
		var specialtitle = routeMarkersList[i][2];
		var km = routeMarkersList[i][3];
		var point = routeMarkersList[i][4];
		
		if(!km) km = 0;
		
		kmBuffer = kmBuffer;
		
		km = Math.round(kmBuffer/10)/100;
				
		if (viewRoute && specialtype == 'null') specialtype = false;
		
		if (specialtype)
		{
			specialtype = specialtype.split("_");
			specialtype = specialtype[0];
			
			html += "<div class=\"marker\" onmouseover=\"javascript:routeMarkerHover("+i+");\" onmouseout=\"javascript:routeMarkerHoverOut();\" "+(viewRoute ? "onclick=\"map.setCenter(routeMarkersList["+i+"][4])\" style=\"cursor:pointer; background-image: url(img/icons/routeSmall/"+specialtype+".gif);\"" : "style=\"background-image: url(img/icons/routeSmall/"+specialtype+".gif);\"")+">"+specialtitle+"</div>";
		}
		else
		{
			html += "<div class=\"marker "+type+"\" onmouseover=\"javascript:routeMarkerHover("+i+");\" onmouseout=\"javascript:routeMarkerHoverOut();\" "+(viewRoute ? "onclick=\"map.setCenter(routeMarkersList["+i+"][4])\" style=\"cursor:pointer;\"" : null)+" "+(type == 'yellow' && !viewRoute ? "onclick=\"openMarker("+(i)+")\"" : null)+">"+(specialtitle ? specialtitle : routeMarkersNames[type])+"</div>";
		}
	}
	
	if(html.length > 0 && viewRoute != true) var undoHtml = "<div class=\"marker undo\"><a href=\"javascript:void(0);\" onclick=\"javascript:routeUndo();\">Laatst aangemaakte locatie ongedaan maken</a></div>";
	
	if(html.length > 0)
	{
		$('routeLinkMore').innerHTML = " | <a href=\"javascript:void(0);\" onclick=\"getDirectionsOverview ();\">uitgebreid / print</a>";
	}
	else
	{
		$('routeLinkMore').innerHTML = "";
	}
	
	$('routeMarkersList').innerHTML = html + undoHtml;
}

function openMarker (id)
{
	GEvent.trigger(routeMarkers[id], 'click');
}

function routeUndo ()
{
	if (currentRoute.length > 0)
	{
		currentRoute.pop();
		routeMarkersList.pop();
		
		map.removeOverlay(routeDirectionsPolyline);
		routeDirectionsPolyline = null;
		routeDirections.loadFromWaypoints(currentRoute, {getPolyline: true, getSteps: true, locale: 'nl'});
				
		map.removeOverlay(currentRoutePol);
		currentRoutePol = new GPolyline(currentRoute,'#0E3152',3,1);
		
		if($('showPolygon').checked)
		{
			//map.addOverlay(currentRoutePol);
		}
		
		total = routeMarkers.length-1;		
		map.removeOverlay(routeMarkers[total]);	
		routeMarkers.pop();
		
		if (routeEnd)
		{
			routeEnd = false;
			markersNavigationEnableAfterGreen ();
		}
		
		if (currentRoute.length == 1)
		{
			$('routeMarkersTotal').innerHTML = "";
		}
		
		if (currentRoute.length == 0)
		{
			$('routeMarkersTotal').innerHTML = "";
			routeNavigationClearAll ();
			$('green_RouteMarker').className = 'active selected';
			routeMarkerActive = 'green';			
		}
		
		updateMarkerlist ();
	}
}

function clearRoute ()
{
	map.removeOverlay(routeDirectionsPolyline);
	currentRoute = Array();
	routeMarkersList = Array();
	$('routeMarkersList').innerHTML = '';
	currentRoutePol = null;
	clearRouteMarkers();
	routeEnd = false;
	routeMarkerActive = false;
	
	$('routeMarkersTotal').innerHTML = '0';
	
	routeNavigationClearAll ();
	setRouteMarkerSelected ('green');
}

function initRouteMarkers ()
{
	for (var i = 0; i < routeMarkersConfig.length; i++)
	{
		name = routeMarkersConfig[i];
		
		// create the icon
		routeMarkersIcons[name] 			= new GIcon();
		routeMarkersIcons[name].image 			= "img/icons/route/" + name + ".png";
		routeMarkersIcons[name].iconSize 		= new GSize(24, 32);
		routeMarkersIcons[name].iconAnchor 		= new GPoint(12, 31);
		routeMarkersIcons[name].infoWindowAnchor 	= new GPoint(12, 31);
		
		// create the transparant icon
		
		var name2 = name + '_trans';
		
		routeMarkersIcons[name2] 			= new GIcon();
		routeMarkersIcons[name2].image 			= "img/icons/route/" + name + ".transparant.png";
		routeMarkersIcons[name2].iconSize 		= new GSize(24, 32);
		routeMarkersIcons[name2].iconAnchor 		= new GPoint(12, 31);
		routeMarkersIcons[name2].infoWindowAnchor 	= new GPoint(12, 31);		
		
		// create the navigation
		$(name+'_RouteMarker').className = 'inactive';
		$(name+'_RouteMarker').onclick = routeNavigationClick;
	}
}

function routeNavigationClick ()
{
	obj = this;
	var name2 = obj.id;
	var name3 = name2.split('_');
	var name = name3[0];
	
	if (this.className == 'active')
	{
		setRouteMarkerSelected (name);
	}
}

function clearRouteMarkers ()
{
	for (var i = 0; i < routeMarkers.length; i++)
	{
		map.removeOverlay(routeMarkers[i]);
	}
}

function checkRouteMarkersNavigation ()
{
	if (routeEdit)
	{
		if (routeEnd)
		{
			// disable all
			for (var i = 0; i < routeMarkersConfig.length; i++)
			{
				var name = routeMarkersConfig[i];
				$(name+'_RouteMarker').className = "inactive";
			}		
		}
		else if (currentRoute.length == 1)
		{
			markersNavigationEnableAfterGreen ();
		}
		else if (currentRoute.length == 0)
		{
			// enable only start/green
			$('green_RouteMarker').className = 'active selected';
			routeMarkerActive = 'green';
		}
	}
}

function markersNavigationEnableAfterGreen ()
{
	// enable all
	for (var i = 0; i < routeMarkersConfig.length; i++)
	{
		var name = routeMarkersConfig[i];
		$(name+'_RouteMarker').className = "active";
	}	

	setRouteMarkerSelected ('grey');
	$('green_RouteMarker').className = "inactive";
}

function setRouteMarkerSelected (type)
{
	for (var i = 0; i < routeMarkersConfig.length; i++)
	{
		var name = routeMarkersConfig[i];
		var className2 = $(name+'_RouteMarker').className.split(' ');
		var className2 = className2[0];
		$(name+'_RouteMarker').className = className2;
	}	
	
	routeMarkerActive = type;
	
	$(type+'_RouteMarker').className = "active selected";
}

function routeNavigationClearAll ()
{
	for (var i = 0; i < routeMarkersConfig.length; i++)
	{
		var name = routeMarkersConfig[i];
		$(name+'_RouteMarker').className = 'inactive';
	}
}/* ********************************************
	lib: 	route v2 library
	class: 	Route
	desc.:	loads all route functions
******************************************** */

function Route() 
{
	var _this = this;
	
	/* bool */
	this._routeEditEnabled 	= false;
	
	/* objects */
	this.routeMenu 		= null;
	this.routeContext 	= null;
	this.routeOptions 	= null;
	this.routeOverview 	= null;
	this.routeData 		= null;
	this.routeTools 	= null;
	this.routeTabs		= null;
	this.routeFind		= null;
	
	this.cfgCodeEdit	= null;
	
	this._constructor = function ()
	{
		debug ('Route :: initialized');
		
		this.routeMenu = new RouteMenu ();
	}
	
	this.enableRouteEdit = function ()
	{
		/* save the bool */
		this._routeEditEnabled = true;

		/* enable objects */
		this.routeData = new RouteData ();
		this.routeOptions = new RouteOptions ();
		this.routeOptionsUser = new RouteOptionsUser ();
		this.routeTools = new RouteTools ();
		
		/* set hand tool active */
		this.routeTools.setActive ('hand');

		/* set the default route title */
		route.routeData.changeData ('route', 'title', 'Nieuwe kaart');
		
		/* add context menu */
		this.routeContext = new RouteContext ();
		
		/* enable menu buttons */
		routeButtons[routeButtonsAliases['start']].setInactive ();
		routeButtons[routeButtonsAliases['open']].setInactive ();
		routeButtons[routeButtonsAliases['save']].setActive ();
		routeButtons[routeButtonsAliases['stop']].setActive ();
		
		/* enable route panel */
		this.routeMenu.initializeRoutePanel ();
		
		/* add default data to RouteOverview */
		this.routeOverview = new RouteOverview();
		
		/* initialize tabs */
		this.routeTabs = new RouteTabs ();
		
		/* initialize search */
		this.routeFind = new RouteFind ();
		
		$('routeTabSearch').style.display = 'block';
		$('routeTabRoute').style.display = 'block';
		
		debug ('Route :: route edit enabled');
	}
	
	this.routeOpen = function ()
	{
		/* enable route edit */
		this.enableRouteEdit ();
		
		route.routeTabs.setActive ('routeTabOverview');
		
		$('routeTabSearch').style.display = 'none';
		$('routeTabRoute').style.display = 'none';
		
		/* set route open vars */
		var html = "";
		html += "<h2>Kaart openen</h2>";
		
		html += "<div id=\"routeOverviewUserError\"></div>";
		
		html += "<p>Kaart wijzig code:</p>";
		html += "<p class=\"formInfo\">Deze code heb je opgestuurd gekregen via e-mail.</p>";
		html += "<p><input type=\"text\" id=\"routeOpenCode\" class=\"inputText\" value=\"\" /></p>";
		html += "<p><input class=\"inputButton\" id=\"routeOpenButton\" type=\"button\" value=\"Openen &raquo;\" /></p>";
		
		$('routeMarkersContent').innerHTML = html;
		
		$('routeOpenButton').onclick = _this.routeOpenHandler;
	}
	
	this.routeOpenHandler = function ()
	{
		$('routeOpenCode').className = "";
		$('routeOverviewUserError').innerHTML = "";
		this.value = "Openen »";
		
		if ($('routeOpenCode').value.length > 20 && $('routeOpenCode').value.length < 40)
		{
			this.value = "Bezig met laden...";
			/* ajax request */
			new Ajax.Request('/route2.open.php',
			{
				method:'get',

				parameters: {
					code_edit: $('routeOpenCode').value
				},

				onSuccess: function(d)
				{
					var response = d.responseText;

					if (response == "notfound")
					{
						debug ("Route :: routeOpen :: code_edit not found");
						
						$('routeOpenCode').className = "error";
						$('routeOverviewUserError').innerHTML = "<p>De ingevoerde code is onjuist</p>";
						this.value = "Openen »";
					}
					else if (response == "error")
					{
						debug ("Route :: routeOpen :: error");
					}					
					else
					{
						debug ("RouteData :: routeOpen :: code found");

						/* code found */
						$('routeTabSearch').style.display = 'block';
						$('routeTabRoute').style.display = 'block';
						
						_this.cfgCodeEdit = $('routeOpenCode').value;
						routeButtons[routeButtonsAliases['send']].setActive ();
						routeButtons[routeButtonsAliases['viewroute']].setActive ();
						route.routeData.fromXml (response);
					}

				},

				onFailure: function()
				{ 
					debug ("RouteData :: save request error");
				}
			});			
		}
		else
		{
			$('routeOpenCode').className = "error";
			$('routeOverviewUserError').innerHTML = "<p>Vul een geldige code in. Deze code heb je opgestuurd gekregen via e-mail toen je de kaart opgeslagen had.</p>";
		}
	}
	
	this.disableRouteEdit = function ()
	{
		if (confirm ("Weet je zeker dat je deze kaart wilt sluiten?"))
		{
			/* save the bool */
			this._routeEditEnabled = false;

			/* clear data */
			this.routeData.clear ();

			/* disable objects */
			this.routeData = null;
			this.routeOptions = null;
			this.routeOptionsUser = null;

			/* remove tools panel */
			this.routeTools.remove();
			this.routeTools = null;

			/* add context menu */
			this.routeContext.clear ();
			this.routeContext = null;

			/* enable menu buttons */
			routeButtons[routeButtonsAliases['start']].setActive ();
			routeButtons[routeButtonsAliases['open']].setActive ();
			routeButtons[routeButtonsAliases['save']].setInactive ();
			routeButtons[routeButtonsAliases['send']].setInactive ();
			routeButtons[routeButtonsAliases['stop']].setInactive ();
			routeButtons[routeButtonsAliases['viewroute']].setInactive ();

			/* enable route panel */
			this.routeMenu.hideRoutePanel ();

			/* remove the routeOverview object */
			this.routeOverview = null;
			
			/* initialize tabs */
			this.routeTabs = null;

			/* initialize search */
			this.routeFind = null;			

			debug ('Route :: route edit disabled');
		}
	}
	
	this.share = function ()
	{
		if ($('routeShareEmails').value.length > 0)
		{
			$('routeShareEmailsButton').value = "Bezig met versturen...";
			
			new Ajax.Request('/route2.mail.php',
			{
				method:'get',

				parameters: {
					emails: encodeURI($('routeShareEmails').value),
					code_edit: encodeURI(this.cfgCodeEdit)
				},

				onSuccess: function(d)
				{
					var response = d.responseText;

					hideOverlay ();
				},

				onFailure: function()
				{ 
					debug ("Route :: mail request error");
					
					hideOverlay ();
				}
			});
		}
	}
	
	this._constructor ();
}/* ********************************************
	lib: 	route v2 library
	class: 	RouteMenu
	desc.:	route menu functions
******************************************** */

var routeButtonsAliases = Array();
var routeButtons = Array();

function RouteMenu() 
{
	// self object
	var _this = this;

	// config
	_this._offsetRouteShowHide = 257;
		
	// menu content div
	this.menuContent = $('routeContent');
	
	// states:
	this._stateRouteShowHide = true;

	this._constructor = function ()
	{
		debug ('RouteMenu :: initialized');
		
		this.addTitle ();
		this.initializeRouteButtons ();
		this.initializeShowHide ();
	}
	
	this.addTitle = function ()
	{
		this.menuContent.innerHTML += "<h2>Kaart maken <span>Vernieuwd!</span></h2>";
	}
	
	this.initializeShowHide = function ()
	{
		/* onclick event */
		$('routeButton').onclick = this.buttonShowHide;
		
		/* mouseover events */
		$('routeButton').onmouseover = this.buttonMouseover;
		$('routeButton').onmouseout = this.buttonMouseout;		
	}
	
	this.buttonMouseover = function ()
	{
		if(_this._stateRouteShowHide)
		{
			$('routeButton').style.background = 'url(img/layers/button.route.hover.png)';
		}
		else
		{
			$('routeButton').style.background = 'url(img/layers/button.route.off.hover.png)';
		}

		iePng(this);	
	}

	this.buttonMouseout = function ()
	{
		if(_this._stateRouteShowHide)
		{
			$('routeButton').style.background = 'url(img/layers/button.route.png)';
		}
		else
		{
			$('routeButton').style.background = 'url(img/layers/button.route.off.png)';
		}

		iePng(this);	
	}	
	
	this.buttonShowHide = function ()
	{
		if (_this._stateRouteShowHide)
		{
			/* close */

			new Effect.Move ($('routeEvent'),{ queue: 'end', x: -(_this._offsetRouteShowHide), y: 0, mode: 'relative', duration: 0.7});
			new Effect.Move ($('routetabs'),{ queue: 'end', x: -(_this._offsetRouteShowHide), y: 0, mode: 'relative', duration: 0.7});
			new Effect.Move ($('routeMarkersEvent'),{ queue: 'end', x: -(_this._offsetRouteShowHide), y: 0, mode: 'relative', duration: 0.7});

			$('routeButton').title = 'Uitklappen';

			_this._stateRouteShowHide = false;
		}
		else
		{
			/* open */

			new Effect.Move ($('routeEvent'),{ queue: 'end', x: _this._offsetRouteShowHide, y: 0, mode: 'relative', duration: 0.7});
			new Effect.Move ($('routetabs'),{ queue: 'end', x: _this._offsetRouteShowHide, y: 0, mode: 'relative', duration: 0.7});
			new Effect.Move ($('routeMarkersEvent'),{ queue: 'end', x: _this._offsetRouteShowHide, y: 0, mode: 'relative', duration: 0.7});

			$('routeButton').title = 'Inklappen';

			_this._stateRouteShowHide = true;
		}
	}
	
	this.initializeRouteButtons = function ()
	{
		routeButtons[0] = 	new RouteMenuButton ('Start', 'start', true);
		routeButtons[1] = 	new RouteMenuButton ('Kaart openen', 'open', true);
		routeButtons[2] = 	new RouteMenuButton ('Bekijk kaart', 'viewroute', false);
		routeButtons[3] = 	new RouteMenuButton ('Kaart versturen', 'send', false);
		routeButtons[4] = 	new RouteMenuButton ('Kaart opslaan', 'save', false);
		routeButtons[5] = 	new RouteMenuButton ('Afsluiten', 'stop', false);
		
		routeButtonsAliases['start'] = 0;
		routeButtonsAliases['open'] = 1;
		routeButtonsAliases['viewroute'] = 2;
		routeButtonsAliases['send'] = 3;
		routeButtonsAliases['save'] = 4;
		routeButtonsAliases['stop'] = 5;
		
		this.drawRouteButtons ();
		this.addRouteButtonsEvents ();
	}
	
	this.drawRouteButtons = function ()
	{
		buttons_html = "";
		
		buttons_html += "<ul class=\"buttons\">";
		buttons_html += "<li>";
		
		for (var i = 0; i < routeButtons.length; i++)
		{
			buttons_html += routeButtons[i].getElement ();
			
			if ((i+1) == Math.round(routeButtons.length / 2))
				buttons_html += "</li><li>";
		}
		
		buttons_html += "</li>";
		buttons_html += "</ul>";
		
		buttons_html += "<div style=\"clear: both;\"></div>";
		
		this.menuContent.innerHTML += buttons_html;
		
		debug ('RouteMenu :: buttons html loaded');
	}
	
	this.addRouteButtonsEvents = function ()
	{
		for (var i = 0; i < routeButtons.length; i++)
		{
			routeButtons[i].createElementEvents ();
		}	
	}
	
	this.enableRouteMenu = function ()
	{
	
	}
	
	this.initializeRoutePanel = function ()
	{
		$('routeMarkers').style.display = 'block';
		
		this.resizeRoutePanel ();
		
		new Effect.Fade($('routeMarkers'), {from:0, to:1.0, queue: 'end'});	
	}
	
	this.hideRoutePanel = function ()
	{
		$('routeMarkers').style.display = 'none';
	}	
	
	this.resizeRoutePanel = function ()
	{
		if ($('routeBackground'))
		{
			$('routeMarkersBackground').style.height = (document.body.clientHeight - $('routeBackground').offsetHeight - 251)+"px";
			$('routeMarkers').style.top = $('routeBackground').offsetHeight+118+"px";
			//$('routeMarkersList').style.height = (document.body.clientHeight - $('routeBackground').offsetHeight - 275)+"px";
		}		
	}
	
	this._constructor ();
}/* ********************************************
	lib: 	route v2 library
	class: 	RouteMenuButton
	desc.:	route menu button
******************************************** */

function RouteMenuButton(name, alias, active) 
{
	this._name = name;
	this._alias = alias;
	this._element = null;
	this._active = active;
	
	var _this = this;
	
	this._constructor = function ()
	{
		debug ('RouteMenuButton :: created \'' + name + '\'');
		
		this.createElement ();
	}
	
	this.createElement = function ()
	{
		this._element = "<a href=\"javascript:void(0);\" class=\"" + (!this._active ? "inactive" : null) + "\" id=\"routeMenuButton_" + this._alias + "\">" + this._name + "</a>";
	}
	
	this.createElementEvents = function ()
	{
		debug ("RouteMenuButton :: createElementEvents :: "+this._alias);
		
		if ($('routeMenuButton_'+this._alias))
		{
			$('routeMenuButton_'+this._alias).onclick = this.onPress;
		}
	}
	
	this.onPress = function ()
	{
		if (_this._active)
		{
			var pressFunction = '_this.onPress_'+_this._alias;
			
			if (eval(pressFunction))
			{
				eval (pressFunction)();
			}
		}
	}
	
	this.onPress_start = function ()
	{
		if (!route._routeEditEnabled)
		{
			route.enableRouteEdit ();
		}
	}
	
	this.onPress_stop = function ()
	{
		if (route._routeEditEnabled)
		{
			route.disableRouteEdit ();
		}
	}
	
	this.onPress_save = function ()
	{
		if (route._routeEditEnabled)
		{
			route.routeTabs.setActive ('routeTabOverview');
			route.routeData.save ();
		}		
	}
	
	this.onPress_open = function ()
	{
		if (!route._routeEditEnabled)
		{
			route.routeOpen ();
		}		
	}
	
	this.onPress_send = function ()
	{
		if (route._routeEditEnabled)
		{
			showOverlay("route_share");
		}		
	}	
	
	this.onPress_viewroute = function ()
	{
		if (route._routeEditEnabled && route.routeData.routeViewCode.length > 0)
		{
			window.open ('showroute/'+route.routeData.routeViewCode, '_blank');
		}		
	}	
	
	this.setInactive = function ()
	{
		this._active = false;
		$('routeMenuButton_'+this._alias).className = 'inactive';
	}
	
	this.setActive = function ()
	{
		this._active = true;
		$('routeMenuButton_'+this._alias).className = '';
	}	
	
	this.getElement = function ()
	{
		return this._element;
	}

	this._constructor ();
}/* ********************************************
	lib: 	route v2 library
	class: 	Route
	desc.:	loads all route functions
******************************************** */

var contextMenuMouseOver = false;

var contextMenuPoint = null;

function RouteContext() 
{
	var _this = this;	
	
	this._constructor = function ()
	{
		this.buildMapPressHtml ();
		
		GEvent.addDomListener($('map'),"contextmenu", _this.mainContext);
		GEvent.addListener(map,"mousemove", _this.mainMove);
		
		GEvent.addListener(map,"mouseout", _this.hideContextmenu);
		GEvent.addListener(map,"dragstart", _this.hideContextmenu);
		GEvent.addListener(map,"click", _this.hideContextmenu);
		
		mainEventListener ($('routeMarkers'), 'mouseover', _this.hideContextmenu);
		mainEventListener ($('route'), 'mouseover', _this.hideContextmenu);
		mainEventListener ($('maptype'), 'mouseover', _this.hideContextmenu);
		mainEventListener ($('controls'), 'mouseover', _this.hideContextmenu);	
		mainEventListener ($('menu'), 'mouseover', _this.hideContextmenu);
		
		$('contextmenu').onmouseout = _this.contextmenuOut;
		$('contextmenu').onmouseover = _this.contextmenuOver;
		
		debug ('RouteContext :: initialized');
	}
	
	this.clear = function ()
	{
		$('contextmenuButtons').innerHTML = "";
		
		GEvent.clearListeners($('map'),  "contextmenu");
		GEvent.clearListeners(map,  "mousemove");
		
		mainRemoveListener ($('routeMarkers'), 'mouseover', _this.hideContextmenu);
		mainRemoveListener ($('route'), 'mouseover', _this.hideContextmenu);
		mainRemoveListener ($('maptype'), 'mouseover', _this.hideContextmenu);
		mainRemoveListener ($('controls'), 'mouseover', _this.hideContextmenu);	
		mainRemoveListener ($('menu'), 'mouseover', _this.hideContextmenu);
		
		$('contextmenu').onmouseout = null;
		$('contextmenu').onmouseover = null;
	}
	
	this.mainContext = function (point)
	{
		var x = Event.pointerX (point);
		var y = Event.pointerY (point);
		
		_this.showContextmenu (x, y);
	}
	
	this.mainMove = function (point)
	{
		contextMenuPoint = point;
	}
	
	this.showContextmenu = function (x, y)
	{
		var dimensions = $('contextmenu').getDimensions ();
		var height = dimensions.height;
		var offset = document.body.clientHeight - height;
		
		if (y > offset)
		{
			$('contextmenu').style.display = 'block';
			$('contextmenu').style.left = x + 'px';
			$('contextmenu').style.top = (y-height) + 'px';
		}
		else
		{		
			$('contextmenu').style.display = 'block';
			$('contextmenu').style.left = x + 'px';
			$('contextmenu').style.top = y + 'px';
		}
	}
	
	this.contextmenuOut = function ()
	{
		contextMenuMouseOver = false;
	}
	
	this.contextmenuOver = function ()
	{
		contextMenuMouseOver = true;
	}
	
	this.hideContextmenu = function ()
	{
		$('contextmenu').style.display = 'none';
	}
	
	this.buildMapPressHtml = function ()
	{
		var html = "";
		
		html += this.htmlButton ("Kaart centreren op dit punt", "contextButtonCenter");
		html += this.htmlButton ("Kaart inzoomen op dit punt", "contextButtonZoom");
		
		html += this.htmlSeparator ();
		
		html += this.htmlButton ("Nieuwe markering op dit punt", "contextButtonMarker");
		html += this.htmlButton ("Nieuwe lijn beginnen vanaf dit punt", "contextButtonLine");
		html += this.htmlButton ("Nieuwe route", "contextButtonLineauto");
		
		html += this.htmlSeparator ();
		
		html += this.htmlButton ("Help", "testets");
		
		$('contextmenuButtons').innerHTML = html;
	}
	
	this.htmlButton = function (title, action)
	{
		var html = "<li><a href=\"javascript:void(0);\" onclick=\"javascript:route.routeContext."+action+"();\"><span>"+title+"</span></a></li>";
		
		return html;
	}
	
	this.htmlSeparator = function ()
	{
		var html = "<li class=\"separator\"></li>";
		
		return html;
	}
	
	this.contextButtonCenter = function ()
	{
		map.setCenter (contextMenuPoint);
		this.hideContextmenu ();
	}
	
	this.contextButtonZoom = function ()
	{
		map.setCenter (contextMenuPoint, 17);
		this.hideContextmenu ();
	}
	
	this.contextButtonMarker = function ()
	{
		route.routeTools.routeToolsMarker.mapClick (null, contextMenuPoint);
		this.hideContextmenu ();
	}
	
	this.contextButtonLine = function ()
	{
		route.routeTools.setActive ('line');
		route.routeTools.routeToolsLine.mapClick (null, contextMenuPoint);
		this.hideContextmenu ();
	}
	
	this.contextButtonLineauto = function ()
	{
		route.routeTools.setActive ('autoline');
		this.hideContextmenu ();
	}	
	
	this._constructor ();
}/* ********************************************
	lib: 	route v2 library
	class: 	Route
	desc.:	loads all route functions
******************************************** */

function RouteData() 
{
	this.data 		= Array();
	
	this.markers 		= Array();
	
	this.overview 		= Array();
	
	this.lineMarkers 	= Array();
	this.lineArray 		= Array();
	this.linePolyline 	= Array();
	
	this.lineautoPolylines 	= Array();
	this.lineautoDirections	= Array();
	this.directionsPoints	= Array();
	
	this.routeId = 0;
	
	this._constructor = function ()
	{
		debug ('RouteData :: initialized');
	}
	
	this.overviewAdd = function (type, icon, title, id)
	{
		this.overview.push (Array(type, icon, title, id));
	}
	
	this.changeData = function (type, key, value)
	{
		if (!this.data[type])
		{
			/* the type is empty, make the new type */
			this.data[type] = Array();
		}
		
		this.data[type][key] = value;
	}
	
	this.getData = function (type, key)
	{
		if (this.data[type])
		{
			if (this.data[type][key])
			{
				if (this.data[type][key].length > 0)
				{
					return this.data[type][key];
				}
				else return '';
			}
			else return '';
		}
		else return '';
	}
	
	this.clear = function ()
	{
		/* remove markers */
		if (this.markers) for (var i = 0; i < this.markers.length; i++)
		{
			map.removeOverlay(this.markers[i]);
		}
		
		/* remove line markers */
		if (this.lineMarkers) for (var i = 0; i < this.lineMarkers.length; i++)
		{
			for (var j = 0; j < this.lineMarkers[i].length; j++)
			{			
				map.removeOverlay(this.lineMarkers[i][j]);
			}
		}
		
		/* remove polygons */
		if (this.linePolyline) for (var i = 0; i < this.linePolyline.length; i++)
		{
			map.removeOverlay(this.linePolyline[i]);
		}	
		
		/* remove auto polylines */
		if (route.routeTools.routeToolsLineauto.gdirections) for (var i = 0; i < route.routeTools.routeToolsLineauto.gdirections.length; i++)
		{
			map.removeOverlay(route.routeTools.routeToolsLineauto.gdirections[i].polyline);
		}
		
		/* unset objects */
		this.data 			= null;
		this.markers 			= null;
		this.lineMarkers 		= null;
		this.lineArray 			= null;
		this.linePolyline 		= null;
		
		route.routeTools.routeToolsLineauto.gdirections	= null;
		this.directionsPoints		= null;
		
		this.routeId 			= 0;
		
		this.overview 			= null;
	}

	this.save = function ()
	{
		if (this.getData ('route', 'done') == 'true' && this.getData ('user', 'done') == 'true')
		{
			if (this.routeId < 1)
			{
				var html = "";

				html += "<h2>Route opslaan</h2>";

				html += "<p>Na het opslaan van je kaart wordt een e-mail verstuurd met daarin een wachtwoord. Met dit wachtwoord kan je later je kaart wijzigen.</p>";

				html += "<p><input class=\"inputButton\" type=\"button\" value=\"Nu opslaan\" onclick=\"javascript:route.routeData.sendRequest ();\" /></p>";

				$('routeMarkersContent').innerHTML = html;		
			}
			else
			{
				route.routeData.sendRequest ();
			}
		}
		else
		{
			if (this.getData ('route', 'done') != 'true')
			{
				var html = "";

				html += "<h2>Vul eerst een beschrijving in</h2>";

				html += "<p>Voordat je de kaart kan opslaan moet je de <a href=\"javascript:void(0);\" onclick=\"javascript:route.routeOptions.fromError = true; route.routeOptions.startEdit();\">beschrijving van de kaart</a> opgegeven hebben.</p>";

				$('routeMarkersContent').innerHTML = html;			
			}
			else
			{
				var html = "";

				html += "<h2>Persoonlijke gegevens</h2>";

				html += "<p>Voordat je de kaart kan opslaan moet je je <a href=\"javascript:void(0);\" onclick=\"javascript:route.routeOptionsUser.startEdit();\">persoonlijke gegevens</a> opgegeven hebben.</p>";

				$('routeMarkersContent').innerHTML = html;
			}
		}
	}
	
	this.sendRequest = function ()
	{
		var xml = this.toXml ();

		debug (encodeURI(xml));

		/* ajax request */
		new Ajax.Request('/route2.save.php',
		{
			method:'post',

			parameters: {
				data: xml
			},

			onSuccess: function(d)
			{
				var response = d.responseText;

				if (response == "error")
				{
					debug ("RouteData :: save php error");
				}
				else
				{
					debug ("RouteData :: data saved");
					debug ("RouteData :: "+response);
					
					routeButtons[routeButtonsAliases['send']].setActive ();
					routeButtons[routeButtonsAliases['viewroute']].setActive ();
					
					var html = "";

					html += "<h2>Route opslaan</h2>";

					if (route.routeData.routeId > 0)
					{
						html += "<p>Je kaart is opgeslagen.</p>";
					}
					else
					{
						html += "<p>Je kaart is opgeslagen. Er is een e-mail verzonden met meer informatie.</p>";
					}
					
					html += "<p><input class=\"inputButton\" type=\"button\" value=\"Ga verder\" onclick=\"javascript:route.routeOverview.showOverview ();\" /></p>";

					$('routeMarkersContent').innerHTML = html;	
					
					var savedRouteId = response.split(';')[0];
					var savedRouteViewCode = response.split(';')[1];
					
					route.routeData.routeId = savedRouteId;
					route.routeData.routeViewCode = savedRouteViewCode;
					
					debug ("RouteData :: stored route with id: "+route.routeData.routeId);
				}

			},

			onFailure: function()
			{ 
				debug ("RouteData :: save request error");
			}
		});	
	}
	
	this.toXml = function ()
	{
		var xml = "";
		
		xml += "<data>";
		
		xml += "<options>";
		
			xml += "<routeId>"+this.routeId+"</routeId>";
			
			xml += "<city_id>"+city_id+"</city_id>";
			
			xml += "<userName><![CDATA["+this.getData('user', 'name')+"]]></userName>";
			xml += "<userEmail><![CDATA["+this.getData('user', 'email')+"]]></userEmail>";
			
			xml += "<routeTitle><![CDATA["+this.getData('route', 'title')+"]]></routeTitle>";
			xml += "<routeDescription><![CDATA["+this.getData('route', 'description')+"]]></routeDescription>";
			
		xml += "</options>";
		
		for (var i = 0; i < this.overview.length; i++)
		{
			/* data */
			var type = this.overview[i][0];
			var id = this.overview[i][3];
			
			var bgimage;
			var extra = "";
						
			if (type == 'marker')
			{
				var title = "<![CDATA["+route.routeData.markers[id].personalData.title+"]]>";
				bgimage = "img/graphic/list/"+route.routeData.markers[id].personalData.iconId+".png";
				
				extra += "<data>";
					extra += "<description><![CDATA["+route.routeData.markers[id].personalData.description+"]]></description>";
					extra += "<lat>"+route.routeData.markers[id].getPoint().lat()+"</lat>";
					extra += "<lng>"+route.routeData.markers[id].getPoint().lng()+"</lng>";
					extra += "<icon_id>"+route.routeData.markers[id].personalData.iconId+"</icon_id>";
					extra += "<icon_image>"+route.routeData.markers[id].personalData.iconImage+"</icon_image>";
				extra += "</data>";
				
					extra += "<pictures>";
						
						for (var z = 0; z < route.routeData.markers[id].personalData.pictures.length; z++)
						{
							extra += "<picture>";
								extra += route.routeData.markers[id].personalData.pictures[z];
							extra += "</picture>";
						}
						
					extra += "</pictures>";				
			}
			
			if (type == 'line')
			{
				var title = route.routeData.lineMarkers[id].personalData.title;
				bgimage = "img/graphic/list/line.gif";
				
				extra += "<data>";
				
					extra += "<description><![CDATA["+ route.routeData.lineMarkers[id].personalData.description +"]]></description>";
					
					extra += "<points>";
						
						for (var j = 0; j < this.lineArray[id].length; j++)
						{
							extra += "<point>";
								extra += "<lat>"+this.lineArray[id][j].lat()+"</lat>";
								extra += "<lng>"+this.lineArray[id][j].lng()+"</lng>";
							extra += "</point>";
						}
						
					extra += "</points>";
					
				extra += "</data>";				
			}
			
			if (type == 'autoline')
			{
				var title = "<![CDATA["+this.overview[i][2]+"]]>";
				bgimage = "img/graphic/list/autoline.gif";
				
				extra += "<data>";
					
					for (var j = 0; j < route.routeTools.routeToolsLineauto.gdirections[id].points.length; j++)
					{
						extra += "<point>";
							extra += "<lat>"+route.routeTools.routeToolsLineauto.gdirections[id].points[j].lat()+"</lat>";
							extra += "<lng>"+route.routeTools.routeToolsLineauto.gdirections[id].points[j].lng()+"</lng>";
						extra += "</point>";
					}
					
					extra += "<from_lat>"+route.routeTools.routeToolsLineauto.gdirections[id].from.lat()+"</from_lat>";
					extra += "<from_lng>"+route.routeTools.routeToolsLineauto.gdirections[id].from.lng()+"</from_lng>";
					extra += "<to_lat>"+route.routeTools.routeToolsLineauto.gdirections[id].to.lat()+"</to_lat>";
					extra += "<to_lng>"+route.routeTools.routeToolsLineauto.gdirections[id].to.lng()+"</to_lng>";					
					
					extra += "<route_html><![CDATA["+route.routeTools.routeToolsLineauto.gdirections[id].getTableHtml()+"]]></route_html>";
					
				extra += "</data>";				
			}			
			
			/* output */
			xml += "<item>";
				xml += "<title>"+title+"</title>";
				xml += "<type>"+type+"</type>";
				xml += "<icon>"+bgimage+"</icon>";
				
				xml += extra;
				
			xml += "</item>";
		}
		
		xml += "</data>";
		
		return xml;
	}
	
	this.fromXml = function (xml)
	{
		var x = GXml.parse(xml);

		var options = x.getElementsByTagName('options')[0];
			
			var route_id 		= GXml.value(options.getElementsByTagName('routeId')[0]);
			var user_name 		= GXml.value(options.getElementsByTagName('userName')[0]);
			var user_email 		= GXml.value(options.getElementsByTagName('userEmail')[0]);
			var route_title 	= GXml.value(options.getElementsByTagName('routeTitle')[0]);
			var route_description 	= GXml.value(options.getElementsByTagName('routeDescription')[0]);
			var cityId 		= GXml.value(options.getElementsByTagName('cityId')[0]);
			var viewCode 		= GXml.value(options.getElementsByTagName('routeViewCode')[0]);
			
			/* change city_id */
			if (city_id != cityId) changeCity (cityId);
			
			route.routeData.routeViewCode = viewCode;

				/* SET */
				this.routeId = route_id;

				route.routeData.changeData ('route', 'title', route_title);
				route.routeData.changeData ('route', 'description', route_description);
				route.routeData.changeData ('route', 'done', 'true');

				route.routeData.changeData ('user', 'name', user_name);
				route.routeData.changeData ('user', 'email', user_email);
				route.routeData.changeData ('user', 'done', 'true');

			var items = x.getElementsByTagName('item');

			for (var i = 0; i < items.length; i++)
			{
				var item 	= items[i];

				var type 	= GXml.value(item.getElementsByTagName('type')[0]);
				var title 	= GXml.value(item.getElementsByTagName('title')[0]);
				var icon 	= GXml.value(item.getElementsByTagName('icon')[0]);

				var data	= item.getElementsByTagName('data')[0];

				if (type == 'marker')
				{
					var description 	= GXml.value(data.getElementsByTagName('description')[0]);
					var lat 		= GXml.value(data.getElementsByTagName('lat')[0]);
					var lng 		= GXml.value(data.getElementsByTagName('lng')[0]);
					var icon_id 		= GXml.value(data.getElementsByTagName('icon_id')[0]);

					/* add the marker to data object */
					route.routeTools.routeToolsMarker.add (new GLatLng(lat, lng), title, description, icon_id);
				
					var pictures 		= data.getElementsByTagName('picture');
					
					var marker_id = route.routeData.markers.length-1;
					
					for (var y = 0; y < pictures.length; y++)
					{
						route.routeData.markers[marker_id].personalData.pictures.push (GXml.value(pictures[y]));
					}
				}

				if (type == 'line')
				{
					var description 	= GXml.value(data.getElementsByTagName('description')[0]);

					var point 		= data.getElementsByTagName('points')[0];
					var points 		= point.getElementsByTagName('point');

					for (var j = 0; j < points.length; j++)
					{
						var lat		= parseFloat(GXml.value(points[j].getElementsByTagName('lat')[0]));
						var lng		= parseFloat(GXml.value(points[j].getElementsByTagName('lng')[0]));

						/* add to array */
						route.routeTools.routeToolsLine.add (new GLatLng(lat, lng), title, description, "true");
					}

					/* hide line & reset */
					var currentPolygon = route.routeTools.routeToolsLine.currentPolygon;
					if (route.routeData) if (route.routeData.lineMarkers[currentPolygon])
					{
						for (var k = 0; k < route.routeData.lineMarkers[currentPolygon].length; k++)
						{
							route.routeData.lineMarkers[currentPolygon][k].hide();
						}
					}						

					route.routeTools.routeToolsLine.currentPolygon = null;

				}

				if (type == 'autoline')
				{
					var from_lat 		= GXml.value(data.getElementsByTagName('from_lat')[0]);
					var from_lng 		= GXml.value(data.getElementsByTagName('from_lng')[0]);
					var to_lat		= GXml.value(data.getElementsByTagName('to_lat')[0]);
					var to_lng 		= GXml.value(data.getElementsByTagName('to_lng')[0]);				

					// make new gdirections
					var new_id = route.routeTools.routeToolsLineauto.gdirections.length;
					route.routeTools.routeToolsLineauto.gdirections[new_id] = new RouteToolsDirections();

					route.routeTools.routeToolsLineauto.gdirections[new_id].assignFrom (new GLatLng(from_lat, from_lng));
					route.routeTools.routeToolsLineauto.gdirections[new_id].assignTo (new GLatLng(to_lat, to_lng));
					route.routeTools.routeToolsLineauto.gdirections[new_id].assignTitle (title);
					route.routeTools.routeToolsLineauto.gdirections[new_id].assignId (new_id);
					route.routeTools.routeToolsLineauto.gdirections[new_id].assignOverviewId (route.routeData.overview.length);
					
					var point 		= data.getElementsByTagName('points')[0];
					var points 		= point.getElementsByTagName('point');
					var points_add		= Array();
				
					for (var l = 0; l < points.length; l++)
					{
						var lat		= parseFloat(GXml.value(points[l].getElementsByTagName('lat')[0]));
						var lng		= parseFloat(GXml.value(points[l].getElementsByTagName('lng')[0]));
						
						/* add to array */
						points_add.push(new GLatLng(lat, lng));
					}
					
					route.routeTools.routeToolsLineauto.gdirections[new_id].setPoints (points_add);
					route.routeTools.routeToolsLineauto.gdirections[new_id].overviewAdd ();
					route.routeTools.routeToolsLineauto.gdirections[new_id].drawPolyline ();
				}					
			}
			
		setTimeout (function () { route.routeOverview.showOverview (); }, 1000);
	}
	
	this._constructor ();
}/* ********************************************
	lib: 	route v2 library
	class: 	Route
	desc.:	loads all route functions
******************************************** */

function RouteOptions() 
{
	var _this = this;
	
	this.fromError = false;
	
	this._constructor = function ()
	{
		debug ('RouteOptions :: initialized');
	}
	
	this.startEdit = function ()	/* triggers when edit button is pressed */
	{
		_this.editOptions ();
	}
	
	this.editOptions = function ()
	{
		$('routeMarkersContent').innerHTML = this.htmlEditOptions ();
		
		$('dataInputSubmit').onclick = _this.save;
		$('dataInputCancel').onclick = _this.cancel;
	}
	
	this.save = function ()
	{
		$('dataInputTitle').className = '';
		$('dataInputDescription').className = '';
		$('routeOverviewUserError').innerHTML = '';
		
		if ($('dataInputTitle').value.length > 0 && $('dataInputDescription').value.length > 0)
		{
			route.routeData.changeData ('route', 'title', $('dataInputTitle').value);
			route.routeData.changeData ('route', 'description', $('dataInputDescription').value);
			route.routeData.changeData ('route', 'done', 'true');
			
			if (_this.fromError)
			{
				_this.fromError = false;
				
				route.routeOptionsUser.fromError = true;
				route.routeOptionsUser.startEdit();
			}
			else
			{
				route.routeOverview.showOverview ();
			}
			
			debug ('RouteOptions :: data stored');
		}
		else
		{
			$('routeOverviewUserError').innerHTML = "<p>Je moet beide velden invullen.</p>";
			
			if ($('dataInputTitle').value.length < 1)
			{
				$('dataInputTitle').className = 'error';
			}
			
			if ($('dataInputDescription').value.length < 1)
			{
				$('dataInputDescription').className = 'error';
			}		
		}
	}
	
	this.cancel = function ()
	{
		route.routeOverview.showOverview ();
		
		debug ('RouteOptions :: canceled');
	}	
	
	this.htmlEditOptions = function ()
	{
		var html = '';
		
		html += "<h2>Kaart gegevens wijzigen</h2>";
		
		html += "<p class=\"formInfo\">Deze gegevens worden getoond bij het bekijken van je kaart door anderen.</p>";
		
		html += "<div id=\"routeOverviewUserError\"></div>";
		
		html += "<p>Kaart titel:<br /><input type=\"text\" id=\"dataInputTitle\" value=\""+ route.routeData.getData ('route', 'title') +"\" /></p>";
		
		html += "<p>Kaart omschrijving:<br /><textarea id=\"dataInputDescription\">"+ route.routeData.getData ('route', 'description') +"</textarea></p>";
		
		html += "<p><input class=\"inputButton\" id=\"dataInputSubmit\" type=\"button\" value=\"Opslaan &raquo;\" />";
		
		html += "<input class=\"inputButton\" id=\"dataInputCancel\" type=\"button\" value=\"&laquo; Annuleren\" /><br clear=\"all\" /></p>";
		
		return html;
	}
	
	this._constructor ();
}/* ********************************************
	lib: 	route v2 library
	class: 	Route
	desc.:	loads all route functions
******************************************** */

function RouteOptionsUser() 
{
	var _this = this;
	
	this.fromError = false;
	
	this._constructor = function ()
	{
		debug ('RouteOptionsUser :: initialized');
	}
	
	this.startEdit = function ()	/* triggers when edit button is pressed */
	{
		_this.editOptions ();
	}
	
	this.editOptions = function ()
	{
		$('routeMarkersContent').innerHTML = this.htmlEditOptions ();
		
		$('dataInputSubmit').onclick = _this.save;
		$('dataInputCancel').onclick = _this.cancel;
	}
	
	this.save = function ()
	{
		$('dataInputName').className = '';
		$('dataInputEmail').className = '';
		$('routeOverviewUserError').innerHTML = '';
		
		if ($('dataInputName').value.length > 0 && $('dataInputEmail').value.length > 0)
		{
			if (_this.checkemail($('dataInputEmail').value))
			{
				route.routeData.changeData ('user', 'name', $('dataInputName').value);
				route.routeData.changeData ('user', 'email', $('dataInputEmail').value);
				route.routeData.changeData ('user', 'done', 'true');

				if (_this.fromError)
				{
					_this.fromError = false;
					route.routeTabs.setActive ('routeTabOverview');
					route.routeData.save ();				
				}
				else
				{
					route.routeOverview.showOverview ();
				}
				
				debug ('RouteOptionsUser :: data stored');
			}
			else
			{
				$('dataInputEmail').className = 'error';
				$('routeOverviewUserError').innerHTML = "<p>Vul een geldig e-mailadres in.</p>";
			}
		}
		else
		{
			$('routeOverviewUserError').innerHTML = "<p>Je moet beide velden invullen.</p>";
			
			if ($('dataInputName').value.length < 1)
			{
				$('dataInputName').className = 'error';
			}
			
			if ($('dataInputEmail').value.length < 1)
			{
				$('dataInputEmail').className = 'error';
			}			
		}
	}
	
	this.checkemail = function(str)
	{
		var filter = /^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
		
		if (filter.test(str))
		{
			return true;
		}
		else
		{
			return false;
		}
	}	
	
	this.cancel = function ()
	{
		route.routeOverview.showOverview ();
		
		debug ('RouteOptionsUser :: canceled');
	}	
	
	this.htmlEditOptions = function ()
	{
		var html = '';
		
		html += "<h2>Persoonlijke gegevens wijzigen</h2>";
				
		html += "<p class=\"formInfo\">Door je persoonlijke gegevens in te vullen kan je de kaart later wijzigingen.</p>";

		html += "<div id=\"routeOverviewUserError\"></div>";
		
		html += "<p>Je naam:<br /><input type=\"text\" id=\"dataInputName\" value=\""+ route.routeData.getData ('user', 'name') +"\" /></p>";
		
		html += "<p>Je e-mailadres:<br /><input type=\"text\" id=\"dataInputEmail\" value=\""+ route.routeData.getData ('user', 'email') +"\" /></p>";
		
		html += "<p><input class=\"inputButton\" id=\"dataInputSubmit\" type=\"button\" value=\"Opslaan &raquo;\" />";
		
		html += "<input class=\"inputButton\" id=\"dataInputCancel\" type=\"button\" value=\"&laquo; Annuleren\" /><br clear=\"all\" /></p>";
		
		return html;
	}
	
	this._constructor ();
}/* ********************************************
	lib: 	route v2 library
	class: 	Route
	desc.:	loads all route functions
******************************************** */

function RouteOverview() 
{
	var _this = this;
	
	this._constructor = function ()
	{
		$('routeMarkersContent').innerHTML = this.getOverviewHtml ();
		
		this.overviewActions ();
		
		debug ('RouteOverview :: initialized');
	}
	
	this.showOverview = function ()
	{
		$('routeMarkersContent').innerHTML = this.getOverviewHtml ();
		
		this.overviewActions ();
	}

	/* *** */
	
	this.getOverviewHtml = function ()
	{
		if (route._routeEditEnabled)
		{
			var html = '';
			
			if (!routeview)
			{
				var routeDescription = route.routeData.getData ('route', 'description');
				if (routeDescription.length > 70) routeDescription = routeDescription.substr(0, 70) + "...";
				if (routeDescription.length > 0) routeDescription = nl2br (routeDescription);
				
				html += "<p>";
				html += "<a href=\"javascript:void(0);\" id=\"routeOverviewTitleEdit\">Wijzig titel en omschrijving</a>"+ (route.routeData.getData ('route', 'done') == 'true' ? ' <img src="img/graphic/icon_checked.gif" />' : '') +"<br />";
				html += "<a href=\"javascript:void(0);\" id=\"routeOverviewUserEdit\">Wijzig persoonlijke gegevens</a>"+ (route.routeData.getData ('user', 'done') == 'true' ? ' <img src="img/graphic/icon_checked.gif" />' : '');
				html += "</p>";
				html += "<p>&nbsp;</p>";
				html += "<h2 id=\"routeOverviewTitle\">"+ route.routeData.getData ('route', 'title') +"</h2>";
				html += "<p>"+ (routeDescription.length > 0 ? routeDescription : "(nog geen omschrijving)") +"</p>";
				html += "<p>&nbsp;</p>";
			}
			
			var routeList = this.getOverviewListHtml ();

			if (routeList.length > 0)
			{
				html += "<h2>Kaart inhoud</h2>";
				html += "<p>";
				html += routeList;
				html += "</p>";
			}

			return html;
		}
	}
	
	this.getOverviewListHtml = function ()
	{
		var htmlData = route.routeData.overview;
		var html = '';

		for (var i = htmlData.length-1; i > -1; i--)
		{
			var type = htmlData[i][0];
			var id = htmlData[i][3];
						
			var bgimage;
			var onclick;
			var mouseover;
			var mouseout;
			
			if (type == 'marker')
			{
				if (routeview)
				{
					var title = route.routeData.markers[id].personalData.title;
					bgimage = "img/graphic/list/"+route.routeData.markers[id].personalData.iconId+".png";
					onclick = "javascript:route.routeTools.routeToolsMarker.open("+id+");";

					mouseover = "javascript:route.routeOverview.overviewMarkerHover ("+id+");";
					mouseout = "javascript:route.routeOverview.overviewLineHoverOut ();";				
				}
				else
				{
					var title = route.routeData.markers[id].personalData.title;
					bgimage = "img/graphic/list/"+route.routeData.markers[id].personalData.iconId+".png";
					onclick = "javascript:route.routeTools.routeToolsMarker.open("+id+");";

					mouseover = "javascript:route.routeOverview.overviewMarkerHover ("+id+");";
					mouseout = "javascript:route.routeOverview.overviewLineHoverOut ();";
				}
			}
			
			if (type == 'line')
			{
				if (routeview)
				{
					var title = route.routeData.lineMarkers[id].personalData.title;
					bgimage = "img/graphic/list/line.gif";
					onclick = "javascript:route.routeOverview.lineViewClick ("+id+");";						

					mouseover = "";
					mouseout = "javascript:route.routeTools.routeToolsLine.mouseOutList ("+id+");";				
				}
				else
				{
					var title = route.routeData.lineMarkers[id].personalData.title;
					bgimage = "img/graphic/list/line.gif";
					onclick = "javascript:route.routeTools.routeToolsLine.open ("+id+");";						

					mouseover = "javascript:route.routeTools.routeToolsLine.mouseOverList ("+id+");";
					mouseout = "javascript:route.routeTools.routeToolsLine.mouseOutList ("+id+");";
				}
			}
			
			if (type == 'autoline')
			{
				if (routeview)
				{
					var title = htmlData[i][2];
					bgimage = "img/graphic/list/autoline.gif";
					onclick = "javascript:route.routeTools.routeToolsLineauto.gdirections["+id+"].overviewViewPress();";				
				
					mouseover = "";
					mouseout = "";	
				}
				else
				{							
					var title = route.routeTools.routeToolsLineauto.gdirections[id].title;
					bgimage = "img/graphic/list/autoline.gif";
					onclick = "javascript:route.routeTools.routeToolsLineauto.gdirections["+id+"].overviewPress();";						

					mouseover = "";
					mouseout = "";	
				}
			}
			
			html += "<a href=\"javascript:void(0);\" onclick=\""+onclick+"\" onmouseover=\""+mouseover+"\" onmouseout=\""+mouseout+"\" class=\"list_"+type+"\" style=\"background-image: url("+bgimage+");\">"+ title + "</a>";
		}
		
		return html;
	}
	
	this.lineViewClick = function (id)
	{
		GEvent.trigger (route.routeData.lineMarkers[id][0], "click");
	}
	
	this.lineautoViewClick = function (id)
	{
		route.routeTools.routeToolsLineauto.viewRoute (id);
	}	
	
	this.overviewActions = function ()
	{
		if (route._routeEditEnabled && !routeview)
		{
			$('routeOverviewTitleEdit').onclick = route.routeOptions.startEdit;
			$('routeOverviewUserEdit').onclick = route.routeOptionsUser.startEdit;
		}
	}
	
	/* *** */
	
	this.overviewLine = function (line_id)
	{
		var html = "";
		
		html += "<p>";
		
		html += "<a href=\"javascript:void(0);\" id=\"routeOverviewTitleEdit\" onclick=\"javascript:route.routeTools.routeToolsLine.edit ("+line_id+");\">Lijn eigenschappen</a><br />";		
		html += "<a href=\"javascript:void(0);\" id=\"routeOverviewDelete\" onclick=\"javascript:route.routeTools.routeToolsLine.deleteLine ("+line_id+");\">Lijn verwijderen</a><br />";		
		html += "<a id=\"routeOverviewBack\" onclick=\"javascript:route.routeTools.routeToolsLine.save(); route.routeTools.setActive ('hand');\" href=\"javascript:void(0);\">Terug</a>";

		html += "</p>";
		
		html += "<p>&nbsp;</p>";
		
		var lineDescription = route.routeData.lineMarkers[line_id].personalData.description;
		if (lineDescription.length > 70) lineDescription = lineDescription.substr(0, 70) + "...";
		if (lineDescription.length > 0) lineDescription = nl2br (lineDescription);		
		
		html += "<h2 id=\"routeOverviewLineTitle\">"+route.routeData.lineMarkers[line_id].personalData.title+"</h2>";
		html += "<p id=\"routeOverviewLineDescription\">"+ (lineDescription.length > 0 ? lineDescription : "(nog geen omschrijving)") +"</p>";

		html += "<p>&nbsp;</p>";

		html += "<p>";
		
		var line_data = route.routeData.lineArray[line_id];
		
		for (var i = 0; i < line_data.length; i++)
		{
			var onclick = "javascript:route.routeOverview.overviewShowLinePoint(route.routeData.lineArray["+line_id+"]["+i+"]);";
			var onmouseover = "javascript:route.routeOverview.overviewLineHover(route.routeData.lineArray["+line_id+"]["+i+"]);";
			var onmouseout = "javascript:route.routeOverview.overviewLineHoverOut ();";
			
			html += "<a href=\"javascript:void(0);\" onmouseover=\""+onmouseover+"\" onmouseout=\""+onmouseout+"\" onclick=\""+onclick+"\" class=\"list_point\">"+(i > 0 ? "<img src=\"img/graphic/icon_delete.gif\" style=\"float: right\" onclick=\"javascript:route.routeTools.routeToolsLine.deletePoint ("+i+"); route.routeOverview.overviewLineHoverOut ();\" onmouseover=\"javascript:Tip('Verwijder dit punt');\" />" : "") + "Punt "+(i+1)+"</a>";
		}
		
		html += "</p>";
		
		html += "<p>&nbsp;</p>";
		
		html += "<p>";
		
			html += "<input type=\"button\" value=\"Klaar met intekenen\" class=\"inputButton\" id=\"buttonLineReady\" />";
		
		html += "</p>";
		
		$('routeMarkersContent').innerHTML = html;
		
		$('buttonLineReady').onclick = route.routeTools.routeToolsLine.save;
		
		route.routeTabs.setActive ('routeTabOverview');
	}
	
	this.overviewMarkerHover = function (id)
	{
		var point = route.routeData.markers[id].getPoint ();
		
		hovermarker.setPoint(point);
	}

	this.overviewLineHover = function (point)
	{
		hovermarker.setPoint(point);
	}

	this.overviewLineHoverOut = function ()
	{
		hovermarker.setPoint(offmap);
	}	
	
	this.overviewShowLinePoint = function (point)
	{
		map.setCenter (point);
	}
	
	/* *** */
	
	this.overviewLineauto = function ()
	{
		var html = "";
		
		html += "<h2 id=\"routeOverviewLineTitle\">Automatisch route berekenen</h2>";
		
		html += "<div id=\"routeOverviewLineautoError\"></div>";
		
		html += "<p>";
		
		html += "<strong>Van:</strong><br />";
		html += "Adres:<br />";
		html += "<input type=\"text\" id=\"from_address\" value=\"\" /><br />";
		html += "Plaats:<br />";
		html += "<input type=\"text\" id=\"from_city\" value=\"\" />";
		
		html += "</p>";
		
		html += "<p>";
		
		html += "<strong>Naar:</strong><br />";
		html += "Adres:<br />";
		html += "<input type=\"text\" id=\"to_address\" value=\"\" /><br />";
		html += "Plaats:<br />";
		html += "<input type=\"text\" id=\"to_city\" value=\"\" />";
		
		html += "</p>";		
		
		html += "<p>&nbsp;</p>";
		
		html += "<p>";
		
			html += "<input type=\"button\" value=\"Bereken route\" class=\"inputButton\" id=\"buttonLineReady\" />";
		
		html += "</p>";
		
		html += "<br clear=\"all\" />";
		
		$('routeMarkersContentMake').innerHTML = html;
		
		$('buttonLineReady').onclick = route.routeTools.routeToolsLineauto.generate;
		
		route.routeTabs.setActive ('routeTabRoute');
	}
	
	this.overviewLineautoItem = function (id)
	{
		var html = "";
				
		html += "<h2 id=\"routeOverviewLineTitle\">"+route.routeTools.routeToolsLineauto.gdirections[id].title+"</h2>";
		
		html += "<p>";
		
		html += "<a href=\"javascript:void(0);\" id=\"routeOverviewDelete\" onclick=\"javascript:route.routeTools.routeToolsLineauto.gdirections["+id+"].deleteDirection();\">Route verwijderen</a><br />";
		html += "<a href=\"javascript:void(0);\" id=\"routeOverviewViewroute\" onclick=\"javascript:route.routeTools.routeToolsLineauto.gdirections["+id+"].view();\">Bekijk routebeschrijving</a><br />";		

		html += "</p>";	
		
		html += "<p></p>";
		
		html += "<p>";
		html += "<strong>Afstand en tijd:</strong><br />";
		
		html += route.routeTools.routeToolsLineauto.gdirections[id].routeDirections.getSummaryHtml();
		
		html += "</p>";
		
		$('routeMarkersContentMake').innerHTML = html;
		
		route.routeTabs.setActive ('routeTabRoute');
	}
		
	this._constructor ();
}					/* ********************************************
	lib: 	route v2 library
	class: 	Route
	desc.:	loads all route functions
******************************************** */

function RouteTools() 
{
	this.active = null;
	
	this.routeToolsMarker = null;
	this.routeToolsLine = null;
	this.routeToolsLineauto = null;
	
	this.tooltips = Array();
	
	var _this = this;
	
	this._constructor = function ()
	{
		debug ('RouteTools :: initialized');
		
		this.initializeTooltips ();
		
		$('tools').style.display = 'block';
		new Draggable ($('tools'), {handle: $('toolsDrag'), starteffect: null, endeffect: null});
		
		this.makeMouseOvers ();
		
		this.routeToolsMarker = new RouteToolsMarker ();
		this.routeToolsLine = new RouteToolsLine ();
		this.routeToolsLineauto = new RouteToolsLineauto ();
	}
	
	this.initializeTooltips = function ()
	{
		this.tooltips['hand'] = 'Navigeer op de kaart';
		this.tooltips['marker'] = 'Punten markeren';
		this.tooltips['line'] = 'Lijnen tekenen';
		this.tooltips['autoline'] = 'Route maken';	
	}
	
	this.setActive = function (type)
	{
		if (route._routeEditEnabled)
		{
			this.active = type;

			obj = $('toolsButtons').getElementsByTagName('IMG');

			/* set the img src */
			for (var i = 0; i < obj.length; i++)
			{
				var toolType = obj[i].className.split('_');
				toolType = toolType[1];	

				if (toolType == this.active)
				{
					obj[i].src = 'img/graphic/tools/'+toolType+'_h.gif';
				}
				else
				{
					obj[i].src = 'img/graphic/tools/'+toolType+'.gif';
				}
			}

			/* init & destroy specific tool object */
			if (type == 'hand')
			{
				route.routeTools.routeToolsMarker.deinitialize ();
				route.routeTools.routeToolsLine.deinitialize ();
				route.routeTools.routeToolsLineauto.deinitialize ();
				
				//if (route.routeTabs != null) route.routeTabs.setActive ('routeTabOverview');
			}
			else if (type == 'marker')
			{
				route.routeTools.routeToolsMarker.deinitialize ();
				route.routeTools.routeToolsMarker.initialize ();
				route.routeTools.routeToolsLine.deinitialize ();
				route.routeTools.routeToolsLineauto.deinitialize ();
				
				//if (route.routeTabs != null) route.routeTabs.setActive ('routeTabOverview');
			}
			else if (type == 'line')
			{
				route.routeTools.routeToolsMarker.deinitialize ();
				route.routeTools.routeToolsLine.deinitialize ();
				route.routeTools.routeToolsLine.initialize ();
				route.routeTools.routeToolsLineauto.deinitialize ();
				
				//if (route.routeTabs != null) route.routeTabs.setActive ('routeTabOverview');
			}
			else if (type == 'autoline')
			{
				route.routeTools.routeToolsMarker.deinitialize ();
				route.routeTools.routeToolsLine.deinitialize ();
				route.routeTools.routeToolsLineauto.deinitialize ();
				route.routeTools.routeToolsLineauto.initialize ();
			}		

			debug ('RouteTools :: active tool set: '+type);
		}
	}
	
	this.remove = function ()
	{
		$('tools').style.display = 'none';
		
		/* all destroy calls */
		route.routeTools.routeToolsMarker.deinitialize ();
		route.routeTools.routeToolsLine.deinitialize ();
		route.routeTools.routeToolsLineauto.deinitialize ();
	}
	
	this.makeMouseOvers = function ()
	{
		obj = $('toolsButtons').getElementsByTagName('IMG');
		
		for (var i = 0; i < obj.length; i++)
		{
			obj[i].onmouseover = this.buttonMouseOver;
			obj[i].onmouseout = this.buttonMouseOut;
			obj[i].onclick = this.buttonMousePress;
		}
	}
	
	this.buttonMousePress = function ()
	{
		var toolType = this.className.split('_');
		toolType = toolType[1];
		
		_this.setActive(toolType);		
	}
	
	this.buttonMouseOver = function ()
	{
		var toolType = this.className.split('_');
		toolType = toolType[1];
		
		this.src = 'img/graphic/tools/'+toolType+'_h.gif';
		
		/* tooltips */
		Tip(_this.tooltips[toolType]);
	}
	
	this.buttonMouseOut = function ()
	{
		var toolType = this.className.split('_');
		toolType = toolType[1];
		
		if (_this.active != toolType)
		{
			this.src = 'img/graphic/tools/'+toolType+'.gif';
		}
	}	
	
	this._constructor ();
}/* ********************************************
	lib: 	route v2 library
	class: 	Route
	desc.:	loads all route functions
******************************************** */
	
var listenerToolsMarkerClick;
var listenerToolsMarkerMove;
	
function RouteToolsMarker() 
{
	var _this = this;
	
	this.countNewMarkers = 0;
	
	this.cfgMarkers = Array();
	this.cfgMarkersCount = 46;
	
	this.iconStorage = Array();
	
	this._constructor = function ()
	{
		debug ('RouteToolsMarker :: initialized');
		
		this.initializeMarkers ();
	}	
	
	this.initialize = function ()
	{
		listenerToolsMarkerClick = GEvent.addListener (map, "click", _this.mapClick);
		listenerToolsMarkerMove = GEvent.addListener (map, "mousemove", _this.mapMove);
	}
	
	this.initializeMarkers = function ()
	{
		for (var i = 1; i < this.cfgMarkersCount; i++)
		{
			var width = $('markerStorage_'+i).offsetWidth;
			var height = $('markerStorage_'+i).offsetHeight;
			
			this.cfgMarkers[i] = new GIcon();
			this.cfgMarkers[i].image = "img/graphic/markers/"+i+".png";
			this.cfgMarkers[i].iconSize = new GSize(width, height);
			this.cfgMarkers[i].iconAnchor = new GPoint(width/2, height-1);
			this.cfgMarkers[i].infoWindowAnchor = new GPoint(width/2, height-1);
			
		}		
	}
	
	this.deinitialize = function ()
	{
		if (listenerToolsMarkerClick && listenerToolsMarkerMove)
		{
			GEvent.removeListener(listenerToolsMarkerClick);
			GEvent.removeListener(listenerToolsMarkerMove);
		}
	}	
	
	this.mapClick = function (marker, point)
	{
		if (!marker)
		{
			_this.add (point, "", "", "");
			route.routeOverview.showOverview ();
		}
	}
	
	this.mapMove = function (point)
	{
		if (!routeview) Tip('Klik om een nieuwe markering op dit punt toe te voegen');
	}
	
	this.add = function (point, inputTitle, inputDescription, inputIconId)
	{
		this.countNewMarkers++;
		var markersTotal = route.routeData.markers.length;
		
		var markerIconCheckInput = (inputIconId > 0 ? inputIconId : 1);
		var markerIcon = this.cfgMarkers[markerIconCheckInput];
		
		this.iconStorage[markersTotal] = markerIcon;
		
		if (viewRoute)
		{
			var marker = new GMarker (point, {draggable: false, bouncy: true, icon: markerIcon});
		}
		else
		{
			var marker = new GMarker (point, {draggable: true, bouncy: true, icon: markerIcon});
		}
		
		marker.personalData = Array();
		marker.personalData.title = (inputTitle.length > 0 ? inputTitle : 'Nieuwe marker '+this.countNewMarkers);
		marker.personalData.description = inputDescription;
		marker.personalData.id = markersTotal;
		marker.personalData.overviewId = route.routeData.overview.length;
		marker.personalData.iconId = (inputIconId > 0 ? inputIconId : 1);
		marker.personalData.iconImage = markerIcon.image;
		marker.personalData.changed = false;
		
		marker.personalData.pictures = Array();
		
		route.routeData.markers.push(marker);
		route.routeData.overviewAdd ('marker', marker.personalData.iconId, marker.personalData.title, marker.personalData.id);
		
		map.addOverlay(route.routeData.markers[markersTotal]);
		
		GEvent.addListener(route.routeData.markers[markersTotal], "click", function() 
		{
			map.closeInfoWindow ();
			
			var html = "<div class=\"baloonWidth\"><strong id=\"routeEditMarkerShowtitle\">"+ this.personalData.title +"</strong>";
			
			html += "<div id=\"routeEditMarker\">";
						
			html += "</div></div>";
			
			var pictureHtml = route.routeTools.routeToolsMarker.getShowPictureHtml (this.personalData.id, this.personalData.overviewId);
			

				var infoTabs = [
				  new GInfoWindowTab("Info", html),
				  new GInfoWindowTab("Foto's", "<div class=\"baloonWidth\"><div id=\"routeEditMarkerPic\">"+pictureHtml+"</div></div>")
				];			


			this.openInfoWindowTabsHtml(infoTabs);
			
			$('routeEditMarker').innerHTML = route.routeTools.routeToolsMarker.getShowHtml (this.personalData.id, this.personalData.overviewId);
		});		
		
		route.routeTools.setActive ('hand');
		
		if (!inputTitle.length > 0) GEvent.trigger(route.routeData.markers[markersTotal], "click");	
		
		if (route.routeTabs != null) route.routeTabs.setActive ('routeTabOverview');
	}
	
	this.remove = function (id, overviewId)
	{
		if (confirm ("Weet je zeker dat je deze markering wilt verwijderen?"))
		{
			/* loop the overview and set from higher id's the peronalData.overviewId to -1 */
			for (var i = 0; i < route.routeData.overview.length; i++)
			{
				if (i > overviewId)
				{
					var personalId = route.routeData.overview[i][3];

					if (route.routeData.overview[i][0] == 'marker')
					{
						route.routeData.markers[personalId].personalData.overviewId--;
						route.routeData.markers[personalId].personalData.id--;
					}

					if (route.routeData.overview[i][0] == 'line')
					{
						route.routeData.lineMarkers[personalId].personalData.overviewId--;
					}

					if (route.routeData.overview[i][0] == 'autoline')
					{
						route.routeTools.routeToolsLineauto.gdirections[personalId].overviewId--;
					}					
				}
			}		

			/* loop marker overview */
			for (var i = 0; i < route.routeData.overview.length; i++)
			{
				if (i > overviewId && route.routeData.overview[i][0] == 'marker')
				{
					/* set higher marker id's to -1 */
					route.routeData.overview[i][3]--; 
				}
			}

			if (!route.routeData.markers[id].personalData.changed)
			{
				_this.countNewMarkers--;
			}

			map.removeOverlay(route.routeData.markers[id]);

			route.routeData.markers.splice(id, 1);
			route.routeData.overview.splice(overviewId, 1);

			route.routeOverview.showOverview ();

			map.closeInfoWindow();
		}
	}
	
	this.edit = function (id)
	{
		var html = '';
		
		html += "<p>Titel:<br /><input type=\"text\" id=\"inputRouteEditTitle\" /></p>";
		html += "<p>Omschrijving:<br /><textarea id=\"inputRouteEditDescription\"></textarea></p>";
		html += "<p><input type=\"button\" class=\"inputButton\" value=\"Wijzigen\" id=\"routeInputSubmit\" /></p>";
		
		$('routeEditMarker').innerHTML = html;
		
		$('inputRouteEditTitle').value = route.routeData.markers[id].personalData.title;
		$('inputRouteEditDescription').value = route.routeData.markers[id].personalData.description;
		
		$('inputRouteEditTitle').onkeyup = function ()
		{
			if ($('inputRouteEditTitle').value.length > 0)
			{
				route.routeData.markers[id].personalData.title = $('inputRouteEditTitle').value;
				$('routeEditMarkerShowtitle').innerHTML = $('inputRouteEditTitle').value;
				route.routeOverview.showOverview ();
			}
		}
		
		$('routeInputSubmit').onclick = function ()
		{
			route.routeData.markers[id].personalData.title = $('inputRouteEditTitle').value;
			route.routeData.markers[id].personalData.description = $('inputRouteEditDescription').value;
			
			if (!route.routeData.markers[id].personalData.changed)
			{
				route.routeData.markers[id].personalData.changed = true;
				_this.countNewMarkers--;
			}
			
			$('routeEditMarkerShowtitle').innerHTML = $('inputRouteEditTitle').value;
			
			route.routeOverview.showOverview ();
			
			_this.show (id, route.routeData.markers[id].personalData.overviewId);
		}
	}
	
	this.show = function (id, overviewId)
	{
		debug ("RouteToolsMarkers :: show :: id: "+id+" :: overviewId: "+overviewId);
		
		$('routeEditMarker').innerHTML = this.getShowHtml (id, overviewId);
	}
	
	this.open = function (id)
	{
		debug ("RouteToolsMarkers :: open :: id: "+id);
		
		GEvent.trigger(route.routeData.markers[id], "click");	
	}
	
	this.getShowHtml = function (id, overviewId)
	{
		var html = '';
		
		if (viewRoute)
		{
			html += "<p>";

			html += route.routeData.markers[id].personalData.description;

			html += "<div style=\"display: none;\">";

			html += "<a href=\"javascript:void(0);\" id=\"routeMarkerEdit\" onclick=\"javascript:route.routeTools.routeToolsMarker.edit("+ id +");\">Wijzig de titel en omschrijving</a><br />";
			html += "<a href=\"javascript:void(0);\" id=\"routeMarkerIcon\" style=\"background-image: url(img/graphic/list/"+route.routeData.markers[id].personalData.iconId+".png);\" onclick=\"javascript:route.routeTools.routeToolsMarker.changeIcon("+ id +");\">Kies een ander icoon</a><br />";
			html += "<a href=\"javascript:void(0);\" id=\"routeMarkerDelete\" onclick=\"javascript:route.routeTools.routeToolsMarker.remove("+id+", "+overviewId+");\">Verwijder deze markering</a><br />";

			html += "</div>";

			html += "</p>";
		}
		else
		{
			var markerDescription = route.routeData.markers[id].personalData.description;
			if (markerDescription.length > 70) markerDescription = markerDescription.substr(0, 70) + "...";
			if (markerDescription.length > 0) markerDescription = nl2br (markerDescription);	
			
			html += "<p>";
			html += (markerDescription.length > 0 ? markerDescription : "(nog geen omschrijving)");
			html += "</p>";
			
			html += "<p>";

			html += "<a href=\"javascript:void(0);\" id=\"routeMarkerEdit\" onclick=\"javascript:route.routeTools.routeToolsMarker.edit("+ id +");\">Wijzig de titel en omschrijving</a><br />";
			html += "<a href=\"javascript:void(0);\" id=\"routeMarkerIcon\" style=\"background-image: url(img/graphic/list/"+route.routeData.markers[id].personalData.iconId+".png);\" onclick=\"javascript:route.routeTools.routeToolsMarker.changeIcon("+ id +");\">Kies een ander icoon</a><br />";
			html += "<a href=\"javascript:void(0);\" id=\"routeMarkerDelete\" onclick=\"javascript:route.routeTools.routeToolsMarker.remove("+id+", "+overviewId+");\">Verwijder deze markering</a><br />";

			html += "</p>";
		}

		return html;
	}
	
	this.getShowPictureHtml = function (id, overviewId)
	{
		var html = '';
		
		if (viewRoute)
		{
			html += "<p>";

			html += "<div id=\"markerPictures\">";
			
			if (route.routeData.markers[id].personalData.pictures.length > 0)
			{
				for (var i = 0; i < route.routeData.markers[id].personalData.pictures.length; i++)
				{
					html += "<a href=\"javascript:void(0);\" onclick=\"javascript:route.routeTools.routeToolsMarker.viewPictures ("+id+", "+overviewId+");\"><img src=\""+route.routeData.markers[id].personalData.pictures[i]+"\" width=\"140\" /></a>&nbsp;";
				}
			}
			
			html += "</div>";

			html += "</p>";
		}
		else
		{
			html += "<p>";
			html += "<strong>Voeg afbeelding toe</strong><br />";
			html += "Adres / URL:<br /><input type=\"text\" id=\"pictureAdd\" class=\"inputText\" /><br />";
			html += "<input type=\"button\" class=\"inputButton\" value=\"Toevoegen\" onclick=\"route.routeTools.routeToolsMarker.addPicture ("+id+");\" />";
			html += "</p>";
			
			html += "<div id=\"markerPictures\">";
			
			if (route.routeData.markers[id].personalData.pictures.length > 0)
			{
				for (var i = 0; i < route.routeData.markers[id].personalData.pictures.length; i++)
				{
					html += route.routeTools.routeToolsMarker.pictureItem(route.routeData.markers[id].personalData.pictures[i], i, id);
				}
			}
			
			html += "</div>";
		}

		return html;
	}
	
	this.viewPictures = function (id, overviewId)
	{
		var html = "";
		
		if (route.routeData.markers[id].personalData.pictures.length > 0)
		{
			for (var i = 0; i < route.routeData.markers[id].personalData.pictures.length; i++)
			{
				html += "<img src='"+route.routeData.markers[id].personalData.pictures[i]+"' /><br /><br />";
			}
		}		
	
		$('formDataData').value = html;
		$('formData').submit ();
	}
	
	this.redrawPictures = function (id)
	{
		var html = "";
		
		if (route.routeData.markers[id].personalData.pictures.length > 0)
		{
			for (var i = 0; i < route.routeData.markers[id].personalData.pictures.length; i++)
			{
				html += route.routeTools.routeToolsMarker.pictureItem(route.routeData.markers[id].personalData.pictures[i], i, id);
			}
		}
		
		$('markerPictures').innerHTML = html;
	}
	
	this.pictureItem = function (url,id,marker_id)
	{
		var returnValue = "<a id=\"routeMarkerDelete\" style=\"float: left;\" onclick=\"route.routeTools.routeToolsMarker.deletePicture ("+id+", "+marker_id+");\" href=\"javascript:void(0);\"></a> "+url+"<br />";
		
		return returnValue;
	}
	
	this.addPicture = function (id)
	{
		if ($('pictureAdd').value.length > 0)
		{
			$('markerPictures').innerHTML += route.routeTools.routeToolsMarker.pictureItem($('pictureAdd').value, route.routeData.markers[id].personalData.pictures.length,id);
			
			route.routeData.markers[id].personalData.pictures.push ($('pictureAdd').value);
			$('pictureAdd').value = "";
			
			$('routeEditMarkerPic').scrollTop = 99999999;
		}
	}
	
	this.deletePicture = function (id, marker_id)
	{
		route.routeData.markers[marker_id].personalData.pictures.splice (id, 1);
		
		this.redrawPictures (marker_id);
		
		$('routeEditMarkerPic').scrollTop = 99999999;
	}
	
	this.changeIcon = function (id)
	{
		var html = '';
		
		html += "<p>Kies een icoon:<br />";
		
		for (var i = 1; i < this.cfgMarkersCount; i++)
		{
			html += "<a href=\"javascript: void(0);\" class=\"routeChangeIcon "+(i == route.routeData.markers[id].personalData.iconId ? "active" : "")+"\"><img src=\"img/graphic/markers/"+i+".png\" alt=\"\" class=\"routeChangeIcon\" onclick=\"javascript:route.routeTools.routeToolsMarker.changeIconPost("+id+", "+i+");\" /></a>";
		}
		
		html += "</p>";
		
		html += "<p><input type=\"button\" class=\"inputButton\" value=\"Annuleren\" onclick=\"javascript:route.routeTools.routeToolsMarker.show ("+id+", "+route.routeData.markers[id].personalData.overviewId+");\" /></p>";
		
		$('routeEditMarker').innerHTML = html;
	}
	
	this.changeIconPost = function (id, iconId)
	{
		route.routeData.markers[id].personalData.iconId = iconId;
		
		var markerIcon = this.cfgMarkers[iconId];
		
		this.iconStorage[id] = markerIcon;		
		
		map.removeOverlay (route.routeData.markers[id]);
		
		var marker = new GMarker (route.routeData.markers[id].getPoint(), {draggable: true, bouncy: true, icon: markerIcon});
		
		marker.personalData = route.routeData.markers[id].personalData;
		
		GEvent.addListener(marker, "click", function() 
		{
			var html = "<strong id=\"routeEditMarkerShowtitle\">"+ this.personalData.title +"</strong>";
			
			html += "<div id=\"routeEditMarker\">";
			
			html += _this.getShowHtml (this.personalData.id, this.personalData.overviewId);
			
			html += "</div>";

			marker.openInfoWindowHtml(html);
		});
		
		route.routeData.markers[id] = marker;
		
		map.addOverlay (route.routeData.markers[id]);
		
		route.routeOverview.showOverview ();
			
		_this.show (id, route.routeData.markers[id].personalData.overviewId);		
	}
	
	this._constructor ();
}/* ********************************************
	lib: 	route v2 library
	class: 	Route
	desc.:	loads all route functions
******************************************** */
	
var listenerToolsLineClick;
var listenerToolsLineMove;
	
function RouteToolsLine() 
{
	var _this = this;
	
	this.lineMarker = null;
	
	this.currentPolygon = null;
	this.currentPolygonMouseover = null;
	
	this.newPolylineCount = 0;
	
	this._constructor = function ()
	{
		debug ('RouteToolsLine :: initialized');
		
		/* initialize line marker */
		this.lineMarker = new GIcon();
		this.lineMarker.image = "img/graphic/linemarker.png";
		this.lineMarker.iconSize = new GSize(10, 10);
		this.lineMarker.iconAnchor = new GPoint(5, 5);
		this.lineMarker.infoWindowAnchor = new GPoint(5, 9);		
	}	
	
	this.initialize = function ()
	{
		listenerToolsLineClick = GEvent.addListener (map, "click", _this.mapClick);
		listenerToolsLineMove = GEvent.addListener (map, "mousemove", _this.mapMove);		
	}
	
	this.deinitialize = function ()
	{
		if (listenerToolsLineClick && listenerToolsLineMove)
		{
			GEvent.removeListener(listenerToolsLineClick);
			GEvent.removeListener(listenerToolsLineMove);
		}
		
		if (route.routeData) if (route.routeData.lineMarkers[this.currentPolygon])
		{
			for (var i = 0; i < route.routeData.lineMarkers[this.currentPolygon].length; i++)
			{
				route.routeData.lineMarkers[this.currentPolygon][i].hide();
			}
		}
		
		if (this.currentPolygon != null) route.routeOverview.showOverview ();
		
		this.currentPolygon = null;	
		map.closeInfoWindow ();
	}	
	
	this.mapClick = function (marker, point)
	{
		if (!marker)
		{
			_this.add (point, "", "", "");
		}
		else
		{
			_this.add (marker.getPoint (), "", "", "");
			
			if (marker.personalData.iconId > 0)
			{
				setTimeout(function () { map.closeInfoWindow (); }, 10);
			}
		}
	}
	
	this.mapMove = function (point)
	{
		if (!routeview) Tip('Klik om een nieuwe lijn te beginnen');
	}
	
	this.add = function (point, inputTitle, inputDescription, inputSkip)
	{
		/* add the polyline on first click */
		if (this.currentPolygon == null)
		{
			this.newPolylineCount++;
			
			/* init */
			var polylineId = route.routeData.linePolyline.length;
			if (!route.routeData.lineArray[polylineId]) route.routeData.lineArray[polylineId] = Array();
			if (!route.routeData.lineMarkers[polylineId]) route.routeData.lineMarkers[polylineId] = Array();
			this.currentPolygon = polylineId;
			
			/* add new data */
			route.routeData.lineMarkers[polylineId].personalData = Array ();
			route.routeData.lineMarkers[polylineId].personalData.title = (inputTitle.length > 0 ? inputTitle : "Nieuwe lijn "+this.newPolylineCount);
			route.routeData.lineMarkers[polylineId].personalData.description = inputDescription;
			route.routeData.lineMarkers[polylineId].personalData.changed = false;
			route.routeData.lineMarkers[polylineId].personalData.overviewId = route.routeData.overview.length;
			
			/* overlay */
			route.routeData.overviewAdd ('line', null, route.routeData.lineMarkers[polylineId].personalData.title, polylineId);
			
			/* set bool */
			var newPolygon = true;
			
			debug ("new polygon");
		}
		else
		{
			var polylineId = this.currentPolygon;
			var newPolygon = false;
		}
		
		/* add the polyline point marker */
		var marker = new GMarker (point, {draggable: true, bouncy: false, icon: this.lineMarker});
		
		marker.personalData = Array();
		marker.personalData.id 		= route.routeData.lineMarkers[polylineId].length;
		marker.personalData.polylineId 	= polylineId;
		
		if (newPolygon)
		{
			GEvent.addListener(marker, "click", function () {
				
				map.setCenter (this.point);
				
				var polylineId = this.personalData.polylineId;
				
				var html = "<strong id=\"routeEditMarkerShowtitle\">"+ route.routeData.lineMarkers[polylineId].personalData.title +"</strong>";

				html += "<div id=\"routeEditMarker\">";

				html += "</div>";

				marker.openInfoWindowHtml(html);
				
				_this.getShowHtml (polylineId);
			});		
		}

		GEvent.addListener(marker, "dragend", function () {
			route.routeData.lineArray[_this.currentPolygon][this.personalData.id] = this.getPoint();

			map.removeOverlay(route.routeData.linePolyline[_this.currentPolygon]);

			route.routeData.linePolyline[_this.currentPolygon] = new GPolyline(route.routeData.lineArray[_this.currentPolygon], "#FF0000", 4);
			map.addOverlay (route.routeData.linePolyline[_this.currentPolygon]);
		});

		GEvent.addListener(marker, "drag", function () {
			route.routeData.lineArray[_this.currentPolygon][this.personalData.id] = this.getPoint();

			map.removeOverlay(route.routeData.linePolyline[_this.currentPolygon]);

			route.routeData.linePolyline[_this.currentPolygon] = new GPolyline(route.routeData.lineArray[_this.currentPolygon], "#FF0000", 4);
			map.addOverlay (route.routeData.linePolyline[_this.currentPolygon]);
		});		

		GEvent.addListener(marker, "mouseover", function () {
			var id = this.personalData.id;

			Tip('Punt '+(id+1));
		});
		
		map.addOverlay(marker);
		route.routeData.lineMarkers[polylineId].push(marker);
		
		/* draw poly */
		map.removeOverlay(route.routeData.linePolyline[polylineId]);
		route.routeData.lineArray[polylineId].push (point);
		route.routeData.linePolyline[polylineId] = new GPolyline(route.routeData.lineArray[polylineId], "#FF0000", 4);
		map.addOverlay(route.routeData.linePolyline[polylineId]);
		
		debug(route.routeData.linePolyline);
		
		/* overview */
		if (inputSkip.length == 0) route.routeOverview.overviewLine (polylineId);
		
		$('routeMarkersContent').scrollTop = 999999999999; /* set high */
	}
	
	this.getShowHtml = function (id)
	{
		var html = '';
		
		if (viewRoute)
		{
			html += "<p>"+ nl2br(route.routeData.lineMarkers[id].personalData.description) +"</p>";
			
			$('routeEditMarker').innerHTML = html;
		}
		else
		{
			html += "<p>Titel:<br /><input type=\"text\" id=\"inputRouteEditTitle\" /></p>";
			html += "<p>Omschrijving:<br /><textarea id=\"inputRouteEditDescription\"></textarea></p>";
			html += "<p><input type=\"button\" class=\"inputButton\" value=\"Wijzigen\" id=\"routeInputSubmit\" /></p>";

			$('routeEditMarker').innerHTML = html;

			$('inputRouteEditTitle').value = route.routeData.lineMarkers[id].personalData.title;
			$('inputRouteEditDescription').value = route.routeData.lineMarkers[id].personalData.description;

			$('inputRouteEditTitle').onkeyup = function ()
			{
				if ($('inputRouteEditTitle').value.length > 0)
				{
					route.routeData.lineMarkers[id].personalData.title = $('inputRouteEditTitle').value;
					$('routeEditMarkerShowtitle').innerHTML = $('inputRouteEditTitle').value;
					$('routeOverviewLineTitle').innerHTML = $('inputRouteEditTitle').value;
				}
			}

			$('routeInputSubmit').onclick = function ()
			{
				route.routeData.lineMarkers[id].personalData.title = $('inputRouteEditTitle').value;
				route.routeData.lineMarkers[id].personalData.description = $('inputRouteEditDescription').value;

				if (!route.routeData.lineMarkers[id].personalData.changed)
				{
					route.routeData.lineMarkers[id].personalData.changed = true;
					_this.newPolylineCount--;
				}

				$('routeEditMarkerShowtitle').innerHTML = $('inputRouteEditTitle').value;

				route.routeOverview.overviewLine (id);
				
				map.closeInfoWindow ();
			}
		}
	}
	
	this.deleteLine = function (id)
	{
		if (confirm ("Weet je zeker dat je deze lijn wilt verwijderen?"))
		{
			var overviewId = route.routeData.lineMarkers[id].personalData.overviewId;
			
			/* loop the overview and set from higher id's the peronalData.overviewId to -1 */
			for (var i = 0; i < route.routeData.overview.length; i++)
			{
				if (i > overviewId)
				{
					var personalId = route.routeData.overview[i][3];
					
					if (route.routeData.overview[i][0] == 'marker')
					{
						route.routeData.markers[personalId].personalData.overviewId--;
					}
					
					if (route.routeData.overview[i][0] == 'line')
					{
						route.routeData.lineMarkers[personalId].personalData.overviewId--;
						route.routeData.lineMarkers[personalId].personalData.polylineId--;
						
						for (var y = 0; y < route.routeData.lineMarkers[personalId].length; y++)
						{
							route.routeData.lineMarkers[personalId][y].personalData.polylineId--;
						}
					}
					
					if (route.routeData.overview[i][0] == 'autoline')
					{
						route.routeTools.routeToolsLineauto.gdirections[personalId].overviewId--;
					}					
				}
			}			
			
			for (var j = 0; j < route.routeData.lineMarkers[id].length; j++)
			{			
				map.removeOverlay(route.routeData.lineMarkers[id][j]);
			}

			map.removeOverlay(route.routeData.linePolyline[id]);
			
			/* loop overview array */
			for (var i = 0; i < route.routeData.overview.length; i++)
			{
				if (i > overviewId && route.routeData.overview[i][0] == 'line')
				{
					/* set higher marker id's to -1 */
					route.routeData.overview[i][3]--; 
				}
			}			

			route.routeData.overview.splice(overviewId, 1);
			route.routeData.lineMarkers.splice(id, 1);
			route.routeData.linePolyline.splice(id, 1);
			route.routeData.lineArray.splice(id, 1);
			
			this.currentPolygon = null;

			route.routeOverview.showOverview ();

			map.closeInfoWindow();
			route.routeTools.setActive ('hand');
		}
	}
	
	this.save = function ()
	{
		_this.finished ();
	}
	
	this.finished = function ()
	{
		this.deinitialize ();	
		route.routeTools.setActive ('hand');				
	}
	
	this.mouseOverList = function (id)
	{
		for (var i = 0; i < route.routeData.lineMarkers[id].length; i++)
		{
			route.routeData.lineMarkers[id][i].show();
		}	
	}
	
	this.mouseOutList = function (id)
	{
		for (var i = 0; i < route.routeData.lineMarkers[id].length; i++)
		{
			route.routeData.lineMarkers[id][i].hide();
		}	
	}	
	
	this.open = function (id)
	{
		debug ("RouteToolsLine :: opening route id "+id);
		
		route.routeTools.setActive ('line');
		
		this.currentPolygon = id;
		//this.initialize ();
		
		route.routeOverview.overviewLine (id);
		
		var point = route.routeData.lineArray[id][0];
		map.closeInfoWindow ();
		map.setCenter (point);
	}
	
	this.edit = function (id)
	{
		GEvent.trigger (route.routeData.lineMarkers[id][0], "click");
	}
	
	this.deletePoint = function (id)
	{
		map.removeOverlay (route.routeData.lineMarkers[this.currentPolygon][id]);
		
		route.routeData.lineMarkers[this.currentPolygon].splice(id, 1);
		route.routeData.lineArray[this.currentPolygon].splice(id, 1);
		
		var linemarkers = route.routeData.lineMarkers[this.currentPolygon].length;
		
		for (var i = id; i < (linemarkers); i++)
		{
			route.routeData.lineMarkers[this.currentPolygon][i].personalData.id--;
		}		
		
		map.removeOverlay(route.routeData.linePolyline[this.currentPolygon]);
		route.routeData.linePolyline[this.currentPolygon] = new GPolyline(route.routeData.lineArray[this.currentPolygon], "#FF0000", 4);
		map.addOverlay(route.routeData.linePolyline[this.currentPolygon]);
		
		route.routeOverview.overviewLine (this.currentPolygon);
	}
	
	this._constructor ();
}/* ********************************************
	lib: 	route v2 library
	class: 	Route
	desc.:	loads all route functions
******************************************** */
	
var listenerToolsLineautoMove;
var globalAllDirectionsLoaded = false;
	
function RouteToolsLineauto() 
{
	var _this 		= this;
	
	this.geocoder 		= null;
	
	this.fromBuffer		= null;
	
	this.gdirections = Array();
	
	this._constructor = function ()
	{
		this.geocoder = new GClientGeocoder();
		
		debug ('RouteToolsLineauto :: initialized');
	}	
	
	this.initialize = function ()
	{
		this.showPanel ();
	}
	
	this.generate = function ()
	{
		/* empty classes */
		$('from_address').className = '';
		$('from_city').className = '';
		$('to_address').className = '';
		$('to_city').className = '';	
		$('routeOverviewLineautoError').innerHTML = "";
		
		/* generate directions */
		if ($('from_address').value.length > 0 && $('from_city').value.length > 0 && $('to_address').value.length > 0 && $('to_city').value.length > 0)
		{
			_this.findAddress ('from');
			_this.findAddress ('to');
		}
		else
		{
			/* assign error classes */
			if ($('from_address').value.length < 1)
			{
				$('from_address').className = 'error';
			}
			
			if ($('from_city').value.length < 1)
			{
				$('from_city').className = 'error';
			}
			
			if ($('to_address').value.length < 1)
			{
				$('to_address').className = 'error';
			}
			
			if ($('to_city').value.length < 1)
			{
				$('to_city').className = 'error';
			}
			
			/* show error message */
			$('routeOverviewLineautoError').innerHTML = "<p>Je hebt niet alle velden ingevuld.</p>";
		}
	}
	
	this.findAddress = function (type) 
	{
		if (type == 'from')
		{
			var address = $('from_address').value + ", " + $('from_city').value + ", NL";
		}
		else
		{
			var address = $('to_address').value + ", " + $('to_city').value + ", NL";
		}
				
		this.geocoder.getLatLng(
			address,
		
			function(point) 
			{
				if (!point)
				{
					/* not found */
					if (type == 'from')
					{
						$('routeOverviewLineautoError').innerHTML 	= "<p>E&eacute;n of meerdere adressen zijn niet gevonden.</p>";
						$('from_address').className 			= 'error';
						$('from_city').className 			= 'error';
					}
					else
					{
						$('routeOverviewLineautoError').innerHTML 	= "<p>E&eacute;n of meerdere adressen zijn niet gevonden.</p>";
						$('to_address').className 			= 'error';
						$('to_city').className 				= 'error';					
					}
				}
				else
				{
					/* success */
					if (type == 'from')
					{
						$('from_address').className 			= 'good';
						$('from_city').className 			= 'good';
						
						_this.fromBuffer = point;
					}
					else
					{
						$('to_address').className 			= 'good';
						$('to_city').className 				= 'good';
						
						if (_this.fromBuffer != null)
						{
							// make new gdirections
							var new_id = _this.gdirections.length;
							_this.gdirections[new_id] = new RouteToolsDirections();
							
							_this.gdirections[new_id].assignFrom (_this.fromBuffer);
							_this.gdirections[new_id].assignTo (point);
							_this.gdirections[new_id].assignTitle ("Van <em>"+$('from_address').value+", "+$('from_city').value+"</em> naar <em>"+$('to_address').value+", "+$('to_city').value+"</em>");
							_this.gdirections[new_id].assignId (new_id);
							_this.gdirections[new_id].assignOverviewId (route.routeData.overview.length);
							
							_this.gdirections[new_id].get ();
							
							// clear from buffer
							_this.fromBuffer = null;
						}
					}
				}
			}
		);
	}
	
	this.checkAllData = function (returnFunction)
	{
		var size = this.gdirections.length;
		var directions_complete = 0;
		
		for (var i = 0; i < size; i++)
		{
			if (!this.gdirections[i].directionsLoaded)
			{
				debug (i + " fout");
				route.routeTools.routeToolsLineauto.gdirections[i].dontOpen = true;
				route.routeTools.routeToolsLineauto.gdirections[i].get ();
				//setTimout("alert("+i+"); route.routeTools.routeToolsLineauto.gdirections["+i+"].get ()", 500);
			}
			else
			{
				debug (i + " goed");
				directions_complete++;
			}
		}
		
		if (directions_complete == size)
		{
			globalAllDirectionsLoaded = true;
			
			eval (returnFunction)();
		}
		else
		{
			setTimeout ("route.routeTools.routeToolsLineauto.checkAllData("+returnFunction+")", 1000);
		}
	}
	
	this.showPanel = function ()
	{
		route.routeOverview.overviewLineauto ();
	}
	
	this.deinitialize = function ()
	{
		if (route.routeOverview) route.routeOverview.showOverview ();
	}
		
	this._constructor ();
}/* ********************************************
	lib: 	route v2 library
	class: 	Route
	desc.:	loads all route functions
******************************************** */
	
var globalLastId;	
	
function RouteToolsDirections() 
{
	var _this 		= this;
	
	this.routeDirections 	= null;
	
	this.routeHtml		= "";
	
	this.title 		= null;
	this.from 		= null;
	this.to 		= null;
	this.id 		= null;
	this.overviewId		= null;
	
	this.points 		= null;
	
	this.polyline		= null;
	
	this.directionsLoaded	= false;
	
	this.dontOpen		= false;
	
	this._constructor = function ()
	{
		this.routeDirections = new GDirections ();
		GEvent.addListener(this.routeDirections, "load", this.onGDirectionsLoad);	
	}
	
	this.assignFrom = function (from)
	{
		this.from 	= from;
	}
	
	this.assignId = function (id)
	{
		this.id = id;
	}
	
	this.assignOverviewId = function (id)
	{
		this.overviewId = id;
	}	
	
	this.assignTo = function (to)
	{
		this.to 	= to;
	}
	
	this.assignTitle = function (title)
	{
		this.title 	= title;
	}	
	
	this.setPoints = function (points)
	{
		this.points 	= points;
	}
	
	this.get = function ()
	{
		var theId = this.id;
		route.routeTools.routeToolsLineauto.gdirections[theId].routeDirections.loadFromWaypoints(new Array(route.routeTools.routeToolsLineauto.gdirections[theId].from, route.routeTools.routeToolsLineauto.gdirections[theId].to), {getPolyline: true, getSteps: true, locale: 'nl'});
	}
	
	this.onGDirectionsLoad = function ()
	{
		if (_this.routeDirections.getStatus().code == 200)
		{		
			if (_this.points == null)
			{
				// no points where set before, make the points array
				
				var polyline_buffer = _this.routeDirections.getPolyline();
				var total_points = polyline_buffer.getVertexCount();
				
				_this.points = Array();
				
				for (var i = 0; i < total_points; i++)
				{
					_this.points.push (polyline_buffer.getVertex(i));
				}
				
				// draw polyline
				_this.drawPolyline ();
				
				// add to overview
				_this.overviewAdd ();
			}
			
			if (!_this.directionsLoaded)
			{
				if (_this.dontOpen == false)
				{
					if (routeview)
					{
						_this.view ();
					}
					else
					{
						_this.overviewShow ();
					}
				}
				else
				{
					_this.dontOpen = false;
				}
			}

			_this.directionsLoaded = true;	
			
			debug ("RouteToolsLineauto Gdirections loaded, id:"+_this.id);
		}
		else
		{
			debug ('RouteToolsLineauto :: onGDirectionsLoad error');
		}	
	}
	
	this.overviewAdd = function ()
	{
		route.routeData.overviewAdd ('autoline', null, this.title, this.id);	
	}
	
	this.overviewPress = function ()
	{
		globalLastId = this.id;
		
		if (!_this.directionsLoaded)
		{
			setTimeout("route.routeTools.routeToolsLineauto.gdirections[globalLastId].get ()", 1000);
		}
		else
		{
			_this.overviewShow ();
		}
	}
	
	this.overviewViewPress = function ()
	{
		globalLastId = this.id;
		
		if (!_this.directionsLoaded)
		{
			setTimeout("route.routeTools.routeToolsLineauto.gdirections[globalLastId].get ()", 1000);
		}
		else
		{
			_this.view ();
		}
	}	
	
	this.overviewShow = function ()
	{
		route.routeOverview.overviewLineautoItem (this.id);
	}
	
	this.drawPolyline = function ()
	{
		map.removeOverlay (this.polyline);
		this.polyline = new GPolyline (this.points, "#252466", 4);
		map.addOverlay (this.polyline);
	}
	
	this.deleteDirection = function ()
	{
		// delete the autoline
		
		if (!routeview)
		{
			if (confirm ("Weet je zeker dat je deze route wilt verwijderen?"))
			{
				var overviewId = this.overviewId;

				for (var i = 0; i < route.routeData.overview.length; i++)
				{
					if (i > overviewId)
					{
						var personalId = route.routeData.overview[i][3];

						if (route.routeData.overview[i][0] == 'marker')
						{
							route.routeData.markers[personalId].personalData.overviewId--;
						}

						if (route.routeData.overview[i][0] == 'line')
						{
							route.routeData.lineMarkers[personalId].personalData.overviewId--;
						}

						if (route.routeData.overview[i][0] == 'autoline')
						{
							route.routeTools.routeToolsLineauto.gdirections[personalId].overviewId--;
							route.routeTools.routeToolsLineauto.gdirections[personalId].id--;
						}					
					}
				}		

				/* loop marker overview */
				for (var i = 0; i < route.routeData.overview.length; i++)
				{
					if (i > overviewId && route.routeData.overview[i][0] == 'autoline')
					{
						/* set higher marker id's to -1 */
						route.routeData.overview[i][3]--; 
					}
				}		

				map.removeOverlay (this.polyline);

				route.routeData.overview.splice(this.overviewId, 1);
				route.routeTools.routeToolsLineauto.gdirections.splice(this.id, 1);

				route.routeOverview.showOverview (); 
				route.routeTools.setActive ('hand');
			}
		}
	}
	
	this.view = function ()
	{
		if (this.routeDirections && this.routeHtml.length == 0)
		{
			var html = this.getTableHtml ();

			this.routeHtml = html;

			showOverlay ("viewroute");
			setTimeout ("route.routeTools.routeToolsLineauto.gdirections["+this.id+"].viewSet()", 500);
		}
		else if (this.routeHtml.length > 0)
		{
			showOverlay ("viewroute");
			setTimeout ("route.routeTools.routeToolsLineauto.gdirections["+this.id+"].viewSet()", 500);
		}
	}
	
	this.getTableHtml = function ()
	{
		if (_this.directionsLoaded)
		{
			var kmBuffer = "0m";
			var timeBuffer = 0;

			var theRoute = this.routeDirections.getRoute (0);
			var html = "";

			html += "<h2>"+this.title+"</h2>";

			html += "<p>"+this.routeDirections.getSummaryHtml()+"</p>";

			html += "<table cellspacing='0' cellpadding='0' class='routeviewTable'>";

			for (var i = 0; i < theRoute.getNumSteps(); i++)
			{
				var step = theRoute.getStep (i);

				timeBuffer = timeBuffer + step.getDuration().seconds;

				html += "<tr><td class='distance'>na "+kmBuffer+"</td><td>" + step.getDescriptionHtml () + "</td><td class='duration'>"+this.formatTime(timeBuffer)+"</td></tr>";

				kmBuffer = this.formatMeters (step.getDistance ().meters);
			}

			html += "</table>";

			return html;
		}
		else
		{
			return "";
		}
	}
	
	this.viewSet = function ()
	{
		if (this.routeHtml.length > 0)
		{
			$('viewrouteHtml').innerHTML = this.routeHtml;
		}
	}
	
	this.formatMeters = function (met)
	{
		var meters;

		if (met >= 1000)
		{
			meters = met / 1000;

			meters = Math.round(meters * 100) / 100;

			meters = meters + "km";
		}
		else
		{
			meters = met + "m";
		}

		return meters;		
	}
	
	this.formatTime = function (sec)
	{
		var hours = (sec/3600);
		if (hours < 1)
		{
			hours = Math.round((sec/60));
			hours = hours + ' min.';
		}
		else
		{
			hours = Math.floor(hours);

			var tempHours = sec/3600;	
			var tempMin = tempHours - hours;
			var tempMin = 60 * tempMin;

			hours = hours + ' uur en ' + Math.round(tempMin) + ' min.';
		}

		return hours;	
	}	
	
	this._constructor ();
}/* ********************************************
	lib: 	route v2 library
	class: 	RouteMenu
	desc.:	route tabs functions
******************************************** */

function RouteTabs() 
{
	// self object
	var _this = this;

	this._constructor = function ()
	{
		debug ('RouteTabs :: initialized');
		
		this.setActive ('routeTabSearch');
		
		$('routeTabSearch').onmouseover 	= _this.tabOver;
		$('routeTabRoute').onmouseover 		= _this.tabOver;
		$('routeTabOverview').onmouseover 	= _this.tabOver;
		
		$('routeTabSearch').onmouseout 		= _this.tabOut;
		$('routeTabRoute').onmouseout 		= _this.tabOut;
		$('routeTabOverview').onmouseout 	= _this.tabOut;
		
		$('routeTabSearch').onclick 		= _this.tabClick;
		$('routeTabRoute').onclick 		= _this.tabClick;
		$('routeTabOverview').onclick 		= _this.tabClick;		
	}
	
	this.tabOver = function ()
	{
		this.className = 'active';
	}
	
	this.tabOut = function ()
	{
		if (this.id == _this.active)
		{
			this.className = 'active';
		}
		else
		{
			this.className = '';
		}
	}
	
	this.tabClick = function ()
	{
		_this.setActive (this.id);
		
		if (this.id == 'routeTabRoute')
		{
			route.routeTools.setActive ('autoline');
		}
		
		if (this.id == 'routeTabSearch')
		{
			route.routeTools.setActive ('hand');
		}
		
		if (this.id == 'routeTabOverview')
		{
			route.routeTools.setActive ('hand');
		}		
	}
	
	this.setActive = function (id)
	{
		$('routeTabSearch').className 		= '';
		$('routeTabRoute').className 		= '';
		$('routeTabOverview').className 	= '';

		$('routeTabSearchContent').style.display 	= 'none';
		$('routeTabRouteContent').style.display 	= 'none';
		$('routeTabOverviewContent').style.display 	= 'none';
		
		$(id).className 			= 'active';
		this.active 				= id;
		
		$(id + 'Content').style.display = 'block';
	}
	
	this._constructor ();
}/* ********************************************
	lib: 	route v2 library
	class: 	RouteMenu
	desc.:	route find functions
******************************************** */

function RouteFind() 
{
	// self object
	var _this = this;

	this.searchString = "";
	
	this.geocoder = new GClientGeocoder();
	
	this.searchMarker;
	this.searchPoint;
	
	this.bufferAddress;
	this.bufferCity;
	
	this._constructor = function ()
	{
		debug ('RouteFind :: initialized');
		
		$('routeFindAddressButton').onclick = this.findByAddress;
	}
	
	this.findByAddress = function ()
	{
		var address = $('routeFindAddress').value;
		var city = $('routeFindAddressCity').value;
		
		_this.searchString = address + ", " + city + ", Nederland";
		
		_this.find ();
	}
	
	this.find = function ()
	{
  		geocoder.getLatLng(
    		this.searchString,
			function(point) 
			{
				if (!point) 
				{
					alert(_this.searchString + " niet gevonden");
				} 
				else 
				{
					map.removeOverlay (_this.searchMarker);
					map.setCenter(point, 13);
					
					_this.searchMarker = new GMarker(point);
					_this.searchMarker.info = _this.searchString;
					_this.searchPoint = point;
					map.addOverlay(_this.searchMarker);
					
					_this.bufferAddress = $('routeFindAddress').value;
					_this.bufferCity = $('routeFindAddressCity').value;
					
					GEvent.addListener(_this.searchMarker, "click", function() 
					{	
						var html = "Gezocht op "+this.info;

						html += "<br /><br />";
						html += "<a href=\"javascript:void(0);\" onclick=\"javascript:route.routeFind.addMarker();\">Voeg toe aan kaart</a><br />";
						html += "<a href=\"javascript:void(0);\" onclick=\"javascript:route.routeFind.addFrom();\">Route plannen vanaf dit punt</a><br />";
						html += "<a href=\"javascript:void(0);\" onclick=\"javascript:route.routeFind.addTo();\">Route plannen naar dit punt</a><br />";						
						
						this.openInfoWindowHtml (html);
					});
					
					GEvent.trigger (_this.searchMarker, "click");
				}
			}
  		);
		
	}
	
	this.addMarker = function ()
	{
		map.removeOverlay (_this.searchMarker);
		route.routeTools.routeToolsMarker.add (this.searchPoint, "", "", "");
	}
	
	this.addFrom = function ()
	{
		route.routeOverview.overviewLineauto ();
		
		$('from_address').value = route.routeFind.bufferAddress;
		$('from_city').value = route.routeFind.bufferCity;
	}
	
	this.addTo = function ()
	{
		route.routeOverview.overviewLineauto ();
		
		$('to_address').value = route.routeFind.bufferAddress;
		$('to_city').value = route.routeFind.bufferCity;
	}	
	
	this._constructor ();
}/* ********************************************
	lib: 	route v2 library
	class: 	Route
	desc.:	loads all route functions
******************************************** */

function RouteView() 
{
	var _this = this;
	
	this.code_view = null;
	
	this._constructor = function ()
	{
		this.code_view = cfg_code_view;
		
		debug ('RouteView :: initialized :: '+this.code_view);
		
		this.getDataRequest ();
		
		/* route print submit event */
		$('printRouteForm').onSubmit = function ()
		{
			return false;
		}		
	}
	
	this.getDataRequest = function ()
	{
		new Ajax.Request('/route2.view.php',
		{
			method:'get',

			parameters: {
				code_view: this.code_view
			},

			onSuccess: function(d)
			{
				var response = d.responseText;

				if (response == "notfound")
				{
					debug ("Route :: routeView :: code_view not found");

				}
				else if (response == "error")
				{
					debug ("Route :: routeView :: error");
				}					
				else
				{
					debug ("RouteData :: routeView :: code found");

					/* code found */
					route.enableRouteEdit ();
					_this.fromXml (response);
					$('routeTabSearch').style.display = 'none';
					$('routeTabRoute').style.display = 'none';
					route.routeTabs.setActive ('routeTabOverview');
				}

			},

			onFailure: function()
			{ 
				debug ("RouteView :: open request error");
			}
		});		
	}
	
	this.fromXml = function (xml)
	{
		var x = GXml.parse(xml);

		var options = x.getElementsByTagName('options')[0];
			
			var route_id 		= GXml.value(options.getElementsByTagName('routeId')[0]);
			var user_name 		= GXml.value(options.getElementsByTagName('userName')[0]);
			var user_email 		= GXml.value(options.getElementsByTagName('userEmail')[0]);
			var route_title 	= GXml.value(options.getElementsByTagName('routeTitle')[0]);
			var route_description 	= GXml.value(options.getElementsByTagName('routeDescription')[0]);
			var cityId 		= GXml.value(options.getElementsByTagName('cityId')[0]);
			
			/* set data to this object */
			this.dataTitle 		= route_title;
			this.dataDescription 	= route_description;
			this.dataEmail 		= user_email;
			this.dataName 		= user_name;
			
			/* change city_id */
			if (city_id != cityId) changeCity (cityId);

				/* SET */
				this.routeId = route_id;
				route.routeData.routeId = route_id;

				route.routeData.changeData ('route', 'title', route_title);
				route.routeData.changeData ('route', 'description', route_description);
				route.routeData.changeData ('route', 'done', 'true');

				route.routeData.changeData ('user', 'name', user_name);
				route.routeData.changeData ('user', 'email', user_email);
				route.routeData.changeData ('user', 'done', 'true');

			var items = x.getElementsByTagName('item');

			for (var i = 0; i < items.length; i++)
			{
				var item 	= items[i];

				var type 	= GXml.value(item.getElementsByTagName('type')[0]);
				var title 	= GXml.value(item.getElementsByTagName('title')[0]);
				var icon 	= GXml.value(item.getElementsByTagName('icon')[0]);

				var data	= item.getElementsByTagName('data')[0];

				if (type == 'marker')
				{
					var description 	= GXml.value(data.getElementsByTagName('description')[0]);
					var lat 		= GXml.value(data.getElementsByTagName('lat')[0]);
					var lng 		= GXml.value(data.getElementsByTagName('lng')[0]);
					var icon_id 		= GXml.value(data.getElementsByTagName('icon_id')[0]);
					
					/* add the marker to data object */
					route.routeTools.routeToolsMarker.add (new GLatLng(lat, lng), title, description, icon_id)
					
					var pictures 		= data.getElementsByTagName('picture');
		
					var marker_id = route.routeData.markers.length-1;
					
					for (var y = 0; y < pictures.length; y++)
					{
						route.routeData.markers[marker_id].personalData.pictures.push (GXml.value(pictures[y]));
					}
				}

				if (type == 'line')
				{
					var description 	= GXml.value(data.getElementsByTagName('description')[0]);
					
					var first_point 	= GXml.value(data.getElementsByTagName('firstPoint')[0]);
					var first_lat = first_point.split(",")[0];
					var first_lng = first_point.split(",")[1];
					
					var point 		= GXml.value(data.getElementsByTagName('points_encoded')[0]);
					var zoom 		= GXml.value(data.getElementsByTagName('zoom_encoded')[0]);
					
					
					/* init */
					var polylineId = route.routeData.linePolyline.length;
					if (!route.routeData.lineArray[polylineId]) route.routeData.lineArray[polylineId] = Array();
					if (!route.routeData.lineMarkers[polylineId]) route.routeData.lineMarkers[polylineId] = Array();

					/* add new data */
					route.routeData.lineMarkers[polylineId].personalData = Array ();
					route.routeData.lineMarkers[polylineId].personalData.title = title;
					route.routeData.lineMarkers[polylineId].personalData.description = description;
					route.routeData.lineMarkers[polylineId].personalData.changed = false;
					route.routeData.lineMarkers[polylineId].personalData.overviewId = route.routeData.overview.length;

					/* overlay */
					route.routeData.overviewAdd ('line', null, route.routeData.lineMarkers[polylineId].personalData.title, polylineId);
					
					/* add the polyline point marker */
					var marker = new GMarker (new GLatLng(first_lat, first_lng), {draggable: true, bouncy: false, icon: route.routeTools.routeToolsLine.lineMarker});

					marker.personalData = Array();
					marker.personalData.id 		= route.routeData.lineMarkers[polylineId].length;
					marker.personalData.polylineId 	= polylineId;

					GEvent.addListener(marker, "click", function () {
			
						map.setCenter (this.point);

						var polylineId = this.personalData.polylineId;

						var html = "<strong id=\"routeEditMarkerShowtitle\">"+ route.routeData.lineMarkers[polylineId].personalData.title +"</strong>";

						html += "<div id=\"routeEditMarker\">";

						html += "</div>";

						marker.openInfoWindowHtml(html);

						route.routeTools.routeToolsLine.getShowHtml (polylineId);
						
					});	
					
					map.addOverlay(marker);
					route.routeData.lineMarkers[polylineId].push(marker);	
					
					route.routeData.linePolyline[polylineId] = new GPolyline.fromEncoded({
						color: "#FF0000",
						weight: 4,
						points: point,
						levels: zoom,
						zoomFactor: 32,
						numLevels: 4
					});

					map.addOverlay(route.routeData.linePolyline[polylineId]); 					

					/*
					for (var j = 0; j < points.length; j++)
					{
						var lat		= parseFloat(GXml.value(points[j].getElementsByTagName('lat')[0]));
						var lng		= parseFloat(GXml.value(points[j].getElementsByTagName('lng')[0]));

						
						route.routeTools.routeToolsLine.add (new GLatLng(lat, lng), title, description, "true");
					}

					
					var currentPolygon = route.routeTools.routeToolsLine.currentPolygon;
					if (route.routeData) if (route.routeData.lineMarkers[currentPolygon])
					{
						for (var k = 0; k < route.routeData.lineMarkers[currentPolygon].length; k++)
						{
							route.routeData.lineMarkers[currentPolygon][k].hide();
						}
					}
					*/

					//route.routeTools.routeToolsLine.currentPolygon = null;

				}

				if (type == 'autoline')
				{
					var from_lat 		= GXml.value(data.getElementsByTagName('from_lat')[0]);
					var from_lng 		= GXml.value(data.getElementsByTagName('from_lng')[0]);
					var to_lat		= GXml.value(data.getElementsByTagName('to_lat')[0]);
					var to_lng 		= GXml.value(data.getElementsByTagName('to_lng')[0]);				

					// make new gdirections
					var new_id = route.routeTools.routeToolsLineauto.gdirections.length;
					route.routeTools.routeToolsLineauto.gdirections[new_id] = new RouteToolsDirections();

					route.routeTools.routeToolsLineauto.gdirections[new_id].assignFrom (new GLatLng(from_lat, from_lng));
					route.routeTools.routeToolsLineauto.gdirections[new_id].assignTo (new GLatLng(to_lat, to_lng));
					route.routeTools.routeToolsLineauto.gdirections[new_id].assignTitle (title);
					route.routeTools.routeToolsLineauto.gdirections[new_id].assignId (new_id);
					route.routeTools.routeToolsLineauto.gdirections[new_id].assignOverviewId (route.routeData.overview.length);
					
					var point 		= data.getElementsByTagName('points')[0];
					var points 		= point.getElementsByTagName('point');
					var points_add		= Array();
				
					for (var l = 0; l < points.length; l++)
					{
						var lat		= parseFloat(GXml.value(points[l].getElementsByTagName('lat')[0]));
						var lng		= parseFloat(GXml.value(points[l].getElementsByTagName('lng')[0]));
						
						/* add to array */
						points_add.push(new GLatLng(lat, lng));
					}
					
					route.routeTools.routeToolsLineauto.gdirections[new_id].setPoints (points_add);
					route.routeTools.routeToolsLineauto.gdirections[new_id].overviewAdd ();
					route.routeTools.routeToolsLineauto.gdirections[new_id].drawPolyline ();
				}					
			}
			
		route.routeOverview.showOverview ();
		
		this.showViewHtml ();
		
		$('tools').style.display = 'none';
		
		route.routeContext.clear ();
		
		if ($('ajaxLoad').style.display == 'block') $('ajaxLoad').style.display = 'none';
	}
	
	this.routePrint = function ()
	{
		route.routeTools.routeToolsLineauto.checkAllData (routeview.routePrintSubmit);
	}
	
	this.routePrintSubmit = function ()
	{
		var xml = route.routeData.toXml();
		
		$('printRouteData').value = xml;
		$('printRouteForm').submit ();		
	}
	
	this.showViewHtml = function ()
	{
		var html = "";
		
		html += "<h2>Kaart bekijken</h2>";
		
		html += "<strong>Gemaakt door:</strong> <a href=\"mailto:"+this.dataEmail+"\">"+ this.dataName + "</a><br />";
		html += "<strong>Titel:</strong> "+ this.dataTitle + "<br />";
		html += "<strong>Omschrijving:</strong> "+ this.dataDescription + "<br /><br />";
		html += "<a href=\"javascript:void(0);\" onclick=\"javascript:routeview.routePrint();\" class=\"buttonPrint\">Complete route printen</a>";
		
		$('routeContent').innerHTML = html;
		
		route.routeMenu.resizeRoutePanel ();	
	}
	
	this._constructor ();
}var geocoder = new GClientGeocoder();

function findAddress ()
{
	if ($('findStreet').value.length > 0)
	{
		/* find street */
		showAddress ($('findStreet').value + ', ' + $('findCity').value + ', ' + $('findCountry').value);
	}
	else if ($('findZip').value.length > 0)
	{
		/* find zip */
		showAddress ($('findZip').value + ', ' + $('findCountry').value);
	}
}

function showAddress(address) {
  geocoder.getLatLng(
    address,
    function(point) {
      if (!point) {
        alert("Het adres '"+address+"' kon niet gevonden worden");
      } else {
        map.panTo(point);

	/* add marker */
	GEvent.trigger(map, "click", null, point);

        hideOverlay();
      }
    }
  );
}var stateCategoryGroups = Array();
var categoryActiveArr = Array();

function initIcons()
{	
	for (var i = 0; i < categories.length; i++)
	{
		// get the name
		var name 			= categories[i];
		
		// init the icon Obj
		icons[name] 			= new GIcon();
		icons[name].image 		= "img/icons/markers/marker." + name + ".png";
		icons[name].shadow 		= "img/icons/markers/shadow.png";
		icons[name].iconSize 		= new GSize(33, 39);
		icons[name].shadowSize 		= new GSize(59, 46);
		icons[name].iconAnchor 		= new GPoint(17, 37);
		icons[name].infoWindowAnchor 	= new GPoint(17, 37);	
	}
	
	// init hover icon
	icons['hover'] 			= new GIcon();
	icons['hover'].image 		= "img/graphic/arrow.png";
	icons['hover'].iconSize 	= new GSize(53, 53);
	icons['hover'].iconAnchor 	= new GPoint(27, 87);
	icons['hover'].infoWindowAnchor = new GPoint(0, 0);	
	
	icons['nike'] 			= new GIcon();
	icons['nike'].image 		= "img/icons/markers/marker.nike.png";
	icons['nike'].iconSize 		= new GSize(33, 39);
	icons['nike'].iconAnchor 	= new GPoint(17, 37);
	icons['nike'].infoWindowAnchor 	= new GPoint(17, 37);
	
	icons['nikefinish'] 			= new GIcon();
	icons['nikefinish'].image 		= "img/icons/markers/marker.nike.finish.png";
	icons['nikefinish'].iconSize 		= new GSize(33, 39);
	icons['nikefinish'].iconAnchor 	= new GPoint(17, 37);
	icons['nikefinish'].infoWindowAnchor 	= new GPoint(17, 37);	
}

function initMarkers()
{
	markerActive	= Array(); // reset the active array
	
	for (var i = 0; i < categories.length; i++)
	{
		var name = categories[i];
		
		$('li_'+name).style.display = 'none';
		
		var type = name.split("_");
		type = type[0];
		
		$('h1_'+type).style.display = 'none';
		$('ul_'+type).style.display = 'none';
		
		// init the markersArr
		markerArr[name] = Array();
		stateCategoryGroups[name] = false;
		
		toggleMarkers (name, type);
	}
}

function addMarker (category, point, type, html, video, info, id, title)
{
	var marker = new GMarker(point, icons[category]);
	
	GEvent.addListener(marker, "click", function() {
		
		if (routeEdit)
		{
		
		}
		else
		{		
			var infoTabs = Array();

			infoTabs.push(new GInfoWindowTab("Adres", html));

			if(video.length > 99) 
			{
				infoTabs.push(new GInfoWindowTab("Video", video));
			}

			if(info.length > 1) 
			{
				infoTabs.push(new GInfoWindowTab("Info", "<div class=\"baloon\">"+info+"</div>"));
			}		

			var replies = "<div class=\"baloon\" id=\"repliesBaloon\"><a href=\"javascript:void(0);\" onclick=\"javascript:$('repliesBaloon').scrollTop = $('repliesBaloon').scrollHeight-280;\">Plaats een reactie!</a><br /><br />";
			
			replies += "<strong>Reacties:</strong><br />";
			
			replies += "<div id=\"repliesContent\"></div>";		
			
			
			replies += "<form action=\"javascript:void(0);\" onsubmit=\"javascript:postReply("+id+");\"><strong>Plaats een reactie:</strong><br />Naam *:<br /><input type=\"text\" id=\"replyData_name\" /><br />E-mail *:<br /><input type=\"text\" id=\"replyData_email\" /><br />Bericht *:<br /><textarea id=\"replyData_message\"></textarea><br />Type onderstaande tekst over *:<br /><div id=\"cryptDisplay\"></div><input type=\"text\" id=\"replyData_crypt\" /><br /><input type=\"submit\" value=\"Plaats reactie\" /></form>";

			replies += "</div>";

			var repliesTab = new GInfoWindowTab("Reacties", replies);
			//infoTabs.push(repliesTab);

			marker.openInfoWindowTabsHtml(infoTabs);
			
			//loadReplyContent(id);
		}
	});
		
	marker.title = title;
	marker.listId = markerArr[category].length;
	markerArr[category].push(marker);
	
	map.addOverlay(marker);
	
	if (id == show_location_id)
	{
		// marker call from url, show balloon
		GEvent.trigger(marker, 'click');
		map.setCenter(point, 17);
		//setMaptype('satellite');
	}	
}

function goToRoute (address, city)
{
	if (route._routeEditEnabled)
	{
		route.routeOverview.overviewLineauto ();
		
		$('to_address').value = address;
		$('to_city').value = city;		
	}
	else
	{
		route.enableRouteEdit ();
		
		route.routeOverview.overviewLineauto ();
		
		$('to_address').value = address;
		$('to_city').value = city;
	}
}

function postReply (location_id)
{
	if (
			$('replyData_name').value.length > 0
		&&
			$('replyData_email').value.length > 0
		&&
			$('replyData_message').value.length > 0
		&&
			$('replyData_crypt').value.length > 0
	)
	{
		new Ajax.Request('/add.reply.php',
		{
			method:'post',
			parameters: 
				'name='+encodeURI($('replyData_name').value)+
				'&email='+encodeURI($('replyData_email').value)+
				'&message='+encodeURI($('replyData_message').value)+
				'&crypt='+encodeURI($('replyData_crypt').value)+
				'&location_id='+encodeURI(location_id)
			,

			onSuccess: function(d)
			{
				var repliesHtml = "";

				var response = d.responseText;
				
				if (response == 'crypterror')
				{
					alert ("De overgetypte tekst is onjuist");
				}
				else if (response == 'empty')
				{
					alert ("Je hebt niet alle verplichte (*) velden ingevuld.");
				}
				else if (response == 'ok')
				{
					$('cryptogram').src='./crypt/cryptographp.php?cfg=0&&'+Math.round(Math.random(0)*1000)+1;
					
					$('replyData_crypt').value = "";
					$('replyData_message').value = "";
					loadReplyContent (location_id);
					$('repliesBaloon').scrollTop = 0;
				}				
			}
			,

			onFailure: function()
			{ 
				//alert('Something went wrong...') 
			}
		});			
	}
	else
	{
		alert('Je hebt niet alle verplichte (*) velden ingevuld.');	
	}	
}

function loadReplyContent (location_id)
{
	if ($('cryptDisplay').innerHTML.length < 1)
	{
		$('cryptDisplay').innerHTML = $('crypt').innerHTML;
		$('crypt').style.display = 'block';
		$('crypt').innerHTML = "";
	}
		
	new Ajax.Request('/load.replies.php',
  	{
    		method:'get',
    		parameters: 'location_id='+location_id,
    		    		
    		onSuccess: function(d)
    		{
      			var repliesHtml = "";
      			
      			var response = d.responseText;
      			      
			var xml = GXml.parse(response);
			var replies = xml.documentElement.getElementsByTagName("reply");
			
			for (var i = 0; i < replies.length; i++) 
			{
				var date = replies[i].getAttribute("date");
				var message = replies[i].getAttribute("message");
				var author = replies[i].getAttribute("author");
				var reply_id = replies[i].getAttribute("id");
				var email = replies[i].getAttribute("email");
				
				repliesHtml += "<em style=\"display: block; background-color: #ddd; color:#555; padding: 2px; font-size: 10px;\">Geplaatst door <a href=\"mailto:"+email+"\">"+author+"</a> op "+date+"</em>"+message+"<br /><br />";
			}
			
			if (replies.length == 0)
			{
				repliesHtml = "Nog geen reacties geplaatst.<br /><br />";
			}
			
			$('repliesContent').innerHTML = repliesHtml;
    		},
    		
    		onFailure: function()
    		{ 
    			//alert('Something went wrong...') 
    		}
  	});			
}

function loadMarkers (category, type)
{
	markersAjaxLoaded++;
	
	new Ajax.Request('/load.markers.php',
  	{
    		method:'get',
    		parameters: 'city_id='+ city_id +'&category_sub_id='+category,
    		    		
    		onSuccess: function(d)
    		{
      			var response = d.responseText;
      			
      			markersAjaxLoadedDone++;
      			      
			var xml = GXml.parse(response);
			var markers = xml.documentElement.getElementsByTagName("marker");
			
			for (var i = 0; i < markers.length; i++) 
			{
				var point = new GLatLng(parseFloat(markers[i].getAttribute("lat")), parseFloat(markers[i].getAttribute("lng")));
				var category = markers[i].getAttribute("alias")+'_'+markers[i].getAttribute("category_sub_id");
				var type = markers[i].getAttribute("alias");
				var html = markers[i].getAttribute("html");
				var video = markers[i].getAttribute("video");
				var info = markers[i].getAttribute("info");
				var id = markers[i].getAttribute("id");
				var title = markers[i].getAttribute("title");
								
				addMarker(category, point, type, html, video, info, id, title);
			}
									
			if (category != 'undefined')
			{
				$('li_'+category).style.display = 'block';
				$('li_'+category).style.zIndex = '99999';
								
				$('h1_'+type).style.display = 'block';
				$('h1_'+type).style.zIndex = '999999';
				
				$('ul_'+type).style.display = 'block';
			}
			
			markerActive[category] = true;

			if ($('category_'+category).checked != true)
			{
				toggleMarkers (category, type);
			}
			
			checkMarkersLoaded ();
    		},
    		
    		onFailure: function()
    		{ 
    			alert('Something went wrong...') 
    		}
  	});
}

function toggleMarkers (category, type)
{
	if(markerActive[category] != true)
	{
		// first time, add marker to map
		
		//markersAjaxLoaded++;
		
		setTimeout("loadMarkers ('"+category+"', '"+type+"')", 500*markersAjaxLoaded);
	}
	else
	{
		// show hide
				
		if ($('category_'+category).checked)
		{
			for (var j = 0; j < markerArr[category].length; j++)
			{
				map.addOverlay(markerArr[category][j]);
			}			
		}
		else
		{
			for (var j = 0; j < markerArr[category].length; j++)
			{
				map.removeOverlay (markerArr[category][j]);
			}
			
			var tmp = category.split('_');
			var category_name = tmp[0];
			var category_id = tmp[1];
			
			if ($('arrow_'+category_name+'_'+category_id).className == 'active')
			{			
				getAddressOverview (category_id, category_name);
			}
		}
	}
	
	// save category state in array
	categoryActiveArr[category] = $('category_'+category).checked;		
}

function toggleMarkersCategory (type)
{
	var checkBoxes = $('contentCategory').getElementsByTagName('INPUT');
	
	for(var i=0; i<checkBoxes.length; i++)
	{
		if (checkBoxes[i].type == 'checkbox')
		{
			var checkBoxType = checkBoxes[i].id.split("_");
			var checkBoxName = checkBoxType[1]+"_"+checkBoxType[2];
			checkBoxType = checkBoxType[1];
			
			if (checkBoxType == type)
			{				
				if(stateCategoryGroups[type])
				{
					// all off
					if (checkBoxes[i].checked)
					{
						//alert("on: "+checkBoxName);

						checkBoxes[i].checked = false;
						toggleMarkers (checkBoxName, type);
						
					}
				}
				else
				{
					// all on
					if (checkBoxes[i].checked == false)
					{
						//alert("on: "+checkBoxName);

						checkBoxes[i].checked = true;
						toggleMarkers (checkBoxName, type);
					}
				}
			}
		}
	}
	
	if (stateCategoryGroups[type])
	{
		stateCategoryGroups[type] = false;
	}
	else
	{
		stateCategoryGroups[type] = true;
	}
}var offmap = new GLatLng(-90, -180);

function getAddressOverview (id, category_name)
{
	//alert(category_name + ' - ' + id);
	
	if ($('arrow_'+category_name+'_'+id).className == 'active')
	{
		// in
		$('arrow_'+category_name+'_'+id).src = 'img/graphic/cat_arrow.gif';
		$('adresses_'+category_name+'_'+id).style.display = 'none';
		$('arrow_'+category_name+'_'+id).className = '';
	}
	else
	{
		// out
		
		if ($('category_'+category_name+'_'+id).checked == false)
		{
			$('category_'+category_name+'_'+id).checked = true;
			toggleMarkers(category_name+'_'+id, category_name);
		}		
		
		$('adresses_'+category_name+'_'+id).style.display = 'block';
		
		if ($('adresses_'+category_name+'_'+id).innerHTML.length > 0)
		{
			$('arrow_'+category_name+'_'+id).src = 'img/graphic/cat_arrow_active.gif';
			$('arrow_'+category_name+'_'+id).className = 'active';			
		}
		else
		{
			$('loader_'+id).style.display = 'block';

			new Ajax.Request('/load.addresses.php',
			{
				method:'get',
				parameters: 'city_id='+ city_id +'&categories='+id,

				onSuccess: function(d)
				{
					var response = d.responseText;

					var xml = GXml.parse(response);
					var markers = xml.documentElement.getElementsByTagName("marker");
					for (var i = 0; i < markers.length; i++) 
					{
						var point = new GLatLng(parseFloat(markers[i].getAttribute("lat")), parseFloat(markers[i].getAttribute("lng")));
						var category = markers[i].getAttribute("alias")+'_'+markers[i].getAttribute("category_sub_id");
						var type = markers[i].getAttribute("alias");
						var html = markers[i].getAttribute("html");

						$('adresses_'+category_name+'_'+id).innerHTML += html;
					}
					
					// if empty
					if (markers.length < 1)
					{
						$('adresses_'+category_name+'_'+id).innerHTML = "<h3>Deze categorie bevat voor deze stad geen locaties</h3>";
						$('arrow_'+category_name+'_'+id).className = 'active';
					}
					
					// hide loading
					$('loader_'+id).style.display = 'none';
					
					// arrow
					$('arrow_'+category_name+'_'+id).src = 'img/graphic/cat_arrow_active.gif';
					$('arrow_'+category_name+'_'+id).className = 'active';
				},

				onFailure: function()
				{ 
					alert('Something went wrong...') 
				}
			});
		}
	}
}

function markerHover (id, category)
{
	hovermarker.setPoint(markerArr[category][id].getPoint());
}

function markerHoverOut ()
{
	hovermarker.setPoint(offmap);
}

function clearAdresses ()
{
	for (var i = 0; i < categories.length; i++)
	{
		var name = categories[i];
		
		var tmp = name.split("_");
		var type = tmp[0];
		var id = tmp[1];
		
		if($('arrow_'+name).className == 'active')
		{
			// current is active, clear and load new data
			$('adresses_'+name).innerHTML = "";
			$('arrow_'+name).src = 'img/graphic/cat_arrow.gif';
			$('adresses_'+name).style.display = 'none';
			$('arrow_'+name).className = '';
			
			getAddressOverview (id, type);
		}
	}	
}/* nike hack */

var startnikePoint;
var endnikePoint;
var routenike;
var startnike;
var endnike;
var stateNike;

function initNike ()
{
	if (cfg_code_view == 'CVexHn6Q4sgg9SGH5treUJbQ3zJKcw')
	{
		$('category_nikecityrun_18').checked = true;
		$('li_nikecityrun_18').style.fontWeight = 'bold';
		stateNike = true;
	}	
	
	if (showNikeRun)
	{
		showNikeRunRoute();
		getAddressOverview(4, "parkerenvervoer");

	}

	if (city_id == 1)
	{
		$('h1_nikecityrun').style.display = 'block';
		$('ul_nikecityrun').style.display = 'block';
		$('li_nikecityrun_18').style.display = 'block';		
	}
}

function showNikeRunRoute ()
{
	hideNikeRunRoute ();
	
	//ROTTERDAM:var coords = "4.478666415184705,51.92266460647442,0 4.479127193835339,51.92173985833617,0 4.479458107284842,51.92113081316214,0 4.479642666555606,51.92078128380074,0 4.479768901704972,51.920494212953,0 4.479852501430926,51.92026894244186,0 4.479924335769823,51.92007957069482,0 4.480052170700944,51.9196917659533,0 4.480275990703747,51.91904572030765,0 4.480359609231059,51.91885280580759,0 4.480452076090316,51.91866055980914,0 4.480549701370947,51.91848860926483,0 4.480842295968344,51.91804108891401,0 4.481175729409998,51.91757422727386,0 4.481421194150784,51.91722733971844,0 4.48159749552525,51.91698350072367,0 4.48168478149617,51.91685072706807,0 4.48173755766436,51.916765551671,0 4.481782202410741,51.91664405403283,0 4.481831334100932,51.91649084962967,0 4.481846513810268,51.91634586730688,0 4.481867193426169,51.91615560428941,0 4.481885731533865,51.91573963508778,0 4.481918588376787,51.91472536758694,0 4.481928842772405,51.91413974545311,0 4.481960347722875,51.91354690707509,0 4.481975756087891,51.91316288186698,0 4.481991756372707,51.91287339171188,0 4.48201917384921,51.91265150392367,0 4.482069396761318,51.91238367044863,0 4.482152823979774,51.91208279512643,0 4.482344893228145,51.91153292831307,0 4.482467024293541,51.91123266871858,0 4.482525490811696,51.91109252065371,0 4.482565423214737,51.91101414938451,0 4.482623413203413,51.91092553268013,0 4.482692755553416,51.91083886622468,0 4.482780825739482,51.91074790218589,0 4.482895426398244,51.91065426571173,0 4.483001492737473,51.91058505311928,0 4.483142617088078,51.91051310443205,0 4.483365109201785,51.91042127257065,0 4.483842026312956,51.91022933325397,0 4.484442931034209,51.90999407072683,0 4.485105081196068,51.90973343924846,0 4.486775160582582,51.90906161166567,0 4.488381212314266,51.90842578855403,0 4.489623435399921,51.90792676703038,0 4.489996854404495,51.90777253682594,0 4.490402207230005,51.90760487730861,0 4.490490858760211,51.90757061866046,0 4.49060529364759,51.90753619180903,0 4.490738959758005,51.90751374491428,0 4.490831283355561,51.90751071874859,0 4.490905510747211,51.90751564628331,0 4.491012899955294,51.90752770375847,0 4.491139621264439,51.90755650918042,0 4.491253546737738,51.90759502103035,0 4.49142408767176,51.90768045337426,0 4.49162552003898,51.90780211201533,0 4.492124408084948,51.90811261930772,0 4.492212104259522,51.90815948187485,0 4.492278706953854,51.90819543747998,0 4.492337557301227,51.90822173525325,0 4.492423670467815,51.90825542900178,0 4.492484734957202,51.90827493663718,0 4.492582539824582,51.9082956041042,0 4.492711875525501,51.90830730247287,0 4.492799379724772,51.90830443232265,0 4.492894049614847,51.9082905243946,0 4.492979415945144,51.90826927282251,0 4.493166467742881,51.9082073642441,0 4.493519852674936,51.90805821942054,0 4.494623458315488,51.9075734456096,0 4.495851879761915,51.90704714392121,0 4.497191959334288,51.9064770767999,0 4.49989722949762,51.90531790783873,0 4.501630285448442,51.90458692008218,0 4.502220476368592,51.90434223505221,0 4.503071289405186,51.90397506637707,0 4.503737831925108,51.90368142842635,0 4.503950411337328,51.90359143703113,0 4.50421986269248,51.9034812723347,0 4.504951642574113,51.90323191244686,0 4.505999283307105,51.90288543767233,0 4.506571766345857,51.90267786581866,0 4.507006268624025,51.90250785562947,0 4.507399159175932,51.90234301236826,0 4.50893298832969,51.90169258789332,0 4.510185535361828,51.90115534683363,0 4.510372817988454,51.90107561230052,0 4.510617495707081,51.90096325551136,0 4.510740767172564,51.90090038727287,0 4.51080760851606,51.90086593515725,0 4.510910792734009,51.90080637943778,0 4.511010619090911,51.90074906778667,0 4.511073292445488,51.90070651098551,0 4.51113199515828,51.90066364318119,0 4.511157631720067,51.90063403125144,0 4.511173053849404,51.90059911220974,0 4.511173998781942,51.90056342982874,0 4.511157207964075,51.90052696672389,0 4.511132350341882,51.90049283800216,0 4.511085765726264,51.90044336252507,0 4.510979528848594,51.90034185326478,0 4.510862615987563,51.90023803431129,0 4.510612296856024,51.90001110855508,0 4.510426338207552,51.89983797717449,0 4.510198185665374,51.89964796726409,0 4.510061451255766,51.89955320455891,0 4.509857741289935,51.89942896332369,0 4.509379411070441,51.89919547362145,0 4.50897969710664,51.89901934192146,0 4.508773642531736,51.89893125952957,0 4.50864842549376,51.89888354934325,0 4.508489811895643,51.89883432042023,0 4.508325220376463,51.89879510574788,0 4.507261138664035,51.89859795468301,0 4.506684412527321,51.8985145729796,0 4.506174295508785,51.89847088508044,0 4.50586598735886,51.89844993253814,0 4.505372023675633,51.89842323444232,0 4.50470005838055,51.89840437863752,0 4.504177980998549,51.8983936275604,0 4.503386765388044,51.89837582031067,0 4.503264040573583,51.89837582120249,0 4.503133560534565,51.89838821079475,0 4.502979756658476,51.89841297504655,0 4.502877225140651,51.89842672922989,0 4.502780266746882,51.89843498054689,0 4.502641327577508,51.89843878502967,0 4.502354161866663,51.89843447311594,0 4.502114642239008,51.89842958496245,0 4.50105001935917,51.89840860462818,0 4.500815383441776,51.89839635681521,0 4.500552907037417,51.8983831064469,0 4.499194227987331,51.89823826900611,0 4.498735296222179,51.89818296638899,0 4.498386960239628,51.89813360373811,0 4.497903897904351,51.89805243422291,0 4.497287348955993,51.89793452453019,0 4.495941279796838,51.89764987064128,0 4.495544580926918,51.8975525481213,0 4.495097062460118,51.89744078526139,0 4.493759403120209,51.89714599773662,0 4.492350235999298,51.89685050482644,0 4.491351480181351,51.89662024829862,0 4.490299346274696,51.8963954644965,0 4.489186847229703,51.89621588087558,0 4.488276665783602,51.8960953921505,0 4.487288866064887,51.89597391045112,0 4.487077615972183,51.8959399176699,0 4.486876577761962,51.89590258748521,0 4.486558171336867,51.89582242261881,0 4.486281720745666,51.89573774625266,0 4.485647966892671,51.89548768056893,0 4.485216456154006,51.89534603705458,0 4.484821001535565,51.89524944223481,0 4.483842219738023,51.89503625137688,0 4.481253337547926,51.89450338117605,0 4.480260172314743,51.89429228367967,0 4.479349478529883,51.89410058299222,0 4.477915286372749,51.89379469653931,0 4.476243175778336,51.89340127960535,0 4.475763231089715,51.89333671044662,0 4.475585596801949,51.89332145640139,0 4.475295270566036,51.89331732350356,0 4.475074613450872,51.8933202074525,0 4.474780683169797,51.89334129624933,0 4.474557815238626,51.89337968801691,0 4.474345045172854,51.89343073901574,0 4.474017183253267,51.89354760464602,0 4.473603528618654,51.8937124465037,0 4.472906871584272,51.89399887196348,0 4.471711518888881,51.89448760568933,0 4.471443166419107,51.89460125754639,0 4.471043399032908,51.89480839507921,0 4.470360445803237,51.89517191532087,0 4.469848839270668,51.89545209699914,0 4.469673021130191,51.89554095956503,0 4.469471673555745,51.89561215811225,0 4.469329394265103,51.8956452664815,0 4.469205911155484,51.8956618129006,0 4.469044848711306,51.89567669716239,0 4.468929422131225,51.8956833057756,0 4.468803259663106,51.89568659975757,0 4.46868515193195,51.8956849254664,0 4.468561679549367,51.89567331150547,0 4.468416730447942,51.8956530277277,0 4.468320105853593,51.89562982237501,0 4.468180539783276,51.89559004570039,0 4.468054395339594,51.89555027100195,0 4.46792557166097,51.89549890057159,0 4.46762769136862,51.89538983702233,0 4.467450730688171,51.89534335934732,0 4.467288538362411,51.89530268738887,0 4.467111816843456,51.89527037622734,0 4.466882421931757,51.89523939666595,0 4.466759087406118,51.89522200228361,0 4.466648447585115,51.89520234925818,0 4.466585893209256,51.89518129475523,0 4.466537832126008,51.89515685665738,0 4.466515220423673,51.89513329527421,0 4.466492613312042,51.89509926382758,0 4.46648555347771,51.89507745003078,0 4.466484151418513,51.89505040214443,0 4.466488400268887,51.89503382525732,0 4.466495476855087,51.89501724883996,0 4.46650962430418,51.89499718357774,0 4.466543571974796,51.89496316151927,0 4.466590248558617,51.89491954399011,0 4.466687840794108,51.89483754453954,0 4.466769956155858,51.89477021097126,0 4.466967103135971,51.89462322156732,0 4.467268531249914,51.89439729358307,0 4.467912167612269,51.893959394772,0 4.469096899158828,51.89324646376478,0 4.470245254025613,51.8925784093037,0 4.47126355870796,51.89203924749826,0 4.472094453957809,51.89163891517764,0 4.472939085160135,51.89126262551244,0 4.473010656591796,51.89123014834296,0 4.473128239552977,51.89118023899923,0 4.473176511213509,51.89115625554036,0 4.473218344696605,51.89113082712323,0 4.47324626479481,51.89110497615081,0 4.473266294971936,51.89107620966444,0 4.473280386784041,51.89104837662413,0 4.473283745519851,51.89102272893449,0 4.473277392551168,51.89099702824893,0 4.47325939873015,51.89096725252926,0 4.47323730488425,51.8909313234001,0 4.47321798678577,51.89089948894318,0 4.473183061788134,51.89084881110609,0 4.472807587151522,51.89031271893411,0 4.472449096606567,51.88980222352322,0 4.472387564575641,51.88970952054314,0 4.472339844008403,51.88961654311774,0 4.472283662832524,51.88949229443372,0 4.472228813438917,51.8893147976846,0 4.472186623654736,51.88910464157677,0 4.472150820063703,51.88888948546007,0 4.472069285503039,51.8884737650182,0 4.47194740671722,51.88783398717796,0 4.471812404570031,51.88712733739704,0 4.471740712270034,51.88669872853101,0 4.471515410626722,51.88551367039396,0 4.471287406639149,51.8842328220878,0 4.471245455106299,51.88403547218402,0 4.471192166907429,51.88384116589904,0 4.471124570134251,51.88359624612884,0 4.471058746716167,51.88337541104157,0 4.470991222721366,51.88320559745126,0 4.470914382427097,51.88303380316361,0 4.470786942121677,51.88280078736423,0 4.470633800117327,51.88256542605102,0 4.470415478638799,51.88226723920287,0 4.470297469559327,51.88211982212884,0 4.470171203507661,51.881973329356,0 4.470077016395521,51.88187364268396,0 4.469874801984403,51.88166850500541,0 4.469679898643292,51.88148888323095,0 4.469458526482228,51.88129921363566,0 4.469238388900408,51.88113191983685,0 4.468736969226982,51.88079763592123,0 4.468020536958122,51.88035647328601,0 4.467078958643128,51.87976998453372,0 4.466024532735588,51.87912602312423,0 4.46451658884871,51.87822047877477,0 4.463322179910264,51.87748425916956,0 4.463033801977872,51.87728028590121,0 4.462894286524005,51.87718415525519,0 4.462755131512125,51.87708318534405,0 4.462710672868412,51.87703899980274,0 4.462701019371806,51.8770079548716,0 4.462702974345319,51.87696855457524,0 4.462708028307674,51.87694212199003,0 4.462708045020321,51.8769106979782,0 4.462706177118463,51.87687810973846,0 4.462698662195265,51.8768292264315,0 4.462683607615929,51.87677801389441,0 4.462659120750089,51.87673843795687,0 4.462653479942361,51.87671050435866,0 4.462649720643427,51.87668955425301,0 4.462655387449146,51.87666860606025,0 4.462674253877694,51.87664184128254,0 4.4627289474451,51.87659995367417,0 4.462800611534277,51.87655108633476,0 4.463207118501728,51.8762836082087,0 4.463482061465442,51.87609921817697,0 4.463787515783338,51.87589106028604,0 4.463997225025395,51.87575604066784,0 4.464238838043258,51.87561539882604,0 4.464475884489289,51.87549163766224,0 4.464699236060682,51.87541570615751,0 4.464921517224583,51.87536170661623,0 4.46535092223624,51.8752821397883,0 4.466139536085649,51.87517322221795,0 4.466908488954289,51.8750902795729,0 4.46802945412506,51.8749986093002,0 4.468474117689283,51.87495911062242,0 4.468703681936674,51.87493552037463,0 4.46885837638655,51.87491900845561,0 4.468988510811755,51.87490668768218,0 4.46907926570141,51.87490508992686,0 4.46912695614988,51.8749066456496,0 4.469182174701558,51.87491440092907,0 4.469222331940244,51.87492525359325,0 4.469247428380385,51.87493765400334,0 4.469270013258765,51.87495470305781,0 4.46929259410048,51.87498414934738,0 4.469327713102544,51.87505078889969,0 4.469362820072277,51.87515462008035,0 4.469506321945418,51.87565533247329,0 4.469719441596396,51.876403841529,0 4.469959875787055,51.87736345694814,0 4.470069372836449,51.87771329136768,0 4.470106986589515,51.87784036739759,0 4.470164665541844,51.87802168357124,0 4.47022338827594,51.87816739928429,0 4.470262243888513,51.87824567074355,0 4.470296034073144,51.87830515751337,0 4.470345032391379,51.87838343007429,0 4.470368691357493,51.87840639110634,0 4.470407564872502,51.87842726679261,0 4.470443060425623,51.87843875005601,0 4.470487008788382,51.87844814717386,0 4.470527576931772,51.87845545677077,0 4.470583359287019,51.87846172455006,0 4.470632381495875,51.87846277374295,0 4.470674924271847,51.87846173506164,0 4.470788356327191,51.8784544431046,0 4.470966549333483,51.8784343903635,0 4.471118995419786,51.87841697186778,0 4.471277084233762,51.87839956242328,0 4.471426703998716,51.87838215187612,0 4.471567854789981,51.87836474025116,0 4.471821924851298,51.87833688428248,0 4.473213911392662,51.87818386362223,0 4.475069974727504,51.87797931238131,0 4.476254315896114,51.87784788767439,0 4.477450265915892,51.87772254051516,0 4.477795460914295,51.87768622383474,0 4.478206758702712,51.877668332177,0 4.478502886164208,51.87766580799334,0 4.478657118005913,51.87767216301815,0 4.478712641112367,51.87767724372332,0 4.478758400532371,51.87769103917,0 4.478796144818759,51.87771328449683,0 4.478835603016222,51.877751418145,0 4.478893932271333,51.87781073694909,0 4.4789333901074,51.87785310738495,0 4.478969415106519,51.87790712902392,0 4.478998576954098,51.87796220955746,0 4.479031167892629,51.8780395337786,0 4.479067186089395,51.87815604920121,0 4.479123934489905,51.87833715135935,0 4.479197097282352,51.87858392164647,0 4.479293465876452,51.87893213056499,0 4.47948123132396,51.87951426837192,0 4.479674493145922,51.88004776605822,0 4.48008502573019,51.88088618949932,0 4.480527173144083,51.88153938220832,0 4.480961449182544,51.88203171796855,0 4.481244878493371,51.88230754625855,0 4.481860174069226,51.88281701936275,0 4.482061331357485,51.88294666980171,0 4.482704696156361,51.88332263788679,0 4.483240334963327,51.88359428569221,0 4.483359748447015,51.88365261245175,0 4.483405752247151,51.88366790259319,0 4.483442909140493,51.88367663977115,0 4.483495990354939,51.88368210039073,0 4.483534916497575,51.88367882375082,0 4.483570303872142,51.88367445495251,0 4.483602152439204,51.88366571751406,0 4.483630462207573,51.88365370360013,0 4.483664080065537,51.88364168965239,0 4.48370300602447,51.88363076782762,0 4.483734854590638,51.88362639900072,0 4.483798551720838,51.88361875348178,0 4.483862249047931,51.88362312170477,0 4.483902944642694,51.88362967438533,0 4.483956025946199,51.88364168776475,0 4.484023262414297,51.88366134613627,0 4.484644270903843,51.88390758470506,0 4.485217444688971,51.88410481375366,0 4.485886343702433,51.88427589599931,0 4.486372528822457,51.88436602718227,0 4.487016626437793,51.88442277479616,0 4.487393109319569,51.88444422784807,0 4.489445174986486,51.8844596445622,0 4.489940188394243,51.88448648961845,0 4.490243580454489,51.8845106512626,0 4.490452808016428,51.88453457545217,0 4.490718422040288,51.88457698336898,0 4.490929042126183,51.88461990240401,0 4.491197374614075,51.88467653615373,0 4.49144354659289,51.88473141221484,0 4.491630645872846,51.88477529438262,0 4.491775096431113,51.88480241124223,0 4.491956823309508,51.88482580795709,0 4.492096877440289,51.88483562750116,0 4.492221490335425,51.88481616196707,0 4.492367673298787,51.88477362990049,0 4.492503582117821,51.88471244994329,0 4.492943042259725,51.88451705803879,0 4.493359156577014,51.88435715864593,0 4.493800553455372,51.88419345734505,0 4.4941963289547,51.88406816174723,0 4.4949844009343,51.88384569021282,0 4.495969816153831,51.88355626604994,0 4.496717103901261,51.88334356860964,0 4.497238833219882,51.88317640483574,0 4.497659825633903,51.88301828032495,0 4.498003132139219,51.88286997756264,0 4.498322706793062,51.88269956187161,0 4.498795931380997,51.88237523447575,0 4.499234050135627,51.88205820461421,0 4.499526860697316,51.88183155380364,0 4.499984872217198,51.88145842843903,0 4.500310024292404,51.88118758470589,0 4.500511273126875,51.88101397454041,0 4.500619685383512,51.88092084316978,0 4.500663743209246,51.88085576040687,0 4.500664794740686,51.88081890369364,0 4.500647251554867,51.88076129520104,0 4.500576461797081,51.88070888472599,0 4.500131332084308,51.88051260474705,0 4.499857699694658,51.88038457163134,0 4.499025655706618,51.88001287469972,0 4.498250619384024,51.87966147633927,0 4.498029398837588,51.87955400535456,0 4.497953237799366,51.87952275802927,0 4.497888126320859,51.87949306187537,0 4.497837169172698,51.87946860585645,0 4.497723931900055,51.87941620052906,0 4.497551106061664,51.87934142674459,0 4.497069426153843,51.87912068548355,0 4.496341994607008,51.87877481831626,0 4.495612084157159,51.8784614252498,0 4.495311936305399,51.87834822300908,0 4.495128637679287,51.87828793825208,0 4.494991443900844,51.87824527897615,0 4.494839534354568,51.87820066906407,0 4.494700592831165,51.87816063420994,0 4.494582324669054,51.8781324820275,0 4.494457777801657,51.87809929517104,0 4.494253975948453,51.87805213719879,0 4.494016208038786,51.87799973999343,0 4.493747303492143,51.8779386083503,0 4.493506703862451,51.87788096800736,0 4.493319886217137,51.87784079562768,0 4.493120463110472,51.87779565003795,0 4.492291116292563,51.87760176621708,0 4.491743740356057,51.87747453529067,0 4.491039406365289,51.87731167401146,0 4.490866747515582,51.87727673935321,0 4.490702581126357,51.87724704585635,0 4.490572380286353,51.87722259189424,0 4.490317639850019,51.87717368316441,0 4.489870433498808,51.87711080664443,0 4.489369451164805,51.87705492026562,0 4.489001781081825,51.87702523581463,0 4.488314379367537,51.87698174612227,0 4.487658573731551,51.87696910040062,0 4.486544594623837,51.87698165293829,0 4.485719928436666,51.87702246684787,0 4.485182161282154,51.87704694148702,0 4.484289588967286,51.87707582582165,0 4.483802767488243,51.87708806211645,0 4.483349911040648,51.87711252712597,0 4.482860766102945,51.87715860788492,0 4.482260726124309,51.87721801601669,0 4.481575776202277,51.87728440857709,0 4.48093340823759,51.87736591910989,0 4.480422014079508,51.87742955964984,0 4.480337469791877,51.87742828481757,0 4.480257049791092,51.8774244640097,0 4.480189002538566,51.87741427842032,0 4.480129203457921,51.8774053659883,0 4.480077004822476,51.87739925612574,0 4.480008957189838,51.87739288942072,0 4.479922351089726,51.8773865222044,0 4.47979862778196,51.8773839729508,0 4.479598608815949,51.87737760242307,0 4.479495506663369,51.87736996143818,0 4.479423335364103,51.87736232129266,0 4.47936774746232,51.87735481398087,0 4.479252300922383,51.87733639201977,0 4.479165932036068,51.87731444751205,0 4.479104087623085,51.87728707701433,0 4.47907444535403,51.87726207773147,0 4.479047411300087,51.87722499880604,0 4.479010634023297,51.87715212323471,0 4.478979710108121,51.87707574202128,0 4.478913740773692,51.87689751944398,0 4.478895186700854,51.87685041771017,0 4.478872510999636,51.87677658274892,0 4.47877657556549,51.87646052911228,0 4.478609515098086,51.87592092835573,0 4.478473472050695,51.87543336299653,0 4.478317006928934,51.87478798473642,0 4.478253270208199,51.87448347658838,0 4.478213001387289,51.87424773163162,0 4.478197665655472,51.8741470642682,0 4.478191915377607,51.87410324441139,0 4.478195754922695,51.87407363670246,0 4.478209185488637,51.87404639799546,0 4.478228370790959,51.8740191595119,0 4.478247555109562,51.87400139553997,0 4.478274412885781,51.87397889460423,0 4.478318534639372,51.87395876294789,0 4.478345391060159,51.87394928945212,0 4.47838567497152,51.87394218508066,0 4.478445141449029,51.87393389708977,0 4.478508444495787,51.87392442489354,0 4.478556401317604,51.87391732074021,0 4.478669579328098,51.87390074434566,0 4.479003439951271,51.87386056768846,0 4.479624956010099,51.87379544854685,0 4.480402315661792,51.87372185106568,0 4.480731641150214,51.8736964553507,0 4.482049473362409,51.87357803916227,0 4.482775600584333,51.87351442263496,0 4.483111290676149,51.87350494768378,0 4.48344698063282,51.87350494623124,0 4.483782418542631,51.87351086541229,0 4.484618455550049,51.87352032983269,0 4.485609483076289,51.87351320430366,0 4.486531092881478,51.87350308667669,0 4.488846647563875,51.87349357355788,0 4.489177038499022,51.87351032177844,0 4.489611525728918,51.8735354458152,0 4.490119557475396,51.87355697222606,0 4.490170934500029,51.87355417016464,0 4.490214755376442,51.87354763674551,0 4.490249509469322,51.87354017093111,0 4.490299372991117,51.87352337461816,0 4.490323548715864,51.87351217764332,0 4.49034772442829,51.87350098066263,0 4.490374921696258,51.87348605166994,0 4.490402119422356,51.87347392152751,0 4.490439894824121,51.87346179068966,0 4.490471627571566,51.87345992271575,0 4.490504871576661,51.87345898758592,0 4.490532071349449,51.87345898579697,0 4.490559271285363,51.87345991695396,0 4.490581937928198,51.87346084840489,0 4.490609138194913,51.87346364545519,0 4.491761468121879,51.87355394990614,0 4.49319818718962,51.87365565187104,0 4.493769727344116,51.87369446996647,0 4.493990398369292,51.87370779820883,0 4.494144597937122,51.87371155961385,0 4.494232239003324,51.87371223114492,0 4.494322551158732,51.87371170011288,0 4.494386583364928,51.87370769206732,0 4.494466385683296,51.87370560835126,0 4.494511869418602,51.87370686784648,0 4.494560692207926,51.87371432455507,0 4.494605306096574,51.87372620933476,0 4.494646118099837,51.87373889706964,0 4.494680937161817,51.87375216158595,0 4.494703636674672,51.87376198252722,0 4.494746856906517,51.87377854837214,0 4.494809534858987,51.87379803150565,0 4.495515095174184,51.87394995772384,0 4.496464531549179,51.87413676285515,0 4.497549877249909,51.87432701880385,0 4.498192142749289,51.87444205958085,0 4.499427341926179,51.87466002921074,0 4.499808117832444,51.8747383136748,0 4.500106295628712,51.87481005893957,0 4.50036875128724,51.87488096279387,0 4.500527747355065,51.87493317768404,0 4.50071543896992,51.87499896796202,0 4.500973917311157,51.8751191902026,0 4.501361445778613,51.87533563897479,0 4.502101950047788,51.87577692879673,0 4.502483028630024,51.87600058172616,0 4.502778859429114,51.87615718243269,0 4.503070957180427,51.87629540437285,0 4.503296318185008,51.87638951254206,0 4.503598405069013,51.8765034811531,0 4.503892753382857,51.87659867887751,0 4.504296795314673,51.87672331701508,0 4.504713707226358,51.87683872199897,0 4.505096394333052,51.87697157638955,0 4.505329693832295,51.87707203185087,0 4.506380936754482,51.87761151113843,0 4.507511510807092,51.87820948965549,0 4.508355538594088,51.87866122041726,0 4.508449633529438,51.87871572099076,0 4.50852161803212,51.87875933346241,0 4.508571390248605,51.87878671580636,0 4.508615385166038,51.87880551244727,0 4.508671067670619,51.87882605724442,0 4.508726218269189,51.87883179963981,0 4.508780654888,51.8788322282769,0 4.508832703621749,51.87882772172001,0 4.508900958437806,51.87881605648305,0 4.508968263663846,51.87879341402763,0 4.50905141321438,51.87876139242985,0 4.509117045758316,51.87873328804054,0 4.509745563484344,51.87845730529926,0 4.510157239751706,51.87825343294627,0 4.510698902124162,51.87793481437154,0 4.510890439587897,51.87782724213566,0 4.511044260982061,51.87776089779771,0 4.511154553577413,51.87772323763353,0 4.511261945098781,51.87768916233999,0 4.511325797625105,51.8776658497969,0 4.511392546681407,51.87763178361355,0 4.512205104417873,51.87716025629781,0 4.512383502789788,51.87706419003467,0 4.512508297401823,51.87701039576446,0 4.512604074309706,51.87697632199879,0 4.512766611546823,51.87692968705346,0 4.512885615291523,51.87690098392219,0 4.512998816412434,51.87687765852578,0 4.513071381589498,51.8768633036645,0 4.513175878301041,51.87684714880849,0 4.513315214138174,51.87683636178536,0 4.513570678474608,51.87683988317181,0 4.513989646637043,51.87685342393299,0 4.51561665853103,51.87692870802119,0 4.516060831427666,51.87695009526057,0 4.516441577222579,51.87696496718034,0 4.517010581181438,51.8769934863153,0 4.51766958227941,51.87702556111852,0 4.519192597061491,51.8770988348868,0 4.520830804077605,51.87717951783151,0 4.521365456581478,51.8772062339821,0 4.522396084194213,51.87728297081528,0 4.522634151157334,51.87730798423047,0 4.522799640495322,51.87732943643125,0 4.522965131710024,51.87735268054202,0 4.523274166280899,51.87741856669356,0 4.523481184988427,51.87746963945796,0 4.5237469194727,51.87755391114911,0 4.523967611227207,51.87762552380726,0 4.527245839900985,51.87877004520233,0 4.528869446660636,51.87933241593679,0 4.530397468281493,51.87988011924091,0 4.532093373609229,51.8804669152065,0 4.533366085753414,51.88091196502904,0 4.534073427174818,51.88115344764205,0 4.534375491665003,51.88126801838224,0 4.534570097308333,51.88134679087637,0 4.534726953375554,51.88141841055232,0 4.534957812509489,51.88153792825161,0 4.535335490995109,51.88176178613979,0 4.535611526940244,51.88195880416887,0 4.535780061314924,51.88208418209977,0 4.536018354798345,51.88227763171403,0 4.536342335752409,51.88253127809981,0 4.536733570925961,51.88284699950789,0 4.536977645002139,51.88301176969885,0 4.537986287310304,51.8835903043972,0 4.539839287295621,51.88464182051009,0 4.540838626049649,51.88520448323703,0 4.541786452999716,51.88573581357272,0 4.542129043350982,51.88593239205707,0 4.542463915446191,51.88610305190984,0 4.542662031896555,51.88620810575396,0 4.542737652461696,51.88624724901502,0 4.542792108762413,51.88628267121468,0 4.542825398300154,51.88631250663959,0 4.542849621912254,51.88634421229005,0 4.542876878076356,51.886383379413,0 4.542889027544163,51.8864281512506,0 4.5428860605643,51.88647106483607,0 4.542823308281726,51.88663713443421,0 4.542729912306712,51.88680770732216,0 4.542479324125893,51.88716816432221,0 4.542457285885021,51.88719851249294,0 4.542433122816263,51.88723206122604,0 4.542412432843392,51.88725976594123,0 4.542395667945698,51.88727995591508,0 4.542368224900471,51.88730791162033,0 4.54234587552979,51.88732235873339,0 4.542313183553574,51.88733425929725,0 4.542288002554031,51.88733914499776,0 4.542260557195647,51.88733937537154,0 4.542239974453707,51.88733760519956,0 4.542194227117534,51.88732978988302,0 4.542151704777353,51.88731506080264,0 4.542106344972751,51.88730202276855,0 4.542060989993871,51.88729271620526,0 4.54198238114313,51.88728156010485,0 4.541825177948924,51.88727044220693,0 4.541637739206493,51.88725374153578,0 4.541519838230229,51.88724633566059,0 4.541341470681985,51.88723149586837,0 4.5409001072847,51.88721118466984,0 4.539701120799919,51.88715633804866,0 4.539031413400195,51.88712700974025,0 4.537577183205201,51.88706013167705,0 4.536364657716135,51.88701652431549,0 4.535232665331307,51.88697037289592,0 4.535141052656357,51.88697311873479,0 4.535074556288478,51.88697874447696,0 4.535038296808409,51.88699182022998,0 4.535026226436614,51.88701048286364,0 4.535029272429313,51.88703100477176,0 4.535044405636313,51.88704779000884,0 4.535086742444193,51.88706269783731,0 4.535135116544211,51.88707014007247,0 4.535186511386144,51.887075715241,0 4.535833441702394,51.88711088449855,0 4.536380610295751,51.88713863094452,0 4.537336422120873,51.88718111835617,0 4.538725348786372,51.88724354732462,0 4.539763410832364,51.88728971205239,0 4.540673812455879,51.88732651732889,0 4.540828497384013,51.88733672726103,0 4.540969928480565,51.88734300995872,0 4.541090428445017,51.88735144140621,0 4.541197799563861,51.88736119563049,0 4.54126728247968,51.88737018754055,0 4.541365014079943,51.88738204442454,0 4.541473480565742,51.88739604551192,0 4.5415753499841,51.88741130664412,0 4.541698483610034,51.88743602219911,0 4.541782324552756,51.88746306635116,0 4.541865614632087,51.88749104280998,0 4.541994877235723,51.88753874259304,0 4.542119078245378,51.88758914631085,0 4.542198889631479,51.8876219425165,0 4.542271718839373,51.88765799489174,0 4.542367130191067,51.88771159363791,0 4.542451309702926,51.88776926707894,0 4.542520777208253,51.88782757346638,0 4.54287540078272,51.88815737859256,0 4.543572225796396,51.88883476479586,0 4.543877692127722,51.88916712792046,0 4.544023062743449,51.88936855510183,0 4.544110935356969,51.88952336737624,0 4.54422679943994,51.88981019950071,0 4.544360215712757,51.89011238238642,0 4.544775790998315,51.89104206501133,0 4.545146456944025,51.89181801337718,0 4.545325155841837,51.89219703618495,0 4.545486974635622,51.89256520099138,0 4.54553317445415,51.89271540808301,0 4.545561961351709,51.89284160578065,0 4.5455840548547,51.89300221870595,0 4.545585607465142,51.89310100324529,0 4.545578110957607,51.89344302705326,0 4.54556616919426,51.89356081702339,0 4.545551465421454,51.89366270339654,0 4.545525447629544,51.89378030348865,0 4.545484845796167,51.89395427402189,0 4.545408766815754,51.89426957211706,0 4.545369744303031,51.8944766898471,0 4.545352057248238,51.8947064943061,0 4.545373735295144,51.89491596577815,0 4.545406218080444,51.89505322786044,0 4.54543917703711,51.89516624221174,0 4.545461544851037,51.89523862969185,0 4.545479863397006,51.89531009588327,0 4.545491400033853,51.89535849455315,0 4.545493716763502,51.89541559463053,0 4.545486852225295,51.89549089930987,0 4.545473084915116,51.8955577539132,0 4.545456171533886,51.89562597018785,0 4.545425320528096,51.89569822489539,0 4.545374275152071,51.89578407508823,0 4.545329841704941,51.89584266225113,0 4.545284093832436,51.89588928013398,0 4.545210739053204,51.89596187472765,0 4.5451564052197,51.89602720373183,0 4.54510810557133,51.89608320086969,0 4.545056797460148,51.8961503939785,0 4.545041712880433,51.89617465638155,0 4.544987403738702,51.89625864268578,0 4.544927052472048,51.89634636357161,0 4.54489692229977,51.89642409069048,0 4.544875863351465,51.89650246275838,0 4.544866905807453,51.89658642581397,0 4.544857940702926,51.89666479161259,0 4.54485196645571,51.89671890121154,0 4.5448423726328,51.89677972249945,0 4.544830927345672,51.89681219911888,0 4.544800734923228,51.89684393219733,0 4.544762114877031,51.89686689453778,0 4.544725200303432,51.89687763721259,0 4.544681763452061,51.89688436177629,0 4.54464483090041,51.89688169967371,0 4.544599202013458,51.89687368008952,0 4.544555740056183,51.89686163795532,0 4.544523144947576,51.89685361169943,0 4.544332896029133,51.89680227361374,0 4.544070576201733,51.89674531772131,0 4.543835898271894,51.89669181696831,0 4.543566471756606,51.89664369512721,0 4.54304367729931,51.89657353769511,0 4.542633589317219,51.89653905056123,0 4.541619639750451,51.89646176680996,0 4.540476451045279,51.89635097488116,0 4.540103829634589,51.8963155520152,0 4.539989966251568,51.89630640543007,0 4.53993710538262,51.89630559392122,0 4.539897804515391,51.8963097943403,0 4.539866641083833,51.89631817286151,0 4.539839545847315,51.89632822223823,0 4.539801628161456,51.89635500443665,0 4.539765682018057,51.89638155796579,0 4.539729867044343,51.89641525796799,0 4.53971226660903,51.89643115756946,0 4.539693307690499,51.89644454864215,0 4.53967434978712,51.89645877609866,0 4.539659451859222,51.89646798332949,0 4.539637778023433,51.89647803011533,0 4.539621798882763,51.89648425024548,0 4.539595780567822,51.89649394110964,0 4.539564673730169,51.89650190913113,0 4.539509123921263,51.89650977159677,0 4.539458323119774,51.89650685659504,0 4.539407517510924,51.8965000233074,0 4.539089774213593,51.89641934254854,0 4.538737255473635,51.89633405561753,0 4.538538066048304,51.89628528723385,0 4.538127040100662,51.89622242711669,0 4.537479862213544,51.89613725464636,0 4.536652182245462,51.89603523659284,0 4.535414573340205,51.89588526352385,0 4.534300091538526,51.89574680352294,0 4.529855407890935,51.89519417767777,0 4.529352186592035,51.895134115595,0 4.529259089508372,51.89512294247616,0 4.529206863617588,51.89511595697284,0 4.52915236735079,51.8951089723015,0 4.529100142872892,51.89510338780544,0 4.529016132975741,51.89509781527967,0 4.528936666622371,51.89509504310178,0 4.528828698384118,51.8950979457323,0 4.528767401983288,51.89510217202313,0 4.528703835205704,51.89510639912603,0 4.528626650231715,51.89511483449152,0 4.528524493726138,51.89512608126173,0 4.528424613074051,51.89514293133598,0 4.527803059594035,51.8952676211208,0 4.527006807919022,51.8954103803943,0 4.526965702286873,51.89541594480342,0 4.526923308206634,51.89541754568117,0 4.526877056259593,51.89541518395264,0 4.526849766284443,51.89541154362686,0 4.526824375538425,51.8954072749472,0 4.526798676053815,51.89540173461377,0 4.526766553762627,51.89539698937461,0 4.526743426703973,51.89539461928575,0 4.526715159310854,51.89539066544321,0 4.526694601685179,51.89538829442238,0 4.526663765624392,51.8953851342808,0 4.526613659640134,51.89538277381332,0 4.526531441815266,51.89538676713802,0 4.52641251852954,51.89540684185386,0 4.521100185192722,51.89659546140899,0 4.518121437044556,51.89727750676466,0 4.517929594499989,51.89733073453698,0 4.517770934511518,51.89738162668183,0 4.517654992212911,51.89742120721512,0 4.517529909228827,51.89748150576694,0 4.51741397801284,51.8975370936084,0 4.517314570115431,51.89758869900103,0 4.517136116377671,51.89770174242872,0 4.517021734115019,51.89779028592762,0 4.516863311017104,51.89791862292023,0 4.516605579449902,51.89813620673807,0 4.516342695406848,51.89836093685519,0 4.516205423723832,51.8984717626897,0 4.51606891645875,51.89856789463601,0 4.515922512429384,51.89866313793162,0 4.515664715013131,51.89879879918903,0 4.515486699224496,51.89887968204373,0 4.515303061465872,51.89895507893,0 4.514894560615403,51.89913339953348,0 4.514609367376195,51.89925995770373,0 4.514469016445489,51.89932214010742,0 4.514249333689264,51.89941635738962,0 4.513346464134699,51.89979843697868,0 4.513072341044733,51.89991645412854,0 4.512829545549437,51.90002092756141,0 4.512678454203524,51.9000940943166,0 4.512285458731711,51.90030578130883,0 4.511949965881087,51.90047850685058,0 4.511505432902084,51.90071223692015,0 4.511204145078281,51.90085111804687,0 4.510201674143104,51.90128612673282,0 4.509160758999997,51.90172678623335,0 4.507456958489797,51.90244985093103,0 4.506650009609331,51.90278061180741,0 4.505928794449545,51.90304370931346,0 4.505384811436414,51.90323595471135,0 4.504539687905677,51.90356407571669,0 4.504266241671019,51.90367806003881,0 4.503715790776539,51.90392414562306,0 4.503217824691376,51.90413919306045,0 4.502353245096984,51.90449486085481,0 4.500877925062142,51.90512210963842,0 4.500080227608976,51.90545603649836,0 4.49825103157211,51.90626554630549,0 4.497951965973898,51.90638458012981,0 4.497468295375441,51.90657445471186,0 4.496150450028594,51.90713258400917,0 4.493244976888221,51.90837602957754,0 4.493166874295326,51.90840765180722,0 4.493104754446435,51.90843074736641,0 4.492981389870693,51.90846649406873,0 4.492880995186027,51.90848501907659,0 4.492778592700191,51.90849768151222,0 4.492685469249267,51.90850427081617,0 4.492603722648084,51.90850168835948,0 4.492513774001438,51.90849560330316,0 4.492430027602836,51.90848186710464,0 4.492340527390468,51.90846553291295,0 4.492262746372475,51.9084437628284,0 4.492181208162762,51.90841375815111,0 4.492081145916274,51.90836735538112,0 4.491947062842385,51.90830187402231,0 4.491876273971727,51.90826454625972,0 4.491765980598118,51.90820750317663,0 4.491422456733659,51.9080268226968,0 4.491063330632613,51.90783424233648,0 4.490974119420429,51.90778181949417,0 4.49093408971342,51.90775707053057,0 4.490885810819961,51.907736598433,0 4.490828427122821,51.90772230041954,0 4.490771302872076,51.90771294729204,0 4.490713720981105,51.90771068609833,0 4.490654757293726,51.90771782269462,0 4.490572960690102,51.907733020427,0 4.490496055168677,51.90775859984394,0 4.490435632317514,51.90778023075852,0 4.490269211499083,51.90784633426212,0 4.490064478573885,51.90792377995555,0 4.489384034214126,51.90817406923718,0 4.488529454982341,51.90850081669145,0 4.487564184099412,51.9088749927264,0 4.486957926580288,51.90910490453734,0 4.48623701701753,51.90939492856876,0 4.485665935925468,51.90962347651308,0 4.484663843538797,51.91003489183266,0 4.483873110249192,51.91034685157968,0 4.483488150556255,51.91050452204379,0 4.4833291619546,51.91058147314803,0 4.483217427468901,51.91064332061394,0 4.483080469602001,51.91073514588382,0 4.482953045597413,51.9108409747903,0 4.482903591727975,51.91090419956699,0 4.482774789913989,51.9110858157743,0 4.482648407302463,51.91138513125073,0 4.482534323097795,51.91166527014703,0 4.482413141851794,51.91200291851079,0 4.48236395436966,51.91212030287593,0 4.482338292849732,51.91216382716237,0 4.482312632493702,51.91219416200293,0 4.482288496637409,51.91222116356763,0 4.482237946879195,51.91228040204295,0 4.482202561161387,51.91233028732092,0 4.482158594506345,51.91238650608597,0 4.482129260560072,51.9124472062954,0 4.482113279210793,51.91250909360346,0 4.482052457973936,51.91288109432187,0 4.482018713519736,51.91322368281091,0 4.482003298346612,51.9136809788651,0 4.48198443824694,51.91419742913291,0 4.481967883493724,51.91466515724325,0 4.481933698180271,51.9156174460291,0 4.481899727055776,51.91633596219421,0 4.481883509802572,51.91644994182059,0 4.481867285753026,51.9165363663729,0 4.481840910263216,51.91663030702663,0 4.481822343750055,51.91668954364306,0 4.48178175347762,51.91678223283716,0 4.481733040164642,51.91687367024773,0 4.481430039689926,51.91730429991388,0 4.481304180991955,51.91748717694069,0 4.481245131166688,51.91757989159557,0 4.481220769699192,51.91760870136605,0 4.481204527180879,51.91762122784035,0 4.481172040693693,51.9176400182486,0 4.48114970470796,51.91764628270866,0 4.481117214495185,51.91764879051855,0 4.481054262190582,51.91764253337956,0 4.481013647023701,51.91763502180091,0 4.480920232660481,51.91761999962159,0 4.480568921524665,51.91756369269732,0 4.48013028166163,51.91748982965452,0 4.47967681961363,51.91741530611668,0 4.478867191206419,51.91726780458535,0 4.478765076721444,51.9172507161849,0 4.478722772605224,51.91724622023317,0 4.478677552410034,51.91724982217282,0 4.478649838581205,51.91726242042732,0 4.478629419189559,51.91727951693671,0 4.478619210178239,51.91729211404976,0 4.478609002387074,51.91731190913439,0 4.478609005454104,51.917329904065,0 4.478611925998862,51.91734789880621,0 4.478623598219784,51.91736139424681,0 4.478639646820895,51.91737578914729,0 4.478667364739621,51.91738658429731,0 4.478718422827399,51.91739917739989,0 4.478823455588866,51.91741896486489,0 4.479380715627215,51.91752959540898,0 4.480146538092015,51.91769401325012,0 4.481857508661889,51.91803136889997,0 4.482653275294894,51.91818025118466,0 4.483516187515377,51.91833787970679,0 4.483899869072815,51.91841881592877,0 4.484029707868615,51.91844579407221,0 4.484133287183838,51.9184673764923,0 4.484301056944105,51.91850334751041,0 4.484406096881443,51.91853032797814,0 4.484499282301954,51.91855362451953,0 4.484709057540698,51.91860953452865,0 4.484902684162449,51.91865959132961,0 4.485532737810275,51.91880305237569,0 4.486098310668538,51.91891786905813,0 4.48739291833698,51.91917265749802,0 4.487919647727722,51.9192772359,0 4.488395341394551,51.91937354824755,0 4.488546627469873,51.9194117482605,0 4.488761730263619,51.91947618348526,0 4.488976204249539,51.91954903044679,0 4.489447875347977,51.91973766184145,0 4.489769631053477,51.919886098748,0 4.490097941853122,51.92006001916226,0 4.490382252552706,51.92020769987519,0 4.490497011598265,51.92026573047998,0 4.490582836696548,51.92031214008097,0 4.490651369629973,51.92035531743822,0 4.490693024908836,51.92039014580797,0 4.490722310239249,51.92042805239058,0 4.490745207215639,51.92047720229801,0 4.490747685476634,51.92051808688461,0 4.490748807971869,51.92057190485967,0 4.49074125367011,51.9206298055664,0 4.490714910495683,51.92068619504791,0 4.490633261498573,51.92079685183545,0 4.490560316164604,51.9208981508263,0 4.49035899687334,51.92121013161161,0 4.490035159948889,51.92170052342723,0 4.489751345974966,51.92221376335183,0 4.488989666478375,51.92361046391304,0 4.488878097149525,51.92381299242118,0 4.488791375584896,51.92398823280619,0 4.488732215188577,51.92412454993932,0 4.488706529515895,51.9242363456899,0 4.488700111003709,51.924350573686,0 4.488714996250423,51.92450475616446,0 4.488747503478294,51.92472827861275,0 4.488848053530248,51.92551238410864,0 4.488860217352922,51.92559732627059,0 4.488882796063393,51.92575449956466,0 4.488888656773696,51.92581568167911,0 4.488897440194535,51.92588856001044,0 4.48891206255756,51.92596863536019,0 4.488931051511898,51.92602261731686,0 4.4889558697203,51.92605950316955,0 4.488979222783598,51.9260810935349,0 4.489011329649486,51.9261017828069,0 4.489046351322301,51.92611437389995,0 4.489081370462614,51.92612066675509,0 4.489141192294241,51.92612515628832,0 4.489224356304902,51.92612424370405,0 4.489363034870422,51.92611878020737,0 4.489541612950589,51.92610874063856,0 4.490559678633929,51.92605601516255,0 4.491413201757496,51.92601802441815,0 4.492914764714584,51.92595776698971,0 4.493617567820294,51.92592965928681,0 4.494037844736951,51.92591270956597,0 4.494565314018217,51.92589449961081,0 4.494725529444224,51.92589705239056,0 4.494881745937278,51.9259139048919,0 4.495164657621629,51.92597745050833,0 4.495450726813857,51.92605329155547,0 4.495761067374602,51.92613126480629,0 4.496008686042089,51.92619884692876,0 4.496052784187711,51.92621687116182,0 4.496102271367263,51.92624711179073,0 4.49614392537319,51.92628100242527,0 4.496166500830753,51.9263082080247,0 4.496178634565567,51.92634405002531,0 4.496205708724929,51.92647262090112,0 4.496223744016263,51.92661629958489,0 4.496254104061919,51.92690912953304,0 4.49630467895966,51.92744469521366,0 4.496324639473755,51.92777567232497,0 4.496339855557267,51.92799098012853,0 4.496341673127049,51.92813957271528,0 4.496350389379273,51.92822509201984,0 4.496399169902105,51.92844289155296,0 4.496519458740906,51.92868420596384,0 4.496607753571823,51.9288312988574,0 4.496642066746901,51.92891727683124,0 4.496694103889922,51.92906601940089,0 4.496772053896947,51.92935411389199,0 4.496830669890215,51.92961431000625,0 4.496859949621737,51.92981164826848,0 4.496893400629759,51.92999423193345,0 4.496930372462728,51.93011169005203,0 4.496977987580479,51.93024951916357,0 4.497025728369252,51.93036664917432,0 4.497064141868691,51.93047720486975,0 4.497116223751078,51.93065978039171,0 4.497408652036725,51.93175494272161,0 4.497433270021233,51.93187218805899,0 4.497475497849081,51.93208233854622,0 4.497551840618399,51.93234440306302,0 4.497674333715595,51.93270976867343,0 4.497792063051378,51.93305135406722,0 4.497875177575821,51.93334056899426,0 4.498020896907221,51.93384177252824,0 4.498206297438856,51.93448218761937,0 4.498383589140644,51.93508395294658,0 4.498503370854948,51.93549259930902,0 4.498648986588307,51.93600652025999,0 4.498689166356783,51.93613137078405,0 4.498729317839988,51.93621048043526,0 4.498781490188009,51.9362735161403,0 4.498865756974908,51.93635632396105,0 4.498956034766195,51.93643171287026,0 4.499028252705145,51.93648485379432,0 4.499136571002595,51.93655034842835,0 4.499263060867705,51.93662203358903,0 4.499547775533088,51.93678760727287,0 4.499954277397919,51.93702164462402,0 4.500170921324667,51.93715510450854,0 4.500366520831847,51.93728755977318,0 4.500655023348315,51.93748867445845,0 4.50080608846821,51.93760948205947,0 4.500917581621195,51.93769537892344,0 4.501050808519381,51.93781502845926,0 4.501366077061491,51.93812305961179,0 4.501396544786573,51.93815071595291,0 4.501420596183536,51.93816948187524,0 4.501468701026525,51.93820997770932,0 4.501529669421714,51.93825031990603,0 4.501563593697199,51.93827121699479,0 4.50160430000804,51.93829211231244,0 4.501647270832208,51.93831858192708,0 4.501677121829289,51.93833540039155,0 4.501725222252759,51.93836898006133,0 4.501781345836989,51.93841737771797,0 4.501899922720682,51.93855219301949,0 4.502130547526164,51.93884740433008,0 4.502326680244181,51.93911561312982,0 4.502623246420839,51.93955286116156,0 4.503071066546653,51.94019563027123,0 4.503436493106889,51.94068586550023,0 4.50361771928678,51.94092426543656,0 4.503844654564419,51.94123495187693,0 4.503999532483689,51.94145002089022,0 4.504215118854361,51.94172223880521,0 4.504414428824276,51.94192004515921,0 4.504582425205214,51.94206205300808,0 4.504915922247237,51.9422862084961,0 4.505099603774482,51.94239335890568,0 4.505336840718485,51.94252881963941,0 4.505701612210501,51.94271425205638,0 4.506631210816181,51.9431362108667,0 4.508330692285256,51.94383405484106,0 4.509116742595141,51.9441028984982,0 4.510471226316312,51.94451286408396,0 4.511372671452634,51.9447773308023,0 4.512679163529754,51.94515716662014,0 4.514202146496629,51.94560674363531,0 4.515321792263137,51.94590310797776,0 4.515857836624804,51.94602415592399,0 4.516269407290253,51.94611555547428,0 4.516583088311037,51.94617582327654,0 4.517850420771566,51.94638935787359,0 4.51853334374951,51.94648609495672,0 4.519085569787393,51.94655669199983,0 4.519472041990866,51.94658846520273,0 4.519905623356451,51.94660560784777,0 4.520299037079042,51.94660049526315,0 4.52081180659664,51.94656439945433,0 4.521293479792931,51.94650851886809,0 4.521753244965353,51.94643853463651,0 4.522210791091851,51.94634925489411,0 4.522996829687813,51.94614538685428,0 4.523624868185209,51.9459582835693,0 4.524036029356225,51.94583598601588,0 4.524421503940332,51.94572360993042,0 4.524830912073867,51.94559793421507,0 4.525195880103325,51.94548142201941,0 4.525668094555982,51.94533747594967,0 4.525960195535518,51.94525909402124,0 4.526319351315294,51.94517625084411,0 4.526685715375137,51.94511259542686,0 4.526940340749462,51.94506417499938,0 4.527144858751157,51.94503334953649,0 4.527196412979166,51.94502166942641,0 4.527239368396593,51.945006814598,0 4.527265136848655,51.94499408714332,0 4.527289183668003,51.94497924130805,0 4.527304631682469,51.94496122077605,0 4.527316643100406,51.94494426147963,0 4.527328638535153,51.9449145870153,0 4.527333744819686,51.94487431985965,0 4.527342348039525,51.94481184149546,0 4.527350791956366,51.94476093472017,0 4.527369507518444,51.94460728386833,0 4.527412222821155,51.94435692816821,0 4.527442173809462,51.94424906509311,0 4.527467875166408,51.94418335760667,0 4.527510713618028,51.94407631763673,0 4.527676519904304,51.9437282815945,0 4.527869908523485,51.94341352691627,0 4.528026014295492,51.94316656500119,0 4.528443509570096,51.9425354480892,0 4.528735278525716,51.94198348626136,0 4.528974973595041,51.94143568924007,0 4.529184019793433,51.94093439628287,0 4.529344753371419,51.94056562137152,0 4.52947499732484,51.94027098870209,0 4.529624774084823,51.9399424670298,0 4.529722423183529,51.93969765143119,0 4.529819281361824,51.93946201792274,0 4.529880935162879,51.93929351108628,0 4.529969794184197,51.93908172929173,0 4.530087584205077,51.93880189795359,0 4.530219531436472,51.93850302511804,0 4.530390764863995,51.93809779653566,0 4.530522943009132,51.93779845674329,0 4.530688112114007,51.93740426430772,0 4.530824350166895,51.93709360521014,0 4.531148432082119,51.9363687042611,0 4.531446823906194,51.9355968320411,0 4.531623092369075,51.93519591175607,0 4.531791852815147,51.93481481779869,0 4.53223488552203,51.93376711123456,0 4.532396529057621,51.93339781865903,0 4.532542889616707,51.93305068655765,0 4.532790516953554,51.93245237976065,0 4.533103586442564,51.93168734336141,0 4.533506983563768,51.93074777189979,0 4.533810128717533,51.93003741149319,0 4.533936141985947,51.92973807073445,0 4.53403883660802,51.92951785614281,0 4.53412822081046,51.92927512067975,0 4.534174612053633,51.9291325637862,0 4.53421111603717,51.92898919482122,0 4.534247585945934,51.92882193454728,0 4.534290139256399,51.92863077952548,0 4.534312252319296,51.92840568398751,0 4.534320464320771,51.92805587781664,0 4.534318254789284,51.92793516389678,0 4.53430996685303,51.9278421171715,0 4.534301687809446,51.92775535768779,0 4.534291383838948,51.9276786588551,0 4.534279062044917,51.92761705045716,0 4.534260638831611,51.92756676234313,0 4.534236126622616,51.92753659666975,0 4.534217749574253,51.92751900220218,0 4.534195296039059,51.92750266735963,0 4.53415518091748,51.92748360916411,0 4.534110297030168,51.92746728635862,0 4.534067461143806,51.92745724968135,0 4.534010344298352,51.92744219082066,0 4.533957311036772,51.92743090209494,0 4.533883879444076,51.92741459441771,0 4.53377373474288,51.92739201896954,0 4.533663597100244,51.9273744731881,0 4.53301124851842,51.92727053513886,0 4.532423846908486,51.92717276153955,0 4.531610859339992,51.92703939910341,0 4.530802343635145,51.92691674192024,0 4.529956699690061,51.92678099134464,0 4.529112735962457,51.92664269698064,0 4.528437939848729,51.9265455217875,0 4.527776141092843,51.92645183334615,0 4.527321307289654,51.92637616662586,0 4.527164106608282,51.92635646163493,0 4.527007133147535,51.92634788614768,0 4.526876770104281,51.92634914753406,0 4.526716040980901,51.92636146971726,0 4.526532740109048,51.92638545001325,0 4.526288279441971,51.92642747069554,0 4.525718318855482,51.92651435842397,0 4.524367192535593,51.92672016363052,0 4.52359635181287,51.92683950487947,0 4.52195594209752,51.92708963494253,0 4.521214710382395,51.9271994686578,0 4.520213338472047,51.92734323575133,0 4.519516903662037,51.92742757593819,0 4.519406488305023,51.92744058023972,0 4.519147184670572,51.92746318363744,0 4.518974758834062,51.92748853684126,0 4.5188592401568,51.92751642758115,0 4.518788839836489,51.92753181776059,0 4.518730062166611,51.92754152988998,0 4.518592796717003,51.92755670431247,0 4.518494397201907,51.92757532670154,0 4.518334679705731,51.92761910560625,0 4.518113208370494,51.9276867429943,0 4.517599332183082,51.92788624262019,0 4.517233334593172,51.92805105015431,0 4.516453477776126,51.92842511564915,0 4.515673286684574,51.92882021479534,0 4.514816573656262,51.92931977079473,0 4.514530383264173,51.92952121972525,0 4.514308695646079,51.92966290025509,0 4.513823901417227,51.92989803349331,0 4.513454203605463,51.93006660937853,0 4.512809838235881,51.93036510560781,0 4.512069090586465,51.93071786890207,0 4.511586147465749,51.93094079179411,0 4.511070772316558,51.93114005738551,0 4.510666528803,51.93127324140522,0 4.50972443194253,51.93158772510778,0 4.508774480579064,51.93190535511777,0 4.508154600319116,51.93212720783505,0 4.507770013298043,51.93227572248094,0 4.507315693851155,51.93244004928192,0 4.506364949476748,51.93274850425957,0 4.505327451559296,51.93307653989684,0 4.503500365083966,51.93369511171732,0 4.503416040006186,51.93372313768099,0 4.503208472563017,51.93379520154124,0 4.503091715326832,51.93383523721097,0 4.503000903237435,51.93386526475376,0 4.502798199819921,51.93393519454995,0 4.502657909189808,51.93398272537864,0 4.502526682959926,51.93403094276322,0 4.502401284610471,51.93408606889688,0 4.502242801873194,51.93416325046169,0 4.502059403072906,51.93428226177909,0 4.500834371234292,51.93527500510791,0 4.500382995731542,51.93564580218727,0 4.500072678607069,51.93591347378791,0 4.499585682465181,51.93629806193018,0 4.499541591756142,51.93633268716449,0 4.499499505306687,51.9363660756727,0 4.499455411294747,51.93639575595837,0 4.499397284405561,51.9364303845655,0 4.499347050843667,51.93645634418367,0 4.499306952900625,51.93646377121871,0 4.499264845135329,51.93646378131749,0 4.499220729126066,51.93645884694639,0 4.499174603334183,51.93644649563573,0 4.499120449292249,51.93642178388374,0 4.49906428553507,51.93638965518424,0 4.49900209874491,51.93634516555008,0 4.498941914098822,51.93629573046731,0 4.498897774393029,51.9362524727187,0 4.498851436948584,51.93619453014293,0 4.498789224602092,51.93610800843145,0 4.498731006628475,51.93599552484706,0 4.498645865457974,51.935708907413,0 4.498509987451797,51.9352124920688,0 4.498296523721507,51.93448093049193,0 4.498150475926579,51.93400535489605,0 4.498029347657622,51.93359836938011,0 4.497902714303606,51.93312746674749,0 4.497619115334501,51.93214907207533,0 4.497507583666931,51.93171973243361,0 4.497429513806324,51.93142699467891,0 4.497293507690074,51.93095369867199,0 4.497174274972309,51.93048982828108,0 4.497106540498436,51.93020981838106,0 4.497066342134502,51.93003551825132,0 4.496998710954742,51.92963387354851,0 4.496938741864327,51.92920087059952,0 4.49691413307626,51.92898491567065,0 4.496865018863261,51.9288470336616,0 4.496800151108276,51.92870274812063,0 4.496730999756792,51.92858178266257,0 4.496659082527671,51.92845570590794,0 4.496595455367469,51.92832962723513,0 4.496555474839397,51.92822165610917,0 4.496505646352517,51.92806319917093,0 4.496477962691557,51.92797289567285,0 4.496461310736052,51.92784510287111,0 4.496402952721297,51.92722077271635,0 4.496371506806128,51.9267931737023,0 4.496362471461495,51.92669644587463,0 4.496353763305223,51.92662482380466,0 4.496345059410544,51.9265606848324,0 4.496333987493686,51.9264693863817,0 4.496323554932246,51.9264137998557,0 4.496309643907651,51.9263379028241,0 4.496294610383046,51.92629324940566,0 4.496273196682864,51.92626094162344,0 4.496252378275486,51.92623208270189,0 4.496210752362444,51.92619360709806,0 4.496172601339296,51.9261690279199,0 4.496132719244869,51.92614872515271,0 4.49608416904664,51.92612735519687,0 4.496047758216023,51.92611453475704,0 4.49600094516653,51.9260995784768,0 4.495963366980504,51.92609220286484,0 4.495905104222473,51.92607824454136,0 4.495837131243874,51.92606229242855,0 4.495691475196054,51.92602839430786,0 4.495510213701436,51.92598452435819,0 4.495232228926938,51.92591222673271,0 4.494996119766128,51.92585806612873,0 4.494814088746566,51.92583244675213,0 4.494644202666876,51.92582606689623,0 4.494429251903966,51.92583145487873,0 4.493768202797114,51.92586793096351,0 4.493219934857066,51.9258916692075,0 4.492633264229042,51.92591945745691,0 4.491980410268383,51.92594706933351,0 4.491216983028181,51.92597448678328,0 4.490344187546072,51.92601110484052,0 4.489470861346661,51.92604603387075,0 4.489329338539207,51.92605145445157,0 4.489241798357782,51.92605416728327,0 4.489186355525987,51.92605417586075,0 4.489146960467664,51.9260505829545,0 4.489116318450485,51.92604428944859,0 4.489095005146154,51.9260361185531,0 4.489078375155017,51.92602270136296,0 4.489068155834502,51.92600740723876,0 4.48906085274794,51.92598761393287,0 4.489053550026867,51.92596872037224,0 4.489046242230529,51.92593723035644,0 4.489015537136851,51.92577438078415,0 4.488944888086564,51.92475805189938,0 4.488926553291904,51.92454141256579,0 4.488940190871049,51.92441761520509,0 4.488958408423429,51.92433883368055,0 4.488999426792489,51.92423472699873,0 4.489145305903364,51.9239589794878,0 4.489281177839558,51.92375145130279,0 4.489454853406301,51.92347818461649,0 4.489650967347131,51.9231415431853,0 4.489947838911846,51.92262074872189,0 4.490291191831901,51.92195931444578,0 4.490486147140359,51.9215994170365,0 4.490665911760317,51.92130430779807,0 4.490841355397365,51.92104037702544,0 4.491100689098317,51.92072036185598,0 4.491135702532105,51.92065292416616,0 4.491152175013411,51.92059455812503,0 4.491158185383001,51.92053106338373,0 4.491141681561032,51.92045868653738,0 4.491105460884583,51.92040281955286,0 4.491077099446244,51.92036267383305,0 4.491031618092151,51.92031971657818,0 4.490973762449684,51.92028255536712,0 4.490912836664847,51.92024923893625,0 4.4908441325545,51.92021499295328,0 4.49070896858764,51.92015373439913,0 4.490599744422198,51.92010717994718,0 4.49049205567654,51.92005870301299,0 4.490165845894609,51.91990944979339,0 4.489708387875425,51.91967919234201,0 4.489210300144109,51.91944606308006,0 4.488841558881475,51.91933593581195,0 4.488528474910311,51.91925545157643,0 4.488148635192246,51.91916870821855,0 4.487468879062079,51.91900562047655,0 4.486957930294452,51.91889033653174,0 4.486364870119729,51.91875818009912,0 4.485173064135552,51.91852589025169,0 4.484924002796845,51.91847369377202,0 4.484784528014529,51.91844145289448,0 4.484617655007767,51.91839692658333,0 4.484503087084363,51.91837082678062,0 4.484338707006074,51.91833244406175,0 4.484109573728702,51.91828638804645,0 4.48324018991454,51.91812281440829,0 4.482497916083972,51.91797080170458,0 4.482134298231983,51.91790017796973,0 4.481972413436509,51.91786639989455,0 4.481852869078665,51.91784644221838,0 4.481775663153357,51.91783262478045,0 4.481713401155815,51.91782495016529,0 4.481623743949939,51.91781420586753,0 4.48154070442358,51.91781012859196,0 4.481475955721678,51.91781781468268,0 4.48141292477348,51.91783771533764,0 4.481358920258003,51.91787619533091,0 4.481305309236788,51.9179465175742,0 4.481259333954,51.9180067690961,0 4.481154538636375,51.91814064252328,0 4.480922012433766,51.91844880343058,0 4.480765152752539,51.91864918285155,0 4.480693740669793,51.91874957421861,0 4.480645616626788,51.91883279766583,0 4.48057716995018,51.91896895580819,0 4.480527851217829,51.91906813611691,0 4.480487745081049,51.91918026032266,0 4.48044826754699,51.91929974167751,0 4.480313090278401,51.91968305933673,0 4.480209244583435,51.91995846683516,0 4.480076192022722,51.92033319605731,0 4.479967271000191,51.92060161391034,0 4.479824541497849,51.92089514814936,0 4.479624785722919,51.92128600384446,0 4.479301567126413,51.92190742220989,0 4.478909031344898,51.92270422075487";
	
	var coords = "5.177652816209303,52.22662760843341,0 5.177452031251747,52.22552694320738,0 5.175602818920567,52.22548962615031,0 5.174159683289716,52.22509279193246,0 5.173681094670116,52.22509679349086,0 5.172049186018256,52.22443930554834,0 5.171592909358438,52.22525098340981,0 5.171078033300574,52.22583365927948,0 5.170310063508566,52.22630407464886,0 5.170690227136376,52.22656810432646,0 5.17082112987822,52.22697437314156,0 5.170890945508731,52.2274127153512,0 5.169285150878892,52.2273645920511,0 5.168447359340433,52.22711333228178,0 5.169101906879718,52.22675518728971,0 5.168918651050831,52.22649859341841,0 5.168883761839197,52.22608697736033,0 5.168115675615383,52.22606128529851,0 5.166029946455893,52.22606656131831,0 5.166047461594474,52.22551596212022,0 5.161654830204896,52.22550199266895,0 5.161139861071263,52.22588683723026,0 5.16116596647754,52.22622361538846,0 5.166009427209204,52.22619184526999,0 5.166044285741023,52.22666226547911,0 5.164962093464155,52.22691880457455,0 5.164098100807962,52.22698824960228,0 5.162727951965508,52.22696677912849,0 5.162300275805094,52.2272073049259,0 5.160877718683651,52.22730341985501,0 5.160628625398091,52.22634547370904,0 5.157879585921293,52.22648953078283,0 5.157451158268444,52.22649426420763,0 5.156718010500768,52.22675076826157,0 5.156438679294568,52.22695386819452,0 5.155740477028076,52.22706069314295,0 5.155874088581953,52.22749258798238,0 5.156092140789994,52.22787215568078,0 5.156004707128133,52.22834790620393,0 5.155995887019117,52.22862053301544,0 5.15647567247639,52.22929414673811,0 5.157170369923577,52.22917529242523,0 5.15806066270838,52.22888138182319,0 5.159055665456151,52.22860351344629,0 5.160382225421259,52.22863036871474,0 5.161066033498329,52.22876636133171,0 5.162076934109663,52.22897390718613,0 5.162574409454223,52.22892048741618,0 5.16498315951651,52.22913980519704,0 5.167968258064349,52.22945665799519,0 5.168594277121088,52.22953290215972,0 5.1687688761874,52.22858138308081,0 5.170409628821489,52.22859209289653,0 5.170758729910716,52.22834619350435,0 5.170819828036827,52.22783300881919,0 5.170915301808208,52.22747563095355,0 5.171072391012871,52.22742752026137,0 5.172826567473138,52.22748630852276,0 5.173572094249295,52.2274380264836,0 5.174313890839231,52.22728298456971,0 5.175457131787638,52.22714930646642,0 5.176452032107207,52.22718668480687,0 5.176758090501053,52.22716340615995,0 5.17699370874179,52.22706182732578,0 5.177255488132659,52.22682660565556,0 5.177569648057371,52.22673036733738,0 5.177742660462513,52.22663930848418,0 5.177665610369601,52.22631691114184,0 5.177548569281868,52.22551763380785,0 5.177508443060972,52.22478779022585,0 5.177606600219761,52.22442108814506";
	
	var arr = Array();

	if (routenike)
	{
	
	}
	else
	{
		coords = coords.split(",0 ");

		for (var i = 0; i<coords.length; i++)
		{
			var point = coords[i].split(",");
			point = new GPoint(point[0], point[1]);
			arr.push (point);
		}

		routenike = new GPolyline(arr,'#C30B0B',3,1);
	}

	map.addOverlay(routenike);
	
	//startnikePoint = new GPoint(4.478666415184705,51.92266460647442);
	//endnikePoint = new GPoint(4.478909031344898,51.92270422075487);

	startnikePoint = new GPoint(5.177652816209303,52.22662760843341);
	endnikePoint = new GPoint(5.177606600219761,52.22442108814506);
	
	startnike = new GMarker(startnikePoint, icons['nike']);
	GEvent.addListener(startnike, "click", function() {
		startnike.openInfoWindowHtml("<div class=\"baloon\"><img src=\"img/upload/nike.jpg\" align=\"right\" />Route van de Nike Hilversum City Run die gehouden is op zondag 1 april 2007.</div>");
	});
	map.addOverlay(startnike);
	
	endnike = new GMarker(endnikePoint, icons['nikefinish']);
	GEvent.addListener(endnike, "click", function() {
		endnike.openInfoWindowHtml("<strong>Finish - Nike City Run</strong><br />");
	});	
	map.addOverlay(endnike);
	
	GEvent.trigger(startnike, 'click');
}

function hideNikeRunRoute ()
{
	map.removeOverlay(endnike);
	map.removeOverlay(startnike);
	map.removeOverlay(routenike);
	map.closeInfoWindow();
}

function toggleNike ()
{
	if($('category_nikecityrun_18').checked)
	{
		if (stateNike != true)
		{
			// show
			viewRoute = true;
			cfg_code_view = 'CVexHn6Q4sgg9SGH5treUJbQ3zJKcw';
			//route = new Route ();
			routeview = new RouteView ();		

			stateNike = true;

			$('li_nikecityrun_18').style.fontWeight = 'bold';
		}
	}
	else
	{

	}
}var geocoder 		= null;
var map 		= null;

var icons 		= Array();

var markerArr		= Array();
var markerActive	= Array();

var hovermarker;

var ajaxCalls = 0;
var ajaxCallsDone = 0;
var ajaxStartLoaded = false;

var directions;

var route;		/* route object */
var routeview;		/* route view object */

function mainLoad() 
{
	if (GBrowserIsCompatible()) 
	{
		new Draggable($('debug'),{tag:'div', zindex: '999999999'});
		
		/* loading */
		initAjaxLoader ();
		
		/* map height */
		resizeMap ();
		
		/* geocoder */
		geocoder = new GClientGeocoder();
		
		/* gMap */
		map = new GMap2($('map'));
		
		map.enableContinuousZoom(); 
		map.enableDoubleClickZoom();
		map.enableScrollWheelZoom();	

		/* set map on default position */
		map.setCenter(new GLatLng(default_lat, default_long), (showNikeRun ? 15 : default_zoomlevel));
		
		/* init windows & functionality */
		initLibraries ();
		
		/* init markers  icons */
		initIcons();
		initMarkers ();		
		initHoverMarker ();	
		
		initNike ();
	}
}

var markersAjaxLoaded = 0;
var markersAjaxLoadedDone = 0;

function ajaxLoadingCheck ()
{
	if ((markersAjaxLoaded == markersAjaxLoadedDone) && (markersAjaxLoaded != 0))
	{
		//alert("DONE");
		setTimeout(function () { $('ajaxLoad').style.display = 'none' }, 1500);
	}
	else
	{
		setTimeout("ajaxLoadingCheck()", 1000);
	}
}

function initAjaxLoader ()
{
	ajaxLoadingCheck();
	
	Ajax.Responders.register({
  		onCreate: function()
  		{
    			// initialized
    			ajaxCalls++;
  		}, 
  		onComplete: function()
  		{
    			if (!ajaxStartLoaded)
    			{
    				ajaxCallsDone++;
    				
    				if (ajaxCalls == ajaxCallsDone)
    				{
    					ajaxStartLoaded = true;
    				}
    			}
  		}
	});
}

function initHoverMarker ()
{
	/* add hover marker */
	hovermarker = new GMarker(offmap, icons['hover']);
	map.addOverlay(hovermarker);
}

function initLibraries ()
{
	initMain ();
	initControls ();
	initMenu ();
	initMaptype ();
	initTabMenu ();	
	initSelectCity ();
	//initRoute ();
	initOverlay ();
	//initViewRoute ();
	
	/* init route library */
	/* init view route */
	if (viewRoute)
	{
		route = new Route ();
		routeview = new RouteView ();
	}
	else
	{
		route = new Route ();
	}
}

function mainResize ()
{
	resizeMenu ();
	resizeMap ();
	if (route) route.routeMenu.resizeRoutePanel ();
	positionOverlay ();
}

function resizeMap ()
{
	$('map').style.height = (document.body.clientHeight - 70)+"px";
}

function iePng (obj)
{
	var image = obj.style.background.substr(4, (obj.style.background.length-5));
			
	if (BrowserDetect.browser == 'Explorer' && BrowserDetect.version == 6)
	{
		if (obj.filters['DXImageTransform.Microsoft.AlphaImageLoader'])
		{
			obj.style.background = 'none';
			obj.style.filter = 'progid:DXImageTransform.Microsoft.AlphaImageLoader(src="../'+image+'")';		
		}
	}
}

function initMain ()
{
	$('logo').onclick = function () 
	{
		window.open('http://staatopdekaart.'+cfgLang, '_top');
	}	
	
	positionOverlay ();
}

/* cookie functions */
function createCookie (name,value,days) 
{
	if (days) 
	{
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/; domain=staatopdekaart."+cfgLang;
}

function readCookie (name) 
{
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) 
	{
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie (name) 
{
	createCookie(name,"",-1);
}

function debug (msg)
{
	$('debug').innerHTML += msg + '<br />';
}

function mainEventListener (object, type, action)
{
	if (object.addEventListener) 
	{
		object.addEventListener(type, action, false);
	}
	else if (object.attachEvent)
	{
		object.attachEvent(type, action);
	}
}

function mainRemoveListener (object, type, action)
{
	if (object.removeEventListener) 
	{
		object.removeEventListener(type, action, false);
	}
	else if (object.detachEvent)
	{
		object.detachEvent(type, action);
	}
}

function getImageWidth(myImage) {
	var x, obj;
	if (document.layers) {
		var img = getImage(myImage);
		return img.width;
	} else {
		return getElementWidth(myImage);
	}
	return -1;
}

function getImageHeight(myImage) {
	var y, obj;
	if (document.layers) {
		var img = getImage(myImage);
		return img.height;
	} else {
		return getElementHeight(myImage);
	}
	return -1;
}

/* add- and stripslashes */
function addslashes(str) 
{
	str = str.replace(/\'/g,'\\\'');
	str = str.replace(/\"/g,'\\"');
	str = str.replace(/\\/g,'\\\\');
	str = str.replace(/\0/g,'\\0');
	
	return str;
}
function stripslashes(str) 
{
	str = str.replace(/\\'/g,'\'');
	str = str.replace(/\\"/g,'"');
	str = str.replace(/\\\\/g,'\\');
	str = str.replace(/\\0/g,'\0');
	
	return str;
}

function nl2br(str) 
{
	if(typeof(str)=="string") return str.replace(/(\r\n)|(\n\r)|\r|\n/g,"<br />");
	else return str;
}