My favorites | Sign in
Project Home Issues
New issue   Search
for
  Advanced search   Search tips   Subscriptions

Issue 1822 attachment: fullcalendar_gemeinden.js (210 KB)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
4026
4027
4028
4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
4063
4064
4065
4066
4067
4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4084
4085
4086
4087
4088
4089
4090
4091
4092
4093
4094
4095
4096
4097
4098
4099
4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
4110
4111
4112
4113
4114
4115
4116
4117
4118
4119
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
4130
4131
4132
4133
4134
4135
4136
4137
4138
4139
4140
4141
4142
4143
4144
4145
4146
4147
4148
4149
4150
4151
4152
4153
4154
4155
4156
4157
4158
4159
4160
4161
4162
4163
4164
4165
4166
4167
4168
4169
4170
4171
4172
4173
4174
4175
4176
4177
4178
4179
4180
4181
4182
4183
4184
4185
4186
4187
4188
4189
4190
4191
4192
4193
4194
4195
4196
4197
4198
4199
4200
4201
4202
4203
4204
4205
4206
4207
4208
4209
4210
4211
4212
4213
4214
4215
4216
4217
4218
4219
4220
4221
4222
4223
4224
4225
4226
4227
4228
4229
4230
4231
4232
4233
4234
4235
4236
4237
4238
4239
4240
4241
4242
4243
4244
4245
4246
4247
4248
4249
4250
4251
4252
4253
4254
4255
4256
4257
4258
4259
4260
4261
4262
4263
4264
4265
4266
4267
4268
4269
4270
4271
4272
4273
4274
4275
4276
4277
4278
4279
4280
4281
4282
4283
4284
4285
4286
4287
4288
4289
4290
4291
4292
4293
4294
4295
4296
4297
4298
4299
4300
4301
4302
4303
4304
4305
4306
4307
4308
4309
4310
4311
4312
4313
4314
4315
4316
4317
4318
4319
4320
4321
4322
4323
4324
4325
4326
4327
4328
4329
4330
4331
4332
4333
4334
4335
4336
4337
4338
4339
4340
4341
4342
4343
4344
4345
4346
4347
4348
4349
4350
4351
4352
4353
4354
4355
4356
4357
4358
4359
4360
4361
4362
4363
4364
4365
4366
4367
4368
4369
4370
4371
4372
4373
4374
4375
4376
4377
4378
4379
4380
4381
4382
4383
4384
4385
4386
4387
4388
4389
4390
4391
4392
4393
4394
4395
4396
4397
4398
4399
4400
4401
4402
4403
4404
4405
4406
4407
4408
4409
4410
4411
4412
4413
4414
4415
4416
4417
4418
4419
4420
4421
4422
4423
4424
4425
4426
4427
4428
4429
4430
4431
4432
4433
4434
4435
4436
4437
4438
4439
4440
4441
4442
4443
4444
4445
4446
4447
4448
4449
4450
4451
4452
4453
4454
4455
4456
4457
4458
4459
4460
4461
4462
4463
4464
4465
4466
4467
4468
4469
4470
4471
4472
4473
4474
4475
4476
4477
4478
4479
4480
4481
4482
4483
4484
4485
4486
4487
4488
4489
4490
4491
4492
4493
4494
4495
4496
4497
4498
4499
4500
4501
4502
4503
4504
4505
4506
4507
4508
4509
4510
4511
4512
4513
4514
4515
4516
4517
4518
4519
4520
4521
4522
4523
4524
4525
4526
4527
4528
4529
4530
4531
4532
4533
4534
4535
4536
4537
4538
4539
4540
4541
4542
4543
4544
4545
4546
4547
4548
4549
4550
4551
4552
4553
4554
4555
4556
4557
4558
4559
4560
4561
4562
4563
4564
4565
4566
4567
4568
4569
4570
4571
4572
4573
4574
4575
4576
4577
4578
4579
4580
4581
4582
4583
4584
4585
4586
4587
4588
4589
4590
4591
4592
4593
4594
4595
4596
4597
4598
4599
4600
4601
4602
4603
4604
4605
4606
4607
4608
4609
4610
4611
4612
4613
4614
4615
4616
4617
4618
4619
4620
4621
4622
4623
4624
4625
4626
4627
4628
4629
4630
4631
4632
4633
4634
4635
4636
4637
4638
4639
4640
4641
4642
4643
4644
4645
4646
4647
4648
4649
4650
4651
4652
4653
4654
4655
4656
4657
4658
4659
4660
4661
4662
4663
4664
4665
4666
4667
4668
4669
4670
4671
4672
4673
4674
4675
4676
4677
4678
4679
4680
4681
4682
4683
4684
4685
4686
4687
4688
4689
4690
4691
4692
4693
4694
4695
4696
4697
4698
4699
4700
4701
4702
4703
4704
4705
4706
4707
4708
4709
4710
4711
4712
4713
4714
4715
4716
4717
4718
4719
4720
4721
4722
4723
4724
4725
4726
4727
4728
4729
4730
4731
4732
4733
4734
4735
4736
4737
4738
4739
4740
4741
4742
4743
4744
4745
4746
4747
4748
4749
4750
4751
4752
4753
4754
4755
4756
4757
4758
4759
4760
4761
4762
4763
4764
4765
4766
4767
4768
4769
4770
4771
4772
4773
4774
4775
4776
4777
4778
4779
4780
4781
4782
4783
4784
4785
4786
4787
4788
4789
4790
4791
4792
4793
4794
4795
4796
4797
4798
4799
4800
4801
4802
4803
4804
4805
4806
4807
4808
4809
4810
4811
4812
4813
4814
4815
4816
4817
4818
4819
4820
4821
4822
4823
4824
4825
4826
4827
4828
4829
4830
4831
4832
4833
4834
4835
4836
4837
4838
4839
4840
4841
4842
4843
4844
4845
4846
4847
4848
4849
4850
4851
4852
4853
4854
4855
4856
4857
4858
4859
4860
4861
4862
4863
4864
4865
4866
4867
4868
4869
4870
4871
4872
4873
4874
4875
4876
4877
4878
4879
4880
4881
4882
4883
4884
4885
4886
4887
4888
4889
4890
4891
4892
4893
4894
4895
4896
4897
4898
4899
4900
4901
4902
4903
4904
4905
4906
4907
4908
4909
4910
4911
4912
4913
4914
4915
4916
4917
4918
4919
4920
4921
4922
4923
4924
4925
4926
4927
4928
4929
4930
4931
4932
4933
4934
4935
4936
4937
4938
4939
4940
4941
4942
4943
4944
4945
4946
4947
4948
4949
4950
4951
4952
4953
4954
4955
4956
4957
4958
4959
4960
4961
4962
4963
4964
4965
4966
4967
4968
4969
4970
4971
4972
4973
4974
4975
4976
4977
4978
4979
4980
4981
4982
4983
4984
4985
4986
4987
4988
4989
4990
4991
4992
4993
4994
4995
4996
4997
4998
4999
5000
5001
5002
5003
5004
5005
5006
5007
5008
5009
5010
5011
5012
5013
5014
5015
5016
5017
5018
5019
5020
5021
5022
5023
5024
5025
5026
5027
5028
5029
5030
5031
5032
5033
5034
5035
5036
5037
5038
5039
5040
5041
5042
5043
5044
5045
5046
5047
5048
5049
5050
5051
5052
5053
5054
5055
5056
5057
5058
5059
5060
5061
5062
5063
5064
5065
5066
5067
5068
5069
5070
5071
5072
5073
5074
5075
5076
5077
5078
5079
5080
5081
5082
5083
5084
5085
5086
5087
5088
5089
5090
5091
5092
5093
5094
5095
5096
5097
5098
5099
5100
5101
5102
5103
5104
5105
5106
5107
5108
5109
5110
5111
5112
5113
5114
5115
5116
5117
5118
5119
5120
5121
5122
5123
5124
5125
5126
5127
5128
5129
5130
5131
5132
5133
5134
5135
5136
5137
5138
5139
5140
5141
5142
5143
5144
5145
5146
5147
5148
5149
5150
5151
5152
5153
5154
5155
5156
5157
5158
5159
5160
5161
5162
5163
5164
5165
5166
5167
5168
5169
5170
5171
5172
5173
5174
5175
5176
5177
5178
5179
5180
5181
5182
5183
5184
5185
5186
5187
5188
5189
5190
5191
5192
5193
5194
5195
5196
5197
5198
5199
5200
5201
5202
5203
5204
5205
5206
5207
5208
5209
5210
5211
5212
5213
5214
5215
5216
5217
5218
5219
5220
5221
5222
5223
5224
5225
5226
5227
5228
5229
5230
5231
5232
5233
5234
5235
5236
5237
5238
5239
5240
5241
5242
5243
5244
5245
5246
5247
5248
5249
5250
5251
5252
5253
5254
5255
5256
5257
5258
5259
5260
5261
5262
5263
5264
5265
5266
5267
5268
5269
5270
5271
5272
5273
5274
5275
5276
5277
5278
5279
5280
5281
5282
5283
5284
5285
5286
5287
5288
5289
5290
5291
5292
5293
5294
5295
5296
5297
5298
5299
5300
5301
5302
5303
5304
5305
5306
5307
5308
5309
5310
5311
5312
5313
5314
5315
5316
5317
5318
5319
5320
5321
5322
5323
5324
5325
5326
5327
5328
5329
5330
5331
5332
5333
5334
5335
5336
5337
5338
5339
5340
5341
5342
5343
5344
5345
5346
5347
5348
5349
5350
5351
5352
5353
5354
5355
5356
5357
5358
5359
5360
5361
5362
5363
5364
5365
5366
5367
5368
5369
5370
5371
5372
5373
5374
5375
5376
5377
5378
5379
5380
5381
5382
5383
5384
5385
5386
5387
5388
5389
5390
5391
5392
5393
5394
5395
5396
5397
5398
5399
5400
5401
5402
5403
5404
5405
5406
5407
5408
5409
5410
5411
5412
5413
5414
5415
5416
5417
5418
5419
5420
5421
5422
5423
5424
5425
5426
5427
5428
5429
5430
5431
5432
5433
5434
5435
5436
5437
5438
5439
5440
5441
5442
5443
5444
5445
5446
5447
5448
5449
5450
5451
5452
5453
5454
5455
5456
5457
5458
5459
5460
5461
5462
5463
5464
5465
5466
5467
5468
5469
5470
5471
5472
5473
5474
5475
5476
5477
5478
5479
5480
5481
5482
5483
5484
5485
5486
5487
5488
5489
5490
5491
5492
5493
5494
5495
5496
5497
5498
5499
5500
5501
5502
5503
5504
5505
5506
5507
5508
5509
5510
5511
5512
5513
5514
5515
5516
5517
5518
5519
5520
5521
5522
5523
5524
5525
5526
5527
5528
5529
5530
5531
5532
5533
5534
5535
5536
5537
5538
5539
5540
5541
5542
5543
5544
5545
5546
5547
5548
5549
5550
5551
5552
5553
5554
5555
5556
5557
5558
5559
5560
5561
5562
5563
5564
5565
5566
5567
5568
5569
5570
5571
5572
5573
5574
5575
5576
5577
5578
5579
5580
5581
5582
5583
5584
5585
5586
5587
5588
5589
5590
5591
5592
5593
5594
5595
5596
5597
5598
5599
5600
5601
5602
5603
5604
5605
5606
5607
5608
5609
5610
5611
5612
5613
5614
5615
5616
5617
5618
5619
5620
5621
5622
5623
5624
5625
5626
5627
5628
5629
5630
5631
5632
5633
5634
5635
5636
5637
5638
5639
5640
5641
5642
5643
5644
5645
5646
5647
5648
5649
5650
5651
5652
5653
5654
5655
5656
5657
5658
5659
5660
5661
5662
5663
5664
5665
5666
5667
5668
5669
5670
5671
5672
5673
5674
5675
5676
5677
5678
5679
5680
5681
5682
5683
5684
5685
5686
5687
5688
5689
5690
5691
5692
5693
5694
5695
5696
5697
5698
5699
5700
5701
5702
5703
5704
5705
5706
5707
5708
5709
5710
5711
5712
5713
5714
5715
5716
5717
5718
5719
5720
5721
5722
5723
5724
5725
5726
5727
5728
5729
5730
5731
5732
5733
5734
5735
5736
5737
5738
5739
5740
5741
5742
5743
5744
5745
5746
5747
5748
5749
5750
5751
5752
5753
5754
5755
5756
5757
5758
5759
5760
5761
5762
5763
5764
5765
5766
5767
5768
5769
5770
5771
5772
5773
5774
5775
5776
5777
5778
5779
5780
5781
5782
5783
5784
5785
5786
5787
5788
5789
5790
5791
5792
5793
5794
5795
5796
5797
5798
5799
5800
5801
5802
5803
5804
5805
5806
5807
5808
5809
5810
5811
5812
5813
5814
5815
5816
5817
5818
5819
5820
5821
5822
5823
5824
5825
5826
5827
5828
5829
5830
5831
5832
5833
5834
5835
5836
5837
5838
5839
5840
5841
5842
5843
5844
5845
5846
5847
5848
5849
5850
5851
5852
5853
5854
5855
5856
5857
5858
5859
5860
5861
5862
5863
5864
5865
5866
5867
5868
5869
5870
5871
5872
5873
5874
5875
5876
5877
5878
5879
5880
5881
5882
5883
5884
5885
5886
5887
5888
5889
5890
5891
5892
5893
5894
5895
5896
5897
5898
5899
5900
5901
5902
5903
5904
5905
5906
5907
5908
5909
5910
5911
5912
5913
5914
5915
5916
5917
5918
5919
5920
5921
5922
5923
5924
5925
5926
5927
5928
5929
5930
5931
5932
5933
5934
5935
5936
5937
5938
5939
5940
5941
5942
5943
5944
5945
5946
5947
5948
5949
5950
5951
5952
5953
5954
5955
5956
5957
5958
5959
5960
5961
5962
5963
5964
5965
5966
5967
5968
5969
5970
5971
5972
5973
5974
5975
5976
5977
5978
5979
5980
5981
5982
5983
5984
5985
5986
5987
5988
5989
5990
5991
5992
5993
5994
5995
5996
5997
5998
5999
6000
6001
6002
6003
6004
6005
6006
6007
6008
6009
6010
6011
6012
6013
6014
6015
6016
6017
6018
6019
6020
6021
6022
6023
6024
6025
6026
6027
6028
6029
6030
6031
6032
6033
6034
6035
6036
6037
6038
6039
6040
6041
6042
6043
6044
6045
6046
6047
6048
6049
6050
6051
6052
6053
6054
6055
6056
6057
6058
6059
6060
6061
6062
6063
6064
6065
6066
6067
6068
6069
6070
6071
6072
6073
6074
6075
6076
6077
6078
6079
6080
6081
6082
6083
6084
6085
6086
6087
/*
* Community calendars
* Add-on for the Full calendar plug-in
* version 0.8.7.3
* by Joseph Bolin, 2014-7-2
*
* To use: call $(object).calendarGemeinden(options)
* See the bottom of this code for the possible options
*
*/

if (!String.prototype.trim) {
String.prototype.trim = function() {
return this.replace(/^\s+|\s+$/g, '');
};
}

