/*
 This program is free software: you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
 the Free Software Foundation, either version 3 of the License, or
 (at your option) any later version.

 This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.

 You should have received a copy of the GNU General Public License
 along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
(function ($) {
    'use strict';
    var e_ = {1: [1]};
    var sao = {1: [2, 3, 4]};
    var e1 = {7: [8]};
    var e2 = {10: [5]};
    var menos = {7: [7, 8, 9, 10, 11]};
    var meia = {8: [8, 9, 10, 11]};
    var cinco = {10: [7, 8, 9, 10, 11]};
    var dez = {10: [1, 2, 3]};
    var um_quarto = {9: [1, 2, 4, 5, 6, 7, 8, 9]};
    var vinte = {8: [1, 2, 3, 4, 5]};
    var layout = {
        "version": 2,
        "language": 'Português',
        "letters": [
            'ÉSÃOUMATRÊS',
            'MEIOLDIADEZ',
            'DUASEISETEY',
            'QUATROHNOVE',
            'CINCOITONZE',
            'ZMEIALNOITE',
            'HORASYMENOS',
            'VINTECAMEIA',
            'UMVQUARTOPM',
            'DEZOEYCINCO'
        ],
        "minutes": {
            "5,6,7,8,9": [e1, cinco],
            "10,11,12,13,14": [e1, dez],
            "15,16,17,18,19": [e1, um_quarto],
            "20,21,22,23,24": [e1, vinte],
            "25,26,27,28,29": [e1, vinte, e2, cinco],
            "30,31,32,33,34": [e1, meia],
            "35,36,37,38,39": [menos, vinte, e2, cinco],
            "40,41,42,43,44": [menos, vinte],
            "45,46,47,48,49": [menos, um_quarto],
            "50,51,52,53,54": [menos, dez],
            "55,56,57,58,59": [menos, cinco]
        },
        "hours": {
            "0": [e_, {"6": [2, 3, 4, 5, 7, 8, 9, 10, 11]}],
            "12": [e_, {"2": [1, 2, 3, 4, 6, 7, 8]}],
            "1,13": [e_, {"1": [5, 6, 7]}],
            "2,14": [sao, {"3": [1, 2, 3, 4]}],
            "3,15": [sao, {"1": [8, 9, 10, 11]}],
            "4,16": [sao, {"4": [1, 2, 3, 4, 5, 6]}],
            "5,17": [sao, {"5": [1, 2, 3, 4, 5]}],
            "6,18": [sao, {"3": [4, 5, 6, 7]}],
            "7,19": [sao, {"3": [7, 8, 9, 10]}],
            "8,20": [sao, {"5": [5, 6, 7, 8]}],
            "9,21": [sao, {"4": [8, 9, 10, 11]}],
            "10,22": [sao, {"2": [9, 10, 11]}],
            "11,23": [sao, {"5": [8, 9, 10, 11]}]
        },
        "getHour": function (date) {
            var hour = date.getHours();
            if (date.getMinutes() >= 35) {
                return (hour + 1) % 24;
            }
            return hour;
        }
    };
    $.fritteli.uhr.register('pt', layout);
}(jQuery));