var map;
var infowindow;
	
function initialize() {
	//initialize map
	var latlng = new google.maps.LatLng(54.444492,-3.255616);
	var myOptions = {
		zoom: 6,
		center: latlng,
		mapTypeId: google.maps.MapTypeId.HYBRID 
	};
		
	map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
		
	//initialize infowindow
	infowindow = new google.maps.InfoWindow({
		size: new google.maps.Size(50,50)
	})
		
	//add the listener to the marker and its effects
	google.maps.event.addListener(map, 'click', function() {
		infowindow.close(map);
	});
		
	//markers
	var myGMarkers = new Array();
	var i = 0;
	
	//myGMarkers[i++]= new Array(createMarker(long,lat), "title", "address", "www", "description")
	
	
	//CARDIFF
	//Hungry Planet
	myGMarkers[i++]=new Array(createMarker(51.48618,-3.158731),"Hungry Planet","142 Clifton street,<br />Cardiff<br />Tel: 02920 440504","http://www.hungryplanet.org.uk", "<p>My local wholefood shop and one that is run by a workers coop, of which I am joyfully a member of.  It reminds me about going into a sweet shop when I was kid as they have lots of lovely things like mangos, goji berries and nuts in a pic n mix, have as much as you want, style.  They sell many of my products.</p><p>It is also 100% vegan and run as a workers cooperative that I am very proud to be a part of.</p>");
	//Waterloo Gardens Teahouse
	myGMarkers[i++]=new Array(createMarker(51.494706,-3.155592),"Waterloo Gardens Teahouse","5 Waterloo Gardens,<br />Penylan,<br />Cardiff<br />Tel: 029 20456073","http://www.waterlootea.com", "<p>Waterloo Gardens Teahouse brings the worlds finest teas to Cardiff.  They serve a broad selection of the finest artisan teas from award-winning estates from around the world.</p>");
	//Snails
	myGMarkers[i++]=new Array(createMarker(51.522213,-3.211472),"Snails","6 Beulah road,<br />Rhiwbina,<br /> Cardiff<br />029 20620415","", "<p>A local deli and specialist food supplier.</p>");
			
	//WEST WALES
	//CAT Quarry Shop
	myGMarkers[i++]=new Array(createMarker(52.590656,-3.852468),"CAT Quarry Shop","Heol Maengwyn,<br />Machynlleth,<br />Powys","http://www.cat.org.uk/qsqc/qsqc.tmpl", "<p>The Centre for Alternative Technology's shop in Machynlleth.  They sell a wonderful selection of tasty and rich ingredients for cooking, beautiful sweets and chocolates and local cakes.  They sell The Happy Hippo and The Voluptuous Vole recipe book.</p>");
	//Blasau Deli
	myGMarkers[i++]=new Array(createMarker(52.591213,-3.852898),"Blasau Deli","The Royal House,<br />13 Heol Penrallt,<br />Machynlleth,<br />SY20 8AY", "", "<p>This small deli has a wonderful selection of food including freshly made nibbles that I used to buy when I had my picnics by the river side.  They stock our chocolate truffles.</p>");
	//Treehouse
	myGMarkers[i++]=new Array(createMarker(52.415312,-4.084313),"Treehouse","14 Baker Street,<br />Aberystwyth<br />SY23 2BJ<br />Tel: 01970 615791","http://www.treehousewales.co.uk", "<p>They aim to provide a one-stop organic shop that stocks over 1000 different food products, as many as possible sourced locally. A fantastic addition to their services is their bicycle delivery service.  They stock our chocolate truffles.</p>");
		
	//BRISTOL
	myGMarkers[i++]=new Array(createMarker(51.470571,-2.593077),"Harvest","11 Gloucester road,<br />Bristol<br />BS7 8AA<br />Tel: 0117 942 5997","http://www.harvest-bristol.coop", "<p>One of this countries greatest food treasures is a health food distribution group called Essential and this shop is one of their outlets.  Run as a cooperative it is friendly and full of lovely vegan goodies.  They stock our truffles.</p>");
		
	//Liverpool
	//Dragon Indulgence
	myGMarkers[i++]=new Array(createMarker(53.406047,-2.984391), "Dragon Indulgence","New Beginnings,<br />28 - 30 Williamson Street,<br />Liverpool<br />L1 1EB", "http://www.facebook.com/pages/Dragon-Indulgence/116171801729989?sk=wall", '<p>To feed your mind, body and soul. Fairly traded items with good ethics.Chocolate from around the world, large selection of vegan and vegetarian chocolate and foods,new age goods: crystals, candles, books, clothes, statues Anna Riva products.</p>');
	
	//London
	//Ms Cupcake
	myGMarkers[i++]=new Array(createMarker(	51.461859,-0.113077), "Ms Cupcake","408 Coldhabour Lane<br />Brixton,<br />London<br />SW9 8LF<br />", "http://www.mscupcake.co.uk", '<p>Styles herself as a sexy 1950s housewive with a dream of bringing vegan cupcakes, brownies, cookies, tray-bakes, loaf and layer cakes to the masses. Ms. Cupcake believes in providing decadent baked goods to those who love a little indulgence in life.  After tasting her gluten free muffin and experiencing one hell of a sugar rush I would strongly recomend visiting her little shop.</p>');
	
	//OTHER
	//Westmorland Farm Shop East
	myGMarkers[i++]=new Array(createMarker(54.44967,-2.60986), "Westmorland Farm Shop East","Westmorland Services Southbound M6,<br />Tebay,<br />Penrith,<br />CA10 3SB", "http://www.westmorland.com/", '<p>Tebay Services is the only family owned and run motorway services in the UK.  It is located one mile north of Junction 38 on the M6 motorway in Cumbria - the Lake District.  In their shop they have an extensive range of carefully selected local and artisan specialities</p>');

	//form the markers and fill the map with them
	for( i=0; i<myGMarkers.length; i++ ){
		myGMarkers[i][0] = addFunctionality( myGMarkers[i][0],myGMarkers[i][1],myGMarkers[i][2],myGMarkers[i][3],myGMarkers[i][4]);
			
		//add the marker to the map
		myGMarkers[i][0].setMap(map);
	}		
}
	
function addFunctionality(marker, title, address, www, description ){
	//add the title to the marker
	marker.setTitle(title);
	
	//first we create the content
	var contentString = '<div id="tab-1"><span style="font-weight:bold; font-size:large;">'+title +'</span><br />';
			
	//add the address and phone number	
	if(address != null){ 
		contentString += '<br />' +address;
	}

	//add the website	
	if(www != null){ 
		contentString += '<br /><a href="' +www +'" target="_blank">' +www +'</a>';
	}
	
	contentString += '</div>';
	
	//add the website	
	if(description != null){ 
		contentString += '<div id="tab-2">' +description +'</div>';
	}
	
	

	//add the listener to the marker and its effects
	google.maps.event.addListener(marker, 'click', function() {
		infowindow.setContent(contentString);
		infowindow.setPosition(marker.getPosition());
		//open the new markers infoWindow
		infowindow.open(map);
	})
		
	return marker;
}
	
function createMarker( lat, lng ){
	var myLatlng = new google.maps.LatLng(lat, lng);
	var marker = new google.maps.Marker({
		position: myLatlng,
	});
		
	return marker;
}

