/*
 * Copyright (C) Schweizerische Bundesbahnen SBB, 2014.
 */

/*
 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 klokken_er = {1: [1, 2, 3, 4, 5, 6, 7, 9, 10]};
    var minutter = {4: [4, 5, 6, 7, 8, 9, 10, 11]};
    var i = {5: [8]};
    var over = {5: [4, 5, 6, 7]};
    var fem = {2: [1, 2, 3]};
    var ti = {4: [1, 2]};
    var kvart = {3: [4, 5, 6, 7, 8]};
    var tyve = {2: [4, 5, 6, 7]};
    var halv = {6: [8, 9, 10, 11]};

    var layout = {
        "version": 2,
        "language": 'Dansk',
        "letters": [
            'KLOKKENVERO',
            'FEMTYVESKLA',
            'OJEKVARTVAT',
            'TIAMINUTTER',
            'VEMOVERILMF',
            'MONALISHALV',
            'ETTOTREFIRE',
            'FEMSEKSRSYV',
            'OTTERNIMETI',
            'ELLEVEATOLV'
        ],
        "permanent": klokken_er,
        "minutes": {
            "5,6,7,8,9": [fem, minutter, over],
            "10,11,12,13,14": [ti, minutter, over],
            "15,16,17,18,19": [kvart, over],
            "20,21,22,23,24": [tyve, minutter, over],
            "25,26,27,28,29": [fem, minutter, i, halv],
            "30,31,32,33,34": [halv],
            "35,36,37,38,39": [fem, minutter, over, halv],
            "40,41,42,43,44": [tyve, minutter, i],
            "45,46,47,48,49": [kvart, i],
            "50,51,52,53,54": [ti, minutter, i],
            "55,56,57,58,59": [fem, minutter, i]
        },
        "hours": {
            "0,12": {10: [8, 9, 10, 11]},
            "1,13": {7: [1, 2]},
            "2,14": {7: [3, 4]},
            "3,15": {7: [5, 6, 7]},
            "4,16": {7: [8, 9, 10, 11]},
            "5,17": {8: [1, 2, 3]},
            "6,18": {8: [4, 5, 6, 7]},
            "7,19": {8: [9, 10, 11]},
            "8,20": {9: [1, 2, 3, 4]},
            "9,21": {9: [6, 7]},
            "10,22": {9: [10, 11]},
            "11,23": {10: [1, 2, 3, 4, 5, 6]}
        },
        "getHour": function (date) {
            var hour = date.getHours();
            if (date.getMinutes() >= 25) {
                return (hour + 1) % 24;
            }
            return hour;
        }
    };
    $.fritteli.uhr.register('dk', layout);
}(jQuery));