/*
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 = {
        "_it_is": {1: [1, 2, 4, 5]},
        "_half": {4: [1, 2, 3, 4]},
        "_to": {4: [10, 11]},
        "_past": {5: [1, 2, 3, 4]},
        "_o_clock": {10: [6, 7, 8, 9, 10, 11]},
        "_5": {3: [7, 8, 9, 10]},
        "_10": {4: [6, 7, 8]},
        "_15": {2: [1, 3, 4, 5, 6, 7, 8, 9]},
        "_20": {3: [1, 2, 3, 4, 5, 6]},
        "_25": {3: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]}
    };
    var layout = {
        "version": 2,
        "language": 'English',
        "letters": [
            'ITLISBFAMPM',
            'ACQUARTERDC',
            'TWENTYFIVEX',
            'HALFBTENFTO',
            'PASTERUNINE',
            'ONESIXTHREE',
            'FOURFIVETWO',
            'EIGHTELEVEN',
            'SEVENTWELVE',
            'TENSEOCLOCK'
        ],
        "permanent": h._it_is,
        "minutes": {
            "0,1,2,3,4": h._o_clock,
            "5,6,7,8,9": [h._5, h._past],
            "10,11,12,13,14": [h._10, h._past],
            "15,16,17,18,19": [h._15, h._past],
            "20,21,22,23,24": [h._20, h._past],
            "25,26,27,28,29": [h._25, h._past],
            "30,31,32,33,34": [h._half, h._past],
            "35,36,37,38,39": [h._25, h._to],
            "40,41,42,43,44": [h._20, h._to],
            "45,46,47,48,49": [h._15, h._to],
            "50,51,52,53,54": [h._10, h._to],
            "55,56,57,58,59": [h._5, h._to]
        },
        "hours": {
            "0,12": {9: [6, 7, 8, 9, 10, 11]},
            "1,13": {6: [1, 2, 3]},
            "2,14": {7: [9, 10, 11]},
            "3,15": {6: [7, 8, 9, 10, 11]},
            "4,16": {7: [1, 2, 3, 4]},
            "5,17": {7: [5, 6, 7, 8]},
            "6,18": {6: [4, 5, 6]},
            "7,19": {9: [1, 2, 3, 4, 5]},
            "8,20": {8: [1, 2, 3, 4, 5]},
            "9,21": {5: [8, 9, 10, 11]},
            "10,22": {10: [1, 2, 3]},
            "11,23": {8: [6, 7, 8, 9, 10, 11]}
        },
        "getHour": function (date) {
            var hour = date.getHours();
            if (date.getMinutes() >= 35) {
                return (hour + 1) % 24;
            }
            return hour;
        }
    };
    $.fritteli.uhr.register('en', layout);
}());