var officeMap = new Object();

//officeMap.apiKey = 'ABQIAAAAF-8FI9pV89EsIWypB45cKBRKEi_XjIS54fMy8DE2CeNzOhRZGxScv-kjtouxQvPqQBaQIhYwTsy8Pg';
officeMap.apiKey = 'ABQIAAAAF-8FI9pV89EsIWypB45cKBSFFGwlh3d-4C8e_QooWNM9Q0pdaRTlKax9W-Gc7l0TmlEvcI-60glMrQ';

officeMap.lat = 51.66574141105715;
officeMap.lng = -0.6161355972290039;
officeMap.zoom = 15;

officeMap.onApiLoad = function(){
	$('div.image_detail div.right').after('<div id="officeMapDiv"></div>').remove();
	$('#officeMapDiv').css({'float':'right', 'width':'345px', 'height':'200px'}).html('Loading Google Maps');
	officeMap.gmap = new GMap2(document.getElementById('officeMapDiv'));
	
	officeMap.gmap.addControl(new GSmallMapControl());

	
	//$('#officeMapDiv').after('<a href="javascript:officeMap.whereAmI();">Get Position</a>');
	
	officeMap.center = new google.maps.LatLng(officeMap.lat, officeMap.lng);
	
	officeMap.gmap.setCenter(officeMap.center, officeMap.zoom);
	
	officeMap.marker = new GMarker(officeMap.center);
	officeMap.gmap.addOverlay(officeMap.marker);
}

officeMap.whereAmI = function(){
	var latlng = officeMap.gmap.getCenter();
	var zoom = officeMap.gmap.getZoom();
	
	var lat = latlng.lat();
	var lng = latlng.lng();
	
	officeMap.marker = new GMarker(latlng);
	officeMap.gmap.addOverlay(officeMap.marker);
	
	if(typeof(console) == 'object'){
		console.log('LAT: '+lat+', LNG: '+lng+', ZOOM: '+zoom);
	}
	else{
		alert('LAT: '+lat+', LNG: '+lng+', ZOOM: '+zoom);
	}
}

$(document).ready(function(){
			   
	// Google maps API
		var script = document.createElement("script");
		script.setAttribute("src", "http://maps.google.com/maps?file=api&v=2.x&key="+officeMap.apiKey+"&c&async=2&callback=officeMap.onApiLoad");
		script.setAttribute("type", "text/javascript");
		document.documentElement.firstChild.appendChild(script);

});