﻿var serviceAddress;
var serviceLocation;

window.onload = function footInitialize() {
    if (serviceLocation == null) {
        serviceAddress = document.getElementById('hdnFooterMap').value;
        var geocoder = new google.maps.Geocoder();
        geocoder.geocode({ 'address': serviceAddress }, function (results, status) {
            if (status == google.maps.GeocoderStatus.OK) {
                serviceLocation = results[0].geometry.location;
                fotInitMap();
            }
            else {
                serviceLocation = new google.maps.LatLng(0, 0);
                fotInitMap();
            }
        });

    }
    else {
        fotInitMap();
    }

}

function fotInitMap() {
    var myOptions = {
        zoom: 14,
        mapTypeId: google.maps.MapTypeId.ROADMAP,
        center: serviceLocation
    }

    mapFooter = new google.maps.Map(document.getElementById('footer-google-map'), myOptions);

    var marker;
    marker = new google.maps.Marker({
        position: serviceLocation,
        title: serviceAddress,
        map: mapFooter
    });
}

function footFormClick(){
    var field = document.getElementById('txtFGetDirections');
    if (field.value == 'Enter your starting address')
        field.value = '';
}

function footFormDefault() {
    var field = document.getElementById('txtFGetDirections');
    if (field.value == '')
        field.value = 'Enter your starting address';
}

function footValidateForm() {
    var field = document.getElementById('txtFGetDirections');
    if (field.value == 'Enter your starting address') {
        alert('Please enter your starting address');
        return false;
    }

    return true;
}
