/*
 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 il_est = {1: [1, 2, 4, 5, 6]};
    var et = {8: [1, 2]};
    var moins = {7: [1, 2, 3, 4, 5]};
    var demie = {10: [4, 5, 6, 7, 8]};
    var heures = {6: [6, 7, 8, 9, 10, 11]};
    var le = {7: [7, 8]};
    var cinq = {9: [7, 8, 9, 10]};
    var dix = {7: [9, 10, 11]};
    var quart = {8: [4, 5, 6, 7, 8]};
    var vingt = {9: [1, 2, 3, 4, 5]};
    var vingtcinq = {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": il_est,
        "minutes": {
            "5,6,7,8,9": cinq,
            "10,11,12,13,14": dix,
            "15,16,17,18,19": [et, quart],
            "20,21,22,23,24": vingt,
            "25,26,27,28,29": vingtcinq,
            "30,31,32,33,34": [et, demie],
            "35,36,37,38,39": [moins, vingtcinq],
            "40,41,42,43,44": [moins, vingt],
            "45,46,47,48,49": [moins, le, quart],
            "50,51,52,53,54": [moins, dix],
            "55,56,57,58,59": [moins, cinq]
        },
        "hours": {
            "0": {5: [6, 7, 8, 9, 10, 11]},
            "1,13": [
                {3: [5, 6, 7]},
                heures
            ],
            "2,14": [
                {1: [8, 9, 10, 11]},
                heures
            ],
            "3,15": [
                {2: [7, 8, 9, 10, 11]},
                heures
            ],
            "4,16": [
                {2: [1, 2, 3, 4, 5, 6]},
                heures
            ],
            "5,17": [
                {4: [8, 9, 10, 11]},
                heures
            ],
            "6,18": [
                {4: [5, 6, 7]},
                heures
            ],
            "7,19": [
                {3: [8, 9, 10, 11]},
                heures
            ],
            "8,20": [
                {4: [1, 2, 3, 4]},
                heures
            ],
            "9,21": [
                {3: [1, 2, 3, 4]},
                heures
            ],
            "10,22": [
                {5: [3, 4, 5]},
                heures
            ],
            "11,23": [
                {6: [1, 2, 3, 4]},
                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);
}(jQuery));