//<![CDATA
    
var iconBlue = new GIcon(); 
    iconBlue.image = '/ikoner/mm_20_blue.png';
    iconBlue.shadow = '/ikoner/mm_20_shadow.png';
    iconBlue.iconSize = new GSize(12, 20);
    iconBlue.shadowSize = new GSize(22, 20);
    iconBlue.iconAnchor = new GPoint(6, 20);
    iconBlue.infoWindowAnchor = new GPoint(5, 1);

var iconRed = new GIcon(); 
    iconRed.image = '/ikoner/mm_20_red.png';
    iconRed.shadow = '/ikoner/mm_20_shadow.png';
    iconRed.iconSize = new GSize(12, 20);
    iconRed.shadowSize = new GSize(22, 20);
    iconRed.iconAnchor = new GPoint(6, 20);
    iconRed.infoWindowAnchor = new GPoint(5, 1);
    
var iconBlack = new GIcon(); 
    iconBlack.image = '/ikoner/mm_20_black.png';
    iconBlack.shadow = '/ikoner/mm_20_shadow.png';
    iconBlack.iconSize = new GSize(12, 20);
    iconBlack.shadowSize = new GSize(22, 20);
    iconBlack.iconAnchor = new GPoint(6, 20);
    iconBlack.infoWindowAnchor = new GPoint(5, 1);
    
var iconWhite = new GIcon(); 
    iconWhite.image = '/ikoner/mm_20_white.png';
    iconWhite.shadow = '/ikoner/mm_20_shadow.png';
    iconWhite.iconSize = new GSize(12, 20);
    iconWhite.shadowSize = new GSize(22, 20);
    iconWhite.iconAnchor = new GPoint(6, 20);
    iconWhite.infoWindowAnchor = new GPoint(5, 1);
    
var iconYellow = new GIcon(); 
    iconYellow.image = '/ikoner/mm_20_yellow.png';
    iconYellow.shadow = '/ikoner/mm_20_shadow.png';
    iconYellow.iconSize = new GSize(12, 20);
    iconYellow.shadowSize = new GSize(22, 20);
    iconYellow.iconAnchor = new GPoint(6, 20);
    iconYellow.infoWindowAnchor = new GPoint(5, 1);
    
var iconPol = new GIcon(); 
    iconPol.image = '/ikoner/pol.gif';
    iconPol.shadow = '/ikoner/mm_20_shadow.png';
    iconPol.iconSize = new GSize(15, 15);
    iconPol.shadowSize = new GSize(22, 20);
    iconPol.iconAnchor = new GPoint(6, 20);
    iconPol.infoWindowAnchor = new GPoint(5, 1);
    
var iconGun = new GIcon(); 
    iconGun.image = '/ikoner/gun.png';
    iconGun.shadow = '/ikoner/mm_20_shadow.png';
    iconGun.iconSize = new GSize(25, 25);
    iconGun.shadowSize = new GSize(15, 15);
    iconGun.iconAnchor = new GPoint(6, 20);
    iconGun.infoWindowAnchor = new GPoint(5, 1);

    var customIcons = [];
    customIcons["pol"] = iconPol;
    customIcons["gun"] = iconGun;
    var markerGroups = { "gun": [], "vold": [], "indbrud": [], "tyveri": [], "roveri": [], "andet": [], "pol": []};

	function load() {
      if (GBrowserIsCompatible()) {
        var map = new GMap2(document.getElementById("map"));
        map.addControl(new GLargeMapControl());
        map.addControl(new GMapTypeControl());
        map.setCenter(new GLatLng(55.67567, 12.59079), 12);
        map.enableDoubleClickZoom();
        map.addControl(new GOverviewMapControl(new GSize(220,80)));
        

        GDownloadUrl("phpsqlajax_genxml.php", function(data) {
          var xml = GXml.parse(data);
          var markers = xml.documentElement.getElementsByTagName("marker");
          
          for (var i = 0; i < markers.length; i++) {
            var name = markers[i].getAttribute("name");
            var tid = markers[i].getAttribute("tid");
            var address = markers[i].getAttribute("address");
            var link = markers[i].getAttribute("link");
            var linknavn = markers[i].getAttribute("linknavn");
            var art = markers[i].getAttribute("art");
            var pollink = markers[i].getAttribute("pollink");
            var point = new GLatLng(parseFloat(markers[i].getAttribute("lat")),
                                    parseFloat(markers[i].getAttribute("lng")));
                                    
                                    
            var marker = createMarker(point, name, tid, address, art, link, linknavn, pollink);
            map.addOverlay(marker);
          }
        });
        
    //Politikredsens graense    
    var polyline = new GPolyline([
    new GLatLng(55.635748, 12.506561),
	new GLatLng(55.641707, 12.500381),
	new GLatLng(55.652265, 12.485962),
	new GLatLng(55.655461, 12.480640),
	new GLatLng(55.658560, 12.477551),
	new GLatLng(55.661465, 12.477808),
	new GLatLng(55.666500, 12.479010),
	new GLatLng(55.672551, 12.481413),
	new GLatLng(55.677246, 12.486391),
	new GLatLng(55.677633, 12.485361),
	new GLatLng(55.676278, 12.480898),
	new GLatLng(55.681456, 12.473946),
	new GLatLng(55.680730, 12.469740),
	new GLatLng(55.691133, 12.466393),
	new GLatLng(55.691762, 12.467251),
	new GLatLng(55.696406, 12.463732),
	new GLatLng(55.702500, 12.463989),
	new GLatLng(55.706514, 12.454548),
	new GLatLng(55.716983, 12.465534),
	new GLatLng(55.719110, 12.475619),
	new GLatLng(55.714686, 12.488708),
	new GLatLng(55.720053, 12.506304),
	new GLatLng(55.719956, 12.512827),
	new GLatLng(55.722421, 12.515144),
	new GLatLng(55.723146, 12.546644),
	new GLatLng(55.726965, 12.551107),
	new GLatLng(55.727787, 12.562008),
	new GLatLng(55.726482, 12.575483),
	new GLatLng(55.723582, 12.577629),
	new GLatLng(55.722808, 12.583637),
	new GLatLng(55.722663, 12.583981)],
	"#000000", 2);
map.addOverlay(polyline);
        
        
        
        
      }
    }

	function createMarker(point, name, tid, address, art, link, linknavn, pollink) {
      var marker = new GMarker(point, customIcons[art]);
      markerGroups[art].push(marker);
      var html = "<div class='iwstyle'><span class='iwstyle2'><span class='over'><a href='" +pollink + "'target='_blank' >"+ name + "</a></span><br /><br /><span class='mellem'>" +tid+ "</span><br /><span class='under'>" + address +"</span><br /><br /><span class='link'><a href='" +link+  "'target='_blank' >" +linknavn+"</a></span></span></div>";
      
      
      
      GEvent.addListener(marker, 'click', function() {
        marker.openInfoWindowHtml(html);
      });
      return marker;
    }
    
   
    function toggleGroup(art) {
      for (var i = 0; i < markerGroups[art].length; i++) {
        var marker = markerGroups[art][i];
        if (marker.isHidden()) {
          marker.show();
        } else {
          marker.hide();
        }
      } 
    }
   
    //]]>
