    //<![CDATA[
    var map;
    var geocoder;

   var iconBlue = new GIcon(); 
    iconBlue.image = 'http://rc.atdt.se/hitta/ico_butik.png'; //veterinarbutik

    iconBlue.iconSize = new GSize(37, 35);
    iconBlue.shadowSize = new GSize(22, 20);
    iconBlue.iconAnchor = new GPoint(19, 35);
    iconBlue.infoWindowAnchor = new GPoint(19, 14);

    var iconRed = new GIcon(); 
    iconRed.image = 'http://rc.atdt.se/hitta/ico_veterinar_club.png'; //veterinar

    iconRed.iconSize = new GSize(37, 35);
    iconRed.shadowSize = new GSize(22, 20);
    iconRed.iconAnchor = new GPoint(19, 35);
    iconRed.infoWindowAnchor = new GPoint(19, 14);
    
    var iconTja = new GIcon(); 
    iconTja.image = 'http://rc.atdt.se/hitta/ico_butik_club.png'; //butik

    iconTja.iconSize = new GSize(37, 35);
    iconTja.shadowSize = new GSize(22, 20);
    iconTja.iconAnchor = new GPoint(19, 35);
    iconTja.infoWindowAnchor = new GPoint(19, 14);

    var iconHej = new GIcon(); 
    iconHej.image = 'http://rc.atdt.se/hitta/ico_butik_club.png'; //butik_club

    iconHej.iconSize = new GSize(37, 35);
    iconHej.shadowSize = new GSize(22, 20);
    iconHej.iconAnchor = new GPoint(19, 35);
    iconHej.infoWindowAnchor = new GPoint(19, 14);

    var iconHejsan = new GIcon(); 
    iconHejsan.image = 'http://rc.atdt.se/hitta/ico_veterinarbutik_club.png'; // veterinarbutik_club

    iconHejsan.iconSize = new GSize(37, 35);
    iconHejsan.shadowSize = new GSize(22, 20);
    iconHejsan.iconAnchor = new GPoint(19, 35);
    iconHejsan.infoWindowAnchor = new GPoint(19, 14);

     var iconLatsas = new GIcon(); 
    iconLatsas.image = 'http://rc.atdt.se/hitta/ico_veterinar_club.png'; // veterinar_club

    iconHejsan.iconSize = new GSize(37, 35);
    iconLatsas.shadowSize = new GSize(22, 20);
    iconLatsas.iconAnchor = new GPoint(19, 35);
    iconLatsas.infoWindowAnchor = new GPoint(19, 14);


    var customIcons = [];
    
    customIcons["butik"] = iconBlue;
    customIcons["klinik"] = iconRed;

	//customIcons["vet-butik"] = iconTja; 
    customIcons["butik-vet-real"] = iconTja; 

	//customIcons["butik-klubb"] = iconHej; 

    customIcons["butik-realklub"] = iconHej;   
    
    customIcons["vet-butik-klub"] = iconHejsan; 
    customIcons["vet-klubb"] = iconHejsan; 

