(function() {
window.onload = function() {
	var infoWindow;
	var mapDiv = document.getElementById('map');
	var latlng = new google.maps.LatLng(51.279528, -2.777138);
	var bounds = new google.maps.LatLngBounds();

	var options = {
		center: latlng,
		zoom: 8,
		mapTypeId: google.maps.MapTypeId.ROADMAP,
		disableDefaultUI: true,
		draggable: false,
		disableDoubleClickZoom: true,
		keyboardShortcuts: false,
		scrollwheel: false,
		noClear: true
	};

	var map = new google.maps.Map(mapDiv, options);
	
	/* now inside your initialise function */
	
	for (var i = 0; i < markers.length; i++) {
		// creating a variable that will hold the current area object
		var area = markers[i];
		
		// Creating marker
		var marker = new google.maps.Marker({
			position: new google.maps.LatLng(area.lat, area.lng),
			map: map,
			title: area.title,
			html: area.html
		});
		
		bounds.extend(marker.getPosition());
		
	var infowindow = new google.maps.InfoWindow({
	});
		
		
		google.maps.event.addListener(marker, 'click', function () {
			// where I have added .html to the marker object.
			infowindow.setContent(this.html);
			infowindow.open(map, this);
		});
		
	}
	map.fitBounds(bounds);
};

})();

/* (function() {
  window.onload = function() {

   // Creating a map
    var options = {
      zoom: 8,
      center: new google.maps.LatLng(51.279528, -2.777138),
      mapTypeId: google.maps.MapTypeId.ROADMAP,
	draggable: false
    };
    var map = new google.maps.Map(document.getElementById('location_map'), options);
    
	var latlng = new google.maps.LatLng(51.384852, -2.360344);
	var circlebath = new CircleOverlay(map, latlng, 9, "#000000", 1, 1, '#009900', 0.25, 40);

	var latlng = new google.maps.LatLng(51.452723, -2.5914);
	var circlebristol = new CircleOverlay(map, latlng, 9, "#000000", 1, 1, '#009900', 0.25, 40);

	var latlng = new google.maps.LatLng(51.471333, -3.167152);
	var circlecardiff = new CircleOverlay(map, latlng, 9, "#000000", 1, 1, '#009900', 0.25, 40);

	var latlng = new google.maps.LatLng(51.279528, -2.777138);
	var circlecheddar = new CircleOverlay(map, latlng, 7, "#000000", 1, 1, '#009900', 0.25, 40);

	var latlng = new google.maps.LatLng(51.010299, -3.109818);
	var circletaunton = new CircleOverlay(map, latlng, 9, "#000000", 1, 1, '#009900', 0.25, 40);

	var latlng = new google.maps.LatLng(51.211185, -2.645645);
	var circlewells = new CircleOverlay(map, latlng, 5, "#000000", 1, 1, '#009900', 0.25, 40);
	
//	var latlng = new google.maps.LatLng(51.344339, -1.790771);
//	var circlewiltshire = new CircleOverlay(map, latlng, 9, "#000000", 1, 1, '#009900', 0.25, 40);
  };

})();

// Circle overlay extension for Google Maps
// App Delegate Inc <http://appdelegateinc.com> 2010

// This file adds a new CircleOverlay to GMaps2 to draw a circle on a map with stroke and fill
// If you include the library at http://appdelegateinc.com/blog/2010/05/16/point-in-polygon-checking/ you can also check to see if a point resides within the circle.

// Constructor
var CircleOverlay = function(map, latLng, radius, strokeColor, strokeWidth, strokeOpacity, fillColor, fillOpacity, numPoints) {
	this.map = map;
	this.setMap(map);
	this.latLng = latLng;
	this.radius = radius;
	this.strokeColor = strokeColor;
	this.strokeWidth = strokeWidth;
	this.strokeOpacity = strokeOpacity;
	this.fillColor = fillColor;
	this.fillOpacity = fillOpacity;

	// Set resolution of polygon
	if (typeof(numPoints) == 'undefined') {
		this.numPoints = 45;
	} else {
		this.numPoints = numPoints;
	}
}

// Inherit from GOverlay
CircleOverlay.prototype = new google.maps.OverlayView();

// Reset overlay
CircleOverlay.prototype.clear = function() {
	if(this.polygon != null && this.map != null) {
		this.polygon.setMap(null);
	}
}

// Calculate all the points of the circle and draw them
CircleOverlay.prototype.draw = function(force) {
	var d2r = Math.PI / 180;
	circleLatLngs = new Array();

	// Convert statute miles into degrees latitude
	var circleLat = this.radius * 0.014483;
	var circleLng = circleLat / Math.cos(this.latLng.lat() * d2r);

	// Create polygon points (extra point to close polygon)
	for (var i = 0; i < this.numPoints + 1; i++) { 
		// Convert degrees to radians
		var theta = Math.PI * (i / (this.numPoints / 2)); 
		var vertexLat = this.latLng.lat() + (circleLat * Math.sin(theta)); 
		var vertexLng = this.latLng.lng() + (circleLng * Math.cos(theta));
		var vertextLatLng = new google.maps.LatLng(vertexLat, vertexLng);
		circleLatLngs.push(vertextLatLng); 
	}

	this.clear();
	this.polygon = new google.maps.Polygon({
		paths: circleLatLngs, 
		strokeColor: this.strokeColor, 
		strokeWeight: this.strokeWidth, 
		strokeOpacity: this.strokeOpacity, 
		fillColor: this.fillColor, 
		fillOpacity: this.fillOpacity
	});
	this.polygon.setMap(this.map);
}

// Remove circle method
CircleOverlay.prototype.remove = function() {
	this.clear();
}

// Can use this method if the library at is included at http://appdelegateinc.com/blog/2010/05/16/point-in-polygon-checking/
CircleOverlay.prototype.containsLatLng = function(latLng) {
	if(this.polygon.containsLatLng) {
		return this.polygon.containsLatLng(latLng);
	}
}

// Set radius of circle
CircleOverlay.prototype.setRadius = function(radius) {
	this.radius = radius;
}

// Set center of circle
CircleOverlay.prototype.setLatLng = function(latLng) {
	this.latLng = latLng;
} */
