// JavaScript Document

function MarkerStruct(Lat, Lng, Text1) {
this.Lat = Lat;
this.Lng = Lng;
this.Text1=Text1;
return this;
}

function showAddress2( arrMarkerStruct, sInfoTitle, sInfoBody ) {

var map;

 if ( document.getElementById("map") ) {
   if (GBrowserIsCompatible()) {


        	map = new GMap2(document.getElementById("map"));
	
        	map.addControl(new GLargeMapControl());
        	map.addControl(new GMapTypeControl());

        if ( arrMarkerStruct.length > 1 )
        { 
	        // assume that map is an instance of a GMap2 object
	        // #0 -- google maps api requires us to call setCenter first before calling any other operation on the map
	        map.setCenter(new GLatLng( 0, 0 ), 6 ); 

	        // #1 -- add markers
	        for (var i = 0; i < arrMarkerStruct.length; i++ )
	        {
			    var latlng = new GLatLng(arrMarkerStruct[i].Lat,arrMarkerStruct[i].Lng);
			    markerOptions = { title:arrMarkerStruct[i].Text1};
		        
		        var marker = new GMarker(latlng  , markerOptions );
		        map.addOverlay( marker );
	        }
 
	        // #2a -- calculate center 
	        var latlngbounds = new GLatLngBounds( ); 
	        for(var i = 0; i < arrMarkerStruct.length; i++ )
	        {
			    var latlng = new GLatLng(arrMarkerStruct[i].Lat,arrMarkerStruct[i].Lng);
		        latlngbounds.extend( latlng );
	        }
 
	        // #2b -- set center using the calculated values
	        map.setCenter( latlngbounds.getCenter( ), map.getBoundsZoomLevel( latlngbounds ) );
	  }
	  else 
	  {
		if ( arrMarkerStruct.length == 1 ) {
		   map.setCenter( new GLatLng(arrMarkerStruct[0].Lat,arrMarkerStruct[0].Lng) , 8);	
		       // Our info window content
	           var infoTabs = [new GInfoWindowTab(sInfoTitle, arrMarkerStruct[0].Text1)];

	           // Place a marker in the center of the map and open the info window automatically
	           var marker = new GMarker(map.getCenter());

	           map.addOverlay(marker);
	           marker.openInfoWindowTabsHtml(infoTabs);		
		}
		else {
			map.setCenter( new GLatLng(53.83227,-1.549072) , 5);  // Default coordinates of Leeds to centralise uk map
		}
	    
        }

   }
  }
	return map;
}

function IncludeJavaScript(jsFile)
{
  document.write('<script type="text/javascript" src="'
    + jsFile + '"></scr' + 'ipt>'); 
}

IncludeJavaScript('http://maps.google.com/maps?file=api&amp;v=2&amp;key=ABQIAAAA-GDGYrT1XHWUiQHSZRXGSBRtH0K3iCjhVok7cIvI1ZCOSL9r2xRDRvVw-OHVwunCdkRyNiIr28KCsw');
//IncludeJavaScript('http://maps.google.com/maps?file=api&amp;v=2&amp;key=ABQIAAAA-GDGYrT1XHWUiQHSZRXGSBSZ5E8TsEsGcCx97qnmfckMhf2ivBT48rU0oCcjYA-Io35aGrwCppyxqA');
//-->

