function initialize() {
	address = $('#map').attr('data-address');
	markertext = $('#map').attr('data-markertext');
	var geocoder = new google.maps.Geocoder();
	geocoder.geocode(
		{'address':address},
		function(results,status){
			if(status == google.maps.GeocoderStatus.OK){ 
				var latitude = results[0].geometry.location.lat();
				var longitude = results[0].geometry.location.lng();
				mapit(latitude,longitude);
			}
		}
	);
}

function mapit(a,b) {
	var mapOptions = {
		zoom: 14,
		center: new google.maps.LatLng(a, b)
	};
	map = new google.maps.Map(document.getElementById('map'),mapOptions);
	var marker = new google.maps.Marker({
		position: new google.maps.LatLng(a, b),
		map: map,
		title: markertext
	});
	
	var center;
	function calculateCenter() { center = map.getCenter(); }
	google.maps.event.addDomListener(map, 'idle', function() {calculateCenter();});
	google.maps.event.addDomListener(window, 'resize', function() {map.setCenter(center);});
}

google.maps.event.addDomListener(window, 'load', initialize);