			var popupid = null;

			function is_array(input){
				return typeof(input)=='object'&&(input instanceof Array);
			}

			function load() {
				if(GBrowserIsCompatible()) {
					var map = new GMap2(document.getElementById("map"));
					map.addControl(new GMapTypeControl());
					map.addControl(new google.maps.LocalSearch());
					map.setCenter(new GLatLng(52.09126, 5.12275), 7);
					map.enableScrollWheelZoom();
					var mgr = new MarkerManager(map);

					GDownloadUrl("data.xml.php?random="+(Math.round(Math.random()*1000000)), function(data, responseCode) {
						var xml = GXml.parse(data);

						var mrkrs = xml.documentElement.getElementsByTagName("marker");
	
						var icon = new GIcon();
						icon.image = "http://www.wietinkaart.nl/weed.gif";
						icon.iconSize = new GSize(30, 30);
						icon.iconAnchor = new GPoint(12, 34);
						icon.infoWindowAnchor = new GPoint(15, 25);

						var count = new Array();

						allmarkers = new Array();

						var citynum = -1;

						var previouscity = null;

						for(var i = 0; i < mrkrs.length; i++) {
							var city = mrkrs[i].getAttribute("city");

							if(previouscity != city) {
								citynum++;
								previouscity = city;
							}

							if(!is_array(allmarkers[citynum])) {
								allmarkers[citynum] = new Array();
							}

							var address = mrkrs[i].getAttribute("street")+ ', '+ city;
							var html = mrkrs[i].getAttribute("html");
							var lat = mrkrs[i].getAttribute("lat");
							var long = mrkrs[i].getAttribute("long");
							marker = getMarker(lat,long,address,html,icon);
							allmarkers[citynum].push(marker);
						}

						percent = new Array();
						percent[11] = 1;
						percent[9] = 0.4;
						percent[3] = 0.001;

						var x;
						var y;
						var markers = new Array();

						for(x in percent) {
							markers[x] = new Array();
							for(y = 0; y < allmarkers.length; y++) {
								var max = Math.ceil(allmarkers[y].length * percent[x]);
								for(var i = 0; i < max; i++) {
									if(i == max) {
										break;
									}
									markers[x].push(allmarkers[y][i]);
								}
							}
						}

						var i;
						for(i in markers) {
							mgr.addMarkers(markers[i], i);
						}
						mgr.refresh();
					});
				}
			}

			function getMarker(lat,long,address,html,icon) {
				point = new GLatLng(lat, long)
			 	var marker = createMarker(point,'<span style="font-weight: bold;">'+html+"</span><br/>"+address,icon);
				return marker;
			}

			function createMarker(point,html,icon){
				var marker = new GMarker(point,icon);
				GEvent.addListener(marker, "click", function() {
					marker.openInfoWindowHtml(html);
				});
				return marker;
			}

			function createPopup(type) {
				if(!popupid) {
					var el = document.createElement('div');
					var id = 'popupdiv';
					el.id = id;
					popupid = id;
					el.style.left='80px';
					el.style.width='520px';
					el.style.zIndex='1';
					el.style.border='1px dotted black';
					el.style.backgroundColor='#eeeeee';
					el.style.padding='5px';
					el.innerHTML='<div style="text-align: right;"><a href="javascript: void(null);" onclick="removePopup(\''+ id +'\');">Sluit venster</a></div><br /><div id="popupContent"></div>';
                    var body  = document.getElementsByTagName("body").item(0);
					body.appendChild(el);
				} else {
					el = document.getElementById('popupContent').parentNode;
					id = popupid;
				}

				if(type == "feedback") {
					el.style.height='320px';
				} else if(type == "taf") {
					el.style.height='480px';
				}

				if(type == "feedback") {
					setPopupContent('<span style="font-weight: bold; color: red;" id="feedbackError"></span><form method="post" name="feedbackform" onsubmit="postFeedbackForm(\''+ id +'\'); return false;"><table><tr><td style="margin-right: 20px;">Bericht:</td><td style="margin-right: 20px;"><textarea style="width: 280px; height: 120px;" name="feedback" id="feedback"></textarea></td><td style="width: 100px; margin-right: 20px; vertical-align: top;" rowspan="2">Bedankt dat je ons wilt helpen door een suggestie in te dienen. Nadat we je suggestie even gecheckt hebben zullen we de aanpassingen doorvoeren in ons systeem.<br /><br /><span style="font-weight: bold;">In verband met de veiligheid moet je de code op het plaatje overtypen.</span></td></tr><tr><td style="vertical-align: top;"><div style="margin-top: 30px;" id="image">&nbsp;</div></td><td style="vertical-align: top;"><div style="margin-top: 30px;" id="field"><input type="text" disabled="disabled" style="width: 1px;" /></div><br /><input type="submit" value="(wachten...)" name="submitButton" id="submitButton" /></td></tr></table></form>');
				} else if (type == "taf") {
					setPopupContent('<div style="font-weight: bold; color: red; height: 60px; overflow: auto;" id="tafError">&nbsp;</div><form method="post" name="tellafriendform" onsubmit="postTafForm(\''+ id +'\'); return false;"><table><tr><td style="margin-right: 20px;">Jouw naam:</td><td><input type="text" name="myname" id="myname" /></td><td style="width: 100px; margin-right: 20px; vertical-align: top;" rowspan="9">Je kunt hier aan maximaal vijf vrienden tegelijk een e-mail over wietinkaart sturen, je moet ten minste &eacute;&eacute;n e-mailadres invullen. Als je een persoonlijk bericht toevoegt, wordt dit bericht toegevoegd aan de standaardtekst van de e-mail.<br /><br /><br /><br /><br /><span style="font-weight: bold;">In verband met de veiligheid moet je de code op het plaatje overtypen.</span></td></tr><tr><td colspan="2">&nbsp;</td></tr><tr><td>Vriend &eacute;&eacute;n:</td><td><input type="text" name="friend1_name" id="friend1_name" style="color: #aaa; font-style: italic;" onfocus="if(this.value == \'Naam\') { this.value = \'\'; this.style.color = \'#000\'; this.style.fontStyle = \'\'; }" onblur="if(this.value == \'\') { this.value = \'Naam\'; this.style.color = \'#aaa\'; this.style.fontStyle = \'italic\'; }" value="Naam" /> <input type="text" name="friend1_email" id="friend1_email" style="color: #aaa; font-style: italic;" onfocus="if(this.value == \'E-mailadres\') { this.value = \'\'; this.style.color = \'#000\'; this.style.fontStyle = \'\'; }" onblur="if(this.value == \'\') { this.value = \'E-mailadres\'; this.style.color = \'#aaa\'; this.style.fontStyle = \'italic\'; }" value="E-mailadres" /></td></tr><tr><td>Vriend twee:</td><td><input type="text" name="friend2_name" id="friend2_name" style="color: #aaa; font-style: italic;" onfocus="if(this.value == \'Naam\') { this.value = \'\'; this.style.color = \'#000\'; this.style.fontStyle = \'\'; }" onblur="if(this.value == \'\') { this.value = \'Naam\'; this.style.color = \'#aaa\'; this.style.fontStyle = \'italic\'; }" value="Naam" /> <input type="text" name="friend2_email" id="friend2_email" style="color: #aaa; font-style: italic;" onfocus="if(this.value == \'E-mailadres\') { this.value = \'\'; this.style.color = \'#000\'; this.style.fontStyle = \'\'; }" onblur="if(this.value == \'\') { this.value = \'E-mailadres\'; this.style.color = \'#aaa\'; this.style.fontStyle = \'italic\'; }" value="E-mailadres" /></td></tr><tr><td>Vriend drie:</td><td><input type="text" name="friend3_name" id="friend3_name" style="color: #aaa; font-style: italic;" onfocus="if(this.value == \'Naam\') { this.value = \'\'; this.style.color = \'#000\'; this.style.fontStyle = \'\'; }" onblur="if(this.value == \'\') { this.value = \'Naam\'; this.style.color = \'#aaa\'; this.style.fontStyle = \'italic\'; }" value="Naam" /> <input type="text" name="friend3_email" id="friend3_email" style="color: #aaa; font-style: italic;" onfocus="if(this.value == \'E-mailadres\') { this.value = \'\'; this.style.color = \'#000\'; this.style.fontStyle = \'\'; }" onblur="if(this.value == \'\') { this.value = \'E-mailadres\'; this.style.color = \'#aaa\'; this.style.fontStyle = \'italic\'; }" value="E-mailadres" /></td></tr><tr><td>Vriend vier:</td><td><input type="text" name="friend4_name" id="friend4_name" style="color: #aaa; font-style: italic;" onfocus="if(this.value == \'Naam\') { this.value = \'\'; this.style.color = \'#000\'; this.style.fontStyle = \'\'; }" onblur="if(this.value == \'\') { this.value = \'Naam\'; this.style.color = \'#aaa\'; this.style.fontStyle = \'italic\'; }" value="Naam" /> <input type="text" name="friend4_email" id="friend4_email" style="color: #aaa; font-style: italic;" onfocus="if(this.value == \'E-mailadres\') { this.value = \'\'; this.style.color = \'#000\'; this.style.fontStyle = \'\'; }" onblur="if(this.value == \'\') { this.value = \'E-mailadres\'; this.style.color = \'#aaa\'; this.style.fontStyle = \'italic\'; }" value="E-mailadres" /></td></tr><tr><td>Vriend vijf:</td><td><input type="text" name="friend5_name" id="friend5_name" style="color: #aaa; font-style: italic;" onfocus="if(this.value == \'Naam\') { this.value = \'\'; this.style.color = \'#000\'; this.style.fontStyle = \'\'; }" onblur="if(this.value == \'\') { this.value = \'Naam\'; this.style.color = \'#aaa\'; this.style.fontStyle = \'italic\'; }" value="Naam" /> <input type="text" name="friend5_email" id="friend5_email" style="color: #aaa; font-style: italic;" onfocus="if(this.value == \'E-mailadres\') { this.value = \'\'; this.style.color = \'#000\'; this.style.fontStyle = \'\'; }" onblur="if(this.value == \'\') { this.value = \'E-mailadres\'; this.style.color = \'#aaa\'; this.style.fontStyle = \'italic\'; }" value="E-mailadres" /></td></tr><tr><td>Persoonlijk bericht:</td><td style="margin-right: 20px;"><textarea style="width: 280px; height: 120px;" name="msg" id="msg"></textarea></td></tr><tr><td><span id="image">&nbsp;</span></td><td style="vertical-align: top;"><div id="field"><input type="text" disabled="disabled" style="width: 1px;" /></div><br /><input type="submit" value="(wachten...)" name="submitButton" id="submitButton" /></td></tr></table></form>');
				}
				getCaptcha();
			}

			function getCaptcha() {
				document.getElementById('submitButton').disabled='disabled';
				var xmlHttp = getXmlHttpObject();
				xmlHttp.open('GET', 'captcha/getimage.php?rnd='+ Math.round(Math.random()*1000000));
				xmlHttp.onreadystatechange = function() {
					if(xmlHttp.readyState == 4) {
						document.getElementById('image').innerHTML = xmlHttp.responseText;
						captcha_getField();
					}
				}
				xmlHttp.send('');
			}

			function captcha_getField() {
				var xmlHttp = getXmlHttpObject();
				xmlHttp.open('GET', 'captcha/getfield.php?rnd='+ Math.round(Math.random()*1000000));
				xmlHttp.onreadystatechange = function() {
					if(xmlHttp.readyState == 4) {
						document.getElementById('field').innerHTML = xmlHttp.responseText;
						document.getElementById('submitButton').value='Verzenden';
						document.getElementById('submitButton').disabled='';
					}
				}
				xmlHttp.send('');
			}

			function removePopup(id) {
                var body  = document.getElementsByTagName("body").item(0);
				body.removeChild(document.getElementById(id));
				popupid = null;
			}

			function setPopupContent(content) {
				document.getElementById('popupContent').innerHTML=content;
			}

			function postFeedbackForm(id) {
				if(document.getElementById('submitButton').disabled == 'disabled') {
					return false;
				}

				document.getElementById('feedbackError').innerHTML='';
				document.getElementById('submitButton').disabled='disabled';
				var xmlHttp = getXmlHttpObject();

				if(!xmlHttp) {
					setPopupContent('<div style="font-size: 11pt; font-weight: bold;">Foutmelding</div>Uw browser of browserinstellingen voldoen niet aan de technische eisen van wietinkaart.nl. Een goede suggestie is <a href="http://www.getfirefox.com/" target="_blank">Mozilla Firefox</a>');
					return;
				}

				xmlHttp.open('POST', 'postfeedback.php');
				xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
				xmlHttp.onreadystatechange = function() {
					if(xmlHttp.readyState == 4) {
						if(xmlHttp.responseText == 'OK') {
							setPopupContent('<div style="font-size: 11pt; font-weight: bold;">Bedankt.</div>Onze beheerders zullen uw feedback zo snel mogelijk behandelen.');
						} else if(xmlHttp.responseText == 'CAPTCHA') {
							document.getElementById('feedbackError').innerHTML='De code die je invulde kwam niet overeen met de code op het plaatje.';
							document.getElementById('captchafield').value='';
							document.getElementById('submitButton').disabled='';
							getCaptcha();
						} else if(xmlHttp.responseText == 'TEXT') {
							document.getElementById('feedbackError').innerHTML='Vul een geldig bericht in.';
							document.getElementById('captchafield').value='';
							document.getElementById('submitButton').disabled='';
							getCaptcha();
						} else {
							setPopupContent('<div style="font-size: 11pt; font-weight: bold;">Foutmelding</div>Er is een onbekende fout opgetreden. Probeer het later opnieuw.');
						}
					}
				}
				var query = document.getElementById('captchafield').name +'='+ urlencode(document.getElementById('captchafield').value) +'&feedback='+ urlencode(nl2br(htmlentities(trim(document.getElementById('feedback').value))));
				xmlHttp.send(query);
			}

			function postTafForm(id) {
				if(document.getElementById('submitButton').disabled == 'disabled') {
					return false;
				}

				document.getElementById('tafError').innerHTML='';
				document.getElementById('submitButton').disabled='disabled';
				var xmlHttp = getXmlHttpObject();

				if(!xmlHttp) {
					setPopupContent('<div style="font-size: 11pt; font-weight: bold;">Foutmelding</div>Uw browser of browserinstellingen voldoen niet aan de technische eisen van wietinkaart.nl. Een goede suggestie is <a href="http://www.getfirefox.com/" target="_blank">Mozilla Firefox</a>');
					return;
				}

				xmlHttp.open('POST', 'sendmail.php');
				xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
				xmlHttp.onreadystatechange = function() {
					if(xmlHttp.readyState == 4) {
						if(xmlHttp.responseText == 'OK') {
							setPopupContent('<div style="font-size: 11pt; font-weight: bold;">De e-mail is aan je vrienden verstuurd.</div>Wil je nog meer vrienden over deze site informeren? <a href="javascript: void(null);" onclick="createPopup(\'taf\');">Vul het formulier dan nogmaals in</a>.');
						} else if(xmlHttp.responseText.substr(0,5) == 'ERROR') {
							document.getElementById('tafError').innerHTML=xmlHttp.responseText.substr(6);
							document.getElementById('captchafield').value='';
							document.getElementById('submitButton').disabled='';
							getCaptcha();
						} else {
							setPopupContent('<div style="font-size: 11pt; font-weight: bold;">Foutmelding</div>Er is een onbekende fout opgetreden. Probeer het later opnieuw.');
						}
					}
				}
				var query = document.getElementById('captchafield').name +'='+ urlencode(document.getElementById('captchafield').value) +'&name='+ urlencode(trim(document.getElementById('myname').value)) +'&message='+ urlencode(nl2br(htmlentities(trim(document.getElementById('msg').value)))) +'&friend1_name='+ urlencode(trim(document.getElementById('friend1_name').value)) +'&friend1_email='+ urlencode(trim(document.getElementById('friend1_email').value)) +'&friend2_name='+ urlencode(trim(document.getElementById('friend2_name').value)) +'&friend2_email='+ urlencode(trim(document.getElementById('friend2_email').value)) +'&friend3_name='+ urlencode(trim(document.getElementById('friend3_name').value)) +'&friend3_email='+ urlencode(trim(document.getElementById('friend3_email').value)) +'&friend4_name='+ urlencode(trim(document.getElementById('friend4_name').value)) +'&friend4_email='+ urlencode(trim(document.getElementById('friend4_email').value)) +'&friend5_name='+ urlencode(trim(document.getElementById('friend5_name').value)) +'&friend5_email='+ urlencode(trim(document.getElementById('friend5_email').value));
				xmlHttp.send(query);
			}

			function getXmlHttpObject() {
				var xmlHttp = null;

				try { // Firefox, Opera 8.0+, Safari
					xmlHttp = new XMLHttpRequest();
				} catch(e) { // Internet Explorer
					try {
						xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
					} catch(e) {
						xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
					}
				}
				return xmlHttp;
			}

			function get_html_translation_table(table, quote_style) {
				var entities = {}, histogram = {}, decimal = 0, symbol = '';
				var constMappingTable = {}, constMappingQuoteStyle = {};
				var useTable = {}, useQuoteStyle = {};
	 		 
				useTable = (table?table.toUpperCase():'HTML_SPECIALCHARS');
				useQuoteStyle = (quote_style?quote_style.toUpperCase():'ENT_COMPAT');
	 		 
				// Translate arguments
				constMappingTable[0] = 'HTML_SPECIALCHARS';
				constMappingTable[1] = 'HTML_ENTITIES';
				constMappingQuoteStyle[0] = 'ENT_NOQUOTES';
				constMappingQuoteStyle[2] = 'ENT_COMPAT';
				constMappingQuoteStyle[3] = 'ENT_QUOTES';
		
				// Map numbers to strings for compatibilty with PHP constants
				if(!isNaN(useTable)) {
					useTable = constMappingTable[useTable];
				}
				if(!isNaN(useQuoteStyle)) {
					useQuoteStyle = constMappingQuoteStyle[useQuoteStyle];
				}
		
				if(useTable == 'HTML_SPECIALCHARS') {
					// ascii decimals for better compatibility
					entities['60'] = '&lt;';
					entities['62'] = '&gt;';
					entities['38'] = '&amp;';
				} else if (useTable == 'HTML_ENTITIES') {
					// ascii decimals for better compatibility
					entities['38'] = '&amp;';
					entities['60'] = '&lt;';
					entities['62'] = '&gt;';
					entities['160'] = '&nbsp;';
					entities['161'] = '&iexcl;';
					entities['162'] = '&cent;';
					entities['163'] = '&pound;';
					entities['164'] = '&curren;';
					entities['165'] = '&yen;';
					entities['166'] = '&brvbar;';
					entities['167'] = '&sect;';
					entities['168'] = '&uml;';
					entities['169'] = '&copy;';
					entities['170'] = '&ordf;';
					entities['171'] = '&laquo;';
					entities['172'] = '&not;';
					entities['173'] = '&shy;';
					entities['174'] = '&reg;';
					entities['175'] = '&macr;';
					entities['176'] = '&deg;';
					entities['177'] = '&plusmn;';
					entities['178'] = '&sup2;';
					entities['179'] = '&sup3;';
					entities['180'] = '&acute;';
					entities['181'] = '&micro;';
					entities['182'] = '&para;';
					entities['183'] = '&middot;';
					entities['184'] = '&cedil;';
					entities['185'] = '&sup1;';
					entities['186'] = '&ordm;';
					entities['187'] = '&raquo;';
					entities['188'] = '&frac14;';
					entities['189'] = '&frac12;';
					entities['190'] = '&frac34;';
					entities['191'] = '&iquest;';
					entities['192'] = '&Agrave;';
					entities['193'] = '&Aacute;';
					entities['194'] = '&Acirc;';
					entities['195'] = '&Atilde;';
					entities['196'] = '&Auml;';
					entities['197'] = '&Aring;';
					entities['198'] = '&AElig;';
					entities['199'] = '&Ccedil;';
					entities['200'] = '&Egrave;';
					entities['201'] = '&Eacute;';
					entities['202'] = '&Ecirc;';
					entities['203'] = '&Euml;';
					entities['204'] = '&Igrave;';
					entities['205'] = '&Iacute;';
					entities['206'] = '&Icirc;';
					entities['207'] = '&Iuml;';
					entities['208'] = '&ETH;';
					entities['209'] = '&Ntilde;';
					entities['210'] = '&Ograve;';
					entities['211'] = '&Oacute;';
					entities['212'] = '&Ocirc;';
					entities['213'] = '&Otilde;';
					entities['214'] = '&Ouml;';
					entities['215'] = '&times;';
					entities['216'] = '&Oslash;';
					entities['217'] = '&Ugrave;';
					entities['218'] = '&Uacute;';
					entities['219'] = '&Ucirc;';
					entities['220'] = '&Uuml;';
					entities['221'] = '&Yacute;';
					entities['222'] = '&THORN;';
					entities['223'] = '&szlig;';
					entities['224'] = '&agrave;';
					entities['225'] = '&aacute;';
					entities['226'] = '&acirc;';
					entities['227'] = '&atilde;';
					entities['228'] = '&auml;';
					entities['229'] = '&aring;';
					entities['230'] = '&aelig;';
					entities['231'] = '&ccedil;';
					entities['232'] = '&egrave;';
					entities['233'] = '&eacute;';
					entities['234'] = '&ecirc;';
					entities['235'] = '&euml;';
					entities['236'] = '&igrave;';
					entities['237'] = '&iacute;';
					entities['238'] = '&icirc;';
					entities['239'] = '&iuml;';
					entities['240'] = '&eth;';
					entities['241'] = '&ntilde;';
					entities['242'] = '&ograve;';
					entities['243'] = '&oacute;';
					entities['244'] = '&ocirc;';
					entities['245'] = '&otilde;';
					entities['246'] = '&ouml;';
					entities['247'] = '&divide;';
					entities['248'] = '&oslash;';
					entities['249'] = '&ugrave;';
					entities['250'] = '&uacute;';
					entities['251'] = '&ucirc;';
					entities['252'] = '&uuml;';
					entities['253'] = '&yacute;';
					entities['254'] = '&thorn;';
					entities['255'] = '&yuml;';
				} else {
					throw Error("Table: "+ useTable +' not supported');
					return false;
				}
		
				if(useQuoteStyle != 'ENT_NOQUOTES') {
					entities['34'] = '&quot;';
				}
		
				if(useQuoteStyle == 'ENT_QUOTES') {
					entities['39'] = '&#039;';
				}
		
				// ascii decimals to real symbols
				for(decimal in entities) {
					symbol = String.fromCharCode(decimal)
					histogram[symbol] = entities[decimal];
				}

				return histogram;
			}

			function htmlentities(string) {
				var histogram = {}, symbol = '', tmp_str = '', i = 0;
				tmp_str = string.toString();
		
				if((histogram = get_html_translation_table('HTML_ENTITIES', 'ENT_QUOTES')) === false) {
					return false;
				}
		
				for(symbol in histogram) {
					entity = histogram[symbol];
					tmp_str = tmp_str.split(symbol).join(entity);
				}
		
				return tmp_str;
			}

			function urlencode(str) {
				str = escape(str);
				str = str.replace('+', '%2B');
				str = str.replace('%20', '+');
				str = str.replace('*', '%2A');
				str = str.replace('/', '%2F');
				str = str.replace('@', '%40');
				return str;
			}

			function nl2br(str) {
				return str.replace(/\n/g, "<br />");
			}

			function trim(value) {
				value = value.replace(/^\s+/,'');
				value = value.replace(/\s+$/,'');
				return value;
			}