google.load("search", "1");

   
        var lat = google.loader.ClientLocation.latitude;
        var lng = google.loader.ClientLocation.longitude;

    
    function load() {
      if (GBrowserIsCompatible()) {
        geocoder = new GClientGeocoder();
        map = new GMap2(document.getElementById('map'));    

		//map.setCenter(new GLatLng(59.332788,  18.0644881), 4); 

    	map.setCenter(new GLatLng(64, 15), 4); /* center on Sweden */
        // Create our "tiny" marker icon
        var blueIcon = new GIcon(G_DEFAULT_ICON);
        blueIcon.image = "http://gmaps-samples.googlecode.com/svn/trunk/markers/blue/blank.png";
		
		// Set up our GMarkerOptions object
		markerOptions = { icon:blueIcon };

        map.addControl(new GSmallMapControl());
        map.addControl(new GMapTypeControl());
        
 		//searchLocationsNear(new GLatLng(57.69698, 11.986383));
      }
    }

   function searchLocations() {
     var address = document.getElementById('addressInput').value;
     geocoder.getLatLng(address, function(latlng) {
       if (!latlng) {
         alert(address + ' hittades inte');
       } else {
         searchLocationsNear(latlng);
       }
     });
   }

   function searchLocationsNear(center) {
     var radius = document.getElementById('radiusSelect').value;
     var searchUrl = '/hitta-ny/phpsqlsearch_genxml_new.php?lat=' + center.lat() + '&lng=' + center.lng() + '&radius=' + radius;
     GDownloadUrl(searchUrl, function(data) {
       var xml = GXml.parse(data);
       var markers = xml.documentElement.getElementsByTagName('marker');
       map.clearOverlays();
	   
		var showHide = document.getElementById('showHideLocations');
	   showHide.style.display = "block";
	   
       var sidebar = document.getElementById('sidebar');
	   sidebar.style.display = "none";
       sidebar.innerHTML = '';
       if (markers.length == 0) {
         sidebar.innerHTML = 'Det finns tyva&uml;rr inga butiker h&auml;r.';
         map.setCenter(new GLatLng(59.332788,  18.0644881), 4); 
	   	 showHide.style.display = "none";
         return;
       }
	   
	   showHide.onclick = function(){
			if( sidebar.style.display == "block"){
				sidebar.style.display = "none";
				showHide.innerHTML = 'Visa butiklista <img src="http://royalcanin.se/hitta-ny/downArrow.gif" alt=""/>';
				}
		   	else{
				sidebar.style.display = "block";
				showHide.innerHTML = 'D&ouml;lj butiklista <img src="http://royalcanin.se/hitta-ny/upArrow.gif" alt=""/>';
				}
		   return false;
		}

       var bounds = new GLatLngBounds();
       for (var i = 0; i < markers.length; i++) {
         var name = markers[i].getAttribute('name');
         var address = markers[i].getAttribute('address');
         var zipcode = markers[i].getAttribute('zipcode');
         var municipality = markers[i].getAttribute('municipality');
         var phone = markers[i].getAttribute('phone');

         var url = markers[i].getAttribute('url');

         var distance = parseFloat(markers[i].getAttribute('distance'));
         var point = new GLatLng(parseFloat(markers[i].getAttribute('lat')),
                                 parseFloat(markers[i].getAttribute('lng')));
        var type = markers[i].getAttribute("type");
         var marker = createMarker(point, name, address,type,zipcode,municipality,phone,url);
         map.addOverlay(marker);
         var sidebarEntry = createSidebarEntry(marker, name, address, distance,zipcode,municipality,phone,url);
         sidebar.appendChild(sidebarEntry);
         bounds.extend(point);
       }
       map.setCenter(bounds.getCenter(), map.getBoundsZoomLevel(bounds));
     });
   }

    function createMarker(point, name, address,type,zipcode,municipality,phone,url) {
      var marker = new GMarker(point, customIcons[type]);

      
      var html = '<b>' + name + '</b> <br/>' + address + '</b> <br/>'+zipcode + ' '+municipality+ '</b> <br/>'+phone + '</b> <br/>'+url;
      GEvent.addListener(marker, 'click', function() {
        marker.openInfoWindowHtml(html);
      });
      return marker;
      

    }

    function createSidebarEntry(marker, name, address, distance,zipcode,municipality,phone,url) {
      	var div = document.createElement('div');
		//var html = '<b>' + name + '</b> (' + distance.toFixed(1) + ')<br/>' + address+ '</b> <br/>'+zipcode;
       var html = '<b>' + name + '</b><br/>' + address+ '</b> <br/>'+zipcode+ ' '+municipality;
       if (phone)
        {
            html = html + '</b> <br/>'+phone;
        }
       
       if (url)
        {
            html = html + '</b> <br/>'+url;
        }
       
       // '</b> <br/>'+url;

      
      // municipality
      
      div.innerHTML = html;
      div.style.cursor = 'pointer';
      div.style.marginBottom = '5px'; 
      GEvent.addDomListener(div, 'click', function() {
        GEvent.trigger(marker, 'click');
      });
      GEvent.addDomListener(div, 'mouseover', function() {
        div.style.backgroundColor = '#eee';
      });
      GEvent.addDomListener(div, 'mouseout', function() {
        div.style.backgroundColor = '#fff';
      });
      return div;
    }
    //]]>
