google.load("maps", "2");
google.setOnLoadCallback(initializeAllLocations);

function initializeAllLocations() {

	var map = new google.maps.Map2(document.getElementById("allmap"));
	map.setCenter(new google.maps.LatLng(54.826008,-3.427734), 6);
	map.setUIToDefault();

	var flexiIcon = new GIcon();
	flexiIcon.image = 'http://www.flexistore.co.uk/uploads/images/markers/image.png';
	flexiIcon.printImage = 'http://www.flexistore.co.uk/uploads/images/markers/printImage.gif';
	flexiIcon.mozPrintImage = 'http://www.flexistore.co.uk/uploads/images/markers/mozPrintImage.gif';
	flexiIcon.iconSize = new GSize(32,45);
	flexiIcon.shadow = 'http://www.flexistore.co.uk/uploads/images/markers/shadow.png';
	flexiIcon.transparent = 'http://www.flexistore.co.uk/uploads/images/markers/transparent.png';
	flexiIcon.shadowSize = new GSize(55,45);
	flexiIcon.printShadow = 'http://www.flexistore.co.uk/uploads/images/markers/printShadow.gif';
	flexiIcon.iconAnchor = new GPoint(16,45);
	flexiIcon.infoWindowAnchor = new GPoint(16,0);
	flexiIcon.imageMap = [0,0,32,0,32,45,0,45];

	var locations	= new Array();
	var marker		= new Array();

	locations[0] = {'location' : 'aberdeen',	'long' : 57.118094,			'lat' : -2.072425}
	locations[1] = {'location' : 'blackpool',	'long' : 53.909344,			'lat' : -2.776215}
	locations[2] = {'location' : 'edinburgh',	'long' : 55.972405,			'lat' : -3.378575}
	locations[3] = {'location' : 'kent',		'long' : 51.291365,			'lat' : 0.473356}
	locations[4] = {'location' : 'glasgow',		'long' : 55.890247,			'lat' : -4.286535}
	locations[5] = {'location' : 'londonnorth', 'long' : 51.609489,			'lat' : -0.036049}
	locations[6] = {'location' : 'londonsouth', 'long' : 51.5529591,		'lat' : -0.253790}
	locations[7] = {'location' : 'manchester',	'long' : 53.396087,			'lat' : -2.293096}
	locations[8] = {'location' : 'westlancs',	'long' : 53.909344,			'lat' : -2.776215}
	locations[9] = {'location' : 'cardiff',		'long' : 51.480048,			'lat' : -3.143390}

	markerOptions = { icon:flexiIcon };

 	for (var i = 0; i < locations.length; i++)
	{
		point			= new GLatLng(locations[i]['long'],locations[i]['lat']);

		marker			= new GMarker(point, markerOptions);

		locationdata	= locations[i]['location'];

		GEvent.addListener(marker, "click", wrap(locations, i));

		map.addOverlay(marker);
	}

}

function wrap(locations, index) {
    return function () {
        window.location = "http://www.flexistore.co.uk/mobile-storage-" + locations[index]['location'];
    }
}
