
    var map = null;
    var geocoder = null;
    var mapCenter = new GLatLng(53.38332836757156, 22.236328125);
    var defaultZoom = 4;

        // Let's roll!
	function initialize() 
	{
            if (GBrowserIsCompatible()) {
                    map = new GMap2(document.getElementById('countryArchiveMap'));
                    
                    map.setUIToDefault();
                    map.enableContinuousZoom();
                    map.enableDoubleClickZoom();
                    geocoder = new GClientGeocoder();
                                    
                                    
                    map.setCenter(mapCenter, defaultZoom);
                    
            } // end is compatible
            else alert("Selaimesi ei tue karttoja.");
            
            
            
            setupCountryLabels();
            
	} // end initialize
        
        
        
    function showAddress(address) {
      if (geocoder) {
        geocoder.getLatLng(
          address,
          function(point) {
            if (!point) {
              alert(address + "? Ei tuollaista taida ollakaan...");
            } else {
              map.setCenter(point, 6);
              var marker = new GMarker(point);
              map.addOverlay(marker);
              marker.openInfoWindowHtml(address);
            }
          }
        );
      }
    }
    
	// Load markers and add them to the map		
	function setupCountryLabels() {
                        
                var layer = countryArr[0];
                
                for (var j in layer["countries"]) {
                        var country = layer["countries"][j];
                        
                        doCountryLabel(country["name"],country["count"]);
                        
                } // end for
	}
    
    
    function doCountryLabel(name,count) {
      if (geocoder) {
        geocoder.getLatLng(
          name,
          function(point) {
            if (point) {
              var label = new ELabel(point, '<span class="countryLabel"><a href="http://www.ihminen.org/aihe/maa/'+name.toLowerCase()+'/" title="Aihe: '+name+'">'+name+'</a></span>', "countryLabelStyle"); //&nbsp;<span class="Count" title="Kirjoituksia maasta '+name+'">'+count+'</span>
                map.addOverlay(label);
            }
          }
        );
      }
    }