/*
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 h = {
        "_il_est": {1: [1, 2, 4, 5, 6]},
        "_et": {8: [1, 2]},
        "_moins": {7: [1, 2, 3, 4, 5]},
        "_demie": {10: [4, 5, 6, 7, 8]},
        "_heures": {6: [6, 7, 8, 9, 10, 11]},
        "_le": {7: [7, 8]},
        "_5": {9: [7, 8, 9, 10]},
        "_10": {7: [9, 10, 11]},
        "_15": {8: [4, 5, 6, 7, 8]},
        "_20": {9: [1, 2, 3, 4, 5]},
        "_25": {9: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]}
    };
    var layout = {
        "version": 2,
        "language": 'Français',
        "letters": [
            'ILNESTODEUX',
            'QUATRETROIS',
            'NEUFUNESEPT',
            'HUITSIXCINQ',
            'MIDIXMINUIT',
            'ONZERHEURES',
            'MOINSOLEDIX',
            'ETRQUARTPMD',
            'VINGT-CINQU',
            'ETSDEMIEPAM'
        ],
        "permanent": h._il_est,
        "minutes": {
            "5,6,7,8,9": h._5,
            "10,11,12,13,14": h._10,
            "15,16,17,18,19": [h._et, h._15],
            "20,21,22,23,24": h._20,
            "25,26,27,28,29": h._25,
            "30,31,32,33,34": [h._et, h._demie],
            "35,36,37,38,39": [h._moins, h._25],
            "40,41,42,43,44": [h._moins, h._20],
            "45,46,47,48,49": [h._moins, h._le, h._15],
            "50,51,52,53,54": [h._moins, h._10],
            "55,56,57,58,59": [h._moins, h._5]
        },
        "hours": {
            "0": {5: [6, 7, 8, 9, 10, 11]},
            "1,13": [
                {3: [5, 6, 7]},
                h._heures
            ],
            "2,14": [
                {1: [8, 9, 10, 11]},
                h._heures
            ],
            "3,15": [
                {2: [7, 8, 9, 10, 11]},
                h._heures
            ],
            "4,16": [
                {2: [1, 2, 3, 4, 5, 6]},
                h._heures
            ],
            "5,17": [
                {4: [8, 9, 10, 11]},
                h._heures
            ],
            "6,18": [
                {4: [5, 6, 7]},
                h._heures
            ],
            "7,19": [
                {3: [8, 9, 10, 11]},
                h._heures
            ],
            "8,20": [
                {4: [1, 2, 3, 4]},
                h._heures
            ],
            "9,21": [
                {3: [1, 2, 3, 4]},
                h._heures
            ],
            "10,22": [
                {5: [3, 4, 5]},
                h._heures
            ],
            "11,23": [
                {6: [1, 2, 3, 4]},
                h._heures
            ],
            "12": {5: [1, 2, 3, 4]}
        },
        "getHour": function (date) {
            var hour = date.getHours();
            if (date.getMinutes() >= 35) {
                return (hour + 1) % 24;
            }
            return hour;
        }
    };
    $.fritteli.uhr.register('fr', layout);
}());