var map = null;


 function initialize() 
{    
 if (GBrowserIsCompatible()) 
{ 


// Set up map
       
map = new GMap2(document.getElementById("map"));

// End of map set up

// ====== Restricting the range of Zoom Levels =====
      // Get the list of map types      
      var mt = map.getMapTypes();
      // Overwrite the getMinimumResolution() and getMaximumResolution() methods
      for (var i=0; i<mt.length; i++) {
        mt[i].getMinimumResolution = function() {return 1;}
        mt[i].getMaximumResolution = function() {return 16;}
      }



// Set up controls

map.addControl(new GLargeMapControl());    //  Adds Navigation Controls to map
map.addControl(new GMapTypeControl());     //  Adds View Controls to map
map.setCenter(new GLatLng(54.52577, -1.3623), 5);   // sets on load coordinates and zoom of map

// end basic map set up


// Add markers to map

function createMarker(point, html) {
      var marker = new GMarker(point);
      GEvent.addListener(marker, 'click', function() {
        marker.openInfoWindowHtml(html);
      });
return marker;
}

// end markers

// Parse xml data

GDownloadUrl("xml.asp", function(data) {
          var xmlDoc = GXml.parse(data);
          var markers = xmlDoc.documentElement.getElementsByTagName("marker");
          for (var i = 0; i < markers.length; i++) {
            var org = markers[i].getAttribute("org");
            var details = markers[i].getAttribute("details");
	    var title = markers[i].getAttribute("event_title");
            var point = new GLatLng(parseFloat(markers[i].getAttribute("lat")), parseFloat(markers[i].getAttribute("lng")));
	   var html = "<div class='marker'><img src='logomini.jpg' height='40px' width='50px' /><br /><br /><p><strong>" + title + "</strong> <br /> " + org + "</p><p>" + details + "</p></div>";
            var marker = createMarker(point, html);
            map.addOverlay(marker);
      
 }
        });

// end of xml parsing





     }   


}




// Connect to postcode anywhere to recentre map
            

	function reCentre() {
			
					pcaGeocodePostcodeBegin(document.getElementById("txtPostCode").value, "", "", "campa11116", "UB79-UF55-NA24-CR38")
				
				}
				
			function pcaGeocodePostcodeBegin(postcode, building, accuracy, account_code, license_code)
			   {
			      var scriptTag = document.getElementById("pcaScriptTag");
			      var headTag = document.getElementsByTagName("head").item(0);
			      var strUrl = "";

			      //Build the url
			      strUrl = "http://services.postcodeanywhere.co.uk/inline.aspx?";
			      strUrl += "&action=geocode";
			      strUrl += "&postcode=" + escape(postcode);
			      strUrl += "&building=" + escape(building);
			      strUrl += "&accuracy=" + escape(accuracy);
			      strUrl += "&account_code=" + escape(account_code);
			      strUrl += "&license_code=" + escape(license_code);
			      strUrl += "&callback=pcaGeocodePostcodeEnd";

			      //Make the request
			      if (scriptTag) 
			         {
			            headTag.removeChild(scriptTag);
			         }
			      scriptTag = document.createElement("script");
			      scriptTag.src = strUrl;
			      scriptTag.type = "text/javascript";
			      scriptTag.id = "pcaScript";
			      headTag.appendChild(scriptTag);
			   }

			function pcaGeocodePostcodeEnd()
			   {
			      //Test for an error
			      if (pcaIsError)
			         {
			            //Show the error message
			            alert(pcaErrorMessage);
			         }
			      else
			         {
			            //Check if there were any items found
			            if (pcaRecordCount==0)
			               {
			                  alert("Sorry, no matching items found");
			               }
			            else
			               {
						
							
							//PUT YOUR CODE HERE
							var point = new GLatLng(pca_wgs84_latitude[0], pca_wgs84_longitude[0]);    
							
							//Centre the map
							map.setCenter(point,14);
			                  
			               }
			         }
			   }



// End of postcode anywhere link






















