// maps 2 module to be loaded 
google.load("maps", "2");



var marker;
var listener;

// adds map control to top left of map 
$(document).ready(function() {
	$("#addresshide").hide();
	var map = new google.maps.Map2(document.getElementById("map"));
	map.addControl(new GSmallMapControl());
	map.addControl(new GMapTypeControl());

// adds overview minimap, can be used for navigation too 
	map.addControl(new GOverviewMapControl());

//  sets center of map using longitude and latitude
    map.setCenter(new google.maps.LatLng(52.976869, -1.309688), 15);

/* adds marker and sets placement for marker using longitude and latitude
the listener enables the marker to be lcicked to call the openinfo function*/       
    marker = new GMarker(new google.maps.LatLng(52.976859, -1.309688));
    listener = GEvent.addListener(marker, "click", openInfo);
   
    
    map.addOverlay(marker);
});

// defines the information to appear when the marker is clicked 
function openInfo() {
	marker.openInfoWindowHtml("Dolci Hair & Beauty<br />1a Manners Road<br />Ilkeston<br />Derbyshire<br />DE73 8AT");
	
	GEvent.removeListener(listener);
	listener = GEvent.addListener(marker, "click", closeInfo);
}
// undoes the click and closes the information box 
function closeInfo() {
	marker.closeInfoWindow();
	
	GEvent.removeListener(listener);
	listener = GEvent.addListener(marker, "click", openInfo);
}

