function requestGeoPosition() {
    // console.log('Requesting GeoLocation data from the browser...');
    if (navigator.geolocation) {
        navigator.geolocation.getCurrentPosition(showGeoPosition, logGeoLocationError,
            {maximumAge: 600000, timeout: 5000, enableHighAccuracy: true});
    } else {
        // console.log('Browser does not support Geo Location');
    }
}

function logGeoLocationError(error) {
    switch (error.code) {
        case error.PERMISSION_DENIED:
            // console.log('User denied the request for GeoLocation.');
            break;
        case error.POSITION_UNAVAILABLE:
            // console.log('Location information is unavailable.');
            break;
        case error.TIMEOUT:
            // console.log('The request to get user location timed out.');
            break;
        default:
            // console.log('An unknown error occurred.');
            break;
    }
}

function showGeoPosition(position) {
    $('[name="geolocation"]').val(position.coords.latitude + ','
        + position.coords.longitude + ',' + position.coords.accuracy + ',' + position.timestamp);
}

function preserveAnchorTagOnForm() {
    $("#fm1").submit(function (event) {
        var hash = decodeURIComponent(self.document.location.hash);
        if (hash && hash.indexOf("#") === -1) {
            hash = "#" + hash;
        }
        var action = $("#fm1").attr("action") + hash;
        $("#fm1").attr("action", action);
    });
}

function areCookiesEnabled() {
    if ($.cookie == undefined) {
        return;
    }

    $.cookie('cookiesEnabled', 'true');
    var value = $.cookie('cookiesEnabled');
    $.removeCookie('cookiesEnabled');
    return value != undefined;

}

function animateCasMessageBoxes() {
    //flash error box
    $('#msg.errors').animate({backgroundColor: 'rgb(187,0,0)'}, 30).animate({backgroundColor: 'rgb(255,238,221)'}, 500);

    //flash success box
    $('#msg.success').animate({backgroundColor: 'rgb(51,204,0)'}, 30).animate({backgroundColor: 'rgb(221,255,170)'}, 500);

    //flash confirm box
    $('#msg.question').animate({backgroundColor: 'rgb(51,204,0)'}, 30).animate({backgroundColor: 'rgb(221,255,170)'}, 500);
}

function disableEmptyInputFormSubmission() {
    var fields = $('#fm1 input[name="username"],[name="password"]');

    if (fields.length == 2) {
        fields.on('input', function (event) {
            var enableSubmission = $('#fm1 input[name="username"]').val().trim() &&
                $('#fm1 input[name="password"]').val().trim();

            if (enableSubmission) {
                $('#fm1 input[name=submit]').removeAttr('disabled');
                event.stopPropagation();
            } else {
                $('#fm1 input[name=submit]').attr('disabled', 'true');
            }
        });
    }

    /**
     * Handle auto-complete events to the extent possible.
     */
    if ($('#fm1 input[name="username"]').length > 0) {
        setTimeout(function () {
            var uid = $('#username').val();
            if (uid != null && uid != '') {
                $('#username').change();
                $('#username').focus();
                $('#fm1 input[name=submit]').removeAttr('disabled');
            }

        }, 100);
    }
}

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

        if (trackGeoLocation) {
            requestGeoPosition();
        }

        if ($(':focus').length === 0) {
            $('input:visible:enabled:first').focus();
        }

        if (areCookiesEnabled()) {
            $('#cookiesDisabled').hide();
        } else {
            $('#cookiesDisabled').show();
            $('#cookiesDisabled').animate({backgroundColor: 'rgb(187,0,0)'}, 30).animate({backgroundColor: 'rgb(255,238,221)'}, 500);
        }

        animateCasMessageBoxes();
        disableEmptyInputFormSubmission();
        preserveAnchorTagOnForm();

        $('#capslock-on').hide();
        $('#fm1 input[name="username"],[name="password"]').trigger('input');
        $('#fm1 input[name="username"]').focus();

        $('#password').keypress(function (e) {
            var s = String.fromCharCode(e.which);
            if (s.toUpperCase() === s && s.toLowerCase() !== s && !e.shiftKey) {
                $('#capslock-on').show();
            } else {
                $('#capslock-on').hide();
            }
        });
        if (typeof(jqueryReady) == 'function') {
            jqueryReady();
        }
    });

}

@@ -1,16 +1,103 @@
+/* global trackGeoLocation, jqueryReady */%0A%0A/* exported resourceLoadedSuccessfully */%0A%0A
 function request
@@ -526,28 +526,24 @@
 ror.code) %7B%0A
-    
     case err
@@ -564,20 +564,16 @@
 DENIED:%0A
-    
         
@@ -628,28 +628,24 @@
 ocation.');%0A
-    
         brea
@@ -639,36 +639,32 @@
 %0A        break;%0A
-    
     case error.P
@@ -684,20 +684,16 @@
 ILABLE:%0A
-    
         
@@ -744,28 +744,24 @@
 ailable.');%0A
-    
         brea
@@ -759,28 +759,24 @@
      break;%0A
-    
     case err
@@ -787,20 +787,16 @@
 IMEOUT:%0A
-    
         
@@ -854,28 +854,24 @@
 med out.');%0A
-    
         brea
@@ -873,20 +873,16 @@
  break;%0A
-    
     defa
@@ -886,20 +886,16 @@
 efault:%0A
-    
         
@@ -936,28 +936,24 @@
 ccurred.');%0A
-    
         brea
@@ -1210,22 +1210,22 @@
 %7B%0A    $(
-%22
+'
 #fm1
-%22
+'
 ).submit
@@ -1227,37 +1227,32 @@
 ubmit(function (
-event
 ) %7B%0A        var 
@@ -1340,19 +1340,19 @@
 indexOf(
-%22#%22
+'#'
 ) === -1
@@ -1378,11 +1378,11 @@
 h = 
-%22#%22
+'#'
  + h
@@ -1419,37 +1419,37 @@
 ion = $(
-%22
+'
 #fm1
-%22
+'
 ).attr(
-%22
+'
 action
-%22
+'
 ) + hash
@@ -1464,29 +1464,29 @@
   $(
-%22
+'
 #fm1
-%22
+'
 ).attr(
-%22
+'
 action
-%22
+'
 , ac

fix linting issues