﻿/*** This functionality is specific to branch template pages ***/

$(document).ready(function() {
    addChildPageSelectChange();
});

function addChildPageSelectChange() {
    var target = $("select#products_include_links");
    if (target.length > 0) {
        target.change(function() {
            if(target.val() != "")
                window.location = target.val()
        });
    }
}

function GMapInitialize() {
    if (GBrowserIsCompatible()) {
        var map = new GMap2(document.getElementById("map_canvas"));
        map.setCenter(new GLatLng(52.483396, -1.896438), 13);
        var marker = new GMarker(new GLatLng(52.483396, -1.896438))
        GEvent.addListener(marker, "click", function() { marker.openInfoWindowHtml('Wesleyan Head Office'); });
        map.addOverlay(marker);
        map.addControl(new GSmallMapControl());
        map.addControl(new GMapTypeControl());
    }
}

function disableEnterKey(e) {
    var key;
    if (window.event)
        key = window.event.keyCode;     //IE
    else
        key = e.which;     //firefox

    if (key == 13) {
        submitGoogleMapsForm();
        return false;
    } else
        return true;
}

function submitGoogleMapsForm() {
    var userLocation = $("#saddr").val();
    newdirectionswindow = window.open("http://maps.google.com/maps?f=d&source=s_d&daddr=Wesleyan%20Assurance%20Society,%20B4%206AR&hl=en&geocode=&saddr=" + userLocation,
    'googleMaps',
    'left=20,top=20,width=750,height=600,toolbar=1,resizable=1');
    if (newdirectionswindow) {
        // Make sure this window receives focus (in case it was already open and minimised)
        newdirectionswindow.focus();
    }
}
