  var geocoder;
  var map;

 function codeAddress(address, isBirth) {
	if (address.length==0) return;
    if (geocoder) {
      geocoder.geocode( { 'address': address +", Sverige"}, function(results, status) {
        if (status == google.maps.GeocoderStatus.OK) {
		
			var image = 'images/markerD.png';
			if (isBirth)
				image =  'images/markerF.png';

			map.setCenter(results[0].geometry.location);
			var marker = new google.maps.Marker({
              map: map, 
			  icon: image,
			  title: isBirth?"Född i " + results[0].formatted_address:"Dog i " + results[0].formatted_address,
              position: results[0].geometry.location
			});
			
		
        } else {
		  splitter = address.split(",");
		  if (splitter.length >0);
		  {
			lastSplit = splitter[splitter.length-1];
			splitter[0] = "";
			address = splitter.join(",");
			codeAddress(address,isBirth);
          }
        }
      });
    }
  }

function fixAddress(address)
{
	address = address.replace(/nr\s[0-9]{1,3}/gi,"");
	return address.replace(/\([A-Z]\)/gi,"");
}
function codeSelectedAddress()
{
codeAddress(fixAddress(document.getElementById("address").value),true);
}
function expandMap()
{
document.getElementById("map_canvas").style.width="500px";
document.getElementById("map_canvas").style.height="500px";
google.maps.event.trigger(map,'resize');
}
