﻿    // SJH - Google Map code
    // 12 October 2007
    //
    // Feel free to use this and adapt it for your own site
    // Google documentation at:
    // http://www.google.com/apis/maps/


    // The Google Map Object
    var mGMapObject;
    // The Google Geocoder object
    var mGeocoderObject;
    // Address marker
    var mGMarker;



    function DisplayGoogleMap(address)
    {   
    
        // For now take them straight to Google
        var strURL = "http://maps.google.co.uk/maps?q=" + address;
        window.open(strURL, "_blank");
        return;
    
               
        var elemMapHolder = document.getElementById("divMapHolder");
        if(elemMapHolder)
        {
            if(elemMapHolder.style.display=="none")
            {
                elemMapHolder.style.display = "block";
            }
            else
            {
                elemMapHolder.style.display = "none";
                return;
            }
        }
        else
        {
            alert("Apologies this is not possible");
        }
   
        // Init the map control
		mGMapObject = new GMap(document.getElementById("map"));        
		mGMapObject.addControl(new GLargeMapControl());
		mGMapObject.addControl(new GScaleControl());
		mGMapObject.addControl(new GMapTypeControl());
		
		// Make it look pretty
		baseicon = new GIcon();
		baseicon.image = "http://labs.google.com/ridefinder/images/mm_20_red.png";
		baseicon.shadow = "http://labs.google.com/ridefinder/images/mm_20_shadow.png";
		baseicon.iconSize = new GSize(15, 20);
		baseicon.shadowSize = new GSize(22, 20);
		baseicon.iconAnchor = new GPoint(7, 20);
		baseicon.infoWindowAnchor = new GPoint(5, 1);
		
		// sort out the decoder to get the post code to work
        mGeocoderObject = new GClientGeocoder();
        mGeocoderObject.setBaseCountryCode('GB');
	
	    
        if(mGeocoderObject)
        {
            mGeocoderObject.getLatLng(address,function(point) {
                if (!point)
                {
                    alert("Your entry '" + address + "' could not be geocoded, please try again");
                }
                else
                {
                    if (mGMarker)
                    {
                        mGMapObject.removeOverlay(mGMarker);
                    }
                    mGMarker = new GMarker(point);
                				
                    mGMapObject.setCenter(point, 13);
                    mGMapObject.addOverlay(mGMarker);
                    mGMapObject.load = "EventLoaded"
                }
                }); // end of the nested function
        } // end of if
        
    }




    function DisplayGoogleMap2(address)
    {   
    
        var elemMapHolder = document.getElementById("divMapHolder");
        if(elemMapHolder)
        {
            if(elemMapHolder.style.display=="none")
            {
                elemMapHolder.style.display = "block";
            }
            else
            {
                elemMapHolder.style.display = "none";
                return;
            }
        }
        else
        {
            alert("Apologies this is not possible");
        }
   
        // Init the map control
		mGMapObject = new GMap(document.getElementById("map"));        
		mGMapObject.addControl(new GLargeMapControl());
		mGMapObject.addControl(new GScaleControl());
		mGMapObject.addControl(new GMapTypeControl());
		
		// Make it look pretty
		baseicon = new GIcon();
		baseicon.image = "http://labs.google.com/ridefinder/images/mm_20_red.png";
		baseicon.shadow = "http://labs.google.com/ridefinder/images/mm_20_shadow.png";
		baseicon.iconSize = new GSize(15, 20);
		baseicon.shadowSize = new GSize(22, 20);
		baseicon.iconAnchor = new GPoint(7, 20);
		baseicon.infoWindowAnchor = new GPoint(5, 1);
		
		// sort out the decoder to get the post code to work
        mGeocoderObject = new GClientGeocoder();
        mGeocoderObject.setBaseCountryCode('GB');
	
	    
        if(mGeocoderObject)
        {
            mGeocoderObject.getLatLng(address,function(point) {
                if (!point)
                {
                    alert("Your entry '" + address + "' could not be geocoded, please try again");
                }
                else
                {
                
                    if (mGMarker)
                    {
                        mGMapObject.removeOverlay(mGMarker);
                    }
                    mGMarker = new GMarker(point);
                				
                    mGMapObject.setCenter(point, 13);
                    //mGMapObject.addOverlay(mGMarker);
                    mGMapObject.load = "EventLoaded"
                }
                }); // end of the nested function
        } // end of if
        
    }

