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

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

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

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

    iconKlinik.iconSize = new GSize(37, 35);
    iconKlinik.shadowSize = new GSize(22, 20);
    iconKlinik.iconAnchor = new GPoint(19, 35);
    iconKlinik.infoWindowAnchor = new GPoint(19, 14);
    
    var iconKombo = new GIcon(); 
    iconKombo.image = 'http://rc.atdt.se/hitta/ico_veterinarbutik.png'; //veterinarbutik

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

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

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

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

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

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

    iconKlinikClub.iconSize = new GSize(37, 35);
    iconKlinikClub.shadowSize = new GSize(22, 20);
    iconKlinikClub.iconAnchor = new GPoint(19, 35);
    iconKlinikClub.infoWindowAnchor = new GPoint(19, 14);
	
	var iconWebb = new GIcon(); 
    iconWebb.image = 'http://rc.atdt.se/hitta/ico_butik.png'; // webbutik

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

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

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


    var customIcons = [];
    
    customIcons["butik"] = iconButik;
    customIcons["klinik"] = iconKlinik;

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

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

    customIcons["butik-realklub"] = iconButikClub;   
    customIcons["vet-realklub"] = iconKlinikClub; 
    customIcons["vet-butik-klub"] = iconKomboClub; 
    //customIcons["vet-klubb"] = iconHejsan; 
	
	customIcons["webb"] = iconWebb; 
    customIcons["webb-klubb"] = iconWebbClub; 
	customIcons["kattensdag"] = iconKattdag; 
	
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 + " Sverige";
     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,type);
         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]);

      if(type=="webb" || type=="webb-klubb")
	  	var html = '<strong>' + name + '</strong> <br/>OBS! Enbart webbutik.<br/><br/><br/><br/>'+url;
	  else
   		var html = '<strong>' + name + '</strong><br/>' + address + '<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,type) {
      	var div = document.createElement('div');
		//var html = '<b>' + name + '</b> (' + distance.toFixed(1) + ')<br/>' + address+ '</b> <br/>'+zipcode;
        if(type=="webb" || type=="webb-klubb")
	  		var html = '<b>' + name + '</b><br/>OBS! Enbart webbutik.';
	  	else
	   		var html = '<b>' + name + '</b><br/>' + address+ '</b> <br/>'+zipcode+ ' '+municipality;
       if (phone)
        {
            html = html + '<br/>'+phone;
        }
       
       if (url)
        {
            html = html + '<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;
    }
    //]]>

