function initialize() {
//var directionDisplay;
//var directionsService = new google.maps.DirectionsService();

var gmarkers = []; 

// MIDDELPUNT VAN DE KAART
var center = new google.maps.LatLng(52.13348804077147, 5.44921875);

directionsDisplay = new google.maps.DirectionsRenderer();

var settings = {
	zoom: 6,
	center: center,
	mapTypeControl: false,
	mapTypeControlOptions: {style: google.maps.MapTypeControlStyle.DROPDOWN_MENU},
	navigationControl: false,
	navigationControlOptions: {style: google.maps.NavigationControlStyle.MEDIUM},
	mapTypeId: google.maps.MapTypeId.ROADMAP,
	disableDefaultUI: true,
	disableDoubleClickZoom: true,
	draggable: true,
	minZoom: 6,
	maxZoom: 6
};
var map = new google.maps.Map(document.getElementById("maps"), settings);

//directionsDisplay.setMap(map);
//directionsDisplay.setPanel(document.getElementById("directions"));
	
var image = new google.maps.MarkerImage(
	'/wp-content/themes/xelvin/img/gm-marker-small.png',
	new google.maps.Size(12,12),
	new google.maps.Point(0,0),
	new google.maps.Point(6,12)
);
	
	/*
var shadow = new google.maps.MarkerImage(
	'/wp-content/themes/xelvin/img/gm-marker-shadow.png',
	new google.maps.Size(34,20),
	new google.maps.Point(0,0),
	new google.maps.Point(10,20)
);
	*/
var shape = {
	coord: [6,0,7,1,8,2,9,3,10,4,11,5,11,6,10,7,9,8,8,9,7,10,6,11,5,11,4,10,3,9,2,8,1,7,0,6,0,5,0,4,1,3,3,2,3,1,4,0,6,0],
	type: 'poly'
};

var infowindow = null;

var infowindow = new google.maps.InfoWindow({
	maxWidth: 220,
	content: ""
});

var imageBounds = new google.maps.LatLngBounds(
    new google.maps.LatLng(45.376676,-5.937424),
    new google.maps.LatLng(58.836334,16.484299)
);

var vectormap = new google.maps.GroundOverlay(
    "http://www.xelvin.nl/wp-content/themes/xelvin/img/nederland-2.jpg",
    imageBounds
);
vectormap.setMap(map);

for (var i=0; i<locations.length; i++) {  
	var marker = locations[i];
	marker = new google.maps.Marker({
    	position: new google.maps.LatLng(locations[i][8], locations[i][9]),
        draggable: true,
        raiseOnDrag: false,
        icon: image,
        //shadow: shadow,
        shape: shape,
        map: map,
        //url: '/vestigingen-xelvin/' + locations[i][1],
        html: '<div class="content">'+
        	'<div id="siteNotice">'+
        	'</div>'+
        	'<strong><a href="/vestigingen-xelvin/' + locations[i][1] + '">' + locations[i][0] + '</a></strong><br />'+
        	locations[i][2] + '<br />'+
        	locations[i][3] + ', ' + locations[i][4] +'<br />'+
        	'T: ' + locations[i][5] +'<br />'+
        	'F: ' + locations[i][6] +'<br />'+
        	'<a href="mailto:' + locations[i][7] + '">' + locations[i][7] + '</a>'+
            '</div>'
    });

	/*
    google.maps.event.addListener(marker, 'mouseover', (function() {
    	infowindow.setContent(this.html);
        infowindow.open(map, this);
    }));
	*/
	google.maps.event.addListener(marker, 'click', (function() {
		//window.location.href = this.url;
		infowindow.setContent(this.html);
		infowindow.open(map, this);
	}));    
	
    google.maps.event.addListener(infowindow, 'closeclick', (function() {
    	map.setCenter(center);
    })); 
    
    gmarkers.push(marker);
    
    google.maps.event.addListener(map, "tilesloaded", removeStaticMap);
}


google.maps.event.addListener(map, 'tilesloaded', function(){
	jQuery('#mapcontainer-side #maps div div a div img').css('margin', '0 0 10em 18em');
}); 
}

function removeStaticMap() {
  setTimeout(pushStaticMap,2000);
  
  function pushStaticMap() {
    var image = document.getElementById("staticmap");
    image.style.zIndex = 0;
  }
}

function myclick(i) {
  google.maps.event.trigger(gmarkers[i], "click");
}


function calcRoute(end) {
	var start = document.getElementById("start").value;
	var request = {
		origin:start,
		destination:end,
		travelMode: google.maps.DirectionsTravelMode.DRIVING
	};
				
	directionsService.route(request, function(response, status) {
		if (status == google.maps.DirectionsStatus.OK) {
			directionsDisplay.setDirections(response);
		}
	});
}
