chengkun
2025-04-18 1bb985f32f2efe0f9dd69f3cf29a1c809b1cf96d
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
/**
 * fullPage 2.5.4
 * https://github.com/alvarotrigo/fullPage.js
 * MIT licensed
 *
 * Copyright (C) 2013 alvarotrigo.com - A project by Alvaro Trigo
 */
 
(function($) {
    $.fn.fullpage = function(options) {
        // Create some defaults, extending them with any options that were provided
        options = $.extend({
            //navigation
            'menu': false,
            'anchors':[],
            'navigation': false,
            'navigationPosition': 'right',
            'navigationColor': '#000',
            'navigationTooltips': [],
            'slidesNavigation': false,
            'slidesNavPosition': 'bottom',
            'scrollBar': false,
 
            //scrolling
            'css3': true,
            'scrollingSpeed': 700,
            'autoScrolling': true,
            'easing': 'easeInQuart',
            'easingcss3': 'ease',
            'loopBottom': false,
            'loopTop': false,
            'loopHorizontal': true,
            'continuousVertical': false,
            'normalScrollElements': null,
            'scrollOverflow': false,
            'touchSensitivity': 5,
            'normalScrollElementTouchThreshold': 5,
 
            //Accessibility
            'keyboardScrolling': true,
            'animateAnchor': true,
            'recordHistory': true,
 
            //design
            'controlArrows': true,
            'controlArrowColor': '#fff',
            "verticalCentered": true,
            'resize': true,
            'sectionsColor' : [],
            'paddingTop': 0,
            'paddingBottom': 0,
            'fixedElements': null,
            'responsive': 0,
 
            //Custom selectors
            'sectionSelector': '.section',
            'slideSelector': '.slide',
 
 
            //events
            'afterLoad': null,
            'onLeave': null,
            'afterRender': null,
            'afterResize': null,
            'afterReBuild': null,
            'afterSlideLoad': null,
            'onSlideLeave': null
        }, options);
 
        displayWarnings();
 
        //easeInQuart animation included in the plugin
        $.extend($.easing,{ easeInQuart: function (x, t, b, c, d) { return c*(t/=d)*t*t*t + b; }});
 
        //Defines the delay to take place before being able to scroll to the next section
        //BE CAREFUL! Not recommened to change it under 400 for a good behavior in laptops and
        //Apple devices (laptops, mouses...)
        var scrollDelay = 600;
 
        $.fn.fullpage.setAutoScrolling = function(value, type){
            setVariableState('autoScrolling', value, type);
 
            var element = $('.fp-section.active');
 
            if(options.autoScrolling && !options.scrollBar){
                $('html, body').css({
                    'overflow' : 'hidden',
                    'height' : '100%'
                });
 
                $.fn.fullpage.setRecordHistory(options.recordHistory, 'internal');
 
                //for IE touch devices
                container.css({
                    '-ms-touch-action': 'none',
                    'touch-action': 'none'
                });
 
                if(element.length){
                    //moving the container up
                    silentScroll(element.position().top);
                }
 
            }else{
                $('html, body').css({
                    'overflow' : 'visible',
                    'height' : 'initial'
                });
 
                $.fn.fullpage.setRecordHistory(false, 'internal');
 
                //for IE touch devices
                container.css({
                    '-ms-touch-action': '',
                    'touch-action': ''
                });
 
                silentScroll(0);
 
                //scrolling the page to the section with no animation
                $('html, body').scrollTop(element.position().top);
            }
 
        };
 
        /**
        * Defines wheter to record the history for each hash change in the URL.
        */
        $.fn.fullpage.setRecordHistory = function(value, type){
            setVariableState('recordHistory', value, type);
        };
 
        /**
        * Defines the scrolling speed
        */
        $.fn.fullpage.setScrollingSpeed = function(value, type){
            setVariableState('scrollingSpeed', value, type);
        };
 
        /**
        * Adds or remove the possiblity of scrolling through sections by using the mouse wheel or the trackpad.
        */
        $.fn.fullpage.setMouseWheelScrolling = function (value){
            if(value){
                addMouseWheelHandler();
            }else{
                removeMouseWheelHandler();
            }
        };
 
        /**
        * Adds or remove the possiblity of scrolling through sections by using the mouse wheel/trackpad or touch gestures.
        * Optionally a second parameter can be used to specify the direction for which the action will be applied.
        *
        * @param directions string containing the direction or directions separated by comma.
        */
        $.fn.fullpage.setAllowScrolling = function (value, directions){
            if(typeof directions != 'undefined'){
                directions = directions.replace(' ', '').split(',');
                $.each(directions, function (index, direction){
                    setIsScrollable(value, direction);
                });
            }
            else if(value){
                $.fn.fullpage.setMouseWheelScrolling(true);
                addTouchHandler();
            }else{
                $.fn.fullpage.setMouseWheelScrolling(false);
                removeTouchHandler();
            }
        };
 
        /**
        * Adds or remove the possiblity of scrolling through sections by using the keyboard arrow keys
        */
        $.fn.fullpage.setKeyboardScrolling = function (value){
            options.keyboardScrolling = value;
        };
 
        $.fn.fullpage.moveSectionUp = function(){
            var prev = $('.fp-section.active').prev('.fp-section');
 
            //looping to the bottom if there's no more sections above
            if (!prev.length && (options.loopTop || options.continuousVertical)) {
                prev = $('.fp-section').last();
            }
 
            if (prev.length) {
                scrollPage(prev, null, true);
            }
        };
 
        $.fn.fullpage.moveSectionDown = function (){
            var next = $('.fp-section.active').next('.fp-section');
 
            //looping to the top if there's no more sections below
            if(!next.length &&
                (options.loopBottom || options.continuousVertical)){
                next = $('.fp-section').first();
            }
 
            if(next.length){
                scrollPage(next, null, false);
            }
        };
 
        $.fn.fullpage.moveTo = function (section, slide){
            var destiny = '';
 
            if(isNaN(section)){
                destiny = $('[data-anchor="'+section+'"]');
            }else{
                destiny = $('.fp-section').eq( (section -1) );
            }
 
            if (typeof slide !== 'undefined'){
                scrollPageAndSlide(section, slide);
            }else if(destiny.length > 0){
                scrollPage(destiny);
            }
        };
 
        $.fn.fullpage.moveSlideRight = function(){
            moveSlide('next');
        };
 
        $.fn.fullpage.moveSlideLeft = function(){
            moveSlide('prev');
        };
 
        /**
         * When resizing is finished, we adjust the slides sizes and positions
         */
        $.fn.fullpage.reBuild = function(resizing){
            isResizing = true;
 
            var windowsWidth = $(window).width();
            windowsHeight = $(window).height();  //updating global var
 
            //text and images resizing
            if (options.resize) {
                resizeMe(windowsHeight, windowsWidth);
            }
 
            $('.fp-section').each(function(){
                var scrollHeight = windowsHeight - parseInt($(this).css('padding-bottom')) - parseInt($(this).css('padding-top'));
 
                //adjusting the height of the table-cell for IE and Firefox
                if(options.verticalCentered){
                    $(this).find('.fp-tableCell').css('height', getTableHeight($(this)) + 'px');
                }
 
                $(this).css('height', windowsHeight + 'px');
 
                //resizing the scrolling divs
                if(options.scrollOverflow){
                    var slides = $(this).find('.fp-slide');
 
                    if(slides.length){
                        slides.each(function(){
                            createSlimScrolling($(this));
                        });
                    }else{
                        createSlimScrolling($(this));
                    }
                }
 
                //adjusting the position fo the FULL WIDTH slides...
                var slides = $(this).find('.fp-slides');
                if (slides.length) {
                    landscapeScroll(slides, slides.find('.fp-slide.active'));
                }
            });
 
            //adjusting the position for the current section
            var destinyPos = $('.fp-section.active').position();
 
            var activeSection = $('.fp-section.active');
 
            //isn't it the first section?
            if(activeSection.index('.fp-section')){
                scrollPage(activeSection);
            }
 
            isResizing = false;
            $.isFunction( options.afterResize ) && resizing && options.afterResize.call( this )
            $.isFunction( options.afterReBuild ) && !resizing && options.afterReBuild.call( this );
        }
 
        //flag to avoid very fast sliding for landscape sliders
        var slideMoving = false;
 
        var isTouchDevice = navigator.userAgent.match(/(iPhone|iPod|iPad|Android|BlackBerry|BB10|Windows Phone|Tizen|Bada)/);
        var isTouch = (('ontouchstart' in window) || (navigator.msMaxTouchPoints > 0) || (navigator.maxTouchPoints));
        var container = $(this);
        var windowsHeight = $(window).height();
        var isMoving = false;
        var isResizing = false;
        var lastScrolledDestiny;
        var lastScrolledSlide;
        var nav;
        var wrapperSelector = 'fullpage-wrapper';
        var isScrollAllowed = { 'up':true, 'down':true, 'left':true, 'right':true };
        var originals = jQuery.extend(true, {}, options); //deep copy
 
        $.fn.fullpage.setAllowScrolling(true);
 
        //if css3 is not supported, it will use jQuery animations
        if(options.css3){
            options.css3 = support3d();
        }
 
        if($(this).length){
            container.css({
                'height': '100%',
                'position': 'relative'
            });
 
            //adding a class to recognize the container internally in the code
            container.addClass(wrapperSelector);
        }
 
        //trying to use fullpage without a selector?
        else{
            showError('error', "Error! Fullpage.js needs to be initialized with a selector. For example: $('#myContainer').fullpage();");
        }
 
        //adding internal class names to void problem with common ones
        $(options.sectionSelector).each(function(){
              $(this).addClass('fp-section');
        });
        $(options.slideSelector).each(function(){
              $(this).addClass('fp-slide');
        });
 
        //creating the navigation dots
        if (options.navigation) {
            addVerticalNavigation();
        }
 
        $('.fp-section').each(function(index){
            var that = $(this);
            var slides = $(this).find('.fp-slide');
            var numSlides = slides.length;
 
            //if no active section is defined, the 1st one will be the default one
            if(!index && $('.fp-section.active').length === 0) {
                $(this).addClass('active');
            }
 
            $(this).css('height', windowsHeight + 'px');
 
            if(options.paddingTop || options.paddingBottom){
                $(this).css('padding', options.paddingTop  + ' 0 ' + options.paddingBottom + ' 0');
            }
 
            if (typeof options.sectionsColor[index] !==  'undefined') {
                $(this).css('background-color', options.sectionsColor[index]);
            }
 
            if (typeof options.anchors[index] !== 'undefined') {
                $(this).attr('data-anchor', options.anchors[index]);
            }
 
            // if there's any slide
            if (numSlides > 1) {
                var sliderWidth = numSlides * 100;
                var slideWidth = 100 / numSlides;
 
                slides.wrapAll('<div class="fp-slidesContainer" />');
                slides.parent().wrap('<div class="fp-slides" />');
 
                $(this).find('.fp-slidesContainer').css('width', sliderWidth + '%');
 
                if(options.controlArrows){
                    createSlideArrows($(this));
                }
 
                if(options.slidesNavigation){
                    addSlidesNavigation($(this), numSlides);
                }
 
                slides.each(function(index) {
                    $(this).css('width', slideWidth + '%');
 
                    if(options.verticalCentered){
                        addTableClass($(this));
                    }
                });
 
                var startingSlide = that.find('.fp-slide.active');
 
                //if the slide won#t be an starting point, the default will be the first one
                if(startingSlide.length == 0){
                    slides.eq(0).addClass('active');
                }
 
                //is there a starting point for a non-starting section?
                else{
                    silentLandscapeScroll(startingSlide);
                }
 
            }else{
                if(options.verticalCentered){
                    addTableClass($(this));
                }
            }
 
        }).promise().done(function(){
            $.fn.fullpage.setAutoScrolling(options.autoScrolling, 'internal');
 
            //the starting point is a slide?
            var activeSlide = $('.fp-section.active').find('.fp-slide.active');
 
            //the active section isn't the first one? Is not the first slide of the first section? Then we load that section/slide by default.
            if( activeSlide.length &&  ($('.fp-section.active').index('.fp-section') != 0 || ($('.fp-section.active').index('.fp-section') == 0 && activeSlide.index() != 0))){
                silentLandscapeScroll(activeSlide);
            }
 
            //fixed elements need to be moved out of the plugin container due to problems with CSS3.
            if(options.fixedElements && options.css3){
                $(options.fixedElements).appendTo('body');
            }
 
            //vertical centered of the navigation + first bullet active
            if(options.navigation){
                nav.css('margin-top', '-' + (nav.height()/2) + 'px');
                nav.find('li').eq($('.fp-section.active').index('.fp-section')).find('a').addClass('active');
            }
 
            //moving the menu outside the main container if it is inside (avoid problems with fixed positions when using CSS3 tranforms)
            if(options.menu && options.css3 && $(options.menu).closest('.fullpage-wrapper').length){
                $(options.menu).appendTo('body');
            }
 
            if(options.scrollOverflow){
                if(document.readyState === "complete"){
                    createSlimScrollingHandler();
                }
                //after DOM and images are loaded
                $(window).on('load', createSlimScrollingHandler);
            }else{
                $.isFunction( options.afterRender ) && options.afterRender.call( this);
            }
 
            responsive();
 
            //getting the anchor link in the URL and deleting the `#`
            var value =  window.location.hash.replace('#', '').split('/');
            var destiny = value[0];
 
            if(destiny.length){
                var section = $('[data-anchor="'+destiny+'"]');
 
                if(!options.animateAnchor && section.length){
 
                    if(options.autoScrolling){
                        silentScroll(section.position().top);
                    }
                    else{
                        silentScroll(0);
                        setBodyClass(destiny);
 
                        //scrolling the page to the section with no animation
                        $('html, body').scrollTop(section.position().top);
                    }
 
                    activateMenuAndNav(destiny, null);
 
                    $.isFunction( options.afterLoad ) && options.afterLoad.call( this, destiny, (section.index('.fp-section') + 1));
 
                    //updating the active class
                    section.addClass('active').siblings().removeClass('active');
                }
            }
 
 
            $(window).on('load', function() {
                scrollToAnchor();
            });
 
        });
 
 
        /**
        * Creates the control arrows for the given section
        */
        function createSlideArrows(section){
            section.find('.fp-slides').after('<div class="fp-controlArrow fp-prev"></div><div class="fp-controlArrow fp-next"></div>');
 
            if(options.controlArrowColor!='#fff'){
                section.find('.fp-controlArrow.fp-next').css('border-color', 'transparent transparent transparent '+options.controlArrowColor);
                section.find('.fp-controlArrow.fp-prev').css('border-color', 'transparent '+ options.controlArrowColor + ' transparent transparent');
            }
 
            if(!options.loopHorizontal){
                section.find('.fp-controlArrow.fp-prev').hide();
            }
        }
 
        /**
        * Creates a vertical navigation bar.
        */
        function addVerticalNavigation(){
            $('body').append('<div id="fp-nav"><ul></ul></div>');
            nav = $('#fp-nav');
 
            nav.css('color', options.navigationColor);
            nav.addClass(options.navigationPosition);
 
            for (var i = 0; i < $('.fp-section').length; i++) {
                var link = '';
                if (options.anchors.length) {
                    link = options.anchors[i];
                }
 
                var li = '<li><a href="#' + link + '"><span></span></a>';
 
                // Only add tooltip if needed (defined by user)
                var tooltip = options.navigationTooltips[i];
                if (tooltip != undefined && tooltip != '') {
                    li += '<div class="fp-tooltip ' + options.navigationPosition + '">' + tooltip + '</div>';
                }
 
                li += '</li>';
 
                nav.find('ul').append(li);
            }
        }
 
        function createSlimScrollingHandler(){
            $('.fp-section').each(function(){
                var slides = $(this).find('.fp-slide');
 
                if(slides.length){
                    slides.each(function(){
                        createSlimScrolling($(this));
                    });
                }else{
                    createSlimScrolling($(this));
                }
 
            });
            $.isFunction( options.afterRender ) && options.afterRender.call( this);
        }
 
        var scrollId;
        var scrollId2;
        var isScrolling = false;
 
        //when scrolling...
        $(window).on('scroll', scrollHandler);
 
        function scrollHandler(){
            if(!options.autoScrolling || options.scrollBar){
                var currentScroll = $(window).scrollTop();
                var visibleSectionIndex = 0;
                var initial = Math.abs(currentScroll - $('.fp-section').first().offset().top);
 
                //taking the section which is showing more content in the viewport
                $('.fp-section').each(function(index){
                    var current = Math.abs(currentScroll - $(this).offset().top);
 
                    if(current < initial){
                        visibleSectionIndex = index;
                        initial = current;
                    }
                });
 
                //geting the last one, the current one on the screen
                var currentSection = $('.fp-section').eq(visibleSectionIndex);
            }
 
            if(!options.autoScrolling){
                //executing only once the first time we reach the section
                if(!currentSection.hasClass('active')){
                    isScrolling = true;
 
                    var leavingSection = $('.fp-section.active').index('.fp-section') + 1;
                    var yMovement = getYmovement(currentSection);
                    var anchorLink  = currentSection.data('anchor');
                    var sectionIndex = currentSection.index('.fp-section') + 1;
                    var activeSlide = currentSection.find('.fp-slide.active');
 
                    if(activeSlide.length){
                        var slideAnchorLink = activeSlide.data('anchor');
                        var slideIndex = activeSlide.index();
                    }
 
                    currentSection.addClass('active').siblings().removeClass('active');
 
                    if(!isMoving){
                        $.isFunction( options.onLeave ) && options.onLeave.call( this, leavingSection, sectionIndex, yMovement);
 
                        $.isFunction( options.afterLoad ) && options.afterLoad.call( this, anchorLink, sectionIndex);
                    }
 
                    activateMenuAndNav(anchorLink, 0);
 
                    if(options.anchors.length && !isMoving){
                        //needed to enter in hashChange event when using the menu with anchor links
                        lastScrolledDestiny = anchorLink;
 
                        setState(slideIndex, slideAnchorLink, anchorLink, sectionIndex);
                    }
 
                    //small timeout in order to avoid entering in hashChange event when scrolling is not finished yet
                    clearTimeout(scrollId);
                    scrollId = setTimeout(function(){
                        isScrolling = false;
                    }, 100);
                }
            }
 
            if(options.scrollBar){
                //for the auto adjust of the viewport to fit a whole section
                clearTimeout(scrollId2);
                scrollId2 = setTimeout(function(){
                    if(!isMoving){
                        scrollPage(currentSection);
                    }
                }, 1000);
            }
        }
 
 
        /**
        * Determines whether the active section or slide is scrollable through and scrolling bar
        */
        function isScrollable(activeSection){
            //if there are landscape slides, we check if the scrolling bar is in the current one or not
            if(activeSection.find('.fp-slides').length){
                scrollable= activeSection.find('.fp-slide.active').find('.fp-scrollable');
            }else{
                scrollable = activeSection.find('.fp-scrollable');
            }
 
            return scrollable;
        }
 
        /**
        * Determines the way of scrolling up or down:
        * by 'automatically' scrolling a section or by using the default and normal scrolling.
        */
        function scrolling(type, scrollable){
            if (!isScrollAllowed[type]){
                return;
            }
 
            if(type == 'down'){
                var check = 'bottom';
                var scrollSection = $.fn.fullpage.moveSectionDown;
            }else{
                var check = 'top';
                var scrollSection = $.fn.fullpage.moveSectionUp;
            }
 
            if(scrollable.length > 0 ){
                //is the scrollbar at the start/end of the scroll?
                if(isScrolled(check, scrollable)){
                    scrollSection();
                }else{
                    return true;
                }
            }else{
                // moved up/down
                scrollSection();
            }
        }
 
 
        var touchStartY = 0;
        var touchStartX = 0;
        var touchEndY = 0;
        var touchEndX = 0;
 
        /* Detecting touch events
 
        * As we are changing the top property of the page on scrolling, we can not use the traditional way to detect it.
        * This way, the touchstart and the touch moves shows an small difference between them which is the
        * used one to determine the direction.
        */
        function touchMoveHandler(event){
            var e = event.originalEvent;
 
            // additional: if one of the normalScrollElements isn't within options.normalScrollElementTouchThreshold hops up the DOM chain
            if (!checkParentForNormalScrollElement(event.target)) {
 
                if(options.autoScrolling && !options.scrollBar){
                    //preventing the easing on iOS devices
                    event.preventDefault();
                }
 
                var activeSection = $('.fp-section.active');
                var scrollable = isScrollable(activeSection);
 
                if (!isMoving && !slideMoving) { //if theres any #
                    var touchEvents = getEventsPage(e);
 
                    touchEndY = touchEvents['y'];
                    touchEndX = touchEvents['x'];
 
                    //if movement in the X axys is greater than in the Y and the currect section has slides...
                    if (activeSection.find('.fp-slides').length && Math.abs(touchStartX - touchEndX) > (Math.abs(touchStartY - touchEndY))) {
 
                        //is the movement greater than the minimum resistance to scroll?
                        if (Math.abs(touchStartX - touchEndX) > ($(window).width() / 100 * options.touchSensitivity)) {
                            if (touchStartX > touchEndX) {
                                if(isScrollAllowed.right){
                                    $.fn.fullpage.moveSlideRight(); //next
                                }
                            } else {
                                if(isScrollAllowed.left){
                                    $.fn.fullpage.moveSlideLeft(); //prev
                                }
                            }
                        }
                    }
 
                    //vertical scrolling (only when autoScrolling is enabled)
                    else if(options.autoScrolling && !options.scrollBar){
 
                        //is the movement greater than the minimum resistance to scroll?
                        if (Math.abs(touchStartY - touchEndY) > ($(window).height() / 100 * options.touchSensitivity)) {
                            if (touchStartY > touchEndY) {
                                scrolling('down', scrollable);
                            } else if (touchEndY > touchStartY) {
                                scrolling('up', scrollable);
                            }
                        }
                    }
                }
            }
 
        }
 
        /**
         * recursive function to loop up the parent nodes to check if one of them exists in options.normalScrollElements
         * Currently works well for iOS - Android might need some testing
         * @param  {Element} el  target element / jquery selector (in subsequent nodes)
         * @param  {int}     hop current hop compared to options.normalScrollElementTouchThreshold
         * @return {boolean} true if there is a match to options.normalScrollElements
         */
        function checkParentForNormalScrollElement (el, hop) {
            hop = hop || 0;
            var parent = $(el).parent();
 
            if (hop < options.normalScrollElementTouchThreshold &&
                parent.is(options.normalScrollElements) ) {
                return true;
            } else if (hop == options.normalScrollElementTouchThreshold) {
                return false;
            } else {
                return checkParentForNormalScrollElement(parent, ++hop);
            }
        }
 
        function touchStartHandler(event){
            var e = event.originalEvent;
 
            var touchEvents = getEventsPage(e);
            touchStartY = touchEvents['y'];
            touchStartX = touchEvents['x'];
        }
 
 
        /**
         * Detecting mousewheel scrolling
         *
         * http://blogs.sitepointstatic.com/examples/tech/mouse-wheel/index.html
         * http://www.sitepoint.com/html5-javascript-mouse-wheel/
         */
        function MouseWheelHandler(e) {
            if(options.autoScrolling){
                // cross-browser wheel delta
                e = window.event || e;
                var delta = Math.max(-1, Math.min(1,
                        (e.wheelDelta || -e.deltaY || -e.detail)));
 
                //preventing to scroll the site on mouse wheel when scrollbar is present
                if(options.scrollBar){
                    e.preventDefault ? e.preventDefault() : e.returnValue = false;
 
                }
 
                var activeSection = $('.fp-section.active');
                var scrollable = isScrollable(activeSection);
 
                if (!isMoving) { //if theres any #
                    //scrolling down?
                    if (delta < 0) {
                        scrolling('down', scrollable);
 
                    //scrolling up?
                    }else {
                        scrolling('up', scrollable);
                    }
                }
 
                return false;
            }
        }
 
        function moveSlide(direction){
            var activeSection = $('.fp-section.active');
            var slides = activeSection.find('.fp-slides');
 
            // more than one slide needed and nothing should be sliding
            if (!slides.length || slideMoving) {
                return;
            }
 
            var currentSlide = slides.find('.fp-slide.active');
            var destiny = null;
 
            if(direction === 'prev'){
                destiny = currentSlide.prev('.fp-slide');
            }else{
                destiny = currentSlide.next('.fp-slide');
            }
 
            //isn't there a next slide in the secuence?
            if(!destiny.length){
                //respect loopHorizontal settin
                if (!options.loopHorizontal) return;
 
                if(direction === 'prev'){
                    destiny = currentSlide.siblings(':last');
                }else{
                    destiny = currentSlide.siblings(':first');
                }
            }
 
            slideMoving = true;
 
            landscapeScroll(slides, destiny);
        }
 
        /**
        * Maintains the active slides in the viewport
        * (Because he `scroll` animation might get lost with some actions, such as when using continuousVertical)
        */
        function keepSlidesPosition(){
            $('.fp-slide.active').each(function(){
                silentLandscapeScroll($(this));
            });
        }
 
        /**
        * Scrolls the site to the given element and scrolls to the slide if a callback is given.
        */
        function scrollPage(element, callback, isMovementUp){
            var dest = element.position();
            if(typeof dest === "undefined"){ return; } //there's no element to scroll, leaving the function
 
            //local variables
            var v = {
                element: element,
                callback: callback,
                isMovementUp: isMovementUp,
                dest: dest,
                dtop: dest.top,
                yMovement: getYmovement(element),
                anchorLink: element.data('anchor'),
                sectionIndex: element.index('.fp-section'),
                activeSlide: element.find('.fp-slide.active'),
                activeSection: $('.fp-section.active'),
                leavingSection: $('.fp-section.active').index('.fp-section') + 1,
 
                //caching the value of isResizing at the momment the function is called
                //because it will be checked later inside a setTimeout and the value might change
                localIsResizing: isResizing
            };
 
            //quiting when destination scroll is the same as the current one
            if((v.activeSection.is(element) && !isResizing) || (options.scrollBar && $(window).scrollTop() === v.dtop)){ return; }
 
            if(v.activeSlide.length){
                var slideAnchorLink = v.activeSlide.data('anchor');
                var slideIndex = v.activeSlide.index();
            }
 
            // If continuousVertical && we need to wrap around
            if (options.autoScrolling && options.continuousVertical && typeof (v.isMovementUp) !== "undefined" &&
                ((!v.isMovementUp && v.yMovement == 'up') || // Intending to scroll down but about to go up or
                (v.isMovementUp && v.yMovement == 'down'))) { // intending to scroll up but about to go down
 
                v = createInfiniteSections(v);
            }
 
            element.addClass('active').siblings().removeClass('active');
 
            //preventing from activating the MouseWheelHandler event
            //more than once if the page is scrolling
            isMoving = true;
 
            setState(slideIndex, slideAnchorLink, v.anchorLink, v.sectionIndex);
 
            //callback (onLeave) if the site is not just resizing and readjusting the slides
            $.isFunction(options.onLeave) && !v.localIsResizing && options.onLeave.call(this, v.leavingSection, (v.sectionIndex + 1), v.yMovement);
 
            performMovement(v);
 
            //flag to avoid callingn `scrollPage()` twice in case of using anchor links
            lastScrolledDestiny = v.anchorLink;
 
            //avoid firing it twice (as it does also on scroll)
            if(options.autoScrolling){
                activateMenuAndNav(v.anchorLink, v.sectionIndex)
            }
        }
 
        /**
        * Performs the movement (by CSS3 or by jQuery)
        */
        function performMovement(v){
            // using CSS3 translate functionality
            if (options.css3 && options.autoScrolling && !options.scrollBar) {
 
                var translate3d = 'translate3d(0px, -' + v.dtop + 'px, 0px)';
                transformContainer(translate3d, true);
 
                setTimeout(function () {
                    afterSectionLoads(v);
                }, options.scrollingSpeed);
            }
 
            // using jQuery animate
            else{
                var scrollSettings = getScrollSettings(v);
 
                $(scrollSettings.element).animate(
                    scrollSettings.options
                , options.scrollingSpeed, options.easing).promise().done(function () { //only one single callback in case of animating  `html, body`
                    afterSectionLoads(v);
                });
            }
        }
 
        /**
        * Gets the scrolling settings depending on the plugin autoScrolling option
        */
        function getScrollSettings(v){
            var scroll = {};
 
            if(options.autoScrolling && !options.scrollBar){
                scroll.options = { 'top': -v.dtop};
                scroll.element = '.'+wrapperSelector;
            }else{
                scroll.options = { 'scrollTop': v.dtop};
                scroll.element = 'html, body';
            }
 
            return scroll;
        }
 
        /**
        * Adds sections before or after the current one to create the infinite effect.
        */
        function createInfiniteSections(v){
            // Scrolling down
            if (!v.isMovementUp) {
                // Move all previous sections to after the active section
                $(".fp-section.active").after(v.activeSection.prevAll(".fp-section").get().reverse());
            }
            else { // Scrolling up
                // Move all next sections to before the active section
                $(".fp-section.active").before(v.activeSection.nextAll(".fp-section"));
            }
 
            // Maintain the displayed position (now that we changed the element order)
            silentScroll($('.fp-section.active').position().top);
 
            // Maintain the active slides visible in the viewport
            keepSlidesPosition();
 
            // save for later the elements that still need to be reordered
            v.wrapAroundElements = v.activeSection;
 
            // Recalculate animation variables
            v.dest = v.element.position();
            v.dtop = v.dest.top;
            v.yMovement = getYmovement(v.element);
 
            return v;
        }
 
        /**
        * Fix section order after continuousVertical changes have been animated
        */
        function continuousVerticalFixSectionOrder (v) {
            // If continuousVertical is in effect (and autoScrolling would also be in effect then),
            // finish moving the elements around so the direct navigation will function more simply
            if (!v.wrapAroundElements || !v.wrapAroundElements.length) {
                return;
            }
 
            if (v.isMovementUp) {
                $('.fp-section:first').before(v.wrapAroundElements);
            }
            else {
                $('.fp-section:last').after(v.wrapAroundElements);
            }
 
            silentScroll($('.fp-section.active').position().top);
 
            // Maintain the active slides visible in the viewport
            keepSlidesPosition();
        };
 
 
        /**
        * Actions to do once the section is loaded
        */
        function afterSectionLoads (v){
            continuousVerticalFixSectionOrder(v);
            //callback (afterLoad) if the site is not just resizing and readjusting the slides
            $.isFunction(options.afterLoad) && !v.localIsResizing && options.afterLoad.call(this, v.anchorLink, (v.sectionIndex + 1));
 
            setTimeout(function () {
                isMoving = false;
                $.isFunction(v.callback) && v.callback.call(this);
            }, scrollDelay);
        }
 
 
        /**
        * Scrolls to the anchor in the URL when loading the site
        */
        function scrollToAnchor(){
            //getting the anchor link in the URL and deleting the `#`
            var value =  window.location.hash.replace('#', '').split('/');
            var section = value[0];
            var slide = value[1];
 
            if(section){  //if theres any #
                scrollPageAndSlide(section, slide);
            }
        }
 
        //detecting any change on the URL to scroll to the given anchor link
        //(a way to detect back history button as we play with the hashes on the URL)
        $(window).on('hashchange', hashChangeHandler);
 
        function hashChangeHandler(){
            if(!isScrolling){
                var value =  window.location.hash.replace('#', '').split('/');
                var section = value[0];
                var slide = value[1];
 
                if(section.length){
                    //when moving to a slide in the first section for the first time (first time to add an anchor to the URL)
                    var isFirstSlideMove =  (typeof lastScrolledDestiny === 'undefined');
                    var isFirstScrollMove = (typeof lastScrolledDestiny === 'undefined' && typeof slide === 'undefined' && !slideMoving);
 
                    /*in order to call scrollpage() only once for each destination at a time
                    It is called twice for each scroll otherwise, as in case of using anchorlinks `hashChange`
                    event is fired on every scroll too.*/
                    if ((section && section !== lastScrolledDestiny) && !isFirstSlideMove || isFirstScrollMove || (!slideMoving && lastScrolledSlide != slide ))  {
                        scrollPageAndSlide(section, slide);
                    }
                }
            }
        }
 
 
        /**
         * Sliding with arrow keys, both, vertical and horizontal
         */
        $(document).keydown(function(e) {
            //Moving the main page with the keyboard arrows if keyboard scrolling is enabled
            if (options.keyboardScrolling && options.autoScrolling) {
 
                //preventing the scroll with arrow keys
                if(e.which == 40 || e.which == 38){
                    e.preventDefault();
                }
 
                if(!isMoving){
                    switch (e.which) {
                        //up
                        case 38:
                        case 33:
                            $.fn.fullpage.moveSectionUp();
                            break;
 
                        //down
                        case 40:
                        case 34:
                            $.fn.fullpage.moveSectionDown();
                            break;
 
                        //Home
                        case 36:
                            $.fn.fullpage.moveTo(1);
                            break;
 
                        //End
                        case 35:
                            $.fn.fullpage.moveTo( $('.fp-section').length );
                            break;
 
                        //left
                        case 37:
                            $.fn.fullpage.moveSlideLeft();
                            break;
 
                        //right
                        case 39:
                            $.fn.fullpage.moveSlideRight();
                            break;
 
                        default:
                            return; // exit this handler for other keys
                    }
                }
            }
        });
 
        /**
        * Scrolls to the section when clicking the navigation bullet
        */
        $(document).on('click touchstart', '#fp-nav a', function(e){
            e.preventDefault();
            var index = $(this).parent().index();
            scrollPage($('.fp-section').eq(index));
        });
 
        /**
        * Scrolls the slider to the given slide destination for the given section
        */
        $(document).on('click touchstart', '.fp-slidesNav a', function(e){
            e.preventDefault();
            var slides = $(this).closest('.fp-section').find('.fp-slides');
            var destiny = slides.find('.fp-slide').eq($(this).closest('li').index());
 
            landscapeScroll(slides, destiny);
        });
 
        if(options.normalScrollElements){
            $(document).on('mouseenter', options.normalScrollElements, function () {
                $.fn.fullpage.setMouseWheelScrolling(false);
            });
 
            $(document).on('mouseleave', options.normalScrollElements, function(){
                $.fn.fullpage.setMouseWheelScrolling(true);
            });
        }
 
        /**
         * Scrolling horizontally when clicking on the slider controls.
         */
        $('.fp-section').on('click touchstart', '.fp-controlArrow', function() {
            if ($(this).hasClass('fp-prev')) {
                $.fn.fullpage.moveSlideLeft();
            } else {
                $.fn.fullpage.moveSlideRight();
            }
        });
 
        /**
        * Scrolls horizontal sliders.
        */
        function landscapeScroll(slides, destiny){
            var destinyPos = destiny.position();
            var slidesContainer = slides.find('.fp-slidesContainer').parent();
            var slideIndex = destiny.index();
            var section = slides.closest('.fp-section');
            var sectionIndex = section.index('.fp-section');
            var anchorLink = section.data('anchor');
            var slidesNav = section.find('.fp-slidesNav');
            var slideAnchor = destiny.data('anchor');
 
            //caching the value of isResizing at the momment the function is called
            //because it will be checked later inside a setTimeout and the value might change
            var localIsResizing = isResizing;
 
            if(options.onSlideLeave){
                var prevSlideIndex = section.find('.fp-slide.active').index();
                var xMovement = getXmovement(prevSlideIndex, slideIndex);
 
                //if the site is not just resizing and readjusting the slides
                if(!localIsResizing && xMovement!=='none'){
                    $.isFunction( options.onSlideLeave ) && options.onSlideLeave.call( this, anchorLink, (sectionIndex + 1), prevSlideIndex, xMovement);
                }
            }
 
            destiny.addClass('active').siblings().removeClass('active');
 
 
            if(typeof slideAnchor === 'undefined'){
                slideAnchor = slideIndex;
            }
 
            if(!options.loopHorizontal && options.controlArrows){
                //hidding it for the fist slide, showing for the rest
                section.find('.fp-controlArrow.fp-prev').toggle(slideIndex!=0);
 
                //hidding it for the last slide, showing for the rest
                section.find('.fp-controlArrow.fp-next').toggle(!destiny.is(':last-child'));
            }
 
            //only changing the URL if the slides are in the current section (not for resize re-adjusting)
            if(section.hasClass('active')){
                setState(slideIndex, slideAnchor, anchorLink, sectionIndex);
            }
 
            var afterSlideLoads = function(){
                //if the site is not just resizing and readjusting the slides
                if(!localIsResizing){
                    $.isFunction( options.afterSlideLoad ) && options.afterSlideLoad.call( this, anchorLink, (sectionIndex + 1), slideAnchor, slideIndex);
                }
                //letting them slide again
                slideMoving = false;
            };
 
            if(options.css3){
                var translate3d = 'translate3d(-' + destinyPos.left + 'px, 0px, 0px)';
 
                addAnimation(slides.find('.fp-slidesContainer'), options.scrollingSpeed>0).css(getTransforms(translate3d));
 
                setTimeout(function(){
                    afterSlideLoads();
                }, options.scrollingSpeed, options.easing);
            }else{
                slidesContainer.animate({
                    scrollLeft : destinyPos.left
                }, options.scrollingSpeed, options.easing, function() {
 
                    afterSlideLoads();
                });
            }
 
            slidesNav.find('.active').removeClass('active');
            slidesNav.find('li').eq(slideIndex).find('a').addClass('active');
        }
 
        //when resizing the site, we adjust the heights of the sections, slimScroll...
        $(window).resize(resizeHandler);
 
        var previousHeight = windowsHeight;
        var resizeId;
        function resizeHandler(){
            //checking if it needs to get responsive
            responsive();
 
            // rebuild immediately on touch devices
            if (isTouchDevice) {
 
                //if the keyboard is visible
                if ($(document.activeElement).attr('type') !== 'text') {
                    var currentHeight = $(window).height();
 
                    //making sure the change in the viewport size is enough to force a rebuild. (20 % of the window to avoid problems when hidding scroll bars)
                    if( Math.abs(currentHeight - previousHeight) > (20 * Math.max(previousHeight, currentHeight) / 100) ){
                        $.fn.fullpage.reBuild(true);
                        previousHeight = currentHeight;
                    }
                }
              }else{
                  //in order to call the functions only when the resize is finished
                //http://stackoverflow.com/questions/4298612/jquery-how-to-call-resize-event-only-once-its-finished-resizing
                  clearTimeout(resizeId);
 
                resizeId = setTimeout(function(){
                    $.fn.fullpage.reBuild(true);
                }, 500);
              }
        }
 
        /**
        * Checks if the site needs to get responsive and disables autoScrolling if so.
        * A class `fp-responsive` is added to the plugin's container in case the user wants to use it for his own responsive CSS.
        */
        function responsive(){
            if(options.responsive){
                var isResponsive = container.hasClass('fp-responsive');
                if ($(window).width() < options.responsive ){
                    if(!isResponsive){
                        $.fn.fullpage.setAutoScrolling(false, 'internal');
                        $('#fp-nav').hide();
                        container.addClass('fp-responsive');
                    }
                }else if(isResponsive){
                    $.fn.fullpage.setAutoScrolling(originals.autoScrolling, 'internal');
                    $('#fp-nav').show();
                    container.removeClass('fp-responsive');
                }
            }
        }
 
        /**
        * Adds transition animations for the given element
        */
        function addAnimation(element){
            var transition = 'all ' + options.scrollingSpeed + 'ms ' + options.easingcss3;
 
            element.removeClass('fp-notransition');
            return element.css({
                '-webkit-transition': transition,
                 'transition': transition
               });
        }
 
        /**
        * Remove transition animations for the given element
        */
        function removeAnimation(element){
            return element.addClass('fp-notransition');
        }
 
        /**
         * Resizing of the font size depending on the window size as well as some of the images on the site.
         */
        function resizeMe(displayHeight, displayWidth) {
            //Standard dimensions, for which the body font size is correct
            var preferredHeight = 825;
            var preferredWidth = 900;
 
            if (displayHeight < preferredHeight || displayWidth < preferredWidth) {
                var heightPercentage = (displayHeight * 100) / preferredHeight;
                var widthPercentage = (displayWidth * 100) / preferredWidth;
                var percentage = Math.min(heightPercentage, widthPercentage);
                var newFontSize = percentage.toFixed(2);
 
                $("body").css("font-size", newFontSize + '%');
            } else {
                $("body").css("font-size", '100%');
            }
        }
 
        /**
         * Activating the website navigation dots according to the given slide name.
         */
        function activateNavDots(name, sectionIndex){
            if(options.navigation){
                $('#fp-nav').find('.active').removeClass('active');
                if(name){
                    $('#fp-nav').find('a[href="#' + name + '"]').addClass('active');
                }else{
                    $('#fp-nav').find('li').eq(sectionIndex).find('a').addClass('active');
                }
            }
        }
 
        /**
         * Activating the website main menu elements according to the given slide name.
         */
        function activateMenuElement(name){
            if(options.menu){
                $(options.menu).find('.active').removeClass('active');
                $(options.menu).find('[data-menuanchor="'+name+'"]').addClass('active');
            }
        }
 
        function activateMenuAndNav(anchor, index){
            activateMenuElement(anchor);
            activateNavDots(anchor, index);
        }
 
        /**
        * Return a boolean depending on whether the scrollable element is at the end or at the start of the scrolling
        * depending on the given type.
        */
        function isScrolled(type, scrollable){
            if(type === 'top'){
                return !scrollable.scrollTop();
            }else if(type === 'bottom'){
                return scrollable.scrollTop() + 1 + scrollable.innerHeight() >= scrollable[0].scrollHeight;
            }
        }
 
        /**
        * Retuns `up` or `down` depending on the scrolling movement to reach its destination
        * from the current section.
        */
        function getYmovement(destiny){
            var fromIndex = $('.fp-section.active').index('.fp-section');
            var toIndex = destiny.index('.fp-section');
            if( fromIndex == toIndex){
                return 'none'
            }
            if(fromIndex > toIndex){
                return 'up';
            }
            return 'down';
        }
 
        /**
        * Retuns `right` or `left` depending on the scrolling movement to reach its destination
        * from the current slide.
        */
        function getXmovement(fromIndex, toIndex){
            if( fromIndex == toIndex){
                return 'none'
            }
            if(fromIndex > toIndex){
                return 'left';
            }
            return 'right';
        }
 
 
        function createSlimScrolling(element){
            //needed to make `scrollHeight` work under Opera 12
            element.css('overflow', 'hidden');
 
            //in case element is a slide
            var section = element.closest('.fp-section');
            var scrollable = element.find('.fp-scrollable');
 
            //if there was scroll, the contentHeight will be the one in the scrollable section
            if(scrollable.length){
                var contentHeight = scrollable.get(0).scrollHeight;
            }else{
                var contentHeight = element.get(0).scrollHeight;
                if(options.verticalCentered){
                    contentHeight = element.find('.fp-tableCell').get(0).scrollHeight;
                }
            }
 
            var scrollHeight = windowsHeight - parseInt(section.css('padding-bottom')) - parseInt(section.css('padding-top'));
 
            //needs scroll?
            if ( contentHeight > scrollHeight) {
                //was there already an scroll ? Updating it
                if(scrollable.length){
                    scrollable.css('height', scrollHeight + 'px').parent().css('height', scrollHeight + 'px');
                }
                //creating the scrolling
                else{
                    if(options.verticalCentered){
                        element.find('.fp-tableCell').wrapInner('<div class="fp-scrollable" />');
                    }else{
                        element.wrapInner('<div class="fp-scrollable" />');
                    }
 
                    element.find('.fp-scrollable').slimScroll({
                        allowPageScroll: true,
                        height: scrollHeight + 'px',
                        size: '10px',
                        alwaysVisible: true
                    });
                }
            }
 
            //removing the scrolling when it is not necessary anymore
            else{
                removeSlimScroll(element);
            }
 
            //undo
            element.css('overflow', '');
        }
 
        function removeSlimScroll(element){
            element.find('.fp-scrollable').children().first().unwrap().unwrap();
            element.find('.slimScrollBar').remove();
            element.find('.slimScrollRail').remove();
        }
 
        function addTableClass(element){
            element.addClass('fp-table').wrapInner('<div class="fp-tableCell" style="height:' + getTableHeight(element) + 'px;" />');
        }
 
        function getTableHeight(element){
            var sectionHeight = windowsHeight;
 
            if(options.paddingTop || options.paddingBottom){
                var section = element;
                if(!section.hasClass('fp-section')){
                    section = element.closest('.fp-section');
                }
 
                var paddings = parseInt(section.css('padding-top')) + parseInt(section.css('padding-bottom'));
                sectionHeight = (windowsHeight - paddings);
            }
 
            return sectionHeight;
        }
 
        /**
        * Adds a css3 transform property to the container class with or without animation depending on the animated param.
        */
        function transformContainer(translate3d, animated){
            if(animated){
                addAnimation(container);
            }else{
                removeAnimation(container);
            }
 
            container.css(getTransforms(translate3d));
 
            //syncronously removing the class after the animation has been applied.
            setTimeout(function(){
                container.removeClass('fp-notransition');
            },10)
        }
 
 
        /**
        * Scrolls to the given section and slide
        */
        function scrollPageAndSlide(destiny, slide){
            if (typeof slide === 'undefined') {
                slide = 0;
            }
 
            if(isNaN(destiny)){
                var section = $('[data-anchor="'+destiny+'"]');
            }else{
                var section = $('.fp-section').eq( (destiny -1) );
            }
 
 
            //we need to scroll to the section and then to the slide
            if (destiny !== lastScrolledDestiny && !section.hasClass('active')){
                scrollPage(section, function(){
                    scrollSlider(section, slide)
                });
            }
            //if we were already in the section
            else{
                scrollSlider(section, slide);
            }
        }
 
        /**
        * Scrolls the slider to the given slide destination for the given section
        */
        function scrollSlider(section, slide){
            if(typeof slide != 'undefined'){
                var slides = section.find('.fp-slides');
                var destiny =  slides.find('[data-anchor="'+slide+'"]');
 
                if(!destiny.length){
                    destiny = slides.find('.fp-slide').eq(slide);
                }
 
                if(destiny.length){
                    landscapeScroll(slides, destiny);
                }
            }
        }
 
        /**
        * Creates a landscape navigation bar with dots for horizontal sliders.
        */
        function addSlidesNavigation(section, numSlides){
            section.append('<div class="fp-slidesNav"><ul></ul></div>');
            var nav = section.find('.fp-slidesNav');
 
            //top or bottom
            nav.addClass(options.slidesNavPosition);
 
            for(var i=0; i< numSlides; i++){
                nav.find('ul').append('<li><a href="#"><span></span></a></li>');
            }
 
            //centering it
            nav.css('margin-left', '-' + (nav.width()/2) + 'px');
 
            nav.find('li').first().find('a').addClass('active');
        }
 
 
        /**
        * Sets the state of the website depending on the active section/slide.
        * It changes the URL hash when needed and updates the body class.
        */
        function setState(slideIndex, slideAnchor, anchorLink, sectionIndex){
            var sectionHash = '';
 
            if(options.anchors.length){
 
                //isn't it the first slide?
                if(slideIndex){
                    if(typeof anchorLink !== 'undefined'){
                        sectionHash = anchorLink;
                    }
 
                    //slide without anchor link? We take the index instead.
                    if(typeof slideAnchor === 'undefined'){
                        slideAnchor = slideIndex;
                    }
 
                    lastScrolledSlide = slideAnchor;
                    setUrlHash(sectionHash + '/' + slideAnchor);
 
                //first slide won't have slide anchor, just the section one
                }else if(typeof slideIndex !== 'undefined'){
                    lastScrolledSlide = slideAnchor;
                    setUrlHash(anchorLink);
                }
 
                //section without slides
                else{
                    setUrlHash(anchorLink);
                }
 
                setBodyClass(location.hash);
            }
            else if(typeof slideIndex !== 'undefined'){
                    setBodyClass(sectionIndex + '-' + slideIndex);
            }
            else{
                setBodyClass(String(sectionIndex));
            }
        }
 
        /**
        * Sets the URL hash.
        */
        function setUrlHash(url){
            if(options.recordHistory){
                location.hash = url;
            }else{
                //Mobile Chrome doesn't work the normal way, so... lets use HTML5 for phones :)
                if(isTouchDevice || isTouch){
                    history.replaceState(undefined, undefined, "#" + url)
                }else{
                    var baseUrl = window.location.href.split('#')[0];
                    window.location.replace( baseUrl + '#' + url );
                }
            }
        }
 
        /**
        * Sets a class for the body of the page depending on the active section / slide
        */
        function setBodyClass(text){
            //changing slash for dash to make it a valid CSS style
            text = text.replace('/', '-').replace('#','');
 
            //removing previous anchor classes
            $("body")[0].className = $("body")[0].className.replace(/\b\s?fp-viewing-[^\s]+\b/g, '');
 
            //adding the current anchor
            $("body").addClass("fp-viewing-" + text);
        }
 
        /**
        * Checks for translate3d support
        * @return boolean
        * http://stackoverflow.com/questions/5661671/detecting-transform-translate3d-support
        */
        function support3d() {
            var el = document.createElement('p'),
                has3d,
                transforms = {
                    'webkitTransform':'-webkit-transform',
                    'OTransform':'-o-transform',
                    'msTransform':'-ms-transform',
                    'MozTransform':'-moz-transform',
                    'transform':'transform'
                };
 
            // Add it to the body to get the computed style.
            document.body.insertBefore(el, null);
 
            for (var t in transforms) {
                if (el.style[t] !== undefined) {
                    el.style[t] = "translate3d(1px,1px,1px)";
                    has3d = window.getComputedStyle(el).getPropertyValue(transforms[t]);
                }
            }
 
            document.body.removeChild(el);
 
            return (has3d !== undefined && has3d.length > 0 && has3d !== "none");
        }
 
 
 
        /**
        * Removes the auto scrolling action fired by the mouse wheel and trackpad.
        * After this function is called, the mousewheel and trackpad movements won't scroll through sections.
        */
        function removeMouseWheelHandler(){
            if (document.addEventListener) {
                document.removeEventListener('mousewheel', MouseWheelHandler, false); //IE9, Chrome, Safari, Oper
                document.removeEventListener('wheel', MouseWheelHandler, false); //Firefox
            } else {
                document.detachEvent("onmousewheel", MouseWheelHandler); //IE 6/7/8
            }
        }
 
 
        /**
        * Adds the auto scrolling action for the mouse wheel and trackpad.
        * After this function is called, the mousewheel and trackpad movements will scroll through sections
        */
        function addMouseWheelHandler(){
            if (document.addEventListener) {
                document.addEventListener("mousewheel", MouseWheelHandler, false); //IE9, Chrome, Safari, Oper
                document.addEventListener("wheel", MouseWheelHandler, false); //Firefox
            } else {
                document.attachEvent("onmousewheel", MouseWheelHandler); //IE 6/7/8
            }
        }
 
 
        /**
        * Adds the possibility to auto scroll through sections on touch devices.
        */
        function addTouchHandler(){
            if(isTouchDevice || isTouch){
                //Microsoft pointers
                MSPointer = getMSPointer();
 
                $(document).off('touchstart ' +  MSPointer.down).on('touchstart ' + MSPointer.down, touchStartHandler);
                $(document).off('touchmove ' + MSPointer.move).on('touchmove ' + MSPointer.move, touchMoveHandler);
            }
        }
 
        /**
        * Removes the auto scrolling for touch devices.
        */
        function removeTouchHandler(){
            if(isTouchDevice || isTouch){
                //Microsoft pointers
                MSPointer = getMSPointer();
 
                $(document).off('touchstart ' + MSPointer.down);
                $(document).off('touchmove ' + MSPointer.move);
            }
        }
 
 
        /*
        * Returns and object with Microsoft pointers (for IE<11 and for IE >= 11)
        * http://msdn.microsoft.com/en-us/library/ie/dn304886(v=vs.85).aspx
        */
        function getMSPointer(){
            var pointer;
 
            //IE >= 11 & rest of browsers
            if(window.PointerEvent){
                pointer = { down: "pointerdown", move: "pointermove"};
            }
 
            //IE < 11
            else{
                pointer = { down: "MSPointerDown", move: "MSPointerMove"};
            }
 
            return pointer;
        }
        /**
        * Gets the pageX and pageY properties depending on the browser.
        * https://github.com/alvarotrigo/fullPage.js/issues/194#issuecomment-34069854
        */
        function getEventsPage(e){
            var events = new Array();
 
            events['y'] = (typeof e.pageY !== 'undefined' && (e.pageY || e.pageX) ? e.pageY : e.touches[0].pageY);
            events['x'] = (typeof e.pageX !== 'undefined' && (e.pageY || e.pageX) ? e.pageX : e.touches[0].pageX);
 
            return events;
        }
 
        function silentLandscapeScroll(activeSlide){
            $.fn.fullpage.setScrollingSpeed (0, 'internal');
            landscapeScroll(activeSlide.closest('.fp-slides'), activeSlide);
            $.fn.fullpage.setScrollingSpeed(originals.scrollingSpeed, 'internal');
        }
 
        function silentScroll(top){
            if(options.scrollBar){
                container.scrollTop(top);
            }
            else if (options.css3) {
                var translate3d = 'translate3d(0px, -' + top + 'px, 0px)';
                transformContainer(translate3d, false);
            }
            else {
                container.css("top", -top);
            }
        }
 
        function getTransforms(translate3d){
            return {
                '-webkit-transform': translate3d,
                '-moz-transform': translate3d,
                '-ms-transform':translate3d,
                'transform': translate3d
            };
        }
 
        function setIsScrollable(value, direction){
            switch (direction){
                case 'up': isScrollAllowed.up = value; break;
                case 'down': isScrollAllowed.down = value; break;
                case 'left': isScrollAllowed.left = value; break;
                case 'right': isScrollAllowed.right = value; break;
                case 'all': $.fn.fullpage.setAllowScrolling(value);
            }
        }
 
 
        /*
        * Destroys fullpage.js plugin events and optinally its html markup and styles
        */
        $.fn.fullpage.destroy = function(all){
            $.fn.fullpage.setAutoScrolling(false, 'internal');
             $.fn.fullpage.setAllowScrolling(false);
             $.fn.fullpage.setKeyboardScrolling(false);
 
 
             $(window)
                .off('scroll', scrollHandler)
                  .off('hashchange', hashChangeHandler)
                  .off('resize', resizeHandler);
 
            $(document)
                .off('click', '#fp-nav a')
                .off('mouseenter', '#fp-nav li')
                .off('mouseleave', '#fp-nav li')
                .off('click', '.fp-slidesNav a')
                  .off('mouseover', options.normalScrollElements)
                  .off('mouseout', options.normalScrollElements);
 
            $('.fp-section')
                .off('click', '.fp-controlArrow');
 
            //lets make a mess!
            if(all){
                destroyStructure();
            }
         };
 
         /*
        * Removes inline styles added by fullpage.js
        */
        function destroyStructure(){
            //reseting the `top` or `translate` properties to 0
             silentScroll(0);
 
            $('#fp-nav, .fp-slidesNav, .fp-controlArrow').remove();
 
            //removing inline styles
            $('.fp-section').css( {
                'height': '',
                'background-color' : '',
                'padding': ''
            });
 
            $('.fp-slide').css( {
                'width': ''
            });
 
            container.css({
                 'height': '',
                 'position': '',
                 '-ms-touch-action': '',
                 'touch-action': ''
             });
 
            //removing added classes
            $('.fp-section, .fp-slide').each(function(){
                removeSlimScroll($(this));
                $(this).removeClass('fp-table active');
            });
 
            removeAnimation(container);
            removeAnimation(container.find('.fp-easing'));
 
            //Unwrapping content
            container.find('.fp-tableCell, .fp-slidesContainer, .fp-slides').each(function(){
                //unwrap not being use in case there's no child element inside and its just text
                $(this).replaceWith(this.childNodes);
            });
 
            //scrolling the page to the top with no animation
            $('html, body').scrollTop(0);
        }
 
        /*
        * Sets the state for a variable with multiple states (original, and temporal)
        * Some variables such as `autoScrolling` or `recordHistory` might change automatically its state when using `responsive` or `autoScrolling:false`.
        * This function is used to keep track of both states, the original and the temporal one.
        * If type is not 'internal', then we assume the user is globally changing the variable.
        */
        function setVariableState(variable, value, type){
            options[variable] = value;
            if(type !== 'internal'){
                originals[variable] = value;
            }
        }
 
        /**
        * Displays warnings
        */
        function displayWarnings(){
            // Disable mutually exclusive settings
            if (options.continuousVertical &&
                (options.loopTop || options.loopBottom)) {
                options.continuousVertical = false;
                showError('warn', "Option `loopTop/loopBottom` is mutually exclusive with `continuousVertical`; `continuousVertical` disabled");
            }
            if(options.continuousVertical && options.scrollBar){
                options.continuousVertical = false;
                showError('warn', "Option `scrollBar` is mutually exclusive with `continuousVertical`; `continuousVertical` disabled");
            }
 
            //anchors can not have the same value as any element ID or NAME
            $.each(options.anchors, function(index, name){
                if($('#' + name).length || $('[name="'+name+'"]').length ){
                    showError('error', "data-anchor tags can not have the same value as any `id` element on the site (or `name` element for IE).");
                }
            });
        }
 
        function showError(type, text){
            console && console[type] && console[type]('fullPage: ' + text);
        }
    };
})(jQuery);