			$(function(){//google maps code for markets page
			
			
		
			
			if (GBrowserIsCompatible()) { // if the browser is compatible with Google Maps
   CreateMap();

  }
else {alert("Your browser is not compatible with Google Maps. Please download Firefox...");}
			
			
	//$('#box_bottom .markets').show();

		
	function CreateMap(){
			var googleMarkerPoints = [];
			
					var markers = [];
					
					
					
					for (i=0; i <=3; i++)
					markers[i]=new Array(20);
					markers[1][0] =[];
					
		
			var i = 0;
			what('map1');
			  		
			
						function what(mape) {
					var s = mape.charAt(3);
			
					return s					
				}
			
			
			
			
				// create the map
			var map1 = new GMap2(document.getElementById("map1"));
			map1.setCenter(new GLatLng(51.50503,-0.090058), 16);
				
			

			
			function AddMarker(map, index, latitude, longitude) {
    			googleMarkerPoints[index] = new GLatLng(latitude, longitude);
    			var marker = new GMarker(googleMarkerPoints[index]);
				map.addOverlay(marker);
				markers[index] = marker;
				
				}
			
	
	
			
						
AddMarker(map1, '1a', 51.50503,-0.090058); //markets
AddMarker(map1, '2a', 51.512, -0.12297);
AddMarker(map1, '3a', 51.538068,-0.207013);
AddMarker(map1, '4a', 51.438788,-0.195973);
AddMarker(map1, '5a', 51.558697,-0.151083);
AddMarker(map1, '6a', 51.41449, -0.05512);

			
			function SelectMarker(map, index){
				map.panTo(googleMarkerPoints[index]);
}

	
	$('.address_list a:not(.market_link)').click (function(){ // select the clicked link
				 var $thisa = $(this);
				 //var link = $this.text();
				  //$('#message').text(link);
				
				$('.address_list a:not(.market_link)').removeClass();
				$thisa.addClass('selected');
			var n = $(this).attr('rel'); //get the marker number
			var x = $(this).parent().parent().attr("title"); //get the map no from parent div
				
				
			if (x == "map1") {
				SelectMarker(map1, n);
				
				return false;
			} else if (x == "map2") {
				SelectMarker(map2, n);
				return false;}
			else if (x == "map3") {
				SelectMarker(map3, n);
								return false;}
								else {}
								
								return false;
								
		});
		};
			
		//$('#map2').css('display', 'none');
		//$('#map2').css('display', 'none');
		//$('#map3').css('display', 'none');
		//$('.address_list').css('display', 'none');
		
					
		$('.address_list a:not(.market_link)').click(function(){
			var $this = $(this);
			var no = $(this).attr('rel');
			$('#buy_welcome').remove();
			$('#buy_nav a').removeClass();
			$this.addClass('selected');
			
		
			//$('#map1').css('display', 'none');
		//$('#map2').css('display', 'none');
		//$('#map3').css('display', 'none');
		//	$('#map' + no).show();
			
		//	$('.address_list').css('display','none');
				//$('.map'+ no).fadeIn();
	return false;
		});


	});

