﻿$(document).ready(function(){

    // Motor Homes map.
    if ($("#motorhomesmap").length > 0) {
        $("#motorhomesmap").googlemap({
            controls: true,
            labels: false,
            zoom: 8,
            latitude: 50.652423,
            longitude: -2.967656,
            addresses: postcodes,
            html: vehicles,
            anchor: ".external-map-marker",
            debug: false
        })
    }

    // Motor Homes map.
    if ($("#motorhomemap").length > 0) {
        $("#motorhomemap").googlemap({
            controls: true,
            labels: false,
            zoom: 3,
            latitude: 50.652423,
            longitude: -2.967656,
            addresses: postcodes,
            html: "",
            anchor: ".external-map-marker",
            debug: false
        })  
    }

    // Contact Us map.
    if ($('body.contact #map').length > 0) {
        var lat = 50.917571; lon = -2.9868
        var address = '<strong>South West Motor Homes</strong><br />Emerald Farm<br />Higher Horton<br />Nr Ilminster';
        var postcode = 'TA19 9LJ';

        if (GBrowserIsCompatible()) {
            var map = new GMap2(document.getElementById("map"));
            map.setCenter(new GLatLng(50.925671, -2.98475), 8);
            var point = new GLatLng(lat, lon);
            var marker = new GMarker(point);
            map.addOverlay(marker);
            map.addControl(new GLargeMapControl());
            marker.openInfoWindowHtml("<div>" + address + "<br />" + postcode + "</div>");
        }
    }

})