(function($, undefined) {
var recordInfoAddress;
var recordErrorAddress;
var userId;
var sessionId;
var cg = $.calendarGemeinden = {version: "0.8.7.3"};
$.fn.calendarGemeinden = function(options) {
if (typeof options == 'string') {
var args = Array.prototype.slice.call(arguments, 1);
var res;
this.each(function() {
var calendar = $.data(this, 'calendarGemeinden');
if (calendar && $.isFunction(calendar[options])) {
var r = calendar[options].apply(calendar, args);
if (res === undefined) {
res = r;
}
if (options == 'destroy') {
$.removeData(this, 'calendarGemeinden');
}
}
});
if (res !== undefined) {
return res;
}
return this;
}
this.each(function(i, _element) {
var element = $(_element);
var calendar = new calendarGemeinden(element, options);
element.data('calendarGemeinden', calendar); // TODO: look into memory leak implications
});

return this;
};


function mergeEventTypes(types, defaultTypes) {
var i,j;
for (i=0; i<types.length; i++) {
if (types[i].test === undefined) {
for (j=0; j<defaultTypes.length; j++) {
if (defaultTypes[j].id === types[i].id) {
types[i] = $.extend({}, defaultTypes[j], types[i]);
}
}
}
}
}

function loadModules(modules) {
var i;
for (i=0; i < modules.length; i++) {
$.getScript(modules[i], function() {
});
}
}
function calendarGemeinden(element, options) {
var t = this;
// options
var calendarGemeindenDefaults;
var calendarFunctionString;
options = options || {};
setupDefaults(options.calendarDiv);
if (options.eventTypes) {
mergeEventTypes(options.eventTypes, calendarGemeindenDefaults.eventTypes);
}
if (options.agendaList) {
options.agendaList = $.extend({}, calendarGemeindenDefaults.agendaList, options.agendaList);
}
var calendarGemeindenOptions = $.extend({}, calendarGemeindenDefaults, options);
options = calendarGemeindenOptions;

// exports
t.selectAllCalendars = selectAllCalendars;
t.selectNoCalendars = selectNoCalendars;
t.showLocationDetails = showLocationDetails;
t.displayCalendarLocation = displayCalendarLocation;
t.changeCalendars = changeCalendars;
t.getCalendars = getCalendars;
t.getCalendarsByName = getCalendarsByName;
t.displayFixedCalendar = displayFixedCalendar;
t.allLocationEvents = allLocationEvents;
t.addLocations = addLocations;
t.addCalendars = addCalendars;
t.restrictSearchLocationManual = restrictSearchLocationManual;
t.updateWhatToDisplay = updateWhatToDisplay;
t.updateSearchLocationChanging = updateSearchLocationChanging;
t.updateSearchFilterChanging = updateSearchFilterChanging;
t.updateSearchFilterDone = updateSearchFilterDone;
t.updateSearchLocationDone = updateSearchLocationDone;
t.restrictVisibleChange = restrictVisibleChange; // Should be called if a change occurs in whether events are being restricted to visible locations
t.displayArea = displayArea;
t.addSearchLocationManual = addSearchLocationManual;
t.isSearchLocationRestricted = isSearchLocationRestricted;
t.isSearchLocationCalendarRestricted = isSearchLocationCalendarRestricted;
t.isLocationCalendarExclusive = isLocationCalendarExclusive;
t.isAdditionalSearchFilter = isAdditionalSearchFilter;
t.isAdditionalLocation = isAdditionalLocation;
t.calendarsForLocation = calendarsForLocation;
t.allCalendarsForLocation = allCalendarsForLocation;
t.calendarsDisplayedForLocation = calendarsDisplayedForLocation;
t.areCalendarsForLocationVisible = areCalendarsForLocationVisible;
t.getVisibleLocations = getVisibleLocations;
t.getVisibleCalendars = getVisibleCalendars;
t.restrictCalendars = restrictCalendars;
t.restrictCalendarsToLocation = restrictCalendarsToLocation;
t.addSearchLocation = addSearchLocation;
t.moveCalendarToFixedList = moveCalendarToFixedList;
t.isEventType = isEventType;
t.compareFilter = compareFilter;
t.nowVisible = nowVisible;
t.nowNotVisible = nowNotVisible;
t.displayCalendar = displayCalendar;
t.notDisplayCalendar = notDisplayCalendar;
t.googleMapOn = googleMapOn;
t.getCalendarOptionsDiv = getCalendarOptionsDiv;
t.queue = queue;

var localStorageCustom;
var _localStorageCustom;
var calendarDiv = options.calendarDiv;
var calendarDivId = calendarDiv.replace("#", "");
var extraGemeindenAutomatischDivId = 'extra_gemeinden_automatisch_' + calendarDivId;
var extraGemeindenAutomatischDiv = '#' + extraGemeindenAutomatischDivId;
var extraGemeindenSelectedDivId = 'extra_gemeinden_selected_' + calendarDivId;
var extraGemeindenSelectedDiv = '#' + extraGemeindenSelectedDivId;
var extraGemeindenAvailableDivId = 'extra_gemeinden_available_' + calendarDivId;
var extraGemeindenAvailableDiv = '#' + extraGemeindenAvailableDivId;
var gemeindenFixedDivId = 'gemeinden_fixed' + calendarDivId;
var gemeindenFixedDiv = '#' + gemeindenFixedDivId;
var afterGemeindenDivId = 'after_gemeinden' + calendarDivId;
var afterGemeindenDiv = '#' + afterGemeindenDivId;
var mapCalendarsDiv = calendarGemeindenOptions.mapCalendarsDiv;
var gmapIconCalendarsId = 'gmap_on_' + calendarDivId;
var terminauswahlId = 'terminauswahl_' + calendarDivId;
var currentFilterId;
var filterId = 'filter_' + calendarDivId;
var filterLocationId = 'filter_location_' + calendarDivId;
var datePickerDiv = '#datepicker_' + calendarDivId;
var gemeindenSelectDiv = '#gemeinden_select_' + calendarDivId;
var calendarOptionsDiv = options.calendarOptionsDiv;
var loadingDiv = options.loadingDiv;
var maxWidth = options.maxWidth || {};
var agendaListOptions = options.agendaList || {};
var agendaMaxWidth = agendaListOptions.maxWidth;
var headerMaxWidth = maxWidth.header;
var optionsMaxWidth = maxWidth.options;
var helperId = false;
var newItem;
var style;
if (headerMaxWidth !== undefined) {
style = $('<style>' + calendarDiv + ' .fc-header {max-width: ' + headerMaxWidth + '; }</style>');
$('html > head').append(style);
}
if (optionsMaxWidth !== undefined) {
style = $('<style>' + calendarOptionsDiv + '.calendar-options {max-width: ' + optionsMaxWidth + '; }</style>');
$('html > head').append(style);
}
var cloneDate = $.fullCalendar.cloneDate;
var calendarMessageDiv = options.calendarMessageDiv;
recordInfoAddress = options.recordInfoAddress;
recordErrorAddress = options.recordErrorAddress;
var storeOptionsLocally = calendarGemeindenOptions.storeOptionsLocally
var storeCalendarDuration = options.storeCalendarDuration;
var storeCalendarOrderDuration = options.storeCalendarOrderDuration;
var storeFilterDuration = options.storeFilterDuration;
var shortLocations = options.shortLocations;
var repeatWeekDaysAfterManyEvents = options.repeatWeekDaysAfterManyEvents;
var calendarVisible = options.calendarVisible;
var calendarMessageHidden = '';
if (typeof (shortLocations) === 'function') {
shortLocation = shortLocations;
}
var restrictedToVisibleMap = options.restrictedToVisibleMap;
var restrictToVisibleMap = options.restrictToVisibleMap;
var notRestrictToVisibleMap = options.notRestrictToVisibleMap;
var eventTypes = options.eventTypes;

var calendarOnceVisible = false;
var timerIsLoading;
var filterChanging = false;
var locationChanging = false;
var timerCalendarMessage;
var eventsCountFilteredOut;
var calendarsDisplayedCount;
var eventsCount, eventsPerDay = [];
var eventsPerDayCalendar = [];
var eventsPerCategoryCalendar = [];
var formatDate = $.fullCalendar.formatDate;

var calOrderIds = [];
var calendarLoading;
var calendarsLoading;
var functionQueue = [];
var functionTimer;
var timerRunning = false;
var eventHoverTimer;
var googleMapDrawn;
// Variables related to filtering
var filterText = '';
var filterWords = [], filterWordsExpanded = [];
var filterLocationText = '';
var filterLocations = [], filterLocationsExpanded = [];
var displayFilterLocation = options.displayFilterLocation;
var filterEventType;
var defaultFilter = options.defaultFilter;
var filterEventId = '';
var timerDelayRefresh;

// Variables related to google maps
var myMap;
var googleMaps = options.googleMaps;
var googleMapsDialog = options.googleMapsDialog;
var googleMapReady = false;
var googleMapIsOn = false;
var googleMapContainer = options.mapContainer;
var googleMapLocation;
var defaultMapIcons = options.defaultMapIcons;
var areas = options.areas;
var selectedEvent = {};
var infowindow;
var currentMarker;
var currentLocation = false;

var equivalentSearchs = options.equivalentSearchs;

var phrases = []; // a list of phrases that should be treated as a single search term -- a specific location, etc.
var feastdays = {}; // will be set up with the various feast days

// Feed id is used when a feed should be cached on an intermediate server - cacheServer gives the URL of the caching server
var calendars = options.calendars;
var locationInfo = options.locations;
loadModules(options.modules || []);

// General functions
function queue(f, delay, id) {
// if id is supplied, it is understood as a unique id -- if added a second time, it won't be performed a second time
if (delay === undefined) {
delay = 0;
}
if (id !== undefined) {
for (var i = 0; i < functionQueue.length; i++) {
if (functionQueue[i].id === id) {
return false; // Hasn't been added
}
}
}
functionQueue.push({myfunction: f, time: new Date().getTime() + delay, id: id});
if (timerRunning === false) {
timerRunning = true;
functionTimer = setTimeout(processQueue, 20);
}
}

function processQueue() {
var f;
var newQueue = [];
var time = new Date().getTime();
for (f = 0; f < functionQueue.length; f++) {
if (functionQueue[f].time < time) {
functionQueue[f].myfunction();
} else {
newQueue.push(functionQueue[f]);
}
}
functionQueue = newQueue;
if (functionQueue.length > 0) {
functionTimer = setTimeout(processQueue, 20);
} else {
timerRunning = false;
}
}

function subtractArraysObjects(wholeArray, partArray, key) {
// Returns a new array composed of the objects in wholeArray, minus those which are in partArray
var i, merge = [], m, keyArray = {};
m = 0;
for (i = 0; i < partArray.length; i++) {
keyArray[partArray[i][key]] = true;
}
for (i = 0; i < wholeArray.length; i++) {
if (keyArray[wholeArray[i][key]] !== true) {
merge[m++] = wholeArray[i];
}
}
return merge;
}
function mergeArraysObjects(array1, array2, key) {
// Returns a new array composed of objects, removing objects that have the same value for the key
var i, merge = [], m, keyArray = {};
m = 0;
for (i = 0; i < array1.length; i++) {
if (keyArray[array1[i][key]] !== true) { // Remove any duplicates from the first array
merge[m++] = array1[i];
keyArray[array1[i][key]] = true;
}
}
for (i = 0; i < array2.length; i++) {
if (keyArray[array2[i][key]] !== true) {
merge[m++] = array2[i];
keyArray[array2[i][key]] = true;
}
}
return merge;
}

function objectToLowerCase(obj) {
// Accepts arrays or strings, and converts them to lower case
var newArray = [], i;
if (typeof (obj) === 'string') {
return obj.toLowerCase();
} else {
for (i = 0; i < obj.length; i++) {
newArray[i] = objectToLowerCase(obj[i]);
}
return newArray;
}
}

function searchInObject(obj, search) {
// If the STRING case-insensitive search term is found in obj, which is a string, returns the index of the string
// If found in obj, which is an array, returns the index of the array in which it is found
// Otherwise returns -1
// Would be marginally more efficient if the lower case of the search term is found only once
var index;
if (typeof (obj) === 'string') {
return obj.toLowerCase().indexOf(search.toLowerCase());
} else {
for (var i = 0; i < obj.length; i++) {
index = searchInObject(obj[i], search);
if (index !== -1) {
return i; // Already found
}
}
return -1; // Did not find within the array
}
}

// General display functions
var overlaps = (function() {
function getPositions(elem) {
var pos, width, height;
pos = $(elem).offset();
width = $(elem).width();
height = $(elem).height();
return [[pos.left, pos.left + width], [pos.top, pos.top + height]];
}

function comparePositions(p1, p2) {
var r1, r2;
r1 = p1[0] < p2[0] ? p1 : p2;
r2 = p1[0] < p2[0] ? p2 : p1;
return r1[1] > r2[0] || r1[0] === r2[0];
}

return function(a, b) {
var pos1 = getPositions(a),
pos2 = getPositions(b);
return comparePositions(pos1[0], pos2[0]) && comparePositions(pos1[1], pos2[1]);
};
})();

// General interface functions
var leftButtonDown;
$(document).mousedown(function(e) {
if (e.which === 1)
leftButtonDown = true;
});
$(document).mouseup(function(e) {
if (e.which === 1)
leftButtonDown = false;
});

// Functions for dealing with calendars
function subtractCalendars(allCalendars, subtractCalendars) {
return subtractArraysObjects(allCalendars, subtractCalendars, 'id');
}
function mergeCalendars(cal1, cal2) {
return mergeArraysObjects(cal1, cal2, 'id');
}
function getCalendarByName(calName) {
// Returns the first calendar object with calName, or FALSE
var c;
if (typeof (calName) === 'string') {
for (c = 0; c < calendars.length; c++) {
if (calendars[c].id === calName) {
return calendars[c];
}
}
} else if (typeof (calName) === 'string') {
return getCalendarsByName(calName);
}
return false;
}
function getCalendarsByName(calName) {
// Returns an empty array or the array of calendars with the names in the array or string calName
var c, cal, cals;
if (typeof (calName) === 'object') {
cals = [];
for (c = 0; c < calName.length; c++) {
cal = getCalendarByName(calName[c]);
if (cal !== false) {
cals.push(cal);
}
}
return cals;
} else {
cals = getCalendarByName(calName);
if (cals === false) {
return [];
}
return [cals];
}
}

function restrictCalendars(calArray) {
// displays only the calendars in the array calendars
var removeCals, removedCals = [];
removeCals = subtractCalendars(calendars, calArray);
for (var c = 0; c < removeCals.length; c++) {
if (removeCals[c].display === true) {
removedCals.push(removeCals[c]);
}
notDisplayCalendar(removeCals[c], 10); // Outside the check in case changes have been made while event sources are still loading
}
return removedCals;
}

function restrictCalendarsToLocation(locations, additionalCalendars) {
// Shows only the calendars that could have events in the location(s)
var c, l, removedCals = [], cals, removeCals = [], cals;
cals = allCalendarsForLocation(locations);
cals = mergeCalendars(cals, additionalCalendars);
removeCals = subtractCalendars(calendars, cals);
for (c = 0; c < removeCals.length; c++) {
if (removeCals[c].display === true) {
removedCals.push(removeCals[c]);
}
notDisplayCalendar(removeCals[c], 10);
}
if (removedCals.length === 0) {
removedCals = false;
}
return removedCals;
}

function getCalendarOptionsDiv() {
return calendarOptionsDiv;
}

// functions dealing with google map
function setMapDroppable() {
$(googleMapContainer).droppable({
//accept: gemeindenFixedDiv + ' .singlecalendar',
//accept: ' .singlecalendar',
accept: function(element) {
if ($(element).closest(mapCalendarsDiv).length > 0) {
return false;
}
return true;
},
drop: function(event, ui) {
var cal;
var id;
if (helperId) {
id = helperId;
} else {
id = ui.draggable.attr('id');
}
cal = getCalendarByDomId(id);
if (cal.selectBox === false) {
return false; //
}
if (restrictedToVisibleMap()) {
if (cal.locationVisible === true) {
moveDroppedCalendarToList(cal, ui.draggable, ui.helper, extraGemeindenAutomatischDiv);
} else {
removeDroppedCalendar(cal, ui.draggable, ui.helper, googleMapContainer);
queue(function() {
notDisplayCalendar(cal);
}
);
}
} else if (cal.display === true) {
moveDroppedCalendarToList(cal, ui.draggable, ui.helper, extraGemeindenSelectedDiv);
} else {
moveDroppedCalendarToList(cal, ui.draggable, ui.helper, extraGemeindenAvailableDiv);
}
//helperId = false;
$(gemeindenFixedDiv).find('.ui-sortable-placeholder').remove();
$(gemeindenFixedDiv).sortable('refresh');
$(gemeindenFixedDiv).sortable('refreshPositions');
$(this).removeClass("droppable");
return true;
},
activate: function(event, ui) {
$(this).addClass('droppable');
if (googleMapsDialog === false) {
$(this).css("max-width", ($(this).width() - 12) + "px"); // to ensure that multiple divs still fit horizontally
}
},
deactivate: function(event, ui) {
$(this).removeClass("droppable");
//$(this).css( "max-width", ($(this).width() - 8) + "px" );
$(this).css("max-width", "none");
}
}
);
}

function getLocationDetails(location) {
var moreContent;
var autogenerated;
location = (typeof location === "undefined") ? currentLocation : location;
if (location === false) {
return false;
}
var fixedInfoAfter;
var fixedInfoBefore = '<a onclick="$(\'#more_location_details\').btOff();">' +
calendarGemeindenOptions.locationDetailsCloseGraphic + '</a>';
if (typeof (calendarGemeindenOptions.getLocationViewOptions) === 'function') {
fixedInfoAfter = calendarGemeindenOptions.getLocationViewOptions(location);
} else {
fixedInfoAfter = '';
}
autogenerated = typeof (location.eventList) !== 'undefined';
$.each(getCalendarsByName(location.calendar), function(index, cal) {
autogenerated = autogenerated || (typeof (location.eventList) !== 'undefined');
});
if (autogenerated === true) {
fixedInfoAfter = calendarGemeindenOptions.automaticLocationNotice + fixedInfoAfter;
}
moreContent = fixedInfoBefore + location.moreInfo + fixedInfoAfter;
if (location.moreInfo === undefined && fixedInfoAfter === '') {
return false;
}
return moreContent;
}
function setLocationDetails(location) {
// location is the location object
var info = getLocationDetails(location);
var nowActive;
if (info !== false) {
if ($('#more_location_details').hasClass('bt-active')) {
nowActive = true;
} else {
nowActive = false;
}
$("#more_location_details").bt(info, calendarGemeindenOptions.locationDetailsTipOptions);
if (nowActive)
$('#more_location_details').btOn();
}
}

function getLocationById(locationId) {
// used with a STRING locationId, returns FALSE or the corresponding location object -- used with an array of strings, returns an array of location objects
var i, locs, loc;
if (typeof (locationId) === 'string') {
var locLower = locationId.toLowerCase();
for (i = 0; i < locationInfo.length; ++i) {
if (locationInfo[i].id === locationId) {
return locationInfo[i];
}
}
} else if (typeof (locationId) === 'object') {
return getLocationsById(locationId);
}
return false;
}

function getLocationsById(locationIds) {
// locationNames can be a string or an array;
// Returns an array of the corresponding locations
var i, loc, locs;
if (typeof (locationIds) === 'undefined') {
return [];
} else if (typeof (locationIds) === 'string') {
loc = getLocationById(locationIds);
if (loc === false) {
return [];
}
return [loc];
} else {
locs = [];
for (i = 0; i < locationIds.length; ++i) {
loc = getLocationById(locationIds[i]);
if (loc !== false) {
locs.push(loc);
}
}
}
return locs;
}

function getLocationByName(locationName) {
// gets a single location by name
var i;
if (typeof (locationName) === 'string') {
var locLower = locationName.toLowerCase();
for (i = 0; i < locationInfo.length; ++i) {
if (locationInfo[i].description.toLowerCase() === locLower) {
return locationInfo[i];
}
if (locationInfo[i].id.toLowerCase() === locLower) {
return locationInfo[i];
}
}
} else if (typeof (locationName) === 'object') {
return getLocationsByName(locationName);
}
return false;
}

function getLocationsByName(locationNames) {
// locationNames can be a string or an array;
// Returns an array of the corresponding locations
var i, loc, locs;
if (typeof (locationNames) === 'undefined') {
return [];
} else if (typeof (locationNames) === 'string') {
loc = getLocationByName(locationNames);
if (loc === false) {
return [];
}
return [loc];
} else {
locs = [];
for (i = 0; i < locationNames.length; ++i) {
loc = getLocationByName(locationNames[i]);
if (loc !== false) {
locs.push(loc);
}
}
}
return locs;
}

function getLocation(locationRef) {
// trys to get location by id, if that fails, then by name
var location;
location = getLocationById(locationRef);
if (location === false) {
location = getLocationByName(locationRef);
}
return location;
}

function getCoords(location) {
// location is the location object
if (typeof (location) !== 'object') {
return false;
}
var coords = location.coords;
if (coords === undefined) {
return false;
}
return coords.split(",");
}

function getMarkerLocation(marker) {
var i;
for (i = 0; i < locationInfo.length; ++i) {
if (locationInfo[i].marker === marker) {
return locationInfo[i];
}
}
return false;
}

function showLocationDetails() {
if ($('#more_location_details').hasClass('bt-active')) {
$('#more_location_details').btOff();
} else {
$('#more_location_details').btOn();
}
}

var standardShape = {
coords: [19, 0, 24, 5, 24, 12, 18, 21, 16, 31, 14, 31, 12, 20, 6, 12, 6, 6, 11, 0],
type: 'poly'
};
function setPin(location, markerIcon)
{
var coords;
var popUpContent;
var marker;
var locationId;

var myLatlng = location.latLng;
if (myLatlng === undefined) {
coords = location.coords.split(",");
myLatlng = new google.maps.LatLng(coords[0], coords[1]);
location.latLng = myLatlng;
}
if (typeof (markerIcon) === 'string') {
marker = new google.maps.Marker({
position: myLatlng,
map: myMap,
title: location.description,
icon: markerIcon,
shape: standardShape
});
} else {
marker = new google.maps.Marker({
position: myLatlng,
map: myMap,
title: location.description,
icon: markerIcon.icon,
shape: markerIcon.shape
});
}
popUpContent = location.info;
var wrapper = document.createElement('div');
wrapper.className = 'info-window';
if (location.moreInfo === undefined || location.moreInfo === '') {
wrapper.innerHTML = popUpContent;
} else {

wrapper.innerHTML = popUpContent + '<div id="more_location_details" onclick="' + calendarFunctionString + '(\'showLocationDetails\')"><p>Mehr Details</p></div>';
}
location.popupInfo = wrapper;
locationId = location.id;
if (popUpContent !== undefined && popUpContent !== '') {
google.maps.event.addListener(marker, 'click', function() {
$("#more_location_details").btOff(); // Close the pop up on any previous window
var view = $(calendarDiv).fullCalendar('getView');
if (view.name === 'agendaList' && view.getAgendaListOrder() !== 'times') {
var obj = $(calendarDiv).find(".fc-eventlist-title." + locationId);
if (obj.length > 0) {
var highest = 999999;
var lowest = -999999;
var top;
var bottom;
var scroll;
var viewHeight = $(calendarDiv).find('.fc-view').height();
obj.each(function()
{
top = $(this).position().top;
bottom = top + $(this).height();
if (top <= highest) {
highest = top;
}
if (bottom > lowest) {
lowest = bottom;
}
}
);
if (highest < 0 && lowest >= viewHeight) { // Flows above top and bottom
scroll = 0;
} else if (highest >= 0 && lowest < viewHeight) {
scroll = 0; // All are already visible
} else {
if (lowest - highest >= viewHeight) {
if (highest < 0) {
scroll = highest; // Scroll to top
} else {
scroll = lowest - viewHeight - 16; // Scroll to bottom
}
} else {
scroll = (highest + lowest - viewHeight) / 2; // Scroll to middle;
}
}
if (scroll >= 0 && scroll < 40) {
scroll = 0;
}

if (scroll) {
$(calendarDiv).find('.fc-view').animate({
scrollTop: Math.max(scroll + $(calendarDiv).find('.fc-view').scrollTop() - 4, 0)
}, 600);
}
}
}
infowindow.setContent(wrapper);
infowindow.open(myMap, marker);
currentMarker = marker;
});
}
return marker;
}
function setLocationPin(location) {
/* Sets or reset the location marker pin for a given location
* normal locations for which events are presently shown use the icon "standard" (red),
* for which no events are shown "noEvents" (transparent faded red),
* and the selected location is the icon source "selected" (blue);
* Icon sources can be associated with a location; otherwise they are taken from defaults
* */
var markerIcon;
var iconSources;
if (location.area !== undefined) {
if (location.area.visible === false && location.area.forceLocsVisible === false) {
return; // Area is shown rather than the individual locations
}
}
if (location.icons === undefined) {
iconSources = defaultMapIcons;
} else {
iconSources = location.icons;
}
//if (selectedEvent.locationId === location.description || selectedEvent.shortLocation === location.description) {
if (selectedEvent.locationId === location.id) {
markerIcon = iconSources.selected;
} else {
if (location.numberEvents > 0) {
markerIcon = iconSources.standard;
if (markerIcon === undefined) {
markerIcon = iconSources.standard;
}
} else {
markerIcon = iconSources.noEvents;
if (markerIcon === undefined) {
markerIcon = iconSources.standard;
}
}
}
if (location.marker === undefined) {
location.marker = setPin(location, markerIcon); // Set the marker for the first time
}
else {
if (location.marker.getVisible() === false) {
location.marker.setVisible(true);
}
if (location.marker.getIcon() !== markerIcon) {
location.marker.setIcon(markerIcon.icon); // Set the type of pin according as whether the event is selected or not, etc.
location.marker.setShape(markerIcon.shape); // Set the shape of pin according as whether the event is selected or not, etc.
}
}

if (selectedEvent.shortLocation === location.description) {
location.oldZIndex = location.marker.getZIndex();
location.marker.setZIndex(google.maps.Marker.MAX_ZINDEX + 1);
} else {
if (location.oldZIndex > 0) {
location.marker.setZIndex(location.oldZIndex);
location.oldZIndex = 0;
}
}
}
function removeLocationPin(location) {
if (location.marker !== undefined && location.marker !== null) {
location.marker.setVisible(false);
//location.marker.setMap(null);
//location.marker = null;
}
}

function setLocationPins() {
var i;
if (googleMapIsOn === false) {
return;
}
for (i = 0; i < locationInfo.length; ++i)
setLocationPin(locationInfo[i]);
}

var mapDragging;

function initializePolygon(area) {
var coords;
var fillColor;
if (area.fillColor === undefined) {
fillColor = '#5555FF';
} else {
fillColor = area.fillColor;
}
area.visible = true;
area.forceLocsVisible = false;
area.poly = new google.maps.Polygon({
strokeWeight: 3,
fillColor: fillColor,
fillOpacity: 0.2,
visible: false
});
var poly = area.poly;
poly.setMap(myMap);
var latLng;
if (area.path === undefined) {
area.path = new google.maps.MVCArray;
}
if (area.markers === undefined) {
area.markers = [];
}
if (area.points === undefined) {
area.points = [];
}
var points = area.points;
var markers = area.markers;
var path = area.path;
for (var i = 0; i < points.length; i++) {
coords = points[i].split(',');
latLng = new google.maps.LatLng(coords[0], coords[1]);
area.path.push(latLng);
/*var marker = new google.maps.Marker({
position: latLng,
map: myMap,
draggable: true
});
markers.push(marker);
google.maps.event.addListener(marker, 'click', function() {
marker.setMap(null);
for (var i = 0, I = markers.length; i < I && markers[i] != marker; ++i);
markers.splice(i, 1);
area.path.removeAt(i);
}
);

google.maps.event.addListener(marker, 'dragend', function() {
for (var i = 0, I = markers.length; i < I && markers[i] != marker; ++i);
path.setAt(i, marker.getPosition());
}
);*/
}
poly.setPaths(new google.maps.MVCArray([path]));
google.maps.event.addListener(poly, 'click', function(event) {
//outputPolygon(event,area);
showAreaDescription(event, area);
});
infoWindow = new google.maps.InfoWindow({disableAutoPan: true});
infoWindow.area = false;
}

function initializeAreas() {
for (var i = 0; i < areas.length; i++) {
initializePolygon(areas[i]);
}
//google.maps.event.addListener(myMap, 'click', function(event) {
// addPoint(event,areas[2]);
// });
}
var infoWindow;

function displayArea(areaNumber) {
if (areaNumber === -1) {
return;
}
var area = areas[areaNumber];
area.forceLocsVisible = true;
infoWindow.close();
//updateAreaDescription(area);
updateAreas();
restrictVisibleChange();
}

function getAreaNumber(area) {
for (var i = 0; i < areas.length; i++) {
if (areas[i] === area) {
return i;
}
}
return -1;
}
function updateAreaDescription(area) {
var contentString = area.description;
var areaNumber = getAreaNumber(area);
if (area.forceLocsVisible === false) {
contentString += '<span id="show_this_area"><br/>Die Orte in diesem Vikariat wurden automatisch ausgeblendet;' +
'<br/>Sie können heranzoomen, oder diese Orte ' +
'<a onclick="' + calendarFunctionString + '(\'displayArea\', \'' + areaNumber + '\')">manuell einblenden</a> (kann bei manchen Rechnern länger dauern)</span><br/> ';
}
infoWindow.setContent(contentString);
infoWindow.open(myMap);
infoWindow.area = area;
}

function showAreaDescription(event, area) {
infoWindow.setPosition(event.latLng);
updateAreaDescription(area);
}

function outputPolygon(event, area) {
// Since this polygon has only one path, we can call getPath()
// to return the MVCArray of LatLngs.
var poly = area.poly;
var vertices = poly.getPath();

var contentString = 'Clicked location: <br>' + event.latLng.lat() + ',' + event.latLng.lng() +
'<br>';

// Iterate over the vertices.
for (var i = 0; i < vertices.getLength(); i++) {
var xy = vertices.getAt(i);
contentString += '<br>"' + xy.lat() + ',' +
xy.lng() + '",';
}

// Replace the info window's content and position.
infoWindow.setContent(contentString);
infoWindow.setPosition(event.latLng);
infoWindow.open(myMap);
}

function addPoint(event, area) {
var path = area.path;
var markers = area.markers;
path.insertAt(path.length, event.latLng);

var marker = new google.maps.Marker({
position: event.latLng,
map: myMap,
draggable: true
});
markers.push(marker);
marker.setTitle("#" + path.length);
//outputPolygon(event);

google.maps.event.addListener(marker, 'click', function() {
marker.setMap(null);
for (var i = 0, I = markers.length; i < I && markers[i] != marker; ++i)
;
markers.splice(i, 1);
path.removeAt(i);
}
);

google.maps.event.addListener(marker, 'dragend', function() {
for (var i = 0, I = markers.length; i < I && markers[i] != marker; ++i)
;
path.setAt(i, marker.getPosition());
}
);
}

function isInVienna(latLng) {
// Vienna is approximately 48.298057, 16.478345 to 48.132086, 16.246087
var area = getArea(latLng);
if (area === false) { // area not defined; do it approximately
var lat = latLng.lat();
var lng = latLng.lng();
if (lat > 48.132086 && lat < 48.298057 && lng > 16.246087 && lng < 16.478345) {
return true;
}
return false;
}
if (area.description === 'Vikariat Wien Stadt') {
return true;
} else {
return false;
}
}

function selectFirstResult() {
var firstResult = $(".pac-container .pac-item:first").text();
var geocoder = new google.maps.Geocoder();
geocoder.geocode({"address": firstResult}, function(results, status) {
if (status === google.maps.GeocoderStatus.OK) {
var lat = results[0].geometry.location.lat(),
lng = results[0].geometry.location.lng(),
placeName = results[0].address_components[0].long_name,
latlng = new google.maps.LatLng(lat, lng);
//var bounds = new google.maps.LatLngBounds();
var bounds = new google.maps.LatLngBounds(
latlng,
new google.maps.LatLng(lat, lng)
);
fitMapToBounds(bounds);
//moveMarker(placeName, latlng);
$("#pac-input").val(firstResult);
}
});
}
function fitMapToBounds(bounds) {
var northEast = bounds.getNorthEast();
var southWest = bounds.getSouthWest();
if (northEast.equals(southWest)) { // ensure a minimum size of the view window
var distance;
if (isInVienna(northEast)) {
distance = 0.009; // Greater location density in Vienna, so make the viewport smaller
} else {
distance = 0.027;
}
var extendPoint1 = new google.maps.LatLng(northEast.lat() + distance, northEast.lng() + distance);
var extendPoint2 = new google.maps.LatLng(northEast.lat() - distance, northEast.lng() - distance);
bounds.extend(extendPoint1);
bounds.extend(extendPoint2);
}
mapDragging = true;
myMap.fitBounds(bounds);
}
function initializeMapSearch() {
if (areas.length === 0) {
return;
}
var markers = [];
var input = /** @type {HTMLInputElement} */(
document.getElementById('pac-input'));
myMap.controls[google.maps.ControlPosition.TOP_LEFT].push(input);
//var searchBox = new google.maps.places.SearchBox(
var options = {
//types: ['locality','sublocality','postal_code','administrative_area1','administrative_area2','administrative_area3'],
types: ['(regions)'],
componentRestrictions: {country: 'at'}
};
var searchBox = new google.maps.places.Autocomplete(
/** @type {HTMLInputElement} */input, options);
//searchBox.bindTo('bounds', myMap);
//google.maps.event.addListener(searchBox, 'places_changed', function() {
$("#pac-input").focusin(function() {
$(document).keypress(function(e) {
if (e.which == 13) {
selectFirstResult();
}
});
});
google.maps.event.addListener(searchBox, 'place_changed', function() {
//var places = searchBox.getPlaces(); searchBox
var place = searchBox.getPlace();
var places = [place];

for (var i = 0, marker; marker = markers[i]; i++) {
marker.setMap(null);
}

// For each place, get the icon, place name, and location.
markers = [];
var bounds = new google.maps.LatLngBounds();
var locations = false;
for (var i = 0, place; place = places[i]; i++) {
if (place.geometry !== undefined) {
var image = {
url: place.icon,
size: new google.maps.Size(71, 71),
origin: new google.maps.Point(0, 0),
anchor: new google.maps.Point(17, 34),
scaledSize: new google.maps.Size(25, 25)
};

// Create a marker for each place.
var marker = new google.maps.Marker({
map: myMap,
icon: image,
title: place.name,
position: place.geometry.location
});
markers.push(marker);
bounds.extend(place.geometry.location);
locations = true;
}
}
if (locations === true) {
fitMapToBounds(bounds);
}
});

}
function initializeGoogleMap()
{
if (!googleMaps) {
return false;
}
var nums;
if (googleMapsDialog === true) {
googleMapReady = false;

$(googleMapContainer).dialog({// Set up the dialog container for the google map
autoOpen: false,
draggable: true,
width: calendarGemeindenOptions.dialogWidth,
height: calendarGemeindenOptions.dialogHeight,
//height: 'auto',
closeOnEscape: true,
title: ' ',
resizeStop: function(event, ui) {
google.maps.event.trigger(myMap, 'resize'); // resize
},
open: function(event, ui) {
google.maps.event.trigger(myMap, 'resize');
setMapDroppable();
},
beforeClose: function(event, ui) {
var cals = getCalendars(function(cal) {
if (cal.selectBox === false && cal.display === true) {
return true;
}
});
$.each(cals, function(index, cal) {
moveCalendarToFixedList(cal);
});
unselectEventsLocation();
},
close: function(event, ui) {
googleMapOff();
},
drag: function(event, ui) {
if ($('#more_location_details').hasClass('bt-active'))
$('#more_location_details').btOn(); // The popup should move with the map
}

});
} else {
setMapDroppable();
googleMapReady = true;
}
nums = getCoords(getLocation(calendarGemeindenOptions.googleMapsStartLocation));
googleMapDrawn = false;
var startLatlng = new google.maps.LatLng(nums[0], nums[1]);
var myOptions = {
zoom: calendarGemeindenOptions.googleMapsStartZoom,
center: startLatlng,
mapTypeId: calendarGemeindenOptions.googleMapsStartType
};
myMap = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
initializeMapSearch();
google.maps.event.addListener(myMap, 'drag', function() {
if ($('#more_location_details').hasClass('bt-active'))
$('#more_location_details').btOn(); // The popup should move with the map
});
infowindow = new google.maps.InfoWindow({
});
google.maps.event.addListener(infowindow, 'domready', function() {
var l = $('.info-window').parent().parent();
l.addClass('bt-gm'); // We add this class so that the info window can be excepted from the click anywhere to close of the bt popup
currentLocation = getMarkerLocation(currentMarker);
var locationId = currentLocation.id;
unselectEventsLocation();
$(".fc-event." + locationId).removeClass("fc-event").addClass("fc-event-loc-sel").css("border", calendarGemeindenOptions.eventLocationSelectedBorder);
$(".fc-eventlist-title." + locationId).addClass("fc-eventlist-title-loc-sel");
$(".fc-agendaList-dayHeader." + locationId).addClass("fc-agendaList-dayHeader-loc-sel"); // Will only apply when sorted by locations
setLocationDetails(currentLocation);
var l = $('.info-window').parent().prev();
l.css('pointer-events', 'none'); // We add this so that one can click on an marker in proximity to the pointed part of the infowindow
});
google.maps.event.addListener(infowindow, 'closeclick', function() {
$("#more_location_details").btOff();
unselectEventsLocation();
});
mapDragging = true;
google.maps.event.addListener(myMap, 'drag', function() {
mapDragging = true;
});
google.maps.event.addListener(myMap, 'idle', function() {
if (restrictedToVisibleMap()) {
if (mapDragging) {
restrictSearchLocationVisibleMap();
mapDragging = false;
}
} else {
updateCalendarsVisibleMap();
}
if (googleMapDrawn === false) {
setLocationPins();
googleMapDrawn = true;
}
});
google.maps.event.addListener(myMap, 'zoom_changed', function() {
if (!mapDragging) {
if (restrictedToVisibleMap()) {
restrictSearchLocationVisibleMap();
mapDragging = false;
} else {
updateCalendarsVisibleMap();
}
}
});
googleMapSetLocation(getLocation(calendarGemeindenOptions.googleMapsStartLocation).id, false); // Center it on the starting location
if (googleMapsDialog === false) {
googleMapOn();
}
initializeAreas();
}

function googleMapOff() { // Doesn't actually destroy the map, but only renders it invisible
if (googleMapsDialog === true) {
$('#more_location_details').btOff();
$(googleMapContainer).dialog("close");
googleMapIsOn = false;
googleMapLocation = '';
} else {
// If the map is in a sidebar, it stays on
}
}
function googleMapSetLocation(locationId, infoWindow) {
var myLocation;
var coords;
myLocation = getLocationById(locationId); // get the location object
if (typeof (myLocation) === 'object') {
coords = myLocation.coords.split(",");
} else {
coords = false;
}
if (coords !== false) {
googleMapLocation = myLocation.id;
if (restrictedToVisibleMap() === false) {
var myLatlng = new google.maps.LatLng(coords[0], coords[1]);
myMap.setCenter(myLatlng, 10);
}
setLocationPins();
if (currentMarker !== myLocation.marker) {
$("#more_location_details").btOff();
currentMarker = myLocation.marker;
}
if (infoWindow === undefined || infoWindow === true) {
infowindow.setContent(myLocation.popupInfo);
infowindow.open(myMap, myLocation.marker);
}
} else {
googleMapLocation = '';
setLocationPins();
}
}

function googleMapOn(locationId) {
if (googleMapsDialog === true) {
$(googleMapContainer).dialog("open");
}
if (googleMapIsOn === false) {
googleMapIsOn = true;
//mapTimer = setTimeout(function(){googleMapOn(location)},10);
//return
}
if (typeof (locationId) !== 'undefined') {
googleMapSetLocation(locationId);
} else if (googleMapReady === false) {
googleMapSetLocation(getLocation(calendarGemeindenOptions.googleMapsStartLocation).id);
googleMapReady = true;
}
}

function toggleGoogleMap(locationId) {

if (googleMapIsOn === true) {
if ((googleMapLocation === locationId && googleMapsDialog === true) || typeof (locationId) === 'undefined') {
googleMapOff(locationId);
} else {
googleMapOn(locationId);
}
} else {
googleMapOn(locationId);
}
}

// functions dealing with number of events total, per day, per location, filtered out, etc.
function clearEvents() {
clearEventsCount();
clearEventsPerLocation();
clearTimeout(eventHoverTimer);
}
function clearEventsCount() {
eventsCount = 0;
eventsCountFilteredOut = 0;
}
function clearEventsCalendar() {
eventsPerDay = new Array();
for (var i = 0; i < eventTypes.length; i++) {
eventsPerDay[eventTypes[i].id] = [];
}
eventsPerDayCalendar = new Array();
eventsPerCategoryCalendar = new Array();
for (var i = 0; i < eventTypes.length; i++) {
eventsPerCategoryCalendar[eventTypes[i].id] = [];
}
}
function clearEventsPerLocation() {
var i;
for (i = 0; i < locationInfo.length; ++i) {
locationInfo[i].numberEvents = 0;
locationInfo[i].numberHiddenEvents = 0;
}
}

function getEventsOnDate(date, category) {
var events;
var dateString = formatDate(date, 'yyMMdd');
if (category === undefined || category === '') {
events = eventsPerDayCalendar[dateString];
} else {
events = eventsPerCategoryCalendar[category][dateString];
}
if (events === undefined) {
return [];
}
return events;
}

function getMaxEventsPerDay() {
var max = 0;
for (var prop in eventsPerDay) {
if (eventsPerDay.hasOwnProperty(prop))
if (eventsPerDay[prop] > max) {
max = eventsPerDay[prop];
}
}
return max;
}
function countEvent(event) {
eventsCount++;
increaseEventsPerDay(event);
increaseEventsPerLocation(event.locationId);
return true; // This value is passed back to the fullcalendar
}
function countEventFilteredOut(event) {
eventsCountFilteredOut++;
increaseHiddenEventsPerLocation(event.locationId);
return false;
}

function isSourcesEqual(source1, source2) {
return source1 && source2 && getSourcePrimitive(source1) == getSourcePrimitive(source2);
}


function getSourcePrimitive(source) {
return ((typeof source == 'object') ? (source.events || source.url) : '') || source;
}

function removeEventSourceDayCalendar(source) {
var dateList;
var category;
for (var i = 0; i < eventTypes.length; i++) {
category = eventTypes[i].id;
dateList = eventsPerCategoryCalendar[category];
for (var day in dateList) {
if (dateList.hasOwnProperty(day)) {
dateList[day] = $.grep(dateList[day], function(e) {
return !isSourcesEqual(e.source, source);
});
}
}
}
}

function removeEventFromDayList(event, list) {
for (var i = 0; i < list.length; i++) {
if (list[i].id === event.id) {
list.splice(i, 1);
break;
}
}
}

function decreaseEventsPerDayCalendar(event) { // TO DO: count multi-day events for each day
var date = formatDate(event.start, 'yyMMdd');
var eventList;
eventList = eventsPerDayCalendar[date];
if (eventList !== undefined) {
removeEventFromDayList(event, eventList);
}
// Count event types per day (for use in calendar)
for (var category in event.category) {
eventList = eventsPerCategoryCalendar[category][date];
if (eventList !== undefined) {
removeEventFromDayList(event, eventList);
}
}
}

function addEventToDayList(event, list) {
for (var i = 0; i < list.length; i++) {
if (list[i].id === event.id) {
break;
}
}
if (i === list.length) {
list.push(event);
}
}

function increaseEventsPerDayCalendar(event) { // TO DO: count multi-day events for each day
var date = formatDate(event.start, 'yyMMdd');
var eventList;
eventList = eventsPerDayCalendar[date];
if (eventList !== undefined) {
addEventToDayList(event, eventList);
} else {
eventsPerDayCalendar[date] = [event];
}

// Count event types per day (for use in calendar)
for (var category in event.category) {
eventList = eventsPerCategoryCalendar[category][date];
if (eventList !== undefined) {
addEventToDayList(event, eventList);
} else {
eventsPerCategoryCalendar[category][date] = [event];
}
}
}


function increaseEventsPerDay(event) { // TO DO: count multi-day events for each day
var date = formatDate(event.start, 'yyMMdd');
if (eventsPerDay[date] !== undefined) {
eventsPerDay[date] += 1;
} else {
eventsPerDay[date] = 1;
}
// Count event types per day (for use in calendar)
for (var category in event.category) {
if (eventsPerDay[category][date] !== undefined) {
eventsPerDay[category][date] += 1;
} else {
eventsPerDay[category][date] = 1;
}
}
}

function increaseEventsPerLocation(location) {
var locationObj;
locationObj = getLocation(location);
if (locationObj !== false) {
locationObj.numberEvents += 1;
} else {
locationObj = getLocation(location);
}
}

function increaseHiddenEventsPerLocation(location) {
var locationObj;
locationObj = getLocation(location);
if (locationObj !== false) {
locationObj.numberHiddenEvents += 1;
}
}

// functions dealing with events
function shortLocation(locationName, source) { // Returns the short location of an event, if available -- MAY NOT BE NEEDED
// TO DO (if to be employed for many calendars and locations): restrict search to possible locations for a given calendar
var short = locationName;
var fullLocation = locationName.toLowerCase();
for (var i = 0; i < shortLocations.length; i++) {
if (fullLocation.indexOf(shortLocations[i].search) !== -1) {
short = shortLocations[i].short;
break;
}
}
return short;
}

function getLocations(locations) {
// locations can be a string (locationId), or an array of location objects or locationIds
// Returns an array of the locations (can be empty)

var i;
var getLocs = [];
var loc;
var locs;
if (typeof (locations) === 'undefined') {
return [];
} else if (typeof (locations) === 'string') { // Is a location id
locs = [locations];
} else {
locs = locations;
}
for (i = 0; i < locs.length; i++) {
if (isLocationObject(locs[i])) {
getLocs.push(locs[i]);
} else {
loc = getLocation(locs[i]);
if (loc !== false) {
getLocs.push(loc);
}
}
}
return getLocs;
}

function getLocationIds(locations) {
// locations can be a string (locationId), or an array of location objects or locationIds
// Returns an array of the location ids (can be empty)

var i;
var locIds = [];
var locs;
if (typeof (locations) === 'string') { // Is a location id
return [locations];
} else {
locs = locations;
}
for (i = 0; i < locs.length; i++) {
if (isLocationObject(locs[i])) {
locIds.push(locs[i].id);
} else {
locIds.push(locs[i]);
}
}
return locIds;
}

function getLocationByDescription(location, source) { // Returns the location (object) of an event, given a full location description, if possible
var short;
var locationLower = location.toLowerCase();
var i;
var locs;
for (i = 0; i < shortLocations.length; i++) {
if (locationLower.indexOf(shortLocations[i].search) !== -1) {
short = shortLocations[i].description;
break;
}
}
if (source.locationExclusive === true) {
locs = getLocations(source.location);
} else if (source.locationsPossible !== undefined) {
locs = source.locationsPossible;
} else {
locs = locationInfo;
}
for (i = 0; i < locs.length; i++) {
if (short === locs[i].description) {
return locs[i];
}
}
return false;
}

function showDetails(event) {
function urlX(u) {
return u;
}
function idX(id) {
return id;
}
var dayBegin = formatDate(event.start, 'dd');
var dayEnd = formatDate(event.end, 'dd');
var monthBegin = formatDate(event.start, 'MMMM');
var monthEnd = formatDate(event.end, 'MMMM');
var timeBegin = formatDate(event.start, 'H:mm');
var timeEnd = formatDate(event.end, 'H:mm');

var day = dayBegin + ". ";
var time = "";
var gmapIconEventId = 'gmap_' + calendarDivId;
var addEventToCalendarId = 'addevent_' + calendarDivId;
if (monthBegin !== monthEnd)
{
day += monthBegin;
}
if (dayBegin !== dayEnd && dayEnd !== '' && dayEnd !== undefined) // all day events that last only one day have no recorded event end.
{
day += "- " + dayEnd + ". ";
}
if (monthEnd !== '' && monthEnd !== undefined) { // all day events that last only one day have no recorded event end.
day += monthEnd;
}

if (!event.allDay || event.mostDay) {
if (event.autoGenerated === true) {
time += timeBegin + " Uhr"; // No specified end time
} else {
time += timeBegin + " - " + timeEnd + " Uhr";
}
}

var title = html_sanitize(event.title || '', urlX, idX);
var location = html_sanitize(event.location || '', urlX, idX);
var shortLocation = event.shortLocation;
var locationId = event.locationId;
var locationObj = getLocationById(locationId);
var description = html_sanitize(event.description || '', urlX, idX);
var id = event.domId;

if ($("#" + id).hasClass('fc-event-sel')) {
unselectEvents();
return;
// If already selected, then deselect
}
unselectEvents();
$("#" + id).removeClass("fc-event").removeClass("fc-event-loc-sel").addClass("fc-event-sel").css("border", calendarGemeindenOptions.locationSelectedBorder); // Add CSS event selected class to newly selected event, and draw a red border

var html;
html = '<a onclick="$(\'.fc-event-sel\').btOff();">' + calendarGemeindenOptions.locationDetailsCloseGraphic + '</a>';
var editGraphic = calendarGemeindenOptions.locationDetailsEditGraphic;
if (editGraphic && event.link) {
html += '<a href="' + event.link +'" target="_blank">' + editGraphic + '</a>';
}
html += "<table id='event_details_table'>";
if (title !== '')
html += '<tr><td>Titel:</td><td>' + title + '</td></tr>';
html += '<tr><td>Datum:&nbsp;&nbsp;&nbsp;</td><td>' + day + '</td></tr>'; // spaces to ensure that there is space for the map icon
if (time !== '')
html += '<tr><td>Zeit:</td><td>' + time + '</td></tr>';
if (location !== '') {
if (googleMaps && getCoords(locationObj) !== false) {
html += '<tr><td>Ort:<img src="' + defaultMapIcons.selected.icon + '" alt="gmap-pin" title="" id="' + gmapIconEventId + '" class="alt-target" height="32" width="32"></td><td>' + location + '</td></tr>';
if (googleMapIsOn) {
googleMapSetLocation(locationId);
}
}
else {
html += '<tr><td>Ort:</td><td>' + location + '</td></tr>';
}
}
var search2 = /(\[.[^\]]*\]*)/i;
while (search2.test(description) !== false) {
description = description.replace(search2, '');
}

if (description.trim().length > 1) {
html += "<tr><td>Beschreibung:</td><td>" + description + "</td></tr>";
}
if (event.autoGenerated === true) {
html += "<tr><td>Hinweis:</td><td>";
if (getFeastDay(event.start) !== false) {
var noticeFeast = calendarGemeindenOptions.automaticEventNoticeFeast;
if (typeof (noticeFeast) === 'function') {
html += noticeFeast(getFeastDay(event.start));
} else {
html += calendarGemeindenOptions.automaticEventNoticeFeast;
}
} else {
html += calendarGemeindenOptions.automaticEventNotice;
}
html += "</td></tr>";
}
html += '<tr><td>Hinzufügen:</td><td id="' + addEventToCalendarId + '"></td></tr>';
html += "</table>";

$("#" + id).bt(html, calendarGemeindenOptions.eventDetailsTipOptions).btOn();
$("#" + gmapIconEventId).click(function() {
toggleGoogleMap(locationId);
});
if ($.icalendar) {
html += $('#' + addEventToCalendarId).icalendar($.extend({icons: 'grafiken/icalendar.png', compact: true, echoUrl: calendarGemeindenOptions.echoUrl}, event));
}

// TO DO: move maps dialog out of the way if necessary
}

function makeCalendarIds() {
var id;
for (var i = 0; i < calendars.length; i++) {
id = calendarChkboxId(calendars[i].id);
calendars[i].domId = id;
calendars[i].divId = id + '_div';
}
}

function calendarChkboxId(calendarName) {
return 'chkcal_' + calendarName.replace(/ /g, '_') + '_' + calendarDivId;
}

function getCalendarByDomId(id) {
var calId = id;

if (id === false || id === undefined) {
return {};
}
if (id.substring(id.length - 4) === '_div') {
calId = id.substring(0, id.length - 4); // If it is the id for a div, get the id proper
}

var cal = $.grep(calendars, function(e) {
return e.domId === calId;
});
if (cal.length === 0) {
return false;
}
return cal[0];
}
function getCalendarById(id) {
var cal = $.grep(calendars, function(e) {
return e.id === id;
});
if (cal.length === 0) {
return false;
}
return cal[0];
}

function getDefaultCalendarOptions(cal) {
var calName;
var disp;
var sel;
var selectBox;
var defaultOption;
calName = cal.id;
sel = getCalendarOption(calName + '_selectBox');
disp = getCalendarOption(calName);
if (cal.displayCalendar === false) {
selectBox = false;
} else if (cal.selectBox === true) {
selectBox = true;
} else {
selectBox = false;
}
if (cal.display === undefined) {
defaultOption = selectBox; // if select box and no value defined, then default is to show the calendar
} else {
defaultOption = cal.display;
}
storeCalendarOption(calName + '_selectBox', selectBox);
cal.selectBox = selectBox;
// display of calendar
cal.display = defaultOption;
storeCalendarOption(calName, cal.display);
}

function storeCalendarOrder() {
var cal;
var calObjs = $(gemeindenFixedDiv).find('.singlecalendar');
var calIds = [];
calObjs.each(function()
{
cal = getCalendarByDomId($(this).attr('id'));
if (cal !== false) {
calIds.push(cal.id);
}
});
var calString = calIds.join(',');
storeCalendarOption('calendarOrder', calString);
}

function getStoredCalendarOrder() {
var calOrderString = getCalendarOption('calendarOrder');
if (calOrderString === undefined) {
return [];
}
return calOrderString.split(',');
}

function getStoredCalendarOptions(cal) {
var calName;
var disp;
var sel;
var selectBox;
var defaultOption;
calName = cal.id;
sel = getCalendarOption(calName + '_selectBox');
disp = getCalendarOption(calName);
if (cal.displayCalendar === false) {
selectBox = false;
} else {
if (sel === 'true') {
//|| (disp === 'true' && googleMapsDialog === true) }) { // if stored as selectable, or if displayed and the map is a dialog (and so not shown at the beginning)
selectBox = true;
} else if (sel === 'false' || cal.selectBox !== true) {
selectBox = false;
} else {
selectBox = true;
}
}
if (cal.display === undefined) {
defaultOption = selectBox; // if select box and no value defined, then default is to show the calendar
} else {
defaultOption = cal.display;
}
storeCalendarOption(calName + '_selectBox', selectBox);
cal.selectBox = selectBox;
// display of calendar
cal.display = defaultOption;
if (disp === "true" && (selectBox === true || (googleMaps === true && googleMapsDialog === false))) { // don't display events from the calendar if the calendar itself is invisible to begin with
cal.display = true;
} else if (disp === "false") {
cal.display = false;
}
storeCalendarOption(calName, cal.display);
}

function getStoredOptions() {
var minutesDiff;

userId = _getCalendarOption('user'); // Always get this
if (userId === undefined) {
initializeUser();
_storeCalendarOption('user', userId); // Always store this
}
if (getCalendarOption('date') !== undefined && storeOptionsLocally === true) {
minutesDiff = ((new Date()).getTime() - getCalendarOption('date')) / 60000; // difference in minutes
} else {
minutesDiff = -1;
}
if (minutesDiff >= calendarGemeindenOptions.storeCalendarDuration || storeOptionsLocally !== true) {
getStoredCalendarOptions = getDefaultCalendarOptions;
}
if (minutesDiff < calendarGemeindenOptions.storeCalendarOrderDuration && storeOptionsLocally === true) {
calOrderIds = getStoredCalendarOrder();
}
filterLocationText = ''; // defaults to not filtering
filterText = '';
filterEventId = defaultFilter;
if (minutesDiff < storeFilterDuration && storeOptionsLocally === true) {
if (getCalendarOption('filterEventId') !== undefined) {
filterEventId = getCalendarOption('filterEventId');
}
if (getCalendarOption('filterText') !== undefined) {
setSearchFilter(getCalendarOption('filterText'), true);
}
if (displayFilterLocation === true) {
if (getCalendarOption('filterLocationText') !== undefined) {
setSearchLocationFilter(getCalendarOption('filterLocationText'), true);
}
}
}
filterEventType = getEventType(filterEventId);
}

function storeCalendarOption(key, value) {
localStorageCustom[calendarGemeindenOptions.calendarConfigurationName + key] = value;
localStorageCustom[calendarGemeindenOptions.calendarConfigurationName + 'date'] = (new Date()).getTime();
}
function getCalendarOption(key) {
return localStorageCustom[calendarGemeindenOptions.calendarConfigurationName + key];
}

function _storeCalendarOption(key, value) {
_localStorageCustom[calendarGemeindenOptions.calendarConfigurationName + key] = value;
_localStorageCustom[calendarGemeindenOptions.calendarConfigurationName + 'date'] = (new Date()).getTime();
}
function _getCalendarOption(key) {
return localStorageCustom[calendarGemeindenOptions.calendarConfigurationName + key];
}

function integrateEvent(event, eventList) {
var days = event.days;
var time;
var title;
var description;
var j;
var event2;
var found;
if (days.length === 0) {
return;
}
time = event.time;
title = event.title;
description = event.description;
for (var i = 0; i < days.length; i++) {
found = false;
for (j = 0; j < eventList.length; j++) {
event2 = eventList[j];
if (time === event2.time && title === event2.title && description === event2.description) { // Add this event to the particular day, if not already present
if (event2.days.indexOf(days[i]) !== -1) { // This day already present
found = true;
break;
} else {
event2.days.push(days[i]); // Add this day to this type of event
found = true;
break;
}
}
}
if (found === false) {
if (description !== undefined) {
eventList.push({days: [days[i]], time: time, title: title, description: description});
} else {
eventList.push({days: [days[i]], time: time, title: title});
}
}
}
}

function compressLocationEvents(loc) {
var eventList = loc.eventList;
if (eventList === undefined) {
return;
}
var newEventList = [];
for (var i = 0; i < eventList.length; i++) {
integrateEvent(eventList[i], newEventList);
}
loc.eventList = newEventList;
}

var locID = 1;
function setupLocation(loc) {
var calendarName;
var cal;
var nums;
//compressLocationEvents(loc);
if (loc === false) {
return;
}
loc.info = loc.info || loc.description;
loc.description = loc.description || loc.info;
loc.id = loc.id || 'loc' + (locID++);
if (loc.moreInfo === undefined) {
if (loc.address !== undefined) {
loc.moreInfo = loc.fullName + '<br/>' + loc.address;
if (loc.pfarre !== undefined) {
loc.moreInfo += '<a target="_blank" href="http://www.erzdioezese-wien.at/pages/pfarren/' + loc.pfarre + '">Webseite bei der Erzdiözese</a>';
}
}
}
if (loc.calendarExclusive === undefined) {
loc.calendarExclusive = true;
}
if (loc.eventList !== undefined) {
calendarName = loc.calendar;
if (calendarName === undefined) {
calendarName = loc.id;
loc.calendar = calendarName;
}
cal = getCalendarByName(calendarName);
if (cal === false) {
calendars.push(
{id: calendarName.replace(/ |\./g, '_'),
description: loc.description,
location: loc.id,
locationExclusive: true,
className: 'c' + calendarName.replace(/ |\./g, '_'),
selectBox: false,
eventList: $.extend(true, [], loc.eventList),
singleEventList: $.extend(true, [], loc.singleEventList)
});
} else if (cal.eventList === undefined) {
cal.eventList = $.extend(true, [], loc.eventList);
cal.singleEventList = $.extend(true, [], loc.singleEventList);
}
}
if (loc.latLng === undefined) {
nums = loc.coords.split(",");
loc.latLng = new google.maps.LatLng(nums[0], nums[1]);
}
if (loc.area === undefined || loc.area === false) {
loc.area = getArea(loc.latLng);
}
}

function getArea(latLng) {
for (var i = 0; i < areas.length; i++) {
if (areas[i].poly !== undefined) {
if (google.maps.geometry.poly.containsLocation(latLng, areas[i].poly)) {
return areas[i];
}
}
}
return false;
}

var ajaxDefaults = {
dataType: 'json',
cache: true,
localCache: true
};

function updateLocations() {
removeDuplicateLocations();
setupLocations();
setPhrasesForLocations();
setupCalendars();
restrictVisibleChange();
}

function escapeJson(object) {
if (typeof (object) === 'object') {
if (object.description !== undefined) {
object.description = object.description.replace(/\"/g, "");
} else {
for (var prop in object) {
escapeJson(prop);
}
}
}
return object;
}

function outputLocations() {
var locs = [];
var loc;
for (var i = 0; i < locationInfo.length; i++) {
loc = locationInfo[i];
locs[i] = {id: loc.id,
coords: loc.coords};
if (loc.fullName !== undefined) {
locs[i].info = loc.info;
locs[i].fullName = loc.fullName;
locs[i].address = loc.address;
locs[i].pfarre = loc.pfarre;
if (loc.eventList !== undefined) {
if (loc.eventList.length > 0) {
locs[i].eventList = escapeJson(loc.eventList);
}
}
if (loc.singleEventList !== undefined) {
if (loc.singleEventList.length > 0) {
locs[i].singleEventList = escapeJson(loc.singleEventList);
}
}
} else {
locs[i].description = loc.description;
if (loc.calendar !== undefined) {
locs[i].calendar = loc.calendar;
}
if (loc.calendarExclusive !== undefined) {
locs[i].calendarExclusive = loc.calendarExclusive;
}
}
}
return locs;
}

function addLocations(locs) {
$.merge(locationInfo, locs);
setupEvents();
updateLocations();
//console.log(JSON.stringify(outputLocations()));
}

function loadLocations(url) {
$.Tache.Get($.extend({}, ajaxDefaults, {url: url}, {
//$.ajax($.extend({}, ajaxDefaults, source, {
data: {},
success: function(locations) {
locations = locations || [];
addLocations(locations);
},
error: function(jqXHR, textStatus, errorThrown) {
console.log('Ajax Error:' + jqXHR + ',' + textStatus + ',' + errorThrown);
//applyAll(error, this, arguments);
//callback();
},
complete: function() {
//applyAll(complete, this, arguments);
//popLoading();
}
}));
}

function removeDuplicateLocations() {
var loc;
var locIds = {};
var l = 0;
var url;
while (l < locationInfo.length) {
loc = locationInfo[l];
if (loc.url !== undefined) {
url = loc.url;
queue(function() {
loadLocations(url);
}
);
locationInfo.splice(l--, 1);
} else if (loc.id !== undefined) {
if (locIds[loc.id] !== undefined) {
locationInfo.splice(l--, 1);
} else {
locIds[loc.id] = true;
}
}
l++;
}
}
function setupLocations() {
var loc;
for (var l = 0; l < locationInfo.length; l++) {
setupLocation(locationInfo[l]);
}
}

var dayNames = ['Montags', 'Dienstags', 'Mittwochs', 'Donnerstags', 'Freitags', 'Samstags'];

function getDayArray(name) {
if (name === 'Sonntags') {
return [0];
}
for (var i = 0; i < dayNames.length; i++) {
if (name === dayNames[i]) {
return [i + 1];
}
}
return []; // no days
}

function transformEvents(eventList) {
// takes an array of objects, returns the events in our format
//{days:
var d;
var days;
var times;
var t;
var transformedList = [];
var eventNum = 0;
var event;
for (d = 0; d < eventList.length; d++) {
days = getDayArray(eventList[d].days);
times = eventList[d].times;
if (days.length > 0) { // Don't add single events
for (t = 0; t < times.length; t++) {
event = times[t];
if (event.description !== undefined) {
transformedList[eventNum++] = {days: days, time: event.time, title: event.title, description: event.description};
} else {
transformedList[eventNum++] = {days: days, time: event.time, title: event.title};
}
}
}
}
return transformedList;
}

function transformSingleEvents(eventList) {
// takes an array of objects, returns the events in our format
//{days:
var d;
var day;
var times;
var t;
var transformedList = [];
var eventNum = 0;
var event;
for (d = 0; d < eventList.length; d++) {
day = eventList[d].days;
if (day.indexOf('Nur am ') === 0) {
day = day.slice(7);
times = eventList[d].times;
for (t = 0; t < times.length; t++) {
event = times[t];
if (event.description !== undefined) {
transformedList[eventNum++] = {day: day, time: event.time, title: event.title, description: event.description};
} else {
transformedList[eventNum++] = {day: day, time: event.time, title: event.title};
}

}
}
}
return transformedList;
}

function setupEvents() {
var events = calendarGemeindenOptions.events;
var locId;
var loc;
if (events === undefined) {
return;
}
var num = 0;
for (var i = 0; i < events.length; i++) {
locId = events[i].location;
loc = getLocationById(locId);
if (loc !== false) {
if (loc.eventList === undefined) {
//num++;
loc.eventList = transformEvents(events[i].events);
}
if (loc.singleEventList === undefined) {
loc.singleEventList = transformSingleEvents(events[i].events);
if (loc.singleEventList.length > 0) {
num++;
}
}
}
}
//console.log('number of churches:' + locationInfo.length);
//console.log('number of churches with single events:' + num);
}

function djb2(str) {
var hash = 5381;
for (var i = 0; i < str.length; i++) {
hash = ((hash << 5) + hash) + str.charCodeAt(i); /* hash * 33 + c */
}
return hash;
}

function hashStringToColor(str) {
// For automatically generating the colors of calendars that have no assigned color
// TO DO: restrict the color range to a nicer range?
var hash = djb2(str);
var r = (hash & 0xFF0000) >> 16;
var g = (hash & 0x00FF00) >> 8;
var b = hash & 0x0000FF;
return "#" + ("0" + r.toString(16)).substr(-2) + ("0" + g.toString(16)).substr(-2) + ("0" + b.toString(16)).substr(-2);
}

function colorLuminance(hex, lum) {
// validate hex string
hex = String(hex).replace(/[^0-9a-f]/gi, '');
if (hex.length < 6) {
hex = hex[0] + hex[0] + hex[1] + hex[1] + hex[2] + hex[2];
}
lum = lum || 0;

// convert to decimal and change luminosity
var rgb = "#", c, i;
for (i = 0; i < 3; i++) {
c = parseInt(hex.substr(i * 2, 2), 16);
c = Math.round(Math.min(Math.max(0, c + (c * lum)), 255)).toString(16);
rgb += ("00" + c).substr(c.length);
}

return rgb;
}

function luminance(hex) {
// validate hex string
hex = String(hex).replace(/[^0-9a-f]/gi, '');
if (hex.length < 6) {
hex = hex[0] + hex[0] + hex[1] + hex[1] + hex[2] + hex[2];
}
return Math.sqrt(.241 * parseInt(hex.substr(0, 2), 16) / 255 + .691 * parseInt(hex.substr(2, 2), 16) / 255 + .068 * parseInt(hex.substr(4, 2), 16) / 255);
}

function setCalendarObject(cal) {
var scope;
var revert;
if (cal.selectBox === true) {
scope = 'extra';
revert = 'invalid';
} else {
scope = 'default';
revert = function(valid) {
if (valid) {
if (this.data.overlaps) {
return true; // If it is coming from the maps container, don't allow it to be dropped on the maps container
}
return false;
}
else { //Dropped in a invalid location
return true;
}
};
}
if (scope === 'default') {
if ($('#' + cal.divId).data('uiDraggable')) {
$('#' + cal.divId).draggable("option", {scope: scope, revert: revert, connectToSortable: gemeindenFixedDiv});
} else {
$('#' + cal.divId).draggable({scope: scope, revert: revert, connectToSortable: gemeindenFixedDiv});
}

}
}

function moveCalendarToFixedList(cal) {
var id = '#' + cal.divId;
if (cal.selectBox === false) {
cal.selectBox = true;
storeCalendarOption(cal.id + '_selectBox', true);
$(id).html(getCalendarInnerHtml(cal, true));
initializeCalendarDraggable(cal);
}
var droppedOn = $(gemeindenFixedDiv);
if ($(element).closest(gemeindenFixedDiv).length === 0) {
$(id).effect('transfer', {to: $(afterGemeindenDiv)}, 500, function() {
$(id).detach().appendTo(droppedOn).css('display', 'inline');
reinitializeSortable();
});
} else {
reinitializeSortable();
}
}
function moveDroppedCalendarToFixedList(cal, element, helper) {
if ($(element).closest(gemeindenFixedDiv).length === 0) {
$(element).detach().appendTo($(gemeindenFixedDiv));
}
if (cal.selectBox === false) {
cal.selectBox = true;
storeCalendarOption(cal.id + '_selectBox', true);
if ($(element).data('uiDraggable')) {
$(element).draggable('disable');
}
$(element).html(getCalendarInnerHtml(cal, true));
}
var divId = cal.divId;
if ($(element).attr('id') !== divId) {
$('#' + divId).remove();
$(element).attr('id', divId);
}
if ($(element).data('uiDraggable')) {
$(element).draggable('disable');
}
if (helper) {
$(element).css('display', 'none');
helper.effect('transfer', {to: $(afterGemeindenDiv)}, 500, function() {
helper.remove();
initializeCalendarDraggable(cal);
$(element).css('display', 'inline-block');
});
} else {
initializeCalendarDraggable(cal);
$(element).css('display', 'inline-block');
}
helperId = false;
reinitializeSortable();
}
function moveDroppedCalendarToList(cal, element, helper, div) {
if (cal.selectBox === true) {
cal.selectBox = false;
storeCalendarOption(cal.id + '_selectBox', false);
$(element).html(getCalendarInnerHtml(cal, false));
}
var divId = cal.divId;
if ($(element).attr('id') !== divId) {
$('#' + divId).remove();
$(element).attr('id', divId);
}
$(element).detach().appendTo($(div));
if (helper) {
$(calendarGemeindenOptions.mapOptionsDiv).css('display', 'inherit');
helper.effect('transfer', {to: $(div)}, 500, function() {
$(element).css('display', 'inline');
helper.remove();
initializeCalendarDraggable(cal);
});
} else {
initializeCalendarDraggable(cal);
$(calendarGemeindenOptions.mapOptionsDiv).css('display', 'inherit');
}
helperId = false;
reinitializeSortable();
//listExtraCalendars();
}
function removeDroppedCalendar(cal, element, helper, div) {
if (helper) {
helper.effect('transfer', {to: $(div)}, 500, function() {
helper.remove();
});
$(element).remove();
} else {
$(element).effect('transfer', {to: $(div)}, 500, function() {
$(element).remove();
});
}
}

function setupCalendar(cal) {
var location;
var locationRef;
var locExtended;
var cal;
var coords;
var coords1;
var coords2;
var color;
var style;
var lum;
var locRestricted;
if (cal.setup === undefined) {
getStoredCalendarOptions(cal);
cal.currentTimezone = 'Europe/Berlin';
if (cal.selectBox === undefined) {
cal.selectBox = true;
}
if (cal.color === undefined) {
color = hashStringToColor(cal.description + cal.id);
lum = luminance(color);
if (lum > 0.8) {
color = colorLuminance(color, (0.8 - lum) * 2);
} else if (lum < 0.2) {
color = colorLuminance(color, 0.2);
}
cal.color = color;
}
if (cal.borderColor === undefined) {
cal.borderColor = colorLuminance(cal.color, -.25);
}
if (cal.selectBox === undefined) {
cal.selectBox = false;
}
if (cal.display === undefined) {
cal.display = false;
if (cal.selectBox === true) {
if (googleMaps === false || googleMapsDialog === true) { // don't display events from the calendar if the calendar itself is invisible to begin with
cal.display = true;
}
}
}
if (cal.className === undefined) {
cal.className = 'c' + cal.id.replace(/ |\./g, '_');
}
style = $('<style>.' + cal.className + '.fc-eventlist-title { color: ' + cal.color + '; }</style>');
$('html > head').append(style);
locationRef = cal.location;
location = false;
if (typeof (locationRef) === 'string') {
location = getLocation(locationRef); // tries to get by id, if fails then by name
} else if (typeof (locationRef) === 'object') {
if (locationRef.length === 1) {
location = getLocation(locationRef[0]);
}
}
if ((cal.eventList !== undefined || cal.singleEventList !== undefined) && cal.events === undefined) {
if (locationRef === undefined || location !== false) {
cal.events = createGenerateEvents(cal, location); // A hack to allow us to load locations after calendars; TO DO: rewrite this
}
}
locExtended = cal.locationExtended;
if (locExtended !== undefined) {
coords1 = locExtended[0].split(",");
coords2 = locExtended[1].split(",");
cal.mapBounds = new google.maps.LatLngBounds(
new google.maps.LatLng(coords1[0], coords1[1]),
new google.maps.LatLng(coords2[0], coords2[1])
);
}
locRestricted = cal.locationRestricted;
if (cal.mapBoundsRestricted === undefined) {
if (locRestricted !== undefined) {
coords1 = locRestricted[0].split(",");
coords2 = locRestricted[1].split(",");
cal.mapBoundsRestricted = new google.maps.LatLngBounds(
new google.maps.LatLng(coords1[0], coords1[1]),
new google.maps.LatLng(coords2[0], coords2[1])
);
} else if (location !== false) { // calendar is linked with just one location
coords = getCoords(location);
var boundsSw = new google.maps.LatLng(parseFloat(coords[0]) - 0.05, parseFloat(coords[1]) - 0.05); // A guess at how far away most communities might celebrate from their principal church
var boundsNe = new google.maps.LatLng(parseFloat(coords[0]) + 0.05, parseFloat(coords[1]) + 0.05);
cal.mapBoundsRestricted = new google.maps.LatLngBounds(boundsSw, boundsNe);
}
//
//locationRestricted: ['47.786273, 16.197329','47.850234, 16.304667']
//coords: '47.8083289,16.2224536',
}
if (cal.locationExclusive === undefined) {
cal.locationExclusive = false;
}
cal.setup = true;
}
if (cal.mapBoundsRestricted !== undefined) {
cal.locationsPossible = getLocationsInBounds(cal.mapBoundsRestricted); // Need to always update this, in case more locations have been added (TO DO: perhaps add a flag for this)
}
if (cal.filter !== undefined) {
cal.filterEventType = getEventType(cal.filter);
}
}

function setupCalendars() {
var c;
makeCalendarIds();
for (c = 0; c < calendars.length; c++)
{
setupCalendar(calendars[c]);
}
}

function addCalendars(cals) {
$.merge(calendars, cals);
setupCalendars();
for (var i = 0; i < cals.length; i++) {
if (cals[i].display === true) {
cals[i].display = false;
displayCalendar(cals[i]);
} else {
displayCalendarSelector(cals[i]);
}
}
}

function normalizeHelperId(id) {
if (id === undefined) {
return false;
}
if (id.substring(0, 6) === 'helper') {
return id.substring(6);
}
return id;
}

var sorting = false;

function initializeDroppable() {
$(calendarOptionsDiv).find('.gemeinden').droppable({
//scope: 'calendars',
//accept: mapCalendarsDiv + ' .singlecalendar',
accept: function(element) {
if ($(element).closest(mapCalendarsDiv).length > 0) {
return true;
}
if (sorting) {
return false;
}
var id;
if (helperId) {
id = helperId;
} else {
id = element.attr('id');
}
if (id === undefined) {
return false;
}
var cal = getCalendarByDomId(id);
if (cal.selectBox === true) {
return false;
}
return true;
},
drop: function(event, ui) {
var id;
if (helperId) {
id = helperId;
} else {
id = ui.draggable.attr('id');
newItem = ui.draggable;
}
if (leftButtonDown) {
return false;
} // Need this hack due to bug in Jquery ui: http://bugs.jqueryui.com/ticket/6259
var cal = getCalendarByDomId(id);
if (cal.selectBox === true) {
helperId = false;
return false;
} else {
moveDroppedCalendarToFixedList(cal, newItem, ui.helper);
}
helperId = false;
$(this).removeClass("droppable");
return true;
},
activate: function(event, ui) {
$(this).addClass('droppable');
},
deactivate: function(event, ui) {
if (leftButtonDown) {
return false;
}
$(this).removeClass("droppable");
}
});
$(calendarDiv).droppable(
{accept: function(element) {
if ($(element).closest(mapCalendarsDiv).length > 0) {
return true;
}
var id;
if (helperId) {
id = helperId;
} else {
id = element.attr('id');
}
if (id === undefined) {
return false;
}
var cal = getCalendarByDomId(id);
if (cal.selectBox === true && cal.display === true) {
return false;
}
return true;
},
drop: function(event, ui) {
if (helperId) {
var id = helperId;
$(newItem).attr('id', id);
} else {
var id = ui.draggable.attr('id');
}
var cal = getCalendarByDomId(id);
if (cal.selectBox === false) {
if (overlaps(ui.helper, $(googleMapContainer))) {
return false; // If it is coming from the maps container, don't allow it to be dropped on the maps container
}
moveDroppedCalendarToFixedList(cal, ui.draggable, ui.helper);
}
if (!overlaps(ui.helper, $(googleMapContainer))) {
queue(function() {
displayCalendar(cal);
});
}
helperId = false;
$(this).removeClass("droppable");
return true;
},
activate: function(event, ui) {
$(this).addClass('droppable');
},
deactivate: function(event, ui) {
if (leftButtonDown) {
return false;
}
$(this).removeClass("droppable");
}
}
);
}

function initializeSortable() {
$(gemeindenFixedDiv).sortable(
{revert: 200, delay: 200, distance: 3,
beforeStop: function(event, ui) {
if (!helperId) {
if (ui.helper) {
newItem = ui.item;
helperId = normalizeHelperId(ui.helper.attr('id'));
}
}
sorting = false;
return true;
},
over: function(event, ui) {
if (!helperId) {
newItem = ui.item;
helperId = normalizeHelperId(ui.helper.attr('id'));
}
},
sort: function(event, ui) {
if (!helperId) {
newItem = ui.item;
helperId = normalizeHelperId(ui.helper.attr('id'));
}
},
helper: 'clone',
start: function(event, ui) {
if (!helperId) {
newItem = ui.item;
helperId = normalizeHelperId(ui.helper.attr('id'));
}
ui.placeholder.height(ui.item.height() - 4); // Not sure why this is necessary
ui.helper.width('auto');
sorting = true;
return true;
},
out: function(event, ui) {
sorting = false;
return true;
},
receive: function(event, ui) {
sorting = false;
return true;
},
stop: function(event, ui) {
sorting = false;
if (helperId) {
var cal = getCalendarByDomId(helperId);
moveDroppedCalendarToFixedList(cal, ui.item);
return true;
} else {
//var id = ui.item.attr('id');
return true;
}
}
}
);
}
function reinitializeSortable() {
if ($(gemeindenFixedDiv).data('uiSortable')) {
$(gemeindenFixedDiv).sortable('destroy');
}
initializeSortable();
storeCalendarOrder();
}
function setupCalendarOptions() {
var html = '';
var i;
var eventId;
var inOptionGroup = false;
html += '<div class="gemeinden">' + calendarGemeindenOptions.calendarSelectionText + '<span id="' + gemeindenFixedDivId + '"></span><div id="' + afterGemeindenDivId + '">&nbsp;</div>';
html += '<div id="' + gemeindenSelectDiv + '">';
html += calendarGemeindenOptions.buttons;
if (typeof (calendarGemeindenOptions.additionalButtons) === 'string') {
html += calendarGemeindenOptions.additionalButtons;
}
if (googleMaps && googleMapsDialog) {
html += '<img src="' + defaultMapIcons.small.icon + '" alt="gmap-pin" title="" id="' + gmapIconCalendarsId + '" class="alt-target" style="vertical-align: middle">';
}
html += '</div></div>';
html += '<div class="terminselection"><div>' + calendarGemeindenOptions.terminAuswahlText;
html += '<select id="' + terminauswahlId + '" name="terminauswahl" onchange="' + calendarFunctionString + '(\'updateWhatToDisplay\')">';
for (i = 0; i < eventTypes.length; i++) {
eventId = eventTypes[i].id;
if (eventId == 'option-group') {
if (inOptionGroup) {
html += '</optgroup>';
}
inOptionGroup = true;
html += '<optgroup label="' + eventTypes[i].menu + '">style="border-top: 1px dotted #ccc; margin: 5px 0;">';
} else if (eventId == 'option-group-end') {
if (inOptionGroup) {
html += '</optgroup>';
inOptionGroup = false;
}
} else {
html += '<option value="' + eventTypes[i].id + '">' + eventTypes[i].menu + '</option>';
}
}
if (inOptionGroup) { // Close any option group
html += '</optgroup>';
}
html += '</select>';
var searchText = calendarGemeindenOptions.searchText;
if (searchText !== false) {
html += '<span><label for="' + filterId + '">' + searchText + '<input type="text" name="filter" id="' + filterId + '"' +
'onchange="' + calendarFunctionString + '(\'updateSearchFilterDone\', this.value)" onkeyup="' + calendarFunctionString + '(\'updateSearchFilterChanging\', this.value)"></span>&nbsp;&nbsp;';
}
if (displayFilterLocation === true || displayFilterLocation === 'activate') {
html += '<label for="' + filterLocationId + '"';
if (displayFilterLocation === 'activate') {
html += ' style="visibility: hidden;"';
}
html += 'class="filter_location">Ort:<input type="text" name="filter_location" id="' + filterLocationId + '" class="filter_location"';
if (displayFilterLocation === 'activate') {
html += ' style="visibility: hidden;"';
}
html += 'onchange="' + calendarFunctionString + '(\'updateSearchLocationDone\', this.value)" onkeyup="' + calendarFunctionString + '(\'updateSearchLocationChanging\', this.value)"></label>';
}
if (typeof (calendarGemeindenOptions.additionalEventSelectionCode) === 'string') {
html += calendarGemeindenOptions.additionalEventSelectionCode;
}
html += '</div>';
$(calendarOptionsDiv).html(html);
$('#' + terminauswahlId).val(filterEventId);
$('#' + filterId).val(filterText);
if (googleMaps && googleMapsDialog) {
$("#" + gmapIconCalendarsId).click(function() {
toggleGoogleMap();
});
}

initializeDroppable();
}

function createGenerateEvents(cal, location) {
// location is location object
return function(start, end, callback) {
var events = generateEvents(start, end, cal, location);
callback(events);
};
}

// eventList: [{days: ['f'], time: '10:30', title: 'Hl. Messe'},
// {days: [6,7], time: '18:30', title: 'Hl. Messe'},

function generateEvents(start, end, cal, location) {
// Eventlist is a list of recurring and or single events
var events, date, dayOfWeek, month, dayList, d, day, event, eventStart, eventEnd, endTime = end.getTime();
var allDay;
var defaultLength;
var startTime = start.getTime();
var eventTime;
var dateString;
var year;
var eventList = cal.eventList;
if (eventList === undefined) {
eventList = [];
}
var singleEventList = cal.singleEventList;
var dateFormatted;
var feastDay, addEvent;
var addDays = $.fullCalendar.addDays;
var eventIdBase = cal.domId + '_';
var timeSplit;
var title;
var autoGenerated;
if (cal.id === 'liturgie') {
autoGenerated = false;
} else {
autoGenerated = true;
}
if (location !== false) {
var locDescription = location.description;
var locId = location.id;
}
var titleLower;
var counter = 0;
date = cloneDate(start);
events = [];

while (date.getTime() < endTime) {
dayOfWeek = date.getDay();
dateFormatted = formatDate(date, 'yyyy-mm-dd');
feastDay = getFeastDay(date);
for (event = 0; event < eventList.length; event++) {
eventStart = cloneDate(date);
dayList = eventList[event].days;
if (dayList !== undefined) {
for (d = 0; d < dayList.length; d++) {
day = dayList[d];
addEvent = false;
title = eventList[event].title;
if (day === 'feast' && feastDay !== false) { // Display the feast day itself; TO DO: break this into a separate generating function
addEvent = true;
title = feastDay;
} else if (dayOfWeek === day && (feastDay === false || dayOfWeek === 0)) { // Assume celebrations on Sunday are also kept when Sunday is a feastday
addEvent = true;
}
if (addEvent === true) {
if (eventList[event].time === 'allday') {
allDay = true;
eventStart.setHours(0);
eventStart.setMinutes(0);
eventEnd = cloneDate(eventStart);
} else {
allDay = false;
timeSplit = eventList[event].time.split(':');
eventStart.setHours(parseInt(timeSplit[0]));
eventStart.setMinutes(parseInt(timeSplit[1]));
eventEnd = cloneDate(eventStart);
titleLower = title.toLowerCase();
if (titleLower.indexOf('messe') !== -1 || titleLower.indexOf('wortgottes') !== -1) { // Default duration for various event types
defaultLength = 45;
} else if (titleLower.indexOf('tagzeitengebet') !== -1 || titleLower.indexOf('laudes') !== -1 || titleLower.indexOf('vesper') !== -1 || titleLower.indexOf('stundengebet') !== -1) {
defaultLength = 25;
} else if (titleLower.indexOf('rosenkranz') !== -1 || titleLower.indexOf('kreuzweg') !== -1) {
defaultLength = 30;
} else {
defaultLength = 60; // Default to 60 minutes long
}
eventEnd.setMinutes(parseInt(timeSplit[1]) + defaultLength);
}
if (location !== false) {
events.push({id: eventIdBase + eventStart.getTime() + counter++, title: title, description: eventList[event].description, allDay: allDay, start: eventStart, end: eventEnd, location: locDescription, locationId: locId, locationObj: location, autoGenerated: autoGenerated, alwaysRender: eventList[event].alwaysRender});
} else {
events.push({id: eventIdBase + eventStart.getTime() + counter++, title: title, description: eventList[event].description, allDay: allDay, start: eventStart, end: eventEnd, autoGenerated: autoGenerated, alwaysRender: eventList[event].alwaysRender});
}
}
}
}
}
date = addDays(date, 1);
}
if (singleEventList === undefined) {
return events;
}
for (event = 0; event < singleEventList.length; event++) {
dateString = singleEventList[event].day;
day = parseInt(dateString.slice(0, 2));
month = parseInt(dateString.slice(3, 5)) - 1;
year = parseInt(dateString.slice(6, 10));
eventStart = cloneDate(start);
eventStart.setFullYear(year);
eventStart.setMonth(month);
eventStart.setDate(day);
if (singleEventList[event].time === 'allday') {
allDay = true;
eventStart.setHours(0);
eventStart.setMinutes(0);
eventEnd = cloneDate(eventStart);
} else {
allDay = false;
timeSplit = singleEventList[event].time.split(':');
eventStart.setHours(parseInt(timeSplit[0]));
eventStart.setMinutes(parseInt(timeSplit[1]));
eventEnd = cloneDate(eventStart);
eventEnd.setHours(parseInt(timeSplit[0]) + 1); // Default to one hour long
}
eventTime = eventStart.getTime();
if (eventTime >= startTime && eventTime <= endTime) {
events.push({id: eventIdBase + eventTime + counter++, title: singleEventList[event].title, description: singleEventList[event].description, allDay: allDay, start: eventStart, end: eventEnd, location: locDescription, locationId: locId});
}
}
return events;
}
function getMoveableFeasts(easterDate) {
var feastDates, feastDatesArray;
var feast;
var cloneDate = $.fullCalendar.cloneDate;
var palmSunday = cloneDate(easterDate);
var holyThursday = cloneDate(easterDate);
var goodFriday = cloneDate(easterDate);
var holySaturday = cloneDate(easterDate);
var easterMonday = cloneDate(easterDate);
var ascension = cloneDate(easterDate);
var pentecost = cloneDate(easterDate);
var pentecostMonday = cloneDate(easterDate);
var corpusChristi = cloneDate(easterDate);
palmSunday.setDate(palmSunday.getDate() - 7);
holyThursday.setDate(goodFriday.getDate() - 3);
goodFriday.setDate(goodFriday.getDate() - 2);
holySaturday.setDate(holySaturday.getDate() - 1);
easterMonday.setDate(easterMonday.getDate() + 1);
ascension.setDate(ascension.getDate() + 39);
pentecost.setDate(pentecost.getDate() + 49);
pentecostMonday.setDate(pentecostMonday.getDate() + 50);
corpusChristi.setDate(corpusChristi.getDate() + 60);
feastDates = [{date: -46, name: 'Aschermittwoch'},
{date: -7, name: 'Palmsonntag'},
{date: 0, name: 'Ostersonntag'},
{date: -3, name: 'Gründonnerstag'},
{date: -2, name: 'Karfreitag'},
{date: -1, name: 'Karsamstag'},
{date: 1, name: 'Ostermontag'},
{date: 39, name: 'Christi Himmelfahrt'},
{date: 49, name: 'Pfingsten'},
{date: 50, name: 'Pfingstmontag'},
{date: 60, name: 'Fronleichnam'}
];
feastDatesArray = {};
var month;
var easterOffset;
var feastDate;
for (var i = 0; i < feastDates.length; i++) {
feast = feastDates[i];
easterOffset = feast.date;
feastDate = cloneDate(easterDate);
feastDate.setDate(feastDate.getDate() + easterOffset);
month = feastDate.getMonth();
feastDatesArray[month] = feastDatesArray[month] || {};
feastDatesArray[month][feastDate.getDate()] = feast.name;
}
return feastDatesArray;
}
function setupFeastdays() {
var easterDates = {2014: new Date(2014, 3, 20, 0, 0, 0, 0),
2015: new Date(2015, 3, 5, 0, 0, 0, 0),
2016: new Date(2016, 2, 27, 0, 0, 0, 0),
2017: new Date(2017, 3, 16, 0, 0, 0, 0)};

feastdays.moveableFeasts = {};
feastdays.moveableFeasts[2014] = getMoveableFeasts(easterDates[2014]);
feastdays.moveableFeasts[2015] = getMoveableFeasts(easterDates[2015]);
feastdays.moveableFeasts[2016] = getMoveableFeasts(easterDates[2016]);

feastdays.fixedFeasts = [
{1: 'Neujahr', 6: 'Erscheinung des Herrn (Dreikönige)'}, // Neujahr, Epiphanie
{}, {}, {}, {1: 'Staatsfeiertag'}, {}, {}, {15: 'Mariä Himmelfahrt'}, // Mariä Aufnahme
{}, {26: 'Nationalfeiertag'}, {1: 'Allerheiligen', 2: 'Allerseelen', 15: 'Hl. Leopold'},
{8: 'Unbeflecktes Empfängnis', 24: 'Heiliger Abend', 25: 'Weihnachten', 26: 'Stephanitag'}]; // on new year's eve special masses are more usually in the evening.

}
function getFeastDay(date) {
// returns false if not a feast day, true if a feast day without a specific name, or the name of the feast day
var dayofMonth = date.getDate();
var month = date.getMonth();
var year = date.getFullYear();
var yearFeasts = feastdays.moveableFeasts[year];
var moveableFeast = false;
var monthFeasts;
var feastDay;
if (yearFeasts !== undefined) {
monthFeasts = yearFeasts[month];
if (monthFeasts !== undefined) {
if (monthFeasts[dayofMonth] !== undefined) {
moveableFeast = monthFeasts[dayofMonth];
}
}
}
if (moveableFeast !== false) {
feastDay = moveableFeast;
} else if (feastdays.fixedFeasts[month][dayofMonth]) {
feastDay = feastdays.fixedFeasts[month][dayofMonth];
} else {
feastDay = false;
}
return feastDay;
}
function initializeUser() {
userId = (Math.floor(Math.random() * 900) + 100).toString();
}
function initializeSession() {
sessionId = (Math.floor(Math.random() * 90) + 10).toString();
}
function isLocalStorageEnabled() {
var store = window.localStorage;
if (store) {
try {
var testKey = '__storejs__';
store[testKey] = testKey;
if (store[testKey] != testKey) {
return false;
} // Cannot use local storage
store.removeItem(testKey);
} catch (e) {
return false; // cannot use local storage
}
return true; // can use local storage
}
return false; // cannot use local storage
}
function initializeLocalStorage() {
if (isLocalStorageEnabled()) {
_localStorageCustom = window.localStorage;
if (storeOptionsLocally === true) {
localStorageCustom = _localStorageCustom;
} else {
localStorageCustom = {}; // if no local storage desired, makes a fake storage
localStorageCustom.removeItem = function() {
};
}
} else {
localStorageCustom = {}; // if no local storage present, makes a fake storage
localStorageCustom.removeItem = function() {
};
_localStorageCustom = {}; // if no local storage present, makes a fake storage
_localStorageCustom.removeItem = function() {
};
}
}
function loadCalendar() {
calendarLoading = true;
initializeSession();
initializeLocalStorage();
removeDuplicateLocations();
setupEvents();
setupLocations();
//console.log(JSON.stringify(outputLocations()));
setPhrasesForLocations();
getStoredOptions();
setupCalendars();
setupCalendarOptions();
setupFeastdays();
listCalendars();
loadCal();
calendarLoading = false;
sendInfo(); // to identify more easily how often the calendar is used
}

function isEventType(event, eventType) {
// eventType is the event type object to test for
// title is the lowercase title, description the lowercase description
// event the event object
var preCategorized = event.category[eventType.id];
if (typeof preCategorized === 'boolean') { // Event has been precategorized
return preCategorized;
}
var test = eventType.test;
if (typeof (test) === 'function') {
return test(event, eventTypes);
} else if (typeof (test) === 'boolean') {
return test;
}
return false; // string or other object which we don't have a way to test
}

function compareFilter(event) {
// returns true if the title, description, or location of the event match the filter
if (filterText === '') {
return true;
}
var title = event.title;
var description = event.description;
var location = event.location;
var posDescription = 0, posTitle = 0;
var posLocation = -1;
var index;
var filterWord;
var found;
var word;
var titleLower = title.toLowerCase();
var descriptionLower = description.toLowerCase();
for (index = 0; index < filterWordsExpanded.length; index++) {
filterWord = filterWordsExpanded[index];
if (typeof (filterWord) === 'string') {
posDescription = descriptionLower.indexOf(filterWord);
posTitle = titleLower.indexOf(filterWord); // Would a user expect that all words must be present in title, or all words must be present in description?
//if (displayFilterLocation == false) {
posLocation = location.indexOf(filterWord); // Always check, so that one can search for a special type of event OR all events in a location
//}
if (posDescription === -1 && posTitle === -1 && posLocation === -1) {
return false;
}
} else {
found = false;
for (word in filterWord) { // Search for this OR that
posDescription = descriptionLower.indexOf(filterWord[word]);
posTitle = titleLower.indexOf(filterWord[word]);
if (displayFilterLocation === false) {
posLocation = location.indexOf(filterWord[word]);
}
if (posDescription !== -1 || posTitle !== -1 || posLocation !== -1) {
found = true;
break;
}
}
if (found === false) {
return false;
}
}
}
return true;
}

function getEventCategoryByCode(code) {
var eventCodes;
var j;
for (var i = 0; i < eventTypes.length; i++) {
eventCodes = eventTypes[i].code;
if (eventCodes === code) {
return eventTypes[i].id;
} else if (typeof (eventCodes) === 'object') {
for (j = 0; j < eventCodes.length; j++) {
if (eventCodes[j] === code) {
return eventTypes[i].id;
}
}
}
}
return false; // No event type found
}

function setupDatePicker() {
try { // TO DO: verify if this needed
var currentDate = $(calendarDiv).fullCalendar('getDate');
$(datePickerDiv).datepicker("setDate", currentDate);
} catch (err) {

}
}

function isInFilterLocation(event) {
var posLocation = -1, filterWord, index, word;
var location = event.shortLocation;
var locationLower = location.toLowerCase();
var found;
for (index = 0; index < filterLocationsExpanded.length; ++index) {
filterWord = filterLocationsExpanded[index];
if (typeof (filterWord) === 'string') {
posLocation = locationLower.indexOf(filterWord);
if (posLocation === -1) {
return countEventFilteredOut(event); // If one of the words is found in neither title nor description nor location
}
} else {
found = false;
for (word in filterWord) { // Search for this OR that
posLocation = locationLower.indexOf(filterWord[word]);
if (posLocation !== -1) {
found = true;
break;
}
}
if (found === false) {
return countEventFilteredOut(event);
}
}
}
return true;
}

function loadCal()
{
var calendarsDisplayed = new Array();
calendarsDisplayedCount = 0;
var i;
for (i = 0; i < calendars.length; i++)
{
if (calendars[i].display === true) {
calendarsDisplayed.push(calendars[i]);
if (!calendars[i].alwaysDisplay) {
calendarsDisplayedCount++;
}
}
}

$(calendarDiv).empty();
var fullCalendarOptions = {
eventDataTransform: function(event) {
var locId = event.locationId;
if (event.end === null) {
event.end = event.start;
}
var locObj = event.locObj;
if (locId === undefined) { // Try to determine location
if (event.location !== undefined) {
locObj = getLocationByDescription(event.location, event.source);
event.locationId = locObj.id;
} else {
locObj = {};
event.locationId = 0;
}
} else {
if (locObj === undefined) {
locObj = getLocationById(locId);
}
}
var location = locObj.description; // Short description of the location
//var loc = shortLocation(event.location, event.source);
var locs;
if (location === undefined) {
locs = event.source.location;
if (locs === undefined) {
locs = ''; // No location
}
if (typeof (locs) === 'string') {
location = locs; // If the calendar has only one location given, presume that events without an explicit location are in this location
event.location = event.location || location;
} else {
location = event.location;
}
if (locId === undefined) {
event.locationId = location;
}
if (location === undefined) {
location = '';
}
}
event.shortLocation = location;
var description = event.description;
if (typeof (description) === 'undefined') {
description = '';
}
var eventDomId = event.id.replace(/\./g, ""); // Remove characters not allowed in dom Ids
eventDomId = eventDomId.replace(/\@/g, "");
event.domId = eventDomId + event.source.domId + (event.start.getTime()); // make a unique id for each instance of repeating events
var eventCategories = {};
var descriptionProcessed = description;
if (event.autoGenerated !== false) { // Don't need to check auto generated events (at least for now)
// Get event categories from the description
var search = /(\s?\[.*?]\s?)/gi;
var searchResult;
while ((searchResult = search.exec(description)) !== null) { // iterate over all search results
var codeString;
var codes;
var code;
var category;
var j;
var categorization;
function urlX(u) {
return u;
}
function idX(id) {
return id;
}
codeString = searchResult[1];
codeString = codeString.substring(codeString.indexOf('[') + 1, codeString.indexOf(']'));
var validCode = false;
if (codeString.indexOf('link:') === 0) {
var link = codeString.replace(/link:/i, '');
link = html_sanitize(link || '', urlX, idX);
event.title = "<a href='" + link + "' target='_blank'>" + event.title + "</a>";
validCode = true;
} else {
codeString = codeString.replace(/kategorie:/i, ''); // For human readability, the code or list of codes separated by commas can optionally begin with "Kategorie:"
codes = codeString.split(",");
for (j = 0; j < codes.length; j++) {
code = codes[j].toLowerCase();
if (code.substring(0, 1) === ' ') {
code = code.substring(1); // Remove an empty space at the beginning
}
if (code.substring(code.length - 1) === ' ') {
code = code.substring(0, code.length - 1); // Remove an empty space at the end
}
if (code.substring(0, 1) === '-') { // When the code is followed by a minus, it excludes the event from being automatically classified in a category
categorization = false;
code = code.substring(1);
} else {
categorization = true;
}
category = getEventCategoryByCode(code);
if (category !== false) {
eventCategories[category] = categorization;
validCode = true;
}
}
}
if (validCode) {
descriptionProcessed = descriptionProcessed.replace(searchResult[1], "").replace(" ", " "); // After processing valid codes, remove them from the description
}
}
descriptionProcessed = descriptionProcessed.replace(/\s?zelebrant:.*/i, "");
}
if (event.title === 'No subject') {
event.private = true;
}
event.category = eventCategories;
event.description = descriptionProcessed;
return event;
},
filterId: function() {
var filterString = filterEventType.id;
if (filterEventType.searchTerm === true) {
filterString += filterWords;
}
if (displayFilterLocation === true) {
filterString += filterLocations;
}
var filterId = djb2(filterString);
if (currentFilterId !== filterId) {
currentFilterId = filterId;
clearEventsCalendar();
}
return filterId;
},
countEvent: function(event) {
increaseEventsPerDayCalendar(event);
},
countOutEvent: function(event) {
countEventFilteredOut(event);
},
removeEvent: function(event) {
decreaseEventsPerDayCalendar(event);
},
removeEventSource: function(source) {
removeEventSourceDayCalendar(source);
},
filterEvent: function(event) { // This is called before the rendering of events; events not rendered will occupy no slot space in the agenda views
if (event.alwaysRender === true) {
return true;
}
if (event.private === true) {
return false; // Don't display private events
}
if (displayFilterLocation === true) {
if (!isInFilterLocation(event)) {
return countEventFilteredOut(event);
}
}
var filterType2;
if (isEventType(event, filterEventType)) {
filterType2 = event.source.filterEventType || filterEventType;
if (filterEventType !== filterType2) {
if (isEventType(event, filterType2)) {
increaseEventsPerDayCalendar(event);
return true; // allow additional filter event type in the calendar options
}
} else {
increaseEventsPerDayCalendar(event);
return true;
}
}
return countEventFilteredOut(event);
},
eventRender: function(event, element) {
if (event.alwaysRender !== true) { // Don't count events which are always rendered (holidays, etc.)
countEvent(event); // Counts the events rendered
}
return true;
},
eventClick: function(event, jsEvent, view) {
selectedEvent = event;
showDetails(event);
},
beforeWindowResize: function(view) {
unselectEvents();
},
windowResize: function(view) {
resizeCalendar(view);
},
loading: function(isLoading, view) {
clearTimeout(timerIsLoading);
if (isLoading) {
timerIsLoading = setTimeout(function() {
showCalendarsLoading();
}, 120); // wait briefly to display, to help flicker
} else {
hideCalendarsLoading();
}
calendarsLoading = isLoading;
},
eventBeforeAllRender: function(view) {
clearTimeout(timerIsLoading);
timerIsLoading = setTimeout(function() {
showCalendarsLoading();
}, 120); // wait briefly to display, to help flicker
clearEvents();
selectedEvent = {};
calendarMessage('none');
},
eventAfterAllRender: function(view) {
setLocationPins();
setLocationDetails();
hideCalendarsLoading();
if (view.name === 'month') {

if (repeatWeekDaysAfterManyEvents !== false && getMaxEventsPerDay() >= repeatWeekDaysAfterManyEvents) {
$(calendarDiv).find('.fc-day-week').css('visibility', 'visible');
} else {
$(calendarDiv).find('.fc-day-week').css('visibility', 'hidden');
}
}
if (eventsCount === 0) {
if (filterChanging || locationChanging) {
clearTimeout(timerCalendarMessage);
timerCalendarMessage = setTimeout(function() {
calendarMessage('no events');
}, 4000); // wait four seconds before displaying message if user is still typing
} else if (calendarsDisplayedCount === 0) {
clearTimeout(timerCalendarMessage);
timerCalendarMessage = setTimeout(function() {
calendarMessage('no calendars');
}, 1500); // wait one and a half seconds before displaying message
} else {
clearTimeout(timerCalendarMessage);
timerCalendarMessage = setTimeout(function() {
calendarMessage('no events');
}, 250); // wait a quarter of a second before displaying message
}
} else {
clearTimeout(timerCalendarMessage);
calendarMessage('none');
}
},
eventAfterFetchEvents: function() {
$(datePickerDiv).datepicker("refresh");
},
eventAfterPrefetchEvents: function() {
$(datePickerDiv).datepicker("refresh");
},
eventAfterRefetchEvents: function() {
hideCalendarsLoading();
},
eventMouseover: function(event, jsEvent, view) {
if (view.name === 'agendaWeek' || view.name === 'agendaDay') {
eventHoverTimer = setTimeout(function() {
$("#" + event.domId).addClass("fc-event-hover");
}, 450);
}

},
eventMouseout: function(event, jsEvent, view) {
clearTimeout(eventHoverTimer);
$("#" + event.domId).removeClass("fc-event-hover");
},
reRender: function() {
unselectEvents();
},
viewRender: function(view, element) {
clearTimeout(timerIsLoading);
timerIsLoading = setTimeout(function() {
showCalendarsLoading();
}, 120); // wait briefly to display, to reduce flicker
unselectEvents();
resizeCalendar(view);
setupDatePicker();
},
viewDestroy: function(view, element) {
unselectEvents();
},
dayClick: function(date, allDay, jsEvent, view) {
$(datePickerDiv).datepicker("setDate", date);
unselectEvents();
},
firstDay: 0,
minTime: 6,
maxTime: 22,
axisFormat: 'H(:mm)',
eventSources: calendarsDisplayed,
calendarDivId: calendarDivId
};
fullCalendarOptions = $.extend({}, fullCalendarOptions, calendarGemeindenOptions);
$(calendarDiv).fullCalendar(fullCalendarOptions);
if (calendarVisible !== false) {
setupDatepicker(); // Wait to initalize, as initializing the hidden date picker to begin with can cause the other, visible datepicker to have a date of 1900
}
resizeCalendar();
}

function resizeToBottom(element, minHeight) {
var newheight;
var offset;
var height;
height = isNaN(window.innerHeight) ? $(window).height() : window.innerHeight;
offset = element.offset();
newheight = height - offset.top;
element.css('height', newheight);
element.css('min-height', minHeight);
}

function resizeCalendar(view) {
if (calendarVisible === false) {
return;
}
resizeToBottom($(calendarDiv).find('.fc-view'), '400px'); // calendar

if (googleMaps === true && googleMapsDialog === false) {
resizeToBottom($(mapCalendarsDiv), '140px'); // map calendars
}
$(calendarDiv).find('.fc-view').scroll(function() {
$('.bt-active').btOn();
});
$(calendarDiv).find('.fc-scroller').scroll(function() {
$('.bt-active').btOn();
});
}

// ****************** functions for recording information
var infoText = '';
var timerInfoUpdate;

function sendInfo() {
$.info(infoText);
infoText = '';
}

function addInfo(newInfo) {

if (infoText !== '') {
infoText += ',' + newInfo;
} else {
infoText = newInfo;
}
if (infoText.length > 100) {
clearTimeout(timerInfoUpdate);
sendInfo(); // Immediately send info if there is a lot
} else {
clearTimeout(timerInfoUpdate);
timerInfoUpdate = setTimeout(function() {
sendInfo();
}, 10000); // send at most every 10 seconds
}
}

// ****************** Functions for processing the description and (when present) location filters
// **** Functions for processing phrases
function setPhrasesForLocations() {
var l;
phrases = [];
for (l = 0; l < locationInfo.length; l++) {
if (locationInfo[l].description === undefined) {
var a = 1;
}
if (locationInfo[l].description.indexOf(' ') !== -1) {
phrases.push(locationInfo[l].description.toLowerCase()); // if the location name has a space, add it to the list of fixed phrases
}
}
}

function isPhrase(text) {
// Checks whether the string text begins with a phrase; if it does, it returns the phrase; otherwise, it returns false
var p, nextChar, lowerText = text.toLowerCase();
for (p = 0; p < phrases.length; p++) {
if (phrases[p] === lowerText.substring(0, phrases[p].length)) {
nextChar = lowerText.charAt(phrases[p].length);
if (nextChar === '' || nextChar === '/' || nextChar === ' ') {
return text.substring(0, phrases[p].length);
}
}
}
return false;
}

function getNextPhrase(text) {
// Returns the next word or phrase -- they can be separated by spaces or slashes
var phrase = isPhrase(text), space, slash, lastIndex;
if (phrase !== false) {
return phrase;
} else {
space = text.indexOf(' ');
if (space === -1) {
space = text.length;
}
slash = text.indexOf('/');
if (slash === -1) {
slash = text.length;
}
lastIndex = Math.min(space, slash);
return text.substring(0, lastIndex);
}
}

// **** Functions for processing filters
function setFilterWords(words, filter) {
// words should be an array (of arrays) -- strings or arrays on the first level will be compared with AND, on the second level with OR
// Returns a string containing the corresponding text, where the arrays on the second level, to be compared with OR, are connected by "/"
var t, w, text;
if (typeof (words) === 'undefined') {
words = filter;
}
filter = words;
text = '';
for (t = 0; t < filter.length; t++) {
if (t > 0) {
text += ' ';
}
if (typeof (filter[t]) === 'string') {
text += filter[t];
} else {
for (w = 0; w < filter[t].length; w++) {
if (w > 0) {
text += '/';
}
text += filter[t][w];
}
}
}
return text;
}

function expandFilterLocations() {
// For now, just makes them lowercase
filterLocationsExpanded = objectToLowerCase(filterLocations);
}
function expandWord(word) {
word = word.toLowerCase();
if (equivalentSearchs[word] !== undefined) { // This search word is to be replaced with an array of equivalent searchs
return equivalentSearchs[word];
}
else {
return word;
}
}

function expandFilterWords() {
// Expands the filter words with the set of equivalents
var t, w, l;

filterWordsExpanded = [];
for (t = 0; t < filterWords.length; t++) {
if (typeof (filterWords[t]) === 'string') {
filterWordsExpanded[t] = expandWord(filterWords[t]);
} else {
filterWordsExpanded[t] = [];
for (w = 0; w < filterWords[t].length; w++) {
filterWordsExpanded[t] = filterWordsExpanded[t].concat(expandWord(filterWords[t][w]));
}
}
}
for (l = 0; l < filterLocations.length; l++) {
filterWordsExpanded[t++] = objectToLowerCase(filterLocations[l]);
}
}

function setFilterText(text, filter, any) {
// text: the filter text
// filter: the array to be filled with the terms contained in the filter text
// any: string of characters separating terms for which the search will be for any of them -- defaults to '/'
// if true, treats '/', ' ', ',' all as characters separating
var w, workingText, phrase, filterSeries, f, text, nextChar;
any = (typeof any === "undefined") ? '/' : any;
workingText = text;
filter.length = 0;
w = 0;
while (workingText.length > 0) {
phrase = getNextPhrase(workingText);
nextChar = workingText.charAt(phrase.length);
if (nextChar !== '' && any.indexOf(nextChar) !== -1) {
filterSeries = [];
f = 0;
while (nextChar !== '' && any.indexOf(nextChar) !== -1) {
if (phrase !== '') {
filterSeries[f++] = phrase;
}

workingText = workingText.substring(phrase.length + 1);
phrase = getNextPhrase(workingText);
nextChar = workingText.charAt(phrase.length);
}
if (phrase !== '') {
filterSeries[f++] = phrase;
}
workingText = workingText.substring(phrase.length + 1);
filter[w++] = filterSeries;
} else {
filter[w++] = phrase;
workingText = workingText.substring(phrase.length + 1);
}
}
}


function setSearchFilter(value, refreshInput) {
var newfilterText, changed = false;
filterChanging = false;
if (typeof (value) === 'string') {
newfilterText = value.toLowerCase();
if (newfilterText.toLowerCase() !== filterText.toLowerCase()) {
filterText = value;
setFilterText(value, filterWords);
updateSearchFilter(refreshInput); // Makes any necessary updates, refreshes the calendar, etc.
}
} else {
newfilterText = setFilterWords(value, filterWords);
filterText = newfilterText;
updateSearchFilter(); // Makes any necessary updates, refreshes the calendar, etc.
}
}

function activateFilterLocation() {
displayFilterLocation = true;
$(calendarOptionsDiv).find('.filter_location').css('visibility', 'visible');
}

function setSearchLocationFilter(value, refreshLocationInput) {
var newfilterText;
locationChanging = false;
if (displayFilterLocation === 'activate') {
activateFilterLocation();
}
if (displayFilterLocation === false) {
setSearchFilter(value, refreshLocationInput);
} else {
if (typeof (value) === 'string') {
newfilterText = value.toLowerCase();
if (newfilterText.toLowerCase() !== filterLocationText.toLowerCase()) {
filterLocationText = value;
setFilterText(value, filterLocations, ' /,'); // Since an event cannot be in two locations, assume spaces also indicate an event in ANY of the given locations
updateSearchLocationFilter(refreshLocationInput);
}
} else {
filterLocationText = setFilterWords(value, filterLocations);
updateSearchLocationFilter();
}
}
}

function refreshSearchFilters() {
$('#' + filterId).val(filterText);
if (displayFilterLocation === true) {
$(calendarOptionsDiv).find('.filter_location').val(filterLocationText);
}
}

function updateSearchFilter(refreshInput) {
var textLower;
filterText = setFilterWords(filterWords, filterWords);
if (typeof (refreshInput) === 'undefined') {
refreshInput = true; // By default refresh
}
storeCalendarOption('filterText', filterText);
textLower = filterText.toLowerCase();
if (textLower === 'messen' || textLower === 'messe') {
$('#' + terminauswahlId).val('mass');
} else if (textLower === '') {
$('#' + terminauswahlId).val('any');
} else {
$('#' + terminauswahlId).val('filter');
}
expandFilterWords();
updateWhatToDisplay(); // which in turn calls refetchEvents
addInfo(filterText); // records searches, to improve the processing of them
if (refreshInput === true) {
$('#' + filterId).val(filterText);
}
}

function updateSearchLocationFilter(refreshLocationInput) {
// refreshLocationInput true means that the input box for the ocation should be refreshed; otherwise it should not
if (typeof (refreshLocationInput) === 'undefined') {
refreshLocationInput = true; // By default refresh
}
filterLocationText = setFilterWords(filterLocations, filterLocations);
expandFilterLocations();
expandFilterWords(); // The location filter is added to the search filter
storeCalendarOption('filterLocation', filterLocationText);
addInfo(filterLocationText); // records searches, to improve the processing of them
if (refreshLocationInput === true) {
$(calendarOptionsDiv).find('.filter_location').val(filterLocationText);
}
updateWhatToDisplay(); // which in turn calls refetchEvents
}

// *** Functions for dealing with locations
function getLocationNames(locs) {
// locs is an array of locations
var names = [];
for (var i = 0; i < locs.length; i++) {
names.push(locs[i].description);
}
return names;
}

function subtractLocations(allLocations, subtractLocations) {
return subtractArraysObjects(allLocations, subtractLocations, 'description');
}
function mergeLocations(loc1, loc2) {
return mergeArraysObjects(loc1, loc2, 'description');
}
function isLocation(name) {
// Returns true if "name" is the name of a location, otherwise returns false
var nameLower = name.toLowerCase();
for (var l = 0; l < locationInfo.length; l++) {
if (nameLower === locationInfo[l].description.toLowerCase()) {
return true;
}
}
return false;
}

function isLocations(names) {
// Returns true if "names" is the name of a location, or if it is an array, in which at least one location is present, otherwise returns false
if (typeof (names) === 'string') {
return isLocation(names);
} else if (typeof (names) === 'object') {
for (var l = 0; l < names.length; l++) {
if (isLocation(names[l])) {
return true;
}
}
}
return false;
}

function calendarsForLocation(locations) {
// locations can be a string (locationId), an array of strings (locationId), or of locations
// RETURNS: an array of the calendars for this/these locations
// TO DO, for efficiency -- precalculate or cache these
var c, l, cal, cals = [], locArray, locs, calNames = [], cals2 = [], n, locIds, locId;
locArray = getLocations(locations);
locIds = getLocationIds(locArray);
if (typeof (locations) === 'string') {
locId = locations;
} else {
locId = locIds;
}
for (c = 0; c < calendars.length; c++) {
locs = calendars[c].location; // If it is defined, it should be either a string (for a single location) or an array (for multiple locations)
if (typeof (locs) === 'string') {
if (searchInObject(locId, locs) !== -1) { // if this location is identical to string locationId or contained in an array locationId
cals.push(calendars[c]);
}
} else if (typeof (locs) === 'object') {
for (l = 0; l < locs.length; l++) {
if (searchInObject(locId, locs[l]) !== -1) {
cals.push(calendars[c]);
}
}
}
}
n = 0;
for (l = 0; l < locArray.length; l++) {
cal = locArray[l].calendar;
if (typeof (cal) === 'string') {
calNames[n++] = cal;
} else if ((typeof (cal)) === 'object') {
calNames = calNames.concat(cal);
n += calNames.length;
}
}
cals2 = getCalendarsByName(calNames);
return mergeCalendars(cals, cals2);
}

function allCalendarsForLocation(locations) {
// locations can be a string (locationId) or an array of strings or location objects
// RETURNS: an array of the calendars that COULD have events in this location
// TO DO, for efficiency -- precalculate or cache these
var c, l, cal, cals = [], locArray, locs, calNames = [], cals2 = [], n;
var locationIds;
if (isLocationCalendarExclusive(locations)) { // If location(s) ONLY has events from certain calendars, return those calendars
return calendarsForLocation(locations);
}
locArray = getLocations(locations);
locationIds = getLocationIds(locArray);
for (c = 0; c < calendars.length; c++) {
if (calendars[c].locationExclusive === true) { // If calendar only has events for certain locations
locs = calendars[c].location;
if (typeof (locs) === 'string') { // should be either string or array
if (searchInObject(locationIds, locs) !== -1) { // if this location is identical to string locationId or contained in an array locationId
cals.push(calendars[c]);
}
} else if (typeof (locs) === 'object') {
for (l = 0; l < locs.length; l++) {
if (searchInObject(locationIds, locs[l]) !== -1) {
cals.push(calendars[c]);
}
}
}
} else {
cals.push(calendars[c]); // If the calendar isn't determined to particular locations, we have to add it
}
}
n = 0;
for (l = 0; l < locArray.length; l++) {
cal = locArray[l].calendar;
if (typeof (cal) === 'string') {
calNames[n++] = cal;
} else if (typeof (cal) === 'object') {
calNames = calNames.concat(cal);
n = calNames.length;
}
}
cals2 = getCalendarsByName(calNames);
return mergeCalendars(cals, cals2);
}

function calendarsDisplayedForLocation(locations) {
// locations can be a string (locationId), an array of strings (locationId), or of locations
// RETURNS: an array of the calendars for this location which are current displayed
var c, cals = [], calsVisible = [];
cals = calendarsForLocation(locations);
for (c = 0; c < cals.length; c++) {
if (cals[c].display === true) { // If calendar especially shows certain locations
calsVisible.push(cals[c]);
}
}
return calsVisible;
}

function areCalendarsForLocationVisible(locations) {
// locations can be a string (locationId), an array of strings (locationId), or of locations
// Returns true if at least one calendar that COULD have events in this/these locations is visible
var c, cals, otherCals;
if (calendarsDisplayedForLocation(locations).length > 0) {
return true; // Some calendars are displayed, that have events in this location
}
if (isLocationCalendarExclusive(locations)) { // There are only specific calendars that have events in the location
return false; // and none of these calendars is currently displayed
} else {
cals = calendarsForLocation(locations);
otherCals = subtractCalendars(calendars, cals);
for (c = 0; c < otherCals.length; c++) {
if (otherCals[c].display === true && otherCals[c].locationExclusive === false) { // If calendar is displayed, and is not restricted to certain locations
return true; // It could potentially have events in this location
}
}
}
return false;
}

function searchArray(searchCorpus, searchTerms) {
// returns true if all the terms in searchTerms are found in searchCorpus, otherwise false
if (typeof (searchTerms) === 'string') {
if (searchInObject(searchCorpus, searchTerms) !== -1) {
return true;
}
return false;
} else {
for (var i = 0; i < searchTerms.length; i++) {
if (searchInObject(searchCorpus, searchTerms[i]) === -1) {
return false;
}
}
return true;
}
}

function areCalendarsForLocationExclusive(locations, calSelection) {
// locations can be a string (locationId), an array of strings (locationId), or of locations
// If there are calendars that COULD (calSelection = 'all') or especially ('some') contain events for a location, and
// these calendars ONLY contain events for that location, returns true; otherwise returns false
// if locationId is an array of locations, returns true if in each case calendars are exclusively for them
// These can used, e.g., to determine whether location can be restricted to a given location by restricting calendars
var c, cals;
var locationId = getLocationIds(locations);
if (typeof (calSelection) === 'undefined') {
calSelection = 'some';
}
if (calSelection === 'some') {
cals = calendarsForLocation(locations);
} else {
cals = allCalendarsForLocation(locations);
}
for (c = 0; c < cals.length; c++) {
if (cals[c].location !== undefined && cals[c].locationExclusive === true) { // If calendar only shows certain locations
if (searchArray(locationId, cals[c].location) === false) {
return false; // This location could display events in other locations
}
} else if (calSelection === 'all') {
return false; // This location is not determinate, so it could potentially display events in other locations
}
}
return true;
}

function isLocationCalendarExclusive(locations) {
// Returns true if only specified calendars may have events in each one of the location(s) (locationId, array thereof, or of calendars)
// otherwise returns false
var locArray, l;
locArray = getLocations(locations);
if (locArray.length > 0) {
for (l = 0; l < locArray.length; l++) {
if (locArray[l].calendarExclusive !== true) { // If false or if undefined
return false;
}
}
return true;
}
}

function displayCalendarLocation(locations) {
// Displays any calendars that especially have events in the given location -- Returns true if any are additionally displayed.
return displayCalendars(calendarsForLocation(locations));
}

function displayCalendars(cals) {
var c, addedCals = false;
for (c = 0; c < cals.length; c++) {
if (cals[c].display === false) {
addedCals = true;
displayCalendar(cals[c], 10);
}
}
return addedCals;
}

function addAllCalendarsLocation(locations) {
// locations can be a string (locationId), an array of strings (locationId), or of locations
// Displays any calendars that could have events in the given location(s) -- Returns true if any are additionally displayed.
// Shows only the calendars that are especially for the location(s), or that are indeterminate
return displayCalendars(allCalendarsForLocation(locations)); // returns true if some were added, false if none were added
}

function addSearchLocation(locations, whichCalendars) {
// Sets the filter to show events in the given location (locationId or location object, or array thereof), in addition to any others
// if whichCalendars (default is true), then add any calendars that especially have events in the location(s)
var locationName;
var loc = false;
var changedLoc = false;
var changedFilter = false;
if (typeof (whichCalendars) === 'undefined') {
whichCalendars = true;
}
loc = isLocationObject(locations);
if (loc === false && typeof (locations) === 'string') {
loc = getLocationById(locations);
}
if (loc !== false) {
locationName = loc.description;
if (displayFilterLocation === true) {
changedLoc = requireFilterTerm(locationName, filterLocations);
}
changedFilter = requireFilterTerm(locationName, filterWords, isLocations);
if (changedFilter) {
updateSearchFilter();
}
if (changedLoc) {
updateSearchLocationFilter();
}
if (whichCalendars) {
displayCalendarLocation(loc.id);
}
} else if (typeof (locations) === 'object') { // is an array of ids or locations
for (var i = 0; i < locations.length; i++) {
addSearchLocation(locations[i], whichCalendars);
}
}
}

function addSearchLocationManual(locations, whichCalendars) {
// disables automatic restrict of location, and sets the filter to show events in the given location(s), in addition to any others
notRestrictToVisibleMap(); // Turn off the automatic updating
addSearchLocation(locations, whichCalendars);
}
function clearAreaCounts() {
for (var i = 0; i < areas.length; i++) {
areas[i].locCount = 0;
}
}
function removeAreaMarkers(area) {
for (var i = 0; i < locationInfo.length; i++) {
if (locationInfo[i].area === area) {
removeLocationPin(locationInfo[i]);
}
}
}
function showAreaMarkers(area) {
for (var i = 0; i < locationInfo.length; i++) {
if (locationInfo[i].area === area) {
setLocationPin(locationInfo[i]);
}
}
}
function updateAreas() {
// TO DO: base changes on rendering time rather than simply absolute number of locations (if many locations take long to render, show just the area)
var totalLocs = 0;
for (var i = 0; i < areas.length; i++) {
totalLocs += areas[i].locCount;
}
for (var i = 0; i < areas.length; i++) {
if (areas[i].forceLocsVisible === false && (areas[i].locCount > 150 || (areas[i].locCount > 110 && totalLocs > 200))) {
if (areas[i].visible === true) {
areas[i].visible = false;
areas[i].poly.setVisible(true);
removeAreaMarkers(areas[i]);
}
} else {
if (areas[i].visible === false) {
areas[i].visible = true;
areas[i].poly.setVisible(false);
showAreaMarkers(areas[i]);
if (infoWindow.area === areas[i]) {
queue(function() {
infoWindow.close(); // Don't show the info window about the area anymore, since the area itself is no longer displayed
infoWindow.area = false;
});
}
}
}
}
var area;
for (i = 0; i < locationInfo.length; i++) {
area = locationInfo[i].area;
if (area !== undefined && area !== false) {
if (area.visible === true) {
locationInfo[i].areaVisible = true;
} else {
locationInfo[i].areaVisible = false;
}
} else {
locationInfo[i].areaVisible = true; // If no area is assigned, the area is assumed to be everywhere
}
}
}

function getVisibleLocations() {
var mapBounds, l, locs, visible;
mapBounds = myMap.getBounds();
clearAreaCounts();
if (mapBounds === undefined) {
return false;
}
for (l = 0; l < locationInfo.length; l++) {
if (mapBounds.contains(locationInfo[l].latLng)) {
visible = true;
} else {
visible = false;
}
locationInfo[l].locationVisible = visible;
if (visible) {
if (locationInfo[l].area !== undefined) {
locationInfo[l].area.locCount++;
}
}
}
updateAreas();
locs = [];
for (l = 0; l < locationInfo.length; l++) {
if (locationInfo[l].locationVisible === true && locationInfo[l].areaVisible === true) {
locs.push(locationInfo[l].id); // Display this location
}
}
return locs;
}

function getLocationsInBounds(bounds) {
var locs = [];
for (var i = 0; i < locationInfo.length; i++) {
if (bounds.intersects(bounds)) {
locs.push(locationInfo[i]);
}
}
return locs;
}
function getVisibleCalendars() {
var mapBounds;
var locs;
var cals = [];
var l;
mapBounds = myMap.getBounds();
for (var i = 0; i < calendars.length; i++) {
locs = getLocations(calendars[i].location);
calendars[i].locationVisible = false;
for (l = 0; l < locs.length; l++) {
if (locs[l].locationVisible === true && locs[l].areaVisible !== false) {
calendars[i].locationVisible = true;
cals.push(calendars[i]);
break;
}
}
if (calendars[i].id = 'wn') {
debugger;
}
if (l === locs.length && calendars[i].locationExtended !== undefined) {
if (mapBounds.intersects(calendars[i].mapBounds)) {
calendars[i].locationVisible = true;
cals.push(calendars[i]);
}
}
}
return cals;
}

function restrictVisibleChange() {
if (restrictedToVisibleMap()) {
restrictSearchLocationVisibleMap();
} else {
listExtraCalendars(); // To add select check boxes
}
}
function restrictSearchLocationVisibleMap() {
var locs, cals;
locs = getVisibleLocations();
if (locs === false) {
return; // Unable to get visible locations
}
cals = getVisibleCalendars(); // should be called after the locations
if (calendarGemeindenOptions.restrictLocation === 'calendar') {
if (displayFilterLocation === true) {
setSearchLocationFilter('', true);
}
restrictSearchLocation([], 'all', cals);
} else {
restrictSearchLocation(locs, 'all', cals);
}
listExtraCalendars();
}

function updateCalendarsVisibleMap() {
var cals, i;
cals = allCalendarsForLocation(getVisibleLocations());
for (i = 0; i < calendars.length; i++) {
calendars[i].locationVisible = false;
}
for (i = 0; i < cals.length; i++) {
cals[i].locationVisible = true;
}
listExtraCalendars();
}

//function
function _restrictSearchLocation(locations, filterArray) {
// locations can be a location, array of locations, a string or array of location ids
var set, l, locationLower, filterWordLower, changed, alreadyRestricted;
var locationName;
if (isLocationObjects(locations)) {
locationName = getLocationNames(locations);
} else {
locationName = locations;
}
var locationNameArray;


if (typeof (locationName) === 'string') {
locationNameArray = [locationName];
} else {
locationNameArray = locationName;
}
locationLower = objectToLowerCase(locationNameArray);
alreadyRestricted = false;
changed = false;
for (set = 0; set < filterArray.length; set++) {
if (typeof (filterArray[set]) === 'string') {
filterWordLower = filterArray[set].toLowerCase();
if (typeof (locationName) === 'string') {
if (filterWordLower === locationLower) {
alreadyRestricted = true; // there is already a filter equal to locationName
}
} else {
if (isLocation(filterWordLower)) { // If location is restricted, make it restricted to the array locationName
filterArray[set] = locationName;
changed = true;
}
}
} else {
if (filterArray[set].length === locationNameArray.length) {
alreadyRestricted = true;
for (l = 0; l < locationNameArray.length; l++) {
if (searchInObject(filterArray[set], locationNameArray[l]) === -1) {
alreadyRestricted = false;
break;
}
}
}
if (alreadyRestricted === false) {
filterArray[set] = locationName;
changed = true;
}
}
}
if (changed === false && alreadyRestricted === false) { // If no change is necessary, function has already returned -- at this point, we need to add the location
filterArray[filterArray.length] = locationName;
changed = true;
}
if (filterArray.length === 0) {
filterArray[0] = locationName;
changed = true;
}
return changed;
}

function removeAllSearchLocations() {
var set, l, changed;
var onlyLocations;
changed = false;
set = 0;
if (displayFilterLocation === true) {
if (filterLocationText !== '') {
filterLocations = [];
filterLocationsExpanded = [];
filterLocationText = '';
changed = true;
}
}
while (set < filterWords.length) {
if (typeof (filterWords[set]) === 'string') {
if (isLocation(filterWords[set])) { // If it is a location, remove it
filterWords.splice(set, 1);
set--;
changed = true;
}
} else {
onlyLocations = true;
for (l = 0; l < filterWords[set].length; l++) {
if (isLocation(filterWords[set][l]) === false) {
onlyLocations = false;
break;
}
}
if (onlyLocations === true) {
filterWords.splice(set, 1);
set--;
changed = true;
}
}
set++;
}
if (changed) {
filterText = setFilterWords(filterWords, filterWords);
expandFilterWords();
refreshSearchFilters();
}
return changed;
}

function removeSearchTerm(term, filterArray) {
// Removes the given term -- string or object -- from the search filter. Returns true if something has been removed
var removed, set, i, termLower;
if (typeof (term) === 'string') {
set = 0;
termLower = term.toLowerCase();
while (set < filterArray.length) {
if (typeof (filterArray[set]) === 'string') {
if (filterArray[set].toLowerCase() === termLower) { // If it is a location, remove it
filterArray.splice(set, 1);
set--;
removed = true;
}
} else {
i = 0;
while (i < filterArray[set].length) {
if (filterArray[set][i].toLowerCase() === termLower) {
filterArray[set].splice(i, 1);
i--;
removed = true;
}
i++;
}
if (i === 0) { // no terms left
filterArray.splice(set, 1);
set--;
}
}
set++;
}
return removed;

} else { // If search is an object, recurse, and return true if any of the terms are found
removed = false;
for (i = 0; i < term.length; i++) {
if (removeSearchTerm(term[i], filterArray) === true) {
removed = true;
}
}
return removed;
}
}

function isLocationObjects(element) {
// returns true if element is a location object or array thereof, otherwise false
if (typeof (element) === 'object') {
if (element.description !== undefined) {
return true;
}
if ($.isArray(element)) {
if (element[0].description !== undefined) {
return true;
}
}
}
return false;
}

function isLocationObject(element) {
// returns true if element is a location object, otherwise false
if (typeof (element) === 'object') {
if (element.description !== undefined) {
return true;
}
}
return false;
}

function removeSearchLocations(locations) {
// locations is either a string or array of location ids, or an array of location objects
var changed = false;
var locationNames;
if (isLocationObjects(locations)) {
locationNames = getLocationNames(locations);
} else {
locationNames = locations;
}
if (typeof (locationNames) === 'undefined') {
return removeAllSearchLocations();
}
if (displayFilterLocation === true) {
changed = removeSearchTerm(locationNames, filterLocations);
}
changed = removeSearchTerm(locationNames, filterWords) || changed;
if (changed) {
filterText = setFilterWords(filterWords, filterWords);
if (displayFilterLocation === true) {
filterLocationText = setFilterWords(filterLocations, filterLocations);
}
expandFilterWords();
refreshSearchFilters();
}
return changed;
}

function restrictSearchLocationManual(locations) {
// disables automatic restrict of location, and sets the filter to restrict events to the given location(s)
notRestrictToVisibleMap(); // Turn off the automatic updating
restrictSearchLocation(locations);
}
function restrictSearchLocation(locations, whichCalendars, additionalCalendars) {
// Shows only the events in the given location(s); if whichCalendars is 'all', add all calendars that could display events in the locations
// if whichCalendars is 'some' (default), add calendars that especially have events for the locations
// additionalCalendars are calendars that should always be/remain selected
var changed, locationList, locs, otherLocs;
var justCalendars;
if (typeof (whichCalendars) === 'undefined') {
whichCalendars = 'some';
}
if (typeof (additionalCalendars) === 'undefined') {
additionalCalendars = [];
}
displayCalendars(additionalCalendars);
locs = getLocations(locations);
if (locs.length === 0) {
restrictCalendars(additionalCalendars);
return true;
}
justCalendars = false;
changed = false;
if (isLocationCalendarExclusive(locs)) {
if (areCalendarsForLocationExclusive(locs, 'all')) {
changed = removeSearchLocations();
refreshSearchFilters();
justCalendars = true;
}
}
if (whichCalendars === 'all') {
addAllCalendarsLocation(locs);
} else if (whichCalendars === 'some') {
displayCalendarLocation(locs); // make sure the calendars for the location are displayed
}
otherLocs = subtractLocations(locationInfo, locs);
if (restrictCalendarsToLocation(locs, additionalCalendars) !== false) {
changed = true;
}
if (justCalendars) {
return changed; // location is adequately restricted by calendars -- don't need to add any filter
}
if (displayFilterLocation === 'activate') {
activateFilterLocation();
}
locationList = getLocationFilterWordList();
changed = _restrictSearchLocation(locs, locationList);
if (changed === true) {
showCalendarsLoading();
locationList = getLocationFilterWordList();
timerDelayRefresh = setTimeout(function() {
setSearchLocationFilter(locationList, true);
}, 20); // wait briefly to refresh, since it could be changed twice
}
return changed;
}

function requireFilterTerm(term, filterArray, condition) {
// requires the term to be present in each group of filters in filterArray that meets the (optional) condition
var termLower, set, termInGroup, changed, num;
termLower = term.toLowerCase();
if (typeof (condition) === 'undefined') {
condition = function() {
return true;
};
}
for (set = 0; set < filterArray.length; set++) {
if (condition(filterArray[set])) {
if (typeof (filterArray[set]) === 'string') {
if (filterArray[set].toLowerCase() !== termLower) {
filterArray[set] = [filterArray[set], term]; // Add the required term
changed = true;
}
} else {
termInGroup = false;
for (num = 0; num < filterArray[set].length; num++) {
if (filterArray[set][num].toLowerCase() === termLower) {
termInGroup = true;
break;
}
}
if (termInGroup === false) { // If term is not in group, add it to the group
filterArray[set].push(term); // add this term to this filter set
changed = true;
}
}
}
}
return changed;
}

function allLocationEvents(locationId) {
var changedLoc = false;
var changedFilter = false;
var loc = getLocationById(locationId);
if (displayFilterLocation === true) {
changedLoc = requireFilterTerm(loc.description, filterLocations);
}
changedFilter = requireFilterTerm(loc.description, filterWords);
if (changedFilter) {
updateSearchFilter();
}
if (changedLoc) {
updateSearchLocationFilter();
}
displayCalendarLocation(loc);
}

function isAdditionalSearchFilter(filter) {
var set, num, inGroup, filterLower, replaceText;

filterLower = filter.toLowerCase();
for (set = 0; set < filterWords.length; set++) {
if (typeof (filterWords[set]) === 'string') {
if (filterWords[set].toLowerCase() !== filterLower) {
return true; // There is a filter different from the input "filter"
}
} else {
inGroup = false;
for (num = 0; num < filterWords[set].length; num++) {
if (filterWords[set][num].toLowerCase() === filterLower) {
inGroup = true;
break;
}
}
if (inGroup === false) {
return true;
}
}
}
return false; // Either there are not search filters, or the filter "filter" is always one of them
}

function getLocationFilterWordList() {
if (displayFilterLocation === true) {
return filterLocations;
} else {
return filterWords;
}
}

function getLocationFilterWordListExpanded() {
if (displayFilterLocation === true) {
return filterLocationsExpanded;
} else {
return filterWordsExpanded;
}
}

function isAdditionalLocation(location) {
// if events may be displayed for any location other than the single locationName
// TO DO (if needed): allow checking for locations beyond a set of locations
var set, num, locationLower, wordList, cals, c;
var locationName;
var isPresent;
var loc = getLocationById(location);
if (loc === false) {
return true;
}
locationName = loc.description;
locationLower = locationName.toLowerCase();
wordList = getLocationFilterWordListExpanded();
for (set = 0; set < wordList.length; set++) {
if (typeof (wordList[set]) === 'string') {
if (wordList[set] === locationLower) {
return false; // There is a filter equal to the input "locationName" -- thus the location has to be present
}
} else if (wordList[set].length === 1) {
if (wordList[set][0] === locationLower) {
return false; // There is a filter equal to the input "locationName" -- thus the location has to be present
}
}
else {
isPresent = false;
for (num = 0; num < wordList[set].length; num++) {
if (isLocation(wordList[set][num]) && wordList[set][num] !== locationLower) {
if (areCalendarsForLocationVisible(wordList[set][num])) {
return true; // There is another allowed location for which some calendar is displayed
}
}
}
}
}
if (areCalendarsForLocationExclusive(location)) {
//if (areCalendarsForLocationExclusive(locationId) , 'all') // to check all calendars that COULD display locations here?
//cals = subtractCalendars(calendar, calendarsForLocation(locationId)); // The calendars that aren't for thise one;
cals = subtractCalendars(calendars, allCalendarsForLocation(location)); // The calendars that aren't for thise one;
for (c = 0; c < cals.length; c++) {
if (cals[c].display === true) {
return true; // Other calendars are displayed;
}
}
return false;
}
return true;
}

function isSearchLocationRestricted(location) {
// If there is a filter restricting the search to a location other than the given one, return a location to which it is restricted, otherwise return false
var set, num, locationLower, locationInGroup, thisLocationInGroup;
var locationName;
var loc = getLocationById(location);
if (loc === false) {
locationName = 'nolocation';
} else {
locationName = loc.description;
}
locationLower = locationName.toLowerCase();
for (set = 0; set < filterWordsExpanded.length; set++) {
if (typeof (filterWordsExpanded[set]) === 'string') {
if (filterWordsExpanded[set] !== locationLower && isLocation(filterWordsExpanded[set])) {
return filterWordsExpanded[set]; // There is a filter for a location other than the given location
}
} else {
locationInGroup = false;
thisLocationInGroup = false;
for (num = 0; num < filterWordsExpanded[set].length; num++) {
if (isLocation(filterWordsExpanded[set][num])) {
locationInGroup = filterWordsExpanded[set][num];
}
if (filterWordsExpanded[set][num] === locationLower) {
thisLocationInGroup = true;
}
}
if (locationInGroup !== false && thisLocationInGroup === false) {
return locationInGroup;
}

}
}
return false;
}

function areSearchLocationsRestricted(locations) {
var t = typeof (locations);
if (t === 'undefined') {
return false;
} else if (t === 'string') {
return isSearchLocationRestricted(locations);
}
for (var i = 0; i < locations.length; i++) {
if (isSearchLocationRestricted(locations[i]) === false) {
return false; // If at least one of the locations is shown
}
}
return true;
}

function isSearchLocationCalendarRestricted(location) {
// if specific calendars especially show this location, and are not shown, returns true. Otherwise false
var c, cals;
cals = calendarsForLocation(location);
for (var c = 0; c < cals.length; c++) {
if (cals[c].display === false) { // If calendar is not displayed, and calendar especially shows certain locations
return true;
}
}
return false;
}

function updateSearchLocationDone(value) {
locationChanging = false;
notRestrictToVisibleMap();
setSearchLocationFilter(value, false);
}
var timerUpdateLocationFilter;

function updateSearchLocationChanging(value) {
var newfilterText;
locationChanging = true;
newfilterText = value.toLowerCase();
if (newfilterText !== filterLocationText.toLowerCase()) {
clearTimeout(timerUpdateLocationFilter);
timerUpdateLocationFilter = setTimeout(function() {
setSearchLocationFilter(value, false);
}, 600); // wait just under one second before refreshing the events, so that while one is still typing, the events are not constantly refreshed
}
}

function updateSearchFilterDone(value) {
filterChanging = false;
setSearchFilter(value, false);
}
var timerUpdateSearchFilter;

function updateSearchFilterChanging(value) {
var newfilterText;
filterChanging = true;
newfilterText = value.toLowerCase();
if (newfilterText !== filterText.toLowerCase()) {
clearTimeout(timerUpdateSearchFilter);
timerUpdateSearchFilter = setTimeout(function() {
setSearchFilter(value, false);
}, 600); // wait just under one second before refreshing the events, so that while one is still typing, the events are not constantly refreshed
}
}

function setupDatepicker() {
var pickerOpts = {monthNames: ['Jänner', 'Februar', 'März', 'April', 'Mai', 'Juni',
'Juli', 'August', 'September', 'Oktober', 'November', 'Dezember'],
monthNamesShort: ['Jän', 'Feb', 'Mär', 'Apr', 'Mai', 'Jun',
'Jul', 'Aug', 'Sep', 'Okt', 'Nov', 'Dez'],
dayNames: ['Sonntag', 'Montag', 'Dienstag', 'Mittwoch', 'Donnerstag', 'Freitag', 'Samstag'],
dayNamesShort: ['So', 'Mo', 'Di', 'Mi', 'Do', 'Fr', 'Sa'],
dayNamesMin: ['So', 'Mo', 'Di', 'Mi', 'Do', 'Fr', 'Sa'],
dateFormat: 'dd.mm.yy',
firstDay: 0,
prevText: '&#x3c;zurück', prevStatus: '',
prevJumpText: '&#x3c;&#x3c;', prevJumpStatus: '',
nextText: 'Vor&#x3e;', nextStatus: '',
nextJumpText: '&#x3e;&#x3e;', nextJumpStatus: '',
currentText: 'heute', currentStatus: '',
todayText: 'heute', todayStatus: '',
clearText: '-', clearStatus: '',
closeText: 'schließen', closeStatus: '',
yearStatus: '', monthStatus: '',
weekText: 'Wo', weekStatus: '',
dayStatus: 'DD d MM',
defaultStatus: '',
//showOtherMonths: true,
//selectOtherMonths: true,
isRTL: false,
defaultDate: 0,
onSelect: function(dateText, inst) {
var date = $(datePickerDiv).datepicker("getDate");
var view = $(calendarDiv).fullCalendar('getView');
if (view.name === 'agendaList' && view.getAgendaListOrder() === 'times') { // TO DO: only scroll up or down if none are currently visible
var events = view.getDisplayEventList();
var event;
var diff;
var closest = false;
var closestDiff = 86400000 * 10000;
for (var i = 0; i < events.length; i++) {
var event = events[i];
diff = events[i].start - date;
if (diff >= 0 && diff < 86400000) {
closest = event;
break;
} else {
diff = Math.abs(diff);
if (diff < closestDiff) {
closest = event;
closestDiff = diff;
}
}
}
if (closest) {
var obj = $("#" + closest.domId);
if (obj.length > 0) {
$(calendarDiv).find('.fc-view').animate({
scrollTop: Math.max(obj.position().top + $(calendarDiv).find('.fc-view').scrollTop() - 4, 0)
}, 600);
}
}
}
$(calendarDiv).fullCalendar('gotoDate', date);
},
onChangeMonthYear: function(year, month, inst) {
if ($(calendarDiv).fullCalendar('getView').name === 'month') {
$(calendarDiv).fullCalendar('gotoDate', year, month - 1);
} else {
$(calendarDiv).fullCalendar('prefetchMonth', new Date(year, month - 1, 2));
$(calendarDiv).fullCalendar('calendarIsActive');
}
},
beforeShowDay: function(date) {
var className = "";
var feastDay = '';
var feast;
feast = getFeastDay(date);
if (feast !== false) {
if (feast === true) {
feastDay = 'Festtag';
} else {
feastDay = feast;
}
className = 'feastday';
}
var events = getEventsOnDate(date, 'selected');
if (events.length > 0) {
className += ' dayhasevents';
for (var i = 0; i < events.length; i++) {

if (feastDay !== '') {
feastDay += '&#10;';
}
feastDay += events[i].title;
}
}
return [true, className, feastDay];
}
};

var date = new Date();
date = date.getDate() + "." + (date.getMonth() + 1) + "." + date.getFullYear();
$(datePickerDiv).datepicker(pickerOpts);
$(datePickerDiv).val(date);
}
function getRangeName(view) {
var range = '';
if (view.name === 'agendaDay') {
range = 'an diesem Tag';
} else if (view.name === 'agendaWeek' || view.name === 'basicWeek') {
range = 'in dieser Woche';
} else if (view.name === 'month') {
range = 'in diesem Monat';
} else {
range = 'in dieser Zeit';
}
return range;
}

function hideCalendarMessage() {
$(calendarMessageDiv).css('visibility', 'hidden');
}
function calendarMessage(msg) {
var message = '', range, location;
var inCalendars;
if (calendarVisible === false) {
calendarMessageHidden = msg;
return;
}
if (msg === 'none') {
hideCalendarMessage();
} else {
range = getRangeName($(calendarDiv).fullCalendar('getView'));
if (displayFilterLocation === true && filterLocationsExpanded.length > 0) {
if (filterLocationsExpanded.length === 1 && typeof (filterLocationsExpanded[0]) === 'string') {
location = ' an dem Ort: ' + filterLocationText;
} else {
location = ' an den Orten: ' + filterLocationText;
}
} else {
location = '';
}
if (calendarsDisplayedCount === 1) {
inCalendars = ' ' + calendarGemeindenOptions.messages.inSelectedCalendarText;
}
else if (calendarsDisplayedCount < calendars.length) {
inCalendars = ' ' + calendarGemeindenOptions.messages.inSelectedCalendarsText;
} else {
inCalendars = '';
}
if (msg === 'no events') {
if (calendarsDisplayedCount === 0) {
message = '<p>Keine Kalender bzw. Gemeinden gewählt</p>';
} else if (eventsCountFilteredOut > 0) {
if (filterEventId === 'filter') {
message = '<p>Keine Termine ' + range + location + inCalendars + ' gefunden mit dem Suchbegriff: ' + filterText + '</p>';
} else {
message = '<p>Keine ' + filterEventType.description + ' ' + range + location + inCalendars + ' gefunden</p>';
}
} else {
if (calendarsDisplayedCount < calendars.length) {
message = '<p>Keine Termine ' + range + location + inCalendars + ' gefunden.</p>';
}
}
} else if (msg === 'no calendars') {
message = '<p>Keine Kalender bzw. Gemeinden gewählt</p>';
}
$(calendarMessageDiv).html(message);
$(calendarMessageDiv).css('visibility', 'visible');
}
}

function unselectEvents() {
var borderColor;
var domId;
var event;

$('.fc-event-sel').btOff();
$('.fc-event-start.bt-active').btOff();
$("div.fc-event-sel").each(function(index, element) {
domId = $(this).attr('id');
event = $(calendarDiv).fullCalendar('getEventById', domId);

if (event !== false) {
var source = event.source || {};
borderColor =
event.borderColor ||
event.color ||
source.borderColor ||
source.color;
} else {
borderColor = '#444444';
}
$(this).removeClass("fc-event-sel").addClass("fc-event").css("border", "1px solid " + borderColor); // Remove CSS event selected class from any previously selected event and return to normal
});
$("tr.fc-event-sel").removeClass("fc-event-sel").css("border", "");
//$('.bt-active').btOff();
}

function unselectEventsLocation() {
var domId;
var event;
var borderColor;
//infowindow.close(); // Don't need to call close if there is only one infowindow

$("div.fc-event-loc-sel").each(function(index, element) {
domId = $(this).attr('id');
event = $(calendarDiv).fullCalendar('getEventById', domId);

if (event !== false) {
var source = event.source || {};
borderColor =
event.borderColor ||
event.color ||
source.borderColor ||
source.color;
} else {
borderColor = '#444444';
}
$(this).removeClass("fc-event-loc-sel").addClass("fc-event").css("border", "1px solid " + borderColor); // Remove CSS event selected class from any previously selected event and return to normal
});
$("tr.fc-event-loc-sel").removeClass("fc-event-loc-sel").css("border", ""); // Remove CSS event selected class from any previously selected event and return to normal
$(".fc-eventlist-title-loc-sel").removeClass("fc-eventlist-title-loc-sel"); // Remove CSS event selected class from any previously selected event and return to normal
$(".fc-agendaList-dayHeader-loc-sel").removeClass("fc-agendaList-dayHeader-loc-sel");
}
function nowVisible() {
if (calendarVisible !== true) {
if (!calendarOnceVisible) {
setupDatepicker(); // Wait to initalize, as initializing the hidden date picker to begin with can cause the other, visible datepicker to have a date of 1900
$(calendarDiv).fullCalendar('render');
calendarOnceVisible = true;
} else {
$(calendarDiv).fullCalendar('updateSize');
}
//updateWhatToDisplay(); // In the event that the user refreshes the page (some browsers retain what was previously selected)
//if (calendarMessageHidden !== '') {
// calendarMessage(calendarMessageHidden);
//}
if (calendarsLoading) {
showCalendarsLoading();
} else {
hideCalendarsLoading();
}
} else {
$(calendarDiv).fullCalendar('windowResize');
}
calendarVisible = true;
}

function showCalendarsLoading() {
if (calendarVisible !== false) {
$(loadingDiv).css('visibility', 'visible');
}
}
function hideCalendarsLoading() {
if (calendarVisible !== false) {
$(loadingDiv).css('visibility', 'hidden');
}
clearTimeout(timerIsLoading);
}
function nowNotVisible() {
unselectEvents();
hideCalendarMessage();
hideCalendarsLoading();
if (googleMapsDialog === true) {
googleMapOff();
}
calendarVisible = false;
}

function getEventType(filterSelection) {
for (var i = 0; i < eventTypes.length; i++) {
if (filterSelection === eventTypes[i].id) {
return eventTypes[i];
}
}
return []; // No event type found
}

function updateWhatToDisplay() {
if (calendarLoading) {
return;
}
var newFilterEventId = $('#' + terminauswahlId + ' :selected').val();
if (newFilterEventId !== filterEventId) {
addInfo(newFilterEventId); // records searches, to improve the processing of them
}
filterEventId = newFilterEventId;
filterEventType = getEventType(filterEventId);
storeCalendarOption('filterEventId', filterEventId);
queue(function() {
unselectEvents();
$(calendarDiv).fullCalendar('refetchEvents');
resizeCalendar();
}, 0, 'refetchEvents'); // a very brief delay, so that when multiple automatic changes trigger a refresh, it is only refreshed once
}

function infoCalendars() {
var calendarList = '';
var i = 0;
$(calendarOptionsDiv).find('input:checked').filter('.chkbox_gemeinde').each(function() {
calendarList += $(this).val() + '-';
});
addInfo(calendarList);
}

var displayCalendarQueue = [];
var removeCalendarQueue = [];

function refreshCalendars() {
$(calendarDiv).fullCalendar('addRemoveEventSources', displayCalendarQueue, removeCalendarQueue);
displayCalendarQueue = [];
removeCalendarQueue = [];
listExtraCalendars();
setLocationDetails();
}

function displayCalendarSelector(cal) {
if (cal.selectBox !== false) {
displayFixedCalendarSelector(cal);
if (cal.display === true) {
$('#' + calendarChkboxId(cal.id)).attr('checked', 'checked');
}
}
}
function displayCalendar(cal, refresh) {
// if refresh is true, immediately refresh; otherwise delay the corresponding number of milliseconds
if (refresh === undefined) {
refresh = 1;
}
if (cal.display === false) {
cal.display = true;
storeCalendarOption(cal.id, 'true');
calendarsDisplayedCount++;
unselectEvents();
setupCalendar(cal);
if (areSearchLocationsRestricted(cal.location)) {
addSearchLocation(cal.location, false); // Add the location to the location filter, but don't add any more calendars
}
showCalendarsLoading();
displayCalendarSelector(cal);
if (refresh === true || refresh === 0) {
$(calendarDiv).fullCalendar('addEventSource', cal);
if (cal.selectBox === false && cal.displayCalendar !== false) {
listExtraCalendars();
}
setLocationDetails();
} else {
displayCalendarQueue.push(cal);
queue(function() {
refreshCalendars();
}, refresh, 'refreshCalendars');
}
}
}

function notDisplayCalendar(cal, refresh) {
var locs;
if (cal.display === true && cal.alwaysDisplay !== true) {
cal.display = false;
storeCalendarOption(cal.id, 'false');
calendarsDisplayedCount--;
unselectEvents();
locs = locationsExclusiveToCalendar(cal);
if (locs !== false) {
locs = getLocationNames(locs);
removeSearchLocations(locs);
}
if (cal.selectBox !== false) {
$('#' + calendarChkboxId(cal.id)).prop('checked', false);
}
if (refresh === true || refresh === 0) {
$(calendarDiv).fullCalendar('removeEventSource', cal);
if (cal.selectBox === false && cal.displayCalendar !== false) {
listExtraCalendars();
}
setLocationDetails();
} else {
removeCalendarQueue.push(cal);
queue(function() {
refreshCalendars();
}, refresh, 'refreshCalendars');
}
}
}

function displayFixedCalendarSelector(cal) {
var selector = '#' + cal.divId;
var html;
var addAfter;
if ($(selector).length === 0) { // Need to create calendar selector
cal.selectBox = true;
html = getCalendarHtml(cal, true);
if (cal.ordered === true) {
$(gemeindenFixedDiv).append(html);
} else {
addAfter = getCalendarOrderPrevVisible(cal);
if (addAfter === 'first') {
$(gemeindenFixedDiv).prepend(html);
} else if (addAfter === 'last') {
$(gemeindenFixedDiv).append(html);
} else {
$('#' + addAfter.divId).after(html);
}
cal.ordered = true;
}
} else if (cal.selectBox === false) { // is not already in the list
cal.ordered = true;
moveCalendarToFixedList(cal);
} else {
$(selector).html(getCalendarInnerHtml(cal, true)); // refresh -- not sure if this is still necessary
}
}
function displayFixedCalendar(cal) {
if (typeof (cal.id) !== 'undefined') {
displayFixedCalendarSelector(cal);
queue(function() {
displayCalendar(cal);
}
);
} else { // multiple calendars
$.each(cal, function(index, singleCal) {
displayFixedCalendar(singleCal);
});
}
}

function getCalendars(condition) {
if (condition === undefined) {
condition = function() {
return true;
};
}
var cals = [];
for (var i = 0; i < calendars.length; i++) {
if (condition(calendars[i])) {
cals.push(calendars[i]);
}
}
return cals;
}

function getCalendarInnerHtml(cal, checkBox) {
var html;
var calendarId = calendarChkboxId(cal.id);
var oneLocation = false;
checkBox = checkBox || !restrictedToVisibleMap(); // If no check box associated with calendar, but it's not determined by the map, make a temporary check box
html = '<label for="' + calendarId + '" style="background-color:' + cal.color + '"';
if (checkBox === true) {
if (cal.selectBox === false) {
cal.tempSelectBox = true;
}
html += '><input name="chk_calendar" id="' + calendarId + '" class="chkbox_gemeinde" type="checkbox" name="kalender" ';
if (cal.display === true) {
html += 'checked=checked ';
}
html += 'onchange="' + calendarFunctionString + '(\'changeCalendars\')" value="' +
cal.id + '"/>&nbsp;';
} else {
if (typeof (cal.location) === 'string') {
oneLocation = true;
} else if (typeof (cal.location) === 'object') {
if (cal.location.length === 1) {
oneLocation = true;
}
}
if (oneLocation) {
html += ' onclick="' + calendarFunctionString + '(\'googleMapOn\',\'' + cal.location + '\');"';
}
html += '>';
}
html += cal.description + '&nbsp;</label>';
return html;
}

function getCalendarHtml(cals, checkBox) {
if (typeof (cals.id) !== 'undefined') {
return getCalendarHtml([cals], checkBox);
}
var calendarId;
var html = '';
for (var i = 0; i < cals.length; i++) {
if (cals[i].displayCalendar !== false) {
calendarId = calendarChkboxId(cals[i].id);
html += '<div id="' + calendarId + '_div" class="singlecalendar" style="display: inline-block">';
html += getCalendarInnerHtml(cals[i], checkBox);
html += '</div>';
}
}
return html;
}

// calOrder is an array of calendar objects
// calOrderIds is a stored array of the ids of the calendars

function getCalendarOrderPrevVisible(cal) {
var i;
var calId;
for (i=0; i < calOrderIds.length; i++) {
calId = calOrderIds[i];
if (cal.id === calId) {
break;
}
}
if (i === calOrderIds.length) {
return 'last'; // No previous element
}
while (i-->=0) {
calId = calOrderIds[i];
cal = getCalendarById(calId);
if (cal.ordered === true && cal.selectBox === true) {
return cal;
}
}
return 'first';
}

function getCalendarsInOrder() {
var i;
var calId;
var cal;
var cals = [];
for (i=0; i < calOrderIds.length; i++) {
calId = calOrderIds[i];
cal = getCalendarById(calId);
if (cal !== false) {
cal.ordered = true;
cals.push(cal);
}
}
for (i=0; i < calendars.length; i++) {
cal = calendars[i];
if (cal.ordered !== true && cal.selectBox !== false) {
cals.push(cal); // No stored order, put them at the end
}
}
return cals;
}

function listCalendars() {
var i;
var html;
var calendarId, calendarsPerRow = 16, // maximum number of calendars per row
calendarInRow = 0;
html = '';
var cals = getCalendarsInOrder();
for (i = 0; i < cals.length; i++)
{
if (cals[i].selectBox !== false) { // If it is true or undefined
if (calendarInRow === calendarsPerRow)
{
html += '<br\>';
calendarInRow = 0;
}
calendarId = calendarChkboxId(cals[i].id);
html += '<div id="' + calendarId + '_div" class="singlecalendar" style="display: inline-block">';
html += getCalendarInnerHtml(cals[i], true);
html += '</div>';
calendarInRow += 1;
}

}
$(gemeindenFixedDiv).html(html);
initializeCalendarsDraggable();
initializeSortable();
}

function initializeCalendarDraggable(cal) {
var scope;
var revert;
var divId = '#' + calendarChkboxId(cal.id) + '_div';
if (cal.selectBox === true) {
scope = 'extra';
revert = 'invalid';
} else {
scope = 'default';
revert = function(valid) {
if (valid) {
if (this.data.overlaps) {
helperId = false;
return true; // If it is coming from the maps container, don't allow it to be dropped on the maps container
}
return false;
}
else { //Dropped in a invalid location
helperId = false;
return true;
}
};
}
if (scope === 'default') {
var options = {delay: 150, revert: revert,
revertDuration: 300, appendTo: "body", helper: "clone", zIndex: 100,
scope: 'default',
connectToSortable: gemeindenFixedDiv,
start: function(event, ui) {
this.style.display = "none";
helperId = $(this).attr('id');
newItem = $(this);
$(ui.helper).attr("id", 'helper' + helperId);
},
stop: function(event, ui) {
var test = ui;
this.style.display = "inline";
},
drag: function(event, ui) {
$(this).data.overlaps = overlaps(ui.helper, $(googleMapContainer));
},
disabled: false
};
if ($(divId).data('uiDraggable')) {
$(divId).draggable('option', options);
} else {
$(divId).draggable(options);
$(divId).draggable("option", "disabled", false);
var test = $(divId);
}
} else {
if ($(divId).data('uiDraggable')) {
var isDisabled = $(".selector").draggable("option", "disabled");
if (!isDisabled) {
$(divId).draggable('disable');
}
}
}
}
function initializeCalendarsDraggable() {
for (var i = 0; i < calendars.length; i++) {
initializeCalendarDraggable(calendars[i]);
}
}
function listExtraCalendars() {
var cals = [];
var i;
var calendarHtml = '';
var numCals = 0;
if (googleMaps === false) {
return false;
}
if (restrictedToVisibleMap() === true) {
cals = getCalendars(function(cal) {
cal.tempSelectBox = false; // Remove check boxes if restricted to visible map
if (cal.selectBox === false && cal.display === true) {
return true;
}
});
if (cals.length > 0) {
if (calendarGemeindenOptions.googleMapsFixedOptions) {
calendarHtml += '<hr>';
}
calendarHtml += calendarGemeindenOptions.noticeCalendarsShown + '<br><div class="gemeinden" id="' + extraGemeindenAutomatischDivId + '">';
calendarHtml += getCalendarHtml(cals, false);
calendarHtml += '</div>';
numCals = cals.length;
} else {
calendarHtml += '<div class="gemeinden" id="' + extraGemeindenAutomatischDivId + '"></div>'
}
} else {
cals = getCalendars(function(cal) {
if (cal.selectBox === false && cal.display === true && cal.displayCalendar !== false) {
return true;
}
});
if (cals.length > 0) {
if (calendarGemeindenOptions.googleMapsFixedOptions) {
calendarHtml += '<hr>';
}
calendarHtml += calendarGemeindenOptions.noticeCalendarsSelected + '<br><div class="gemeinden" id="' + extraGemeindenSelectedDivId + '">';
calendarHtml += getCalendarHtml(cals, true);
calendarHtml += '</div>';
numCals = cals.length;
} else {
calendarHtml += '<div class="gemeinden" id="' + extraGemeindenSelectedDivId + '"></div>'; // empty container to move divs to
}
cals = getCalendars(function(cal) {
if (cal.selectBox === false && cal.locationVisible === true && cal.display === false) {
return true;
}
});
if (cals.length > 0) {
if (numCals > 0 || calendarGemeindenOptions.googleMapsFixedOptions === true) {
calendarHtml += '<hr>';
}
calendarHtml += calendarGemeindenOptions.noticeCalendarsVisible + '<br><div class="gemeinden" id="' + extraGemeindenAvailableDivId + '">';
calendarHtml += getCalendarHtml(cals, true);
calendarHtml += '</div>';
numCals += cals.length;
} else {
calendarHtml += '<div class="gemeinden" id="' + extraGemeindenAvailableDivId + '"></div>'; // empty container to move divs to
}
}
if (calendarGemeindenOptions.collapseMapOptions) {
if (numCals === 0) {
$(calendarGemeindenOptions.mapOptionsDiv).css('display', 'none');
} else {
$(calendarGemeindenOptions.mapOptionsDiv).css('display', 'inherit');
}
}
while (numCals < 9) {
numCals += 3;
calendarHtml += '<br/>'; // space to drag and drop calendars
}

$(mapCalendarsDiv).html(calendarHtml);
initializeCalendarsDraggable();

var fixedCalendars = false;
for (i = 0; i < calendars.length; i++) {
if (calendars[i].selectBox === true) {
fixedCalendars = true;
}
}
if (fixedCalendars) {
$(gemeindenSelectDiv).css('visibility', 'visible');
} else {
$(gemeindenSelectDiv).css('visibility', 'hidden');
}
}

function locationsExclusiveToCalendar(cal) {
var i, locs;
locs = [];
for (i = 0; i < locationInfo.length; i++) {
if (locationInfo[i].calendarExclusive === true) {
if (locationInfo[i].calendar === cal.id) {
locs.push(locationInfo[i]);
}
}
}
if (locs.length === 0) {
locs = false;
}
return locs;
}

var timerChangeCalendarsInfo;

function changeCalendars() {
/* This function updates the list of event sources to match the calendars selected on the webpage */
var calsToAdd = [], calsToRemove = [];
var i;
var calendarId;
clearTimeout(timerChangeCalendarsInfo);
unselectEvents();

for (i = 0; i < calendars.length; i++)
{
if (calendars[i].selectBox === true || calendars[i].tempSelectBox === true) {
calendarId = calendarChkboxId(calendars[i].id);
if ($('#' + calendarId).is(':checked')) { // Calendar is to be displayed
if (calendars[i].display === false) { // Calendar is not displayed at present; need to add source
calsToAdd.push(calendars[i]);
}
} else { // Calendar is not to be displayed
if (calendars[i].display === true) { // Calendar is displayed at present; need to remove source
calsToRemove.push(calendars[i]);
}
}
}
}
for (i = 0; i < calsToRemove.length; i++) {
notDisplayCalendar(calsToRemove[i], 10);
}
for (i = 0; i < calsToAdd.length; i++) {
displayCalendar(calsToAdd[i], 10);
}
timerChangeCalendarsInfo = setTimeout(function() {
infoCalendars();
}, 1500);
}

function selectAllCalendars() {
$('.chkbox_gemeinde', gemeindenFixedDiv).attr('checked', 'checked');
changeCalendars();
}

function selectNoCalendars() {
$('.chkbox_gemeinde', gemeindenFixedDiv).removeAttr('checked');
changeCalendars();
}

function _getLocationViewOptions(location) { // the default function to return html code for options under the "mehr Details" of a location
var searchLocationRestricted = $(calendarDiv).calendarGemeinden('isSearchLocationRestricted', location.id);
var html;
var cals;
var calNames;
cals = $(calendarDiv).calendarGemeinden('calendarsForLocation', location.id);
calNames = [];
for (var c = 0; c < cals.length; c++) {
calNames.push(cals[c].description);
}
calNames = calNames.join();
if ($(calendarDiv).calendarGemeinden('isSearchLocationCalendarRestricted', location.id) === true) {
if (searchLocationRestricted === false) {
html = '<a onclick="' + calendarFunctionString + '(\'displayCalendarLocation\', \'' + location.id + '\')">die Kalender der ';
var gemeinde;
var gemeindeNumber;
if (cals.length === 1) {
gemeinde = 'Gemeinde';
gemeindeNumber = 'ist';
} else {
gemeinde = 'Gemeinden';
gemeindeNumber = 'sind';
}
if ($(calendarDiv).calendarGemeinden('isLocationCalendarExclusive', location.id) === true) {
html += gemeinde + ' einblenden (' + calNames + '), die an diesem Ort aktiv ' + gemeindeNumber + '</a>';
} else {
html += gemeinde + ' einblenden (' + calNames + '), die besonders an diesem Ort aktiv ' + gemeindeNumber + '</a>';
}
} else {
html = '<a onclick="' + calendarFunctionString + '(\'addSearchLocationManual\', \'' + location.id + '\')">Auch Termine an diesem Ort zeigen</a>';
}
} else if (searchLocationRestricted !== false && location.numberHiddenEvents > 0) {
html = '<a onclick="' + calendarFunctionString + '(\'addSearchLocationManual\', \'' + location.id + '\')">Auch Termine an diesem Ort zeigen</a>';
} else if ($(calendarDiv).calendarGemeinden('isAdditionalSearchFilter', location.id) && location.numberHiddenEvents > 0) {
html = '<a onclick="' + calendarFunctionString + '(\'allLocationEvents\',\'' + location.id + '\')">Alle Termine an diesem Ort zeigen</a>';
} else {
html = '';
}
if (location.numberEvents > 0) { // If some events in this location are visible, allow one to view only them
if ($(calendarDiv).calendarGemeinden('isAdditionalLocation', location.id)) {
if (html !== '') {
html += '<br/>';
}
html += '<a onclick="' + calendarFunctionString + '(\'restrictSearchLocationManual\',\'' + location.id + '\')">Nur Termine an diesem Ort zeigen</a>';
}
}
if (html !== '') {
html = '<div id="show_this_location">' + html + '</div>';
}
return html;
}

/* Elements from the jQuery Client Side Logging Plugin by Remy Bach, version 1.1.2 (MIT license http://remybach.mit-license.org) is here used to record calendar searches; this may be used to improve the search procedure; searches are not associated with IP addresses or otherwise personally identifiable information */

$.info = function(what) {
if (recordInfoAddress !== false) {
_send(recordInfoAddress, what);
}
};
// Log errors whenever there's a generic js error on the page.
window.onerror = function(message, file, line) {
if (recordErrorAddress !== false) {
_send(recordErrorAddress, {
message: message,
file: file,
line: line
});
}

};

/*===== Private Functions =====*/
/**
* Send the log information to the server.
* @param url The url to submit the information to.
* @param what The information to be logged.
*/
_send = function(url, what) {
url += url.match(/\?.+$/) ? '&' : '?';

if (typeof what === 'object') {
// Let's grab the additional logging info before we send this off.
$.extend(what, _buildClientInfo());

var _data = {};
_data['msg'] = userId + sessionId + '-' + JSON.stringify(what);

$.ajax({
type: 'POST',
url: url + 'format=json',
data: _data
});
} else {
$.post(url + 'format=text&' + 'msg=' + userId + sessionId + '-' + what);
}
};

/**
* Build up an object containing the requested information about the client (as specified in defaults).
* @return _info The object containing the requested information.
*/
_buildClientInfo = function() {
var _info = {};
_info.user_agent = navigator.userAgent;
_info.window_size = $(window).width() + ' x ' + $(window).height();
_info.screen_size = window.screen.availWidth + ' x ' + window.screen.availHeight;
_info.location = window.location.href;
return _info;
};

/*===== Compatibility Functions =====*/
/**
* Fallback for older browsers that don't implement JSON.stringify
* @param obj The JSON object to turn into a string.
* @return A string representation of the JSON object.
*/
var JSON;
if (!JSON) {
JSON = {};
}
JSON.stringify = JSON.stringify || function(obj) {
var t = typeof (obj);
if (t !== "object" || obj === null) {
// simple data type
if (t === "string")
obj = '"' + obj + '"';
return String(obj);
} else {
// recurse array or object
var n, v, json = [], arr = (obj && obj.constructor == Array);
for (n in obj) {
v = obj[n];
t = typeof (v);
if (t === "string")
v = '"' + v + '"';
else if (t === "object" && v !== null)
v = JSON.stringify(v);
json.push((arr ? "" : '"' + n + '":') + String(v));
}
return (arr ? "[" : "{") + String(json) + (arr ? "]" : "}");
}
};

loadCalendar();
$(document).ready(function()
{
initializeGoogleMap();
});

function setupDefaults(calendarDiv) { // setup defaults when first called -- ensures that google api has been loaded
standardShape = {
coords: [19, 0, 24, 5, 24, 12, 18, 21, 16, 31, 14, 31, 12, 20, 6, 12, 6, 6, 11, 0],
type: 'poly'
};
calendarDiv = calendarDiv || '#calendar'; // calendarDiv default
calendarFunctionString = '$(\'' + calendarDiv + '\').calendarGemeinden';
calendarGemeindenDefaults = {
calendarDiv: calendarDiv, // The div in which the calendar itself is located
calendarOptionsDiv: '#calendar-options', // The div in which the calendar options are located (selection of communities, filters, location, etc.)
recordInfoAddress: false, // server-side script to record searches, etc. -- FALSE if not recording
recordErrorAddress: false, // server-side script to record javascript errors -- FALSE if not recording
loadingDiv: '#loading', // a div for displaying a loading icon -- should already be populated; it will only be made visible and invisible by the plugin
calendarMessageDiv: '#cal_message', // a div for displaying calendar messages (z.B. keine Termine an dem Ort gefunden)
googleMaps: true, // Whether to enable google maps
googleMapsDialog: true, // if true, displays the map in a dialog box
dialogWidth: 510, // The width and height of the dialog box to be opened
dialogHeight: 420,
googleMapsStartType: google.maps.MapTypeId.ROADMAP, // The default view type for the map
googleMapsStartLocation: 'Dom', // The starting location for the map
googleMapsStartZoom: 12, // The starting zoom for the map
googleMapsFixedOptions: false, // Indicates whether fixed options are present above where additional calendars will be shown for the map
// if true such calendars will be separated from this by a horizontal line
mapContainer: '#map_container', // a div for the google maps itself
mapOptionsDiv: '#map-options', // a div in which map options occur
collapseMapOptions: true, // map options are rendered invisible when there are no calendars to display (can be of use when all options are related to those calendars)
mapCalendarsDiv: '#map-calendars', // a div in which calendars will be placed
displayFilterLocation: 'activate', // TRUE/FALSE/'activate' -- if true, displays a second filter for filtering locations;
// if 'activate', displays a second filter when restricting location programatically
// if false, never displays
storeOptionsLocally: true, // Whether to store the options in local storage
storeCalendarDuration: 60 * 36 * 1, // How long, in minutes, to store the selection of calendars displayed and in the choice. Only applies if storeOptionsLocally is true
storeCalendarOrderDuration: 60 * 24 * 14, // How long, in minutes, to store the selection of calendars displayed and in the choice. Only applies if storeOptionsLocally is true
storeFilterDuration: 10, // How long, in minutes, to store search filters, selection of event types, etc. Only applies if storeOptionsLocally is true
//storeViewDuration: 60, // How long to store view type (month, week, day) and date -- NOT YET IMPLEMENTED: Would it be desirable?
buttons: '<button type="button" name="allegemeinden" onclick="' + calendarFunctionString + '(\'selectAllCalendars\')">Alle auswählen</button>' +
'<button type="button" name="keinegemeinden" onclick="' + calendarFunctionString + '(\'selectNoCalendars\')">Alle deselektieren</button>',
additionalButtons: false, // STRING of html code for additional buttons (e.g., select a group of calendars)
additionalEventSelectionCode: false, // STRING of html code for additional options to select types of events, etc.
calendarConfigurationName: 'cg', // The name of the calendar configuration -- enables the possibility of multiple sets on the same domain
defaultFilter: 'any', // 'selected' shows only special important events for Wr. Neustadt, 'all' shows all events (apart from other filters applied)
repeatWeekDaysAfterManyEvents: 7, // Applies only to calendar month view; shows the day of the week on each row when at least one row has this many events; a value of false disables the option
terminAuswahlText: 'Terminauswahl:', // Text to display for the selection of event types
searchText: 'Suchbegriff:', // Text to display for entering an arbitrary search term; FALSE disables this search
calendarVisible: true, // Whether the calendar is visible (if it is hidden, will not pop up messages, etc.)
eventTypes: [
{id: 'any',
menu: 'Alle Termine',
description: 'Termine', // Description is shown in messages, etc.
test: true
},
{id: 'selected', // Events matching 'selected' or 'families' are not excluded from the event type 'other'
menu: 'Ausgewählte, besondere Termine',
description: 'ausgewählte, besondere Termine', // Those events particularly important for the area Wr. Neustadt (the type of event for which one makes flyers or posters, etc.)
test: function(event) { // eventTypes is passed so that one can check which other types the event matches (for the sake of an event type: 'other events')
if (event.source.className == 'ssr') { // if the event is in the calendar for a pastoral area (considered important by default for Wr. Neustadt); needs this comparison -- strict comparison doesn't work; not sure why
return true;
}
return event.special;
},
code: 'fa'
},
{id: 'families',
menu: 'Für Kinder + Familien',
description: 'Angebote für Kinder und Familien',
test: function(event) {
var titleModified = event.title.replace(/Familienkirche/g, '');
var isFamilySearchExp = /kind|jungschar|famili/i;
var isFamily = isFamilySearchExp.test(titleModified);
if (isFamily) {
return true;
}
var descriptionModified = event.description.replace(/Familienkirche/g, '');
return isFamilySearchExp.test(descriptionModified);
},
code: ['kinder', 'familien']
},
{id: 'youth',
menu: 'Für Jugend',
description: 'Jugendveranstaltungen und Treffen',
test: function(event) {
var isYouthSearchExp = /jugend/i;
var isYouth = isYouthSearchExp.test(event.title);
if (isYouth) {
return true;
}
return isYouthSearchExp.test(event.description);
},
code: ['ju', 'jugend']
},
{id: 'option-group',
menu: 'Terminarten'},
{id: 'mass',
menu: 'Hl. Messen',
description: 'Hl. Messen',
test: function(event) {
var isMesseSearchExp = /messe|messfeier|rorate|patrozinium|eucharistie|hochamt|abendmahl|erstkommunion|firmung[^a-z]/i;
return isMesseSearchExp.test(event.title);
},
code: 'messe',
eventGroup: 'type'
},
{id: 'liturgyhours',
menu: 'Tagzeitengebet (Laudes, Vesper usw.)',
description: 'Tagzeitengebet (Morgengebet, Vesper, usw.)',
test: function(event) {
var isLiturgyHoursSearchExp = /morgengebet|morgenlob|laudes|vesper|abendlob|komplett|trauermette|terz|sext|none|mittagshore/gi;
return isLiturgyHoursSearchExp.test(event.title);
},
eventGroup: 'type'
},
{id: 'liturgy',
menu: 'Messen, Andachten, Gebete, usw.',
description: 'Gottesdienste, Gebetsstunden, oder Ähnliches',
test: function(event) {
var isGottesdienstSearchExp = /gottesdienst|wort-gottes-feier|auferstehungsfeier|auferstehungsfest|wortgottesfeier|messfeier|andacht|messe|rorate|patrozinium|hochamt|eucharist|anbetung|gebet|rosenkranz|kreuzweg|liturgie|laudes|vesper|bibelkreis|abend der barmherzigkeit|abendmahl|cruzifix|erstkommunion/i;
return isGottesdienstSearchExp.test(event.title);
},
code: ['messe', 'gebet'],
eventGroup: 'type'
},
{id: 'confession',
menu: 'Beichtgelegenheit',
description: 'Beichtgelegenheit',
test: function(event) {
var isConfessionSearchExp = /beicht/gi;
return isConfessionSearchExp.test(event.title);
},
eventGroup: 'type'
},
{id: 'groups',
menu: 'Gruppenstunden (Minis, Jungschar...)',
description: 'Gruppenstunden (Minis, Jungschar, Jugend usw.)',
test: function(event) {
var isGroupSearchExp = /Ministrantenstunde|Ministunde|-Minis|Jungscharstunde|Firmstunde|Jugendstunde|Jugendgruppe|firmvorbereitung/;
if (isGroupSearchExp.test(event.title)) {
return true;
}
return isGroupSearchExp.test(event.description);
},
code: ['gs', 'gruppenstunde'],
eventGroup: 'type'
},
{id: 'faith',
menu: 'Glaubensvertiefung',
description: 'Glaubensvertiefung',
test: function(event) {
var isFaithSearchExp = /katechese|bibelrunde|bibelgruppe|bibelkreis/i;
return isFaithSearchExp.test(event.title);
},
code: ['gv', 'glaubensvertiefung'],
eventGroup: 'type'
},
{id: 'concert',
menu: 'Konzerte',
description: 'Konzerte',
test: function(event) {
var isConcertSearchExp = /konzert/i;
return isConcertSearchExp.test(event.title);
},
code: ['gv', 'glaubensvertiefung'],
eventGroup: 'type'
},
{id: 'other',
menu: 'sonstige Veranstaltungen oder Termine',
description: 'sonstige Veranstaltungen oder Termine',
test: function(event, eventTypes) {
for (var i = 0; i < eventTypes.length; i++) {
if (eventTypes[i].eventGroup === 'type') {
if (isEventType(event, eventTypes[i])) {
return false;
}
}
}
return true;
}
// 'other' // an event is considered to be this type of event if it doesn't match any of the other types (events with eventType: true
},
{id: 'option-group', // To make an unnamed separator between the previous options and the option to filter by search term
menu: ''},
{id: 'option-group-end'},
{id: 'filter', // Important! (1) events matching 'filter' are not excluded from the event type 'other'
searchTerm: true, // Uses the specified search term
menu: 'Mit Suchbegriff übereinstimmend',
description: 'mit dem Suchbegriff', // unused at present
test: function(event) {
return compareFilter(event);
}
}
],
messages: {
inSelectedCalendarText: 'im gewählten Kalender',
inSelectedCalendarsText: 'in den gewählten Kalendern'
},
automaticLocationNotice: '<br/><br/><strong>Hinweis:</strong>Termine an diesem Ort werden von einer Liste wiederkehrenden Termine automatisch erzeugt.' +
'Gegebenenfalls kontrollieren Sie bei der Gemeinde, ob eine Änderung vorliegt.', // Notice given in the details of a location, if events are automatically generated by a set of rules
automaticEventNotice: 'dieser Termin wurde von einer Liste wiederkehrenden Termine in der Gemeinde genommen. Gegebenenfalls kontrollieren Sie bei der Gemeinde, ob eine Änderung vorliegt.',
//automaticEventNoticeFeast: 'dieser Termin wurde von einer Liste wiederkehrenden Termine in der Gemeinde genommen. In diesem Fall fällt der Termin mit einem Festtag zusammen! Kontrollieren Sie gegebenenfalls bei der Gemeinde, ob der Termin auch an diesem Festtag stattfindet.',
automaticEventNoticeFeast: function(feast) {
return 'dieser Termin wurde von einer Liste regelmäßigen Termine an Sonntagen in der Gemeinde genommen. ' +
'Da dieser Sonntag ein besonderer Festtag (' + feast + ') ist, kontrollieren Sie gegebenenfalls bei der Gemeinde, ' +
'ob der Termin auch an diesem Festtag stattfindet.';
},
calendarSelectionText: 'Gemeinden: ', // Text displayed before the list of calendars that the user can select or deselect
noticeCalendarsVisible: 'Zusätzliche Kalender/Orte auf der Karte sichtbar:',
noticeCalendarsSelected: 'Zusätzlich zu den allgemein wählbaren Kalendern sind ausgewählt:',
noticeCalendarsShown: 'Zusätzlich zu den allgemein wählbaren Kalendern werden nun angezeigt:',
restrictedToVisibleMap: function() { // Returns true if only calendars and locations should be shown which are visible on the map, otherwise false
if ($('#restrict_to_visible').is(':checked')) {
return true;
} else {
return false;
}
},
restrictToVisibleMap: function() { // Sets the option to have only calendars and locations should be shown which are visible on the map, otherwise false
$('#restrict_to_visible').prop('checked', true);
},
notRestrictToVisibleMap: function() { // Clears the option to have only calendars and locations should be shown which are visible on the map, otherwise false
$('#restrict_to_visible').prop('checked', false); // Is called when a change is made manually to to the locations (e.g., "show only events in this location")
},
// restrictVisibleChange is an exported function which should be called if a change is made as to whether the display of calendars
// is restricted to visible locations
getLocationViewOptions: function(location) { // FALSE, or a function that returns html code for appropiate options under the "mehr Details" of a location
// (z.B., zeige auch Termine an diesem Ort, zeige nur Termine an diesem Ort, usw.)
return _getLocationViewOptions(location);
},
locationDetailsTipOptions: {
trigger: 'none',
closeWhenOthersOpen: true,
clickAnywhereToClose: false,
textzIndex: 9999,
boxzIndex: 9998,
wrapperzIndex: 9997,
width: 320,
padding: 20,
spikeLength: 60,
spikeGirth: 30,
cornerRadius: 15,
offsetParent: 'body',
fill: 'rgba(208, 138, 120, 0.96)',
strokeWidth: 3,
strokeStyle: '#A60',
cssStyles: {color: '#000', offsetParent: 'body'}},
locationDetailsCloseGraphic: '<img class="bt-close" width="12" height="12" alt="schließen" title="schließen" src="grafiken/close.gif">',
locationDetailsEditGraphic: '<img class="bt-edit" width="16" height="16" alt="bearbeiten" title="bearbeiten (für berechtigte)" src="grafiken/edit.png">',
eventDetailsTipOptions: {
trigger: 'none',
closeWhenOthersOpen: false,
width: 320,
padding: 20,
spikeLength: 60,
spikeGirth: 30,
cornerRadius: 15,
offsetParent: 'body',
fill: 'rgba(238, 238, 100, 0.94)',
strokeWidth: 3,
strokeStyle: '#A60',
cssStyles: {color: '#000', fontWeight: 'bold', offsetParent: 'body'}},
defaultMapIcons: {
standard: {icon: 'http://www.google.com/mapfiles/ms/micons/red-dot.png', shape: standardShape}, // The normal pin icon
selected: {icon: 'http://www.google.com/mapfiles/ms/micons/blue-dot.png', shape: standardShape}, // The icon for a location that the user has selected
noEvents: {icon: 'grafiken/red-dot-transparent.png', shape: standardShape}, // The icon for a location for which no events are shown
small: {icon: 'grafiken/red-dot-small.png'} // A small icon, used in the calendar options to toggle the map when it is a dialog
},
locationSelectedBorder: '4px solid Red', // The border of an event that is selected
eventLocationSelectedBorder: '3px solid #FFB000', // The border of events for which the location is selected
equivalentSearchs: {// When a search is made for an item contained in this list, the search will return events that match any of the words in the corresponding array
kind: ['kind', 'kinder', 'jungschar'],
kinder: ['kind', 'kinder', 'jungschar']
},
areas: [],
calendars: [], // An array of the calendars and info for them
// each calendar is an object with the possible properties
// name: STRING unique internal name for the calendar
// description: STRING name used on the site to describe the calendar
// location: STRING/ARRAY string or array of the location(s) for which this calendar especially has events --
// If a single location is assigned for a calendar, the events in that calendar for which no particular location is assigned
// will be assumed to be in that location.
// at present it must match the name property of the location (in the future location should also have a unique id, so that two locations can have the same name)
// locationExclusive: TRUE/FALSE, // if this calendar only contains events in the given location(s)
// color: "#DC3670", // color of the calendar and events in it -- if unassigned, a color will be assigned based on a hase of the name
// borderColor: "#6B1B38", // border color -- if unassigned, a darker tone of the calendar color will be assigned
// className: STRING, // a class added to events of the calendar (the class 'ssr' is used for 'special selected events' -- 'besondere, ausgewählte Termine')
// selectBox: TRUE/FALSE, // whether there is initially a select box to select/unselect the calendar
// display: TRUE/FALSE, // whether the calendar is initially displayed -- if omitted, and a select box is present, defaults to TRUE
// // if set to true, displays when there is no selectBox, and the map is not displayed (because it is a dialog)
// url: feed for the calendar, e.g., "http://www.google.com/calendar/feeds/h4578d3uo4kpv1drhd4mvq1shc%40group.calendar.google.com/public/basic",
// feedid: "h4578d3uo4kpv1drhd4mvq1shc%40group.calendar.google.com" // when caching is used, feed id is used to build the url for the feed and the cache server
// cacheServer="http://www.erloeserkirche.at/scripts/cache/", // root location of a server that can cache requests for feeds -- WARNING! Have not tested for several revisions
// -- under frequent usage of the calendar by various users, caching could increase responsiveness; otherwise does not help much
// locations: [], // An array of info for the locations
// description: 'Herz Mariä' - STRING, the location's description
// calendar: ['hm','nk'] - STRING or ARRAY - the calendars that especially have events in this location
// calendarExclusive: TRUE/FALSE -- whether ONLY those calendars have events in this location - defaults to FALSE
// coords: '47.831423,16.263058', ' STRING - coordinates of the location
// info: 'Herz Mariä', STRING, 'info displayed on the map for the location
// moreInfo: 'Die katholische Pfarrkirche Mariä<br>Adresse: Pottendorfer Straße 117, 2700 Wiener Neustadt' STRING (can have html markup),
// info displayed for the location in a popup window from the map

shortLocations: [{search: 'katharinenkapelle', description: 'Katharinenkapelle'}, // An array of short locations; they are search in sequential order; if the search term "search" is found
{search: 'erlöserkirche', description: 'Erlöserkirche'}, // the short location is the value of "short"; otherwise the short location defaults to the full location
{search: 'familienkirche', description: 'Familienkirche'}, // In place of an array, a function(location){... return shortLocation}
{search: 'schmuckerau', description: 'Familienkirche'}, // which takes as input the full location and returns the short location can be provided
{search: 'evangelische kirche', description: 'Evangelische Kirche'},
{search: 'leopold', description: 'Sankt Leopold'},
{search: 'bildungszentrum', description: 'Bildungszentrum'},
{search: 'dom', description: 'Dom'},
{search: 'josef', description: 'Sankt Josef'},
{search: 'anton', description: 'Sankt Anton'},
{search: 'herz mari', description: 'Herz Mariä'},
{search: 'neukloster', description: 'Neukloster'},
{search: 'kapuziner', description: 'Kapuziner'},
{search: 'maria theresia', description: 'Siedlung Maria Theresia'},
{search: 'weidlingbach', description: 'Weidlingbach'},
{search: 'weidling', description: 'Weidling'},
{search: 'scheiblingstein', description: 'Scheiblingstein'}],
// Calendar display options that are passed on to the full calendar plugin
firstDay: 0,
minTime: 6,
maxTime: 22,
lengthAllDay: 10, // If an event is longer than this many hours, it will be put into the all day slot
axisFormat: 'H(:mm)',
slotEventOverlap: true,
slotHeightNoEvents: 14,
slotHeightWithEvents: 35,
weekMode: 'liquid',
header: {
left: 'prev,next today date',
center: 'title',
right: 'month, agendaWeek,basicWeek, agendaDay ,agendaList'
},
maxWidth: {
//header: '1000px',
agendaList: '720px',
agendaDay: '1400px',
'': ''
},
buttonText: {
prev: '&lsaquo;', // <
next: '&rsaquo;', // >
prevYear: '&laquo;', // <<
nextYear: '&raquo;', // >>
today: 'Heute',
month: 'Monat',
week: 'Woche',
basicWeek: 'Woche (kompakt)',
day: 'Tag',
agendaList: 'Liste',
date: '' // text shown before the date entry box
},
titleFormat: {
month: 'MMMM yyyy', // September 2009
week: " d [ MMM] [ yyyy]{ '- 'd MMM yyyy}", // Sep 7 - 13 2009
day: 'dddd, d.MMM.yyyy' // Tuesday, Sep 8, 2009
},
columnFormat: {
month: 'ddd', // September 2009
week: "ddd d.M", // Sep 7 - 13 2009
day: 'dddd d.M' // Tuesday, Sep 8, 2009
},
timeFormat:
{
// for agendaWeek and agendaDay
agenda: 'H:mm{ - H:mm}', // 5:00 - 6:30
// for all other views
'': 'H:mm{ - H:mm}'
},
defaultView: 'agendaWeek',
fetch: 'auto',
prefetch: true,
prefetchMonths: 1, // Number of months ahead to prefetch
cacheToleration: 51, // Retrieve a cached list of events that includes up to this many more days than the range we're looking for
agendaList: {
location: 'short',
skipLocation: false, // Can skip displaying this location (useful when, e.g., it is a "default" location, which can be taken for granted when no location is listed
timeRange: true, // If true, displays starting time till ending time -- if false, displays only starting time
minTimeRange: 0, // displays only starting time, unless event is longer than minTimeRange hours
completeMonth: true, // always displays till the end of a month
repeatMultidayEvents: 60, // Number of times to repeat multi-day events in agenda list view
repeatMultidayEventDescriptions: 7 // Number of times to repeat multi-day events in agenda list view
//maxDescriptionLength: 200 // Descriptions longer than this will be cut off with an ellipsis in the list
},
agendaListOrder: 'times', // the default sorting order for the agenda list view -- by 'times', or by 'places'
agendaListAllowReorder: true, // Give the user an option to swap from ordering by times to places or conversely
agendaListDisplayRange: true, // Displays the range of dates displayed
agendaListLoadingNotice: '<span style="font-style: italic;">&nbsp;wird geladen...</span>',
agendaListPreviousEvents: 'Zeige auch frühere Termine.', // is put in a span with class fc-agendaList-previous
agendaListNextEvents: 'Zeige auch weitere Termine.', // is put in a span with class fc-agendaList-next
defaultDaysAgendaList: 14, // Default number of days to show in agenda list mode (is only relevant when defaultView is agendaWeek -- otherwise the range is taken from the previous range (day, week, or month)
agendaListExtend: 7,
agendaListExtendAfterMonth: 28,
modules: ['scripts/jquery.icalendar.js'], // Modules loaded upon initialization
echoUrl: 'http://www.erloeserkirche.at/scripts/ical/' // echos an ical entry to be downloaded
};
}

}
;

})(jQuery);
Powered by Google Project Hosting