
$(document).ready(function(){
	
	initialiseMap();
	
}); //end document.ready


function initialiseMap() {

        mapCentre = new google.maps.LatLng(51.344339,3.47168 );

        var myOptions = {
            zoom: 3,
            center: mapCentre,
            mapTypeId: google.maps.MapTypeId.ROADMAP
        }

        var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);

        setMarkers(map, sites);
		
    }

   /* var sites = [
		['Edinburgh', 55.978306, -3.208008, 1, 'Edinburgh','location1'],
		['Milton Keynes', 52.038076 , -0.752563, 2, 'Milton Keynes','location2'],
		['Trieste', 45.653003, 13.78458, 3, 'Trieste','location3'],
		['Bradford', 53.796541, -1.757813, 4, 'Bradford','location4'],
		['Southampton', 50.905400, -1.403503, 5, 'Southampton','location5'],
		['Oxford', 51.751846, -1.250381, 6, 'Oxford','location6'],
		['Cardiff', 51.486286, -3.188782, 7, 'Cardiff','location7'],
		['Dublin', 53.344864, -6.239033, 8, 'Dublin','location8'],
		['Torquay', 50.462476, -3.530388, 9, 'Torquay','location9'],
		['Woking', 51.320877, -0.560153, 10, 'Woking','location10'],
		['Manchester', 53.475506, -2.241254, 11, 'Manchester','location11'],
		['Aylesbury', 51.814929, -0.810671, 12, 'Aylesbury','location12'],
		['Blackpool', 53.818465, -3.050508, 13, 'Blackpool','location13'],
		['Sunderland', 54.911159, -1.387367, 14, 'Sunderland','location14'],
		['Liverpool', 53.40943, -2.978497, 15, 'Liverpool','location15'],
		['Norwich', 52.632021, 1.28952, 16, 'Norwich','location16'],
		['Birmingham', 52.495323, -1.899261, 17, 'Birmingham','location17']
	];*/


    function setMarkers(map, markers) {

        for (var i = 0; i < markers.length; i++) {
            var sites = markers[i];
            var siteLatLng = new google.maps.LatLng(sites[1], sites[2]);
            var marker = new google.maps.Marker({
                position: siteLatLng,
                map: map,
                title: sites[0],
                zIndex: sites[3],
                html: sites[4],
				id: sites[5],
				clickable: true,
				icon: 'images/icon_map-lightening.png' 
            });


/*			$("<li />").html("Point "+i).click(function(){
					displayPointB(marker, i);
					}).appendTo("#list");
				
			function displayPointB(marker, index){
				//alert(i)
				//$('#map_canvas #location'+i).hide();
				markerId = marker.attr('id');
				pointId =  $(this).attr('id');
				//map.panTo(marker.getLatLng());
				
				alert(markerId)
			}*/
							
				
			
//			//PULLED FROM BELOW TO REPLICATE ABOVE
//			google.maps.event.addListener(marker, 'click', function() {
//    			//map.panTo(marker.siteLatLng); 
//				//map.panTo(marker.getLatLng());
//				
//				//this works....
//				markerId = $(this).attr('id');
//				markerTitle = $(this).attr('title');
//				//alert('this marker: '+markerId)
//  				}); 
//			
//				google.maps.event.addListener(marker, 'click', function() {
//					displayPoint(marker, i);
//				});
//				
//				function displayPoint(marker, index){
//					//$("#message").hide();
//					
//					var moveEnd = GEvent.addListener(map, "moveend", function(){
//						
//						var markerOffset = map.fromLatLngToDivPixel(marker.getLatLng());
//						
//						$("#message").fadeIn().css({ top:markerOffset.y, left:markerOffset.x });
//					
//						GEvent.removeListener(moveEnd);
//					});
//					map.panTo(marker.getLatLng());
//				}
				

	
			
			
        }//end for
		

		
    }//end setMarkers
	

