/**
 * Functions to launch when document is ready
 */
$(document).ready(function() {
    setDateTimezones();
});

/**
 * Based on today's date, get the user's timezone offset and print them into the appropriate form elements
 *
 * These values are used for controlling access/logins to the web site to detect abuse and/or fraud
 * This is done through JavaScript as we need the USER's info
 */
var setDateTimezones = function() {
    var today   = new Date();
    $('#mDate').val(today.getFullYear() + '-' + pad((today.getMonth() + 1)) + '-' + pad(today.getDate()));
    $('#mTime').val(pad(today.getHours()) + ':' + pad(today.getMinutes()));
    $('#mOffset').val(-(today.getTimezoneOffset()/60));
}

/**
 * Pad values with a 0 if it is lower than 10
 */
var pad = function (value) {
    if (value < 10) {
        return '0' + value;
    }
    return value;
}
