PageSourceSearch

https://jacksonsbarandoven.com/wp-content/themes/rosa/assets/js/main.js?ver=2.9.0

js jacksonsbarandoven.com collected 2026-10-06 17:36:07 UTC 68,543 bytes, 2,527 lines download raw bytes

1(function ($, window, undefined) {
2
3	/* --- DETECT VIEWPORT SIZE --- */
4
5	function browserSize() {
6		wh = $(window).height();
7		ww = $(window).width();
8		dh = $(document).height();
9		ar = ww / wh;
10	}
11
12
13	/* --- DETECT PLATFORM --- */
14
15	function platformDetect() {
16		$.support.touch = 'ontouchend' in document;
17		var navUA = navigator.userAgent.toLowerCase(),
18			navPlat = navigator.platform.toLowerCase();
19
20		var isiPhone = navPlat.indexOf("iphone"),
21			isiPod = navPlat.indexOf("ipod"),
22			isAndroidPhone = navPlat.indexOf("android"),
23			safari = (navUA.indexOf('safari') != -1 && navUA.indexOf('chrome') == -1) ? true : false,
24			svgSupport = (window.SVGAngle) ? true : false,
25			svgSupportAlt = (document.implementation.hasFeature("http://www.w3.org/TR/SVG11/feature#BasicStructure", "1.1")) ? true : false,
26			ff3x = (/gecko/i.test(navUA) && /rv:1.9/i.test(navUA)) ? true : false;
27
28        ieMobile = navigator.userAgent.match(/Windows Phone/i) ? true : false;
29		phone = (isiPhone > -1 || isiPod > -1 || isAndroidPhone > -1) ? true : false;
30		touch = $.support.touch ? true : false;
31		ltie9 = $.support.leadingWhitespace ? false : true;
32
33		var $bod = $('body');
34
35		if (touch) $('html').addClass('touch');
36		if (ieMobile) $('html').addClass('is--winmob');
37		if (is_android) $('html').addClass('is--ancient-android');
38		if (safari) $bod.addClass('safari');
39		if (phone) $bod.addClass('phone');
40	}
41// /* ====== SHARED VARS ====== */
42
43var phone, touch, ltie9, dh, ar, fonts, ieMobile;
44
45var ua = navigator.userAgent;
46var winLoc = window.location.toString();
47
48var is_webkit       = ua.match(/webkit/i);
49var is_firefox      = ua.match(/gecko/i);
50var is_newer_ie     = ua.match(/msie (9|([1-9][0-9]))/i);
51var is_older_ie     = ua.match(/msie/i) && !is_newer_ie;
52var is_ancient_ie   = ua.match(/msie 6/i);
53var is_ie           = is_ancient_ie || is_older_ie || is_newer_ie;
54var is_mobile_ie    = navigator.userAgent.indexOf('IEMobile') !== -1;
55var is_mobile       = ua.match(/mobile/i) ? true : false;
56var is_OSX          = ua.match(/(iPad|iPhone|iPod|Macintosh)/g) ? true : false;
57var iOS 			= getIOSVersion(ua);
58var is_EDGE 		= /Edge\/12./i.test(navigator.userAgent);
59
60var latestKnownScrollY = -1,
61	newScrollY = (window.pageYOffset || document.documentElement.scrollTop) - (document.documentElement.clientTop || 0),
62	ticking = false;
63
64if (is_EDGE) {
65	jQuery('body').addClass('is-edge');
66}
67
68
69var nua = navigator.userAgent;
70var is_android = ((nua.indexOf('Mozilla/5.0') !== -1 && nua.indexOf('Android ') !== -1 && nua.indexOf('AppleWebKit') !== -1) && nua.indexOf('Chrome') === -1);
71var isAndroid = ua.indexOf("android") > -1; //&& ua.indexOf("mobile");
72
73var useTransform = true;
74var use2DTransform = (ua.match(/msie 9/i) || winLoc.match(/transform\=2d/i));
75var transform;
76
77// setting up transform prefixes
78var prefixes = {
79	webkit: 'webkitTransform',
80	firefox: 'MozTransform',
81	ie: 'msTransform',
82	w3c: 'transform'
83};
84
85if (useTransform) {
86	if (is_webkit) {
87		transform = prefixes.webkit;
88	} else if (is_firefox) {
89		transform = prefixes.firefox;
90	} else if (is_newer_ie) {
91		transform = prefixes.ie;
92	}
93}
94
95var windowWidth 		= window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth,
96    windowHeight 		= window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight;
97
98/* --- To enable verbose debug add to Theme Options > Custom Code footer -> globalDebug=true; --- */
99var globalDebug = false,
100	timestamp;
101
102/* --- 404 Page --- */
103if ( typeof window.gifImages !== "undefined" && ! window.gifImages instanceof Array && window.gifImages.length !== 0 ) {
104
105	window.gifImages = [
106		"http://i.imgur.com/ShiZM6m.gif",
107		"http://i.imgur.com/8ZYNp.gif",
108		"http://i.imgur.com/Xb4fq.gif",
109		"http://i.imgur.com/UYPLKwN.gif",
110		"http://media.tumblr.com/d9e792a91d5391b8a7aa22689d4e2555/tumblr_inline_mwq1hmelce1qmoozl.gif",
111		"http://www.teen.com/wp-content/uploads/2013/10/world-without-jennifer-lawrence-gifs-food-uproxx-2.gif"
112	];
113
114}
115
116function getGif() {
117	return gifImages[Math.floor( Math.random() * gifImages.length )];
118}
119
120function changeBackground() {
121	$( '.error404' ).css( 'background-image', 'url(' + getGif() + ')' );
122}
123
124$( window ).on( 'load', function() {
125	if ( $( '.error404' ).length ) {
126		changeBackground();
127	}
128} );
129
130$( window ).keydown( function( e ) {
131	if ( e.keyCode === 32 ) {
132		changeBackground();
133	}
134} );
135
136/* --- Cover Animations Init --- */
137
138var CoverAnimation = {
139    selector:       '.article__header',
140    initialized:    false,
141    animated:       false,
142
143    initialize: function () {
144
145        if (is_EDGE) {
146            return;
147        }
148
149        var that = this;
150
151        $(this.selector).each(function(i, header) {
152
153            var $header         = $(header),
154                $headline       = $header.find('.article__headline'),
155                timeline        = new TimelineMax({ paused: true }),
156                $title          = $headline.find('.headline__primary'),
157                $subtitle       = $headline.find('.headline__secondary'),
158                $description    = $headline.find('.headline__description'),
159                $star           = $headline.find('.star'),
160                $lines          = $headline.find('.line'),
161                $arrows         = $description.find('.arrow'),
162                $hr             = $description.find('hr'),
163                headerTop       = $header.offset().top,
164                headerHeight    = $header.outerHeight();
165
166            $header.find('.pixcode--separator').width($title.width());
167
168            $description.css({opacity: 1});
169            $description = $description.children().not('.pixcode--separator');
170            $description.css({opacity: 0});
171
172            // ------ A
173
174            if ( $title.length && $title.text().trim().length ) {
175                timeline.fromTo($title, 0.72, {'letter-spacing': '1em', 'margin-right': '-0.9em'}, {'letter-spacing': '0.2em', 'margin-right': '-0.1em', ease: Expo.easeOut});
176                timeline.fromTo($title, 0.89, {opacity: 0}, {opacity: 1, ease: Expo.easeOut}, '-=0.72');
177                timeline.fromTo($title, 1, {'y': 30}, {'y': 0, ease: Expo.easeOut}, '-=0.89');
178            }
179
180            if ( $subtitle.length ) {
181                timeline.fromTo($subtitle, 0.65, {opacity: 0}, {opacity: 1, ease: Quint.easeOut}, '-=0.65');
182                timeline.fromTo($subtitle, 0.9, {y: 30}, {y: 0, ease: Quint.easeOut}, '-=0.65');
183            }
184
185            if ( $star.length ) {
186                timeline.fromTo($star, 0.15, {opacity: 0}, {opacity: 1, ease: Quint.easeOut}, '-=0.6');
187                timeline.fromTo($star, 0.55, {rotation: -270}, {rotation: 0, ease: Back.easeOut}, '-=0.5');
188            }
189
190            if ( $lines.length ) {
191                timeline.fromTo($lines, 0.6, {width: 0}, {width: '42%', opacity: 1, ease: Quint.easeOut}, '-=0.55');
192                timeline.fromTo($hr, 0.6, {width: 0}, {width: '100%', opacity: 1, ease: Quint.easeOut}, '-=0.6');
193            }
194
195            if ( $arrows.length ) {
196                timeline.fromTo($arrows, 0.2, {opacity: 0}, {opacity: 1, ease: Quint.easeOut}, '-=0.27');
197            }
198
199            if ( $description.length ) {
200                timeline.fromTo($description, 0.5, {opacity: 0}, {opacity: 1, ease: Quint.easeOut}, '-=0.28');
201                timeline.fromTo($description, 0.75, {y: -20}, {y: 0}, '-=0.5');
202            }
203
204            // ------ B
205            timeline.addLabel("animatedIn");
206
207            // if (i == 0) {
208            //     timeline.fromTo($headline, 1.08, {y: 0}, {y: 150, ease: Linear.easeNone});
209            //     timeline.fromTo($title, 1.08, {y: 0}, {opacity: 0, y: -60, ease: Quad.easeIn}, '-=1.08');
210            // } else {
211                timeline.fromTo($title, 1.08, {y: 0}, {opacity: 0, y: -60, ease: Quad.easeIn});
212            // }
213
214            timeline.to($description, 1.08, {y: 60, opacity: 0, ease: Quad.easeIn}, '-=1.08');
215            timeline.to($subtitle, 1.08, {opacity: 0, y: -90, ease: Quad.easeIn}, '-=1.08');
216            timeline.to($lines, 0.86, {width: 0, opacity: 0, ease: Quad.easeIn}, '-=0.94');
217            timeline.to($hr, 0.86, {width: 0, opacity: 0, ease: Quad.easeIn}, '-=0.86');
218            timeline.to($star, 1, {rotation: 180}, '-=1.08');
219            timeline.to($star, 0.11, {opacity: 0}, '-=0.03');
220            timeline.to($arrows, 0.14, {opacity: 0}
220, '-=1.08');
221
222            timeline.addLabel("animatedOut");
223
224            // ------ C
225
226            var animatedInTime      = timeline.getLabelTime("animatedIn"),
227                animatedOutTime     = timeline.getLabelTime("animatedOut"),
228                start               = headerTop + headerHeight / 2 - windowHeight / 2,
229                end                 = start + headerHeight / 2,
230                ab, bc;
231
232            if (i === 0) {
233                start = headerTop;
234                end = start + windowHeight / 2;
235            }
236
237            ab = animatedInTime / animatedOutTime;
238            bc = 1 - ab;
239
240            if (!that.initialized) {
241
242                timeline.tweenTo("animatedIn", {
243                    onComplete: function () {
244                        if (Modernizr.touchevents) {
245                            $headline.data("animated", true);
246                        }
247                    }
248                });
249
250                if (!Modernizr.touchevents) {
251                    timeline.tweenTo("animatedOut", {
252                        onComplete: function () {
253                            $headline.data("animated", true);
254                        },
255                        onUpdate: function () {
256                            var progress        = (1 / (end - start)) * (latestKnownScrollY - start),
257                                partialProgress = progress < 0 ? ab : ab + bc * progress,
258                                currentProgress = timeline.progress();
259
260                            if (Math.abs(partialProgress - currentProgress) < 0.01) {
261                                $headline.data("animated", true);
262                                this.kill();
263                            }
264                        }
265                    });
266                }
267            }
268
269            $headline.data('tween', {
270                timeline:       timeline,
271                ab:             ab,
272                bc:             bc,
273                start:          start,
274                end:            end
275            });
276
277        });
278
279        that.initialized = true;
280        that.update();
281    },
282
283    update: function () {
284
285        if (is_EDGE) {
286            return;
287        }
288
289        var that = this;
290
291        $(this.selector).each(function (i, element) {
292
293            var $headline   = $(element).find('.article__headline'),
294                options     = $headline.data('tween'),
295                progress    = 0;
296
297            // some sanity check
298            // we wouldn't want to divide by 0 - the Universe might come to an end
299            if (! empty(options) && (options.end - options.start) !== 0) {
300
301                // progress on the total timeline (ac)
302                progress = (1 / (options.end - options.start)) * (latestKnownScrollY - options.start);
303
304                // progress on partial timeline (bc)
305                // point B being labeled as "animated"
306                var partialProgress = options.ab + options.bc * progress;
307
308                $headline.data('progress', partialProgress);
309
310                if (!$headline.data("animated")) {
311                    return;
312                }
313
314                if (0 > progress) {
315                    partialProgress = options.ab;
316                }
317
318                if (1 > partialProgress) {
319                    options.timeline.progress(partialProgress);
320                    return;
321                }
322
323                options.timeline.progress(1);
324            }
325        });
326    }
327}
328var DownArrow = {
329    selector:   '.down-arrow',
330    $arrow:     null,
331    timeline:   null,
332    start:      0,
333    end:        0,
334    bubble:     false,
335
336    initialize: function () {
337
338        var that = this;
339
340        this.$arrow = $(this.selector);
341
342        if (empty(this.$arrow)) {
343            return;
344        }
345
346        this.start      = 0;
347        this.end        = this.start + 300;
348        this.timeline   = new TimelineMax({ paused: true });
349        this.$next      = this.$arrow.closest('.article--page');
350
351        if (!empty(this.$next)) {
352            this.nextTop    = this.$next.offset().top;
353            this.nextHeight = this.$next.outerHeight();
354        }
355
356
357        if (this.$arrow.hasClass('down-arrow--bubble')) {
358            this.timeline.to(this.$arrow, .2, {y: 10, opacity: 0, ease: Linear.easeNone, overwrite: "none"});
359            this.timeline.to('.blurp--top', .3, {scaleY: 0, ease: Linear.easeNone, overwrite: "none"});
360            this.bubble = true;
361        } else {
362            this.timeline.to(this.$arrow, 1, {y: 100, opacity: 0, ease: Linear.easeNone, overwrite: "none"});
363        }
364
365        this.$arrow.on('click', function (e) {
366            e.preventDefault();
367
368            if (empty(that.$next)) {
369                return;
370            }
371
372            if (that.$next.is('.article__header')) {
373                smoothScrollTo(that.nextTop - windowHeight/2 + that.nextHeight/2);
374            } else {
375                smoothScrollTo(that.nextTop - $('.site-header').height());
376            }
377
378        });
379    },
380
381    update: function () {
382
383        if (empty(this.$arrow) || this.bubble) {
384            return;
385        }
386
387        if (Modernizr.touchevents && is_OSX) {
388            this.timeline.progress(0);
389            return;
390        }
391
392        setProgress(this.timeline, this.start, this.end);
393    }
394}
395// /* ====== HELPER FUNCTIONS ====== */
396
397//similar to PHP's empty function
398function empty(data) {
399	if (typeof(data) == 'number' || typeof(data) == 'boolean') {
400		return false;
401	}
402	if (typeof(data) == 'undefined' || data === null) {
403		return true;
404	}
405	if (typeof(data.length) != 'undefined') {
406		return data.length === 0;
407	}
408	var count = 0;
409	for (var i in data) {
410		// if(data.hasOwnProperty(i))
411		//
412		// This doesn't work in ie8/ie9 due the fact that hasOwnProperty works only on native objects.
413		// http://stackoverflow.com/questions/8157700/object-has-no-hasownproperty-method-i-e-its-undefined-ie8
414		//
415		// for hosts objects we do this
416		if (Object.prototype.hasOwnProperty.call(data, i)) {
417			count++;
418		}
419	}
420	return count === 0;
421}
422
423function extend(a, b) {
424	for (var key in b) {
425		if (b.hasOwnProperty(key)) {
426			a[key] = b[key];
427		}
428	}
429	return a;
430}
431
432// taken from https://github.com/inuyaksa/jquery.nicescroll/blob/master/jquery.nicescroll.js
433function hasParent(e, id) {
434	if (!e) return false;
435	var el = e.target || e.srcElement || e || false;
436	while (el && el.id != id) {
437		el = el.parentNode || false;
438	}
439	return (el !== false);
440}
441
442function mobilecheck() {
443	var check = false;
444	(function (a) {
445		if (/(android|ipad|playbook|silk|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i.test(a) || /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(a.substr(0, 4)))check = true;
446	})(navigator.userAgent || navigator.vendor || window.opera);
447	return check;
448}
449
450/* --- Set Query Parameter--- */
451function setQueryParameter(uri, key, value) {
452	var re = new RegExp("([?|&])" + key + "=.*?(&|$)", "i");
453	separator = uri.indexOf('?') !== -1 ? "&" : "?";
454	if (uri.match(re)) {
455		return uri.replace(re, '$1' + key + "=" + value + '$2');
456	}
457	else {
458		return uri + separator + key + "=" + value;
459	}
460}
461
462// http://stackoverflow.com/a/7557433
463function isElementInViewport (el) {
464
465    //special bonus for those using jQuery
466    if (el instanceof jQuery) {
467        el = el[0];
468    }
469
470    var rect = el.getBoundingClientRect();
471
472    return (
473    rect.top >= 0 &&
474    rect.left >= 0 &&
475    rect.bottom <= (window.innerHeight || document.documentElement.clientHeight) && /*or $(window).height() */
476    rect.right <= (window.innerWidth || document.documentElement.clientWidth) /*or $(window).width() */
477    );
478}
479
480function getIOSVersion(ua) {
481	ua = ua || navigator.userAgent;
482	return parseFloat(
483			('' + (/CPU.*OS ([0-9_]{1,5})|(CPU like).*AppleWebKit.*Mobile/i.exec(ua) || [0,''])[1])
484				.replace('undefined', '3_2').replace('_', '.').replace('_', '')
485		) || false;
486}
487
488function setProgress(timeline, start, end) {
489
490    var progress = (latestKnownScrollY - start) / (end - start);
491
492    if (0 > progress) {
493        timeline.progress(0);
494        return;
495    }
496
497    if (1 < progress) {
498        timeline.progress(1);
499        return;
500    }
501
502    timeline.progress(progress);
503}
504
505/**
506 * Generic tree implementation
507 *
508 * This class represents any node in the tree.
509 */
510var Node = function( val ) {
511
512	this.val = val;
513	this.children = [];
514	this.parent = null;
515
516	/**
517	 * Sets the parent node of this node.
518	 */
519	this.setParentNode = function( node ) {
520		this.parent = node;
521		node.children[node.children.length] = this;
522	}
523
524	/**
525	 * Gets the parent node of this node.
526	 */
527	this.getParentNode = function() {
528		return this.parent;
529	}
530
531	/**
532	 * Adds a child node of this node.
533	 */
534	this.addChild = function( node ) {
535		node.parent = this;
536		this.children[this.children.length] = node;
537	}
538
539	/**
540	 * Gets the array of child nodes of this node.
541	 */
542	this.getChildren = function() {
543		return this.children;
544	}
545
546	/**
547	 * Removes all the children of this node.
548	 */
549	this.removeChildren = function() {
550		var child;
551		for ( var i = 0; i < this.children.length; i++ ) {
552			child = this.children[i];
553			child.parent = null;
554		}
555		this.children = [];
556	}
557
558	/**
559	 * Recursively counts the number of all descendants, from children down, and
560	 * returns the total number.
561	 */
562	this.getTotalDescendantCount = function() {
563		var count = 0,
564			child;
565		for ( var i = 0; i < this.children.length; i++ ) {
566			child = this.children[i];
567			count += child.getTotalDescendantCount();
568		}
569		return count + this.children.length;
570	}
571}
572
573/**
574 * Protocol Buffer implementation, which extends the functionality of Node
575 * while specifically typing the stored value
576 */
577var PrBufNode = function( id, type, value ) {
578	this.val = {
579		id: id,
580		type: type,
581		value: value
582	};
583	this.children = [];
584	this.parent = null;
585}
586
587PrBufNode.prototype = new Node();
588PrBufNode.prototype.constructor = PrBufNode;
589
590PrBufNode.prototype.id = function() {
591	return this.val.id;
592}
593PrBufNode.prototype.type = function() {
594	return this.val.type;
595}
596PrBufNode.prototype.value = function() {
597	return this.val.value;
598}
599
600/**
601 * Compares the number of descendants with the value specified in the map element.
602 * If all the children have not yet been added, we continue adding to this element.
603 */
604PrBufNode.prototype.findLatestIncompleteNode = function() {
605
606	//if it's a branch (map) node ('m') and has room,
607	//or if it's the root (identified by having a null parent), which has no element limit,
608	//then return this node
609	if ( (
610		     (
611			     this.val.type === 'm'
612		     ) && (
613			     this.val.value > this.getTotalDescendantCount()
614		     )
615	     )
616	     || (
617		     null === this.parent
618	     ) ) {
619		return this;
620	}
621	else {
622		return this.parent.findLatestIncompleteNode();
623	}
624}
625
626/**
627 * Parses the input URL 'data' protocol buffer parameter into a tree
628 */
629PrBufNode.create = function( urlToParse ) {
630	var rootNode = null;
631	var re = /data=!([^?&]+)/;
632	var dataArray = urlToParse.match( re );
633	if ( dataArray && dataArray.length >= 1 ) {
634		rootNode = new PrBufNode();
635		var workingNode = rootNode;
636		//we iterate through each of the elements, creating a node for it, and
637		//deciding where to place it in the tree
638		var elemArray = dataArray[1].split( "!" );
639		for ( var i = 0; i < elemArray.length; i ++ ) {
640			var elemRe = /^([0-9]+)([a-z])(.+)$/;
641			var elemValsArray = elemArray[i].match( elemRe );
642			if ( elemValsArray && elemValsArray.length > 3 ) {
643				var elemNode = new PrBufNode( elemValsArray[1], elemValsArray[2], elemValsArray[3] );
644				workingNode.addChild( elemNode );
645				workingNode = elemNode.findLatestIncompleteNode();
646			}
647		}
648	}
649	return rootNode;
650}
651
652
653/**
654 * Represents a basic waypoint, with latitude and longitude.
655 *
656 * If both are not specified, the waypoint is considered to be valid
657 * but empty waypoint (these can exist in the data parameter, where
658 * the coordinates have been specified in the URL path.
659 */
660var GmdpWaypoint = function( lat, lng, primary ) {
661	this.lat = lat;
662	this.lng = lng;
663	this.primary = primary ? true : false;
664}
665
666/**
667 * Represents a basic route, comprised of an ordered list of
668 * GmdpWaypoint objects.
669 */
670var GmdpRoute = function() {
671	this.route = new Array();
672}
673
674/**
675 * Pushes a GmdpWaypoint on to the end of this GmdpRoute.
676 */
677GmdpRoute.prototype.pushWaypoint = function( wpt ) {
678	if ( wpt instanceof GmdpWaypoint ) {
679		this.route.push( wpt );
680	}
681}
682
683/**
684 * Sets the mode of transportation.
685 * If the passed parameter represents one of the integers normally used by Google Maps,
686 * it will be interpreted as the relevant transport mode, and set as a string:
687 * "car", "bike", "foot", "transit", "flight"
688 */
689GmdpRoute.prototype.setTransportation = function( transportation ) {
690	switch ( transportation ) {
691		case '0':
692			this.transportation = "car";
693			break;
694		case '1':
695			this.transportation = "bike";
696			break;
697		case '2':
698			this.transportation = "foot";
699			break;
700		case '3':
701			this.transportation = "transit";
702			break;
703		case '4':
704			this.transportation = "flight";
705			break;
706		default:
707			this.transportation = transportation;
708			break;
709	}
710}
711
712/**
713 * Returns the mode of transportation (if any) for the route.
714 */
715GmdpRoute.prototype.getTransportation = function() {
716	return this.transportation;
717}
718
719GmdpRoute.prototype.setUnit = function( unit ) {
720	switch ( unit ) {
721		case '0':
722			this.unit = "km";
723			break;
724		case '1':
725			this.unit = "miles";
726			break;
727	}
728}
729
730GmdpRoute.prototype.getUnit = function() {
731	return this.unit;
732}
733
734GmdpRoute.prototype.setRoutePref = function( routePref ) {
735	switch ( routePref ) {
736		case '0':
737		case '1':
738			this.routePref = "best route";
739			break;
740		case '2':
741			this.routePref = "fewer transfers";
742			break;
743		case '3':
744			this.routePref = "less walking";
745			break;
746	}
747}
748
749GmdpRoute.prototype.getRoutePref = function() {
750	return this.routePref;
751}
752
753GmdpRoute.prototype.setArrDepTimeType = function( arrDepTimeType ) {
754	switch ( arrDepTimeType ) {
755		case '0':
756			this.arrDepTimeType = "depart at";
757			break;
758		case '1':
759			this.arrDepTimeType = "arrive by";
760			break;
761		case '2':
762			this.arrDepTimeType = "last available";
763			break;
764	}
765}
766
767GmdpRoute.prototype.getArrDepTimeType = function() {
768	return this.arrDepTimeType;
769}
770
771GmdpRoute.prototype.addTransitModePref = function( transitModePref ) {
772	//there can be multiple preferred transit modes, so we store them in an array
773	//we assume there will be no duplicate values, but it probably doesn't matter
774	//even if there are
775	switch ( transitModePref ) {
776		case '0':
777			this.transitModePref.push( "bus" );
778			break;
779		case '1':
780			this.transitModePref.push( "subway" );
781			break;
782		case '2':
783			this.transitModePref.push( "train" );
784			break;
785		case '3':
786			this.transitModePref.push( "tram / light rail" );
787			break;
788	}
789}
790
791GmdpRoute.prototype.getTransitModePref = function() {
792	return this.transitModePref;
793}
794
795
796/**
797 * Returns the list of all waypoints belonging to this route.
798 */
799GmdpRoute.prototype.getAllWaypoints = function() {
800	return this.route;
801}
802
803
804function GmdpException( message ) {
805	this.message = message;
806	// Use V8's native method if available, otherwise fallback
807	if ( "captureStackTrace" in Error ) {
808		Error.captureStackTrace( this, GmdpException );
809	} else {
810		this.stack = (
811			new Error()
812		).stack;
813	}
814}
815
816GmdpException.prototype = Object.create( Error.prototype );
817GmdpException.prototype.name = "GmdpException";
818
819/**
820 * Represents a google maps data parameter, constructed from the passed URL.
821 *
822 * Utility methods defined below allow the user to easily extract interesting
823 * information from the data parameter.
824 */
825var Gmdp = function( url ) {
826	this.prBufRoot = PrBufNode.create( url );
827	this.mapType = "map";
828
829	if ( this.prBufRoot == null ) {
830		throw new GmdpException( "no parsable data parameter found" );
831	}
832
833	//the main top node for routes is 4m; other urls (eg. streetview) feature 3m etc.
834	var routeTop = null;
835	var streetviewTop = null;
836	var rootChildren = this.prBufRoot.getChildren(),
837		child;
838
839	for ( var i = 0; i < rootChildren.length; i++ ) {
840		child = rootChildren[i];
841		if ( child.id() == 3 && child.type() == 'm' ) {
842			var mapTypeChildren = child.getChildren();
843			if ( mapTypeChildren && mapTypeChildren.length >= 1 ) {
844				if ( mapTypeChildren[0].id() == 1 && mapTypeChildren[0].type() == 'e' ) {
845					switch ( mapTypeChildren[0].value() ) {
846						case '1':
847							this.mapType = "streetview";
848							streetviewTop = child;
849							break;
850						case '3':
851							this.mapType = "earth";
852							break;
853					}
854				}
855			}
856		} else if ( child.id() == 4 && child.type() == 'm' ) {
857			routeTop = child;
858		}
859	}
860	if ( routeTop ) {
861		var directions = null,
862			routeChildren = routeTop.getChildren();
863
864		for ( var i = 0; i < routeChildren.length; i++ ) {
865			child = routeChildren[i];
866			if ( child.id() == 4 && child.type() == 'm' ) {
867				directions = child;
868			}
869		}
870		if ( directions ) {
871			this.route = new GmdpRoute();
872			this.route.arrDepTimeType = "leave now"; //default if no value is specified
873			this.route.avoidHighways = false;
874			this.route.avoidTolls = false;
875			this.route.avoidFerries = false;
876			this.route.transitModePref = [];
877
878			var directionsChildren = directions.getChildren();
879
880			for ( var i = 0; i < directionsChildren.length; i++ ) {
881				child = directionsChildren[i];
882				if ( primaryChild.id() == 1 && primaryChild.type() == 'm' ) {
883					if ( primaryChild.value() == 0 ) {
884						this.route.pushWaypoint( new GmdpWaypoint( undefined, undefined, true ) );
885					}
886					else {
887						var addedPrimaryWpt = false;
888						var wptNodes = primaryChild.getChildren(),
889							wptNode;
890						for ( var i = 0; i < wptNodes.length; i++ ) {
891							wptNode = wptNodes[i];
892							if ( wptNode.id() == 2 ) {
893								//this is the primary wpt, add coords
894								var coordNodes = wptNode.getChildren();
895								if ( coordNodes &&
896								     coordNodes.length >= 2 &&
897								     coordNodes[0].id() == 1 &&
898								     coordNodes[0].type() == 'd' &&
899								     coordNodes[1].id() == 2 &&
900								     coordNodes[1].type() == 'd' ) {
901									this.route.pushWaypoint(
902										new GmdpWaypoint( coordNodes[1].value(),
903											coordNodes[0].value(),
904											true ) );
905								}
906								addedPrimaryWpt = true;
907							} else if ( wptNode.id() == 3 ) {
908								//this is a secondary (unnamed) wpt
909								//
910								//but first, if we haven't yet added the primary wpt,
911								//then the coordinates are apparently not specified,
912								//so we should add an empty wpt
913								if ( ! addedPrimaryWpt ) {
914									this.route.pushWaypoint( new GmdpWaypoint( undefined, undefined, true ) );
915									addedPrimaryWpt = true;
916								}
917
918								//now proceed with the secondary wpt itself
919								var secondaryWpts = wptNode.getChildren();
920								if ( secondaryWpts && secondaryWpts.length > 1 ) {
921									var coordNodes = secondaryWpts[0].getChildren();
922									if ( coordNodes &&
923									     coordNodes.length >= 2 &&
924									     coordNodes[0].id() == 1 &&
925									     coordNodes[0].type() == 'd' &&
926									     coordNodes[1].id() == 2 &&
927									     coordNodes[1].type() == 'd' ) {
928										this.route.pushWaypoint(
929											new GmdpWaypoint( coordNodes[1].value(),
930												coordNodes[0].value(),
931												false ) );
932									}
933								}
934							}
935						}
936					}
937				} else if ( primaryChild.id() == 2 && primaryChild.type() == 'm' ) {
938					var routeOptions = primaryChild.getChildren(),
939						routeOption;
940					for ( var i = 0; i < routeOptions.length; i++ ) {
941						routeOption = routeOptions[i];
942
943						if ( routeOption.id() == 1 && routeOption.type() == 'b' ) {
944							this.route.avoidHighways = true;
945						}
946						else if ( routeOption.id() == 2 && routeOption.type() == 'b' ) {
947							this.route.avoidTolls = true;
948						}
949						else if ( routeOption.id() == 3 && routeOption.type() == 'b' ) {
950							this.route.avoidFerries = true;
951						}
952						else if ( routeOption.id() == 4 && routeOption.type() == 'e' ) {
953							this.route.setRoutePref( routeOption.value() );
954						}
955						else if ( routeOption.id() == 5 && routeOption.type() == 'e' ) {
956							this.route.addTransitModePref( routeOption.value() );
957						}
958						else if ( routeOption.id() == 6 && routeOption.type() == 'e' ) {
959							this.route.setArrDepTimeType( routeOption.value() );
960						}
961						if ( routeOption.id() == 8 && routeOption.type() == 'j' ) {
962							this.route.arrDepTime = routeOption.value(); //as a unix timestamp
963						}
964					}
965				} else if ( primaryChild.id() == 3 && primaryChild.type() == 'e' ) {
966					this.route.setTransportation( primaryChild.value() );
967				} else if ( primaryChild.id() == 4 && primaryChild.type() == 'e' ) {
968					this.route.setUnit( primaryChild.value() );
969				}
970			}
971		}
972	}
973	if ( streetviewTop ) {
974		var streetviewChildren = streetviewTop.getChildren(),
975			streetviewChild;
976		for ( var i = 0; i < streetviewChildren.length; i++ ) {
977			streetviewChild = streetviewChildren[i];
978			if ( streetviewChild.id() == 3 && streetviewChild.type() == 'm' ) {
979				var svInfos = streetviewChild.getChildren(),
980					svInfo;
981				for ( var i = 0; i < svInfos.length; i++ ) {
982					svInfo = svInfos[i];
983					if ( svInfo.id() == 2 && svInfo.type() == 'e' ) {
984						if ( svInfo.value() == 4 ) {
985							//!2e4!3e11 indicates a photosphere, rather than standard streetview
986							//but the 3e11 doesn't seem to matter too much (?)
987							this.mapType = "photosphere";
988						}
989					}
990					if ( svInfo.id() == 6 && svInfo.type() == 's' ) {
991						this.svURL = decodeURIComponent( svInfo.value() );
992					}
993				}
994			}
995		}
996	}
997}
998
999/**
1000 * Returns the route defined by this data parameter.
1001 */
1002Gmdp.prototype.getRoute = function() {
1003	return this.route;
1004}
1005
1006/**
1007 * Returns the main map type ("map", "earth").
1008 */
1009Gmdp.prototype.getMapType = function() {
1010	return this.mapType;
1011}
1012
1013/**
1014 * Returns the main map type ("map", "earth").
1015 */
1016Gmdp.prototype.getStreetviewURL = function() {
1017	return this.svURL;
1018}
1019/* --- Magnific Popup Initialization --- */
1020
1021function magnificPopupInit() {
1022	if ( globalDebug ) {
1023		console.log( "Magnific Popup - Init" );
1024	}
1025
1026	$( '.js-post-gallery' ).each( function () { // the containers for all your galleries should have the class gallery
1027		$( this ).magnificPopup( {
1028			tPrev: rosaStrings.tPrev,
1029			tNext: rosaStrings.tNext,
1030			tCounter: rosaStrings.tCounter,
1031			delegate: 'a[href*=".jpg"], a[href*=".jpeg"], a[href*=".png"], a[href*=".gif"]', // the container for each your gallery items
1032			type: 'image',
1033			closeOnContentClick: false,
1034			closeBtnInside: false,
1035			closeOnBgClick: false,
1036			fixedContentPos: true,
1037			removalDelay: 500,
1038			mainClass: 'mfp-fade',
1039			image: {
1040				markup: '<div class="mfp-figure">' +
1041				        '<div class="mfp-close"></div>' +
1042				        '<div class="mfp-img"></div>' +
1043				        '<div class="mfp-bottom-bar">' +
1044				        '<div class="mfp-title"></div>' +
1045				        '<div class="mfp-counter"></div>' +
1046				        '</div>' +
1047				        '</div>',
1048				titleSrc: function ( item ) {
1049					var output = '';
1050					if ( typeof item.el.attr( 'data-alt' ) !== "undefined" && item.el.attr( 'data-alt' ) !== "" ) {
1051						output += '<small>' + item.el.attr( 'data-alt' ) + '</small>';
1052					}
1053					return output;
1054				}
1055			},
1056			gallery: {
1057				enabled: true,
1058				navigateByImgClick: true
1059				//arrowMarkup: '<a href="#" class="gallery-arrow gallery-arrow--%dir% control-item arrow-button arrow-button--%dir%">%dir%</a>'
1060			},
1061			callbacks: {
1062				elementParse: function ( item ) {
1063
1064					if ( this.currItem != undefined ) {
1065						item = this.currItem;
1066					}
1067
1068					var output = '';
1069					if ( typeof item.el.attr( 'data-alt' ) !== "undefined" && item.el.attr( 'data-alt' ) !== "" ) {
1070						output += '<small>' + item.el.attr( 'data-alt' ) + '</small>';
1071					}
1072
1073					$( '.mfp-title' ).html( output );
1074				},
1075				change: function ( item ) {
1076					var output = '';
1077					if ( typeof item.el.attr( 'data-alt' ) !== "undefined" && item.el.attr( 'data-alt' ) !== "" ) {
1078						output += '<small>' + item.el.attr( 'data-alt' ) + '</small>';
1079					}
1080
1081					$( '.mfp-title' ).html( output );
1082				},
1083				beforeClose: function () {
1084					$( '.mfp-arrow, .mfp-close' ).hide();
1085				}
1086			}
1087		} );
1088	} );
1089}
1090
1091var GMap = function() {
1092	this.pinIconMarkup = $( '.js-map-pin' ).html();
1093};
1094
1095GMap.prototype.init = function( $container ) {
1096	var that = this;
1097	var $body = $( 'body' );
1098
1099	$container = typeof $container !== "undefined" ? $container : $body;
1100
1101	$container.find( '.c-hero__map' ).each( function( i, obj ) {
1102		var $map = $( obj );
1103		that.initializeMap( $map );
1104	} );
1105};
1106
1107GMap.prototype.initializeMap = function( $map ) {
1108	var that = this;
1109
1110	if ( typeof google !== 'undefined' ) {
1111
1112		var url = $map.data( 'url' ),
1113			style = typeof $map.data( 'customstyle' ) !== "undefined" ? "rosa" : google.maps.MapTypeId.ROADMAP,
1114			markerContent = $map.data( 'markercontent' ),
1115			coordinates,
1116			pins = [];
1117
1118		if ( typeof url === "string" ) {
1119
1120			coordinates = that.getCenterFrom( url );
1121			pins = that.getPinsFrom( url, markerContent );
1122
1123			// if there are no markers encoded in the url
1124			// place a pin the center of the map
1125			if ( pins.length === 0 && typeof coordinates !== "undefined" ) {
1126				pins.push( {
1127					position: [coordinates.latitude, coordinates.longitude],
1128					content: that.getPinMarkup( markerContent ),
1129					x: 0,
1130					y: 4
1131				} );
1132			} else {
1133				var pinPosition = pins[0]['position'];
1134
1135				if ( typeof pinPosition !== "undefined" ) {
1136					coordinates.latitude = pinPosition[0];
1137					coordinates.longitude = pinPosition[1];
1138				}
1139			}
1140		} else {
1141			var pinsData = $map.data( 'pins' );
1142
1143			$.each( pinsData, function( label, url ) {
1144				coordinates = that.getCenterFrom( url );
1145
1146				pins.push( {
1147					position: [coordinates['latitude'], coordinates['longitude']],
1148					content: that.getPinMarkup( label, 'pin' ),
1149					x: 0,
1150					y: 4
1151				} );
1152
1153			} );
1154		}
1155
1156		$map
1157			.gmap3( {
1158				center: [coordinates.latitude, coordinates.longitude],
1159				zoom: parseInt( coordinates.zoom ),
1160				mapTypeId: style,
1161				scrollwheel: false,
1162				mapTypeControl: false,
1163				zoomControl: true,
1164				zoomControlOptions: {
1165					position: google.maps.ControlPosition.LEFT_CENTER
1166				},
1167				scaleControl: true,
1168				streetViewControl: true,
1169				streetViewControlOptions: {
1170					position: google.maps.ControlPosition.LEFT_CENTER
1171				},
1172				fullscreenControl: true
1173			} )
1174			.styledmaptype( "rosa", that.customStyle, {name: "Rosa"} )
1175			.overlay( pins );
1176
1177		$body.on( 'rosa:update-map-color', function(e, color) {
1178			that.customStyle[1].stylers[0].hue = color;
1179			$map.gmap3().styledmaptype( "rosa", that.customStyle, {name: "Rosa"} );
1180		});
1181
1182		if ( pins.length > 1 ) {
1183			$map.gmap3().fit();
1184		}
1185
1186	}
1187
1188};
1189
1190GMap.prototype.getCenterFrom = function( url ) {
1191	var split = url.split( '@' )[1].split( '/' )[0].split( 'z' )[0].split( ',' ),
1192		coordinates = {},
1193		urlCheck = false;
1194
1195	function parseChildren( obj ) {
1196		var coord = [];
1197		$.each( obj.getChildren(), function( i, child ) {
1198			if ( child.type() == "d" ) {
1199				coord.push( child.value() );
1200			}
1201			parseChildren( child );
1202		} );
1203
1204		if ( coord.length === 2 ) {
1205			urlCheck = true;
1206
1207			coordinates.latitude = parseFloat(coord[0]);
1208			coordinates.longitude = parseFloat(coord[1]);
1209			coordinates.zoom = parseFloat( split[2] );
1210		}
1211	}
1212
1213	if ( url.indexOf( 'data=' ) > - 1 ) {
1214		parseChildren( new Gmdp( url ).prBufRoot );
1215	}
1216
1217
1218	if ( urlCheck === false && ( 2 === split.length || 3 === split.length ) ) {
1219
1220		coordinates.latitude = parseFloat( split[0] );
1221		coordinates.longitude = parseFloat( split[1] );
1222
1223		if ( 3 === split.length ) {
1224			coordinates.zoom = parseFloat( split[2] );
1225		}
1226	}
1227
1228	return coordinates;
1229};
1230
1231GMap.prototype.getPinsFrom = function( url, markerContent ) {
1232	var that = this,
1233		coordinates = [],
1234		pins = [];
1235
1236	function parseChildren( obj ) {
1237		var coord = [];
1238		$.each( obj.getChildren(), function( i, child ) {
1239			if ( child.type() == "d" ) {
1240				coord.push( child.value() );
1241			}
1242			parseChildren( child );
1243		} );
1244
1245		if ( coord.length === 2 ) {
1246			coordinates.push( coord );
1247		}
1248	}
1249
1250	if ( url.indexOf( 'data=' ) > - 1 ) {
1251		parseChildren( new Gmdp( url ).prBufRoot );
1252	}
1253
1254	$.each( coordinates, function( i, coord ) {
1255		pins.push( {
1256			position: [coord[0], coord[1]],
1257			content: that.getPinMarkup( markerContent, 'tooltip' ),
1258			x: 0,
1259			y: 4
1260		} );
1261	} );
1262
1263	return pins;
1264};
1265
1266GMap.prototype.getPinMarkup = function( content, type ) {
1267	type = type || 'tooltip';
1268
1269	if ( type === 'tooltip' ) {
1270		return '<div class="map-tooltip"><div class="map-tooltip__content">' + content + '</div></div>';
1271	} else {
1272		return '<div class="map-pin"><div class="map-pin__text">' + content + '</div>' + this.pinIconMarkup + '</div>'
1273	}
1274};
1275
1276GMap.prototype.customStyle = [
1277	{
1278		"stylers": [
1279			{"saturation": - 100},
1280			{"gamma": 3.00},
1281			{"visibility": "simplified"}
1282		]
1283	}, {
1284		"featureType": "road",
1285		"stylers": [
1286			{"hue": $( "body" ).data( "color" ) ? $( "body" ).data( "color" ) : "#ffaa00"},
1287			{"saturation": 48},
1288			{"gamma": 0.40},
1289			{"visibility": "on"}
1290		]
1291	}, {
1292		"featureType": "administrative",
1293		"stylers": [
1294			{"saturation": - 30},
1295			{"gamma": 0.6},
1296			{"visibility": "on"}
1297		]
1298	}, {
1299		"featureType": "administrative.neighborhood",
1300		"stylers": [
1301			{"visibility": "off"}
1302		]
1303	}
1304];
1305
1306var Parallax = function( selector, options ) {
1307    this.disabled = false;
1308    this.selector = selector;
1309    this.options = options;
1310};
1311
1312Parallax.prototype.init = function( $container ) {
1313    $container = $container || $( 'body' );
1314    if ( this.disabled === false ) {
1315        $container.find( this.selector ).rellax( this.options );
1316    }
1317};
1318
1319Parallax.prototype.disable = function() {
1320    this.disabled = true;
1321    this.destroy();
1322};
1323
1324Parallax.prototype.destroy = function() {
1325    $( this.selector ).rellax( "destroy" );
1326};
1327
1328Parallax.prototype.enable = function() {
1329    this.disabled = false;
1330    $( this.selector ).rellax( this.options );
1331};
1332
1333(function($) {
1334
1335	function observe( $container ) {
1336		var MutationObserver = window.MutationObserver,
1337			observer, config;
1338
1339		if ( typeof MutationObserver === "undefined" ) {
1340			return;
1341		}
1342
1343		observer = new MutationObserver( function() {
1344			$( window ).trigger( 'rellax' );
1345		} );
1346
1347		config = {
1348			childList: true,
1349			characterData: false,
1350			attributes: false,
1351			subtree: true
1352		};
1353
1354		$container.each( function() {
1355			observer.observe( this, config );
1356		} );
1357	}
1358
1359	observe( $('.article__content') );
1360
1361})(jQuery);
1362/* --- Royal Slider Init --- */
1363
1364function royalSliderInit( $container ) {
1365	if ( globalDebug ) {
1366		console.log( "Royal Slider - Init" );
1367	}
1368
1369	$container = typeof $container !== 'undefined' ? $container : $( 'body' );
1370
1371	// Transform Wordpress Galleries to Sliders
1372	$container.find( '.wp-gallery' ).each( function () {
1373		sliderMarkupGallery( $( this ) );
1374	} );
1375
1376	// Find and initialize each slider
1377	$container.find( '.js-pixslider' ).each( function () {
1378		var $slider = $( this );
1379		$slider.imagesLoaded( function () {
1380			sliderInit( $slider );
1381		} );
1382	} );
1383
1384}
1385
1386/*
1387 * Slider Initialization
1388 */
1389function sliderInit( $slider ) {
1390
1391	$slider.find( 'img' ).removeClass( 'invisible' );
1392
1393	var $children = $( this ).children(),
1394		rs_arrows = typeof $slider.data( 'arrows' ) !== "undefined",
1395		rs_bullets = typeof $slider.data( 'bullets' ) !== "undefined" ? "bullets" : "none",
1396		rs_autoheight = typeof $slider.data( 'autoheight' ) !== "undefined",
1397		rs_autoScaleSlider = false,
1398		rs_autoScaleSliderWidth = $slider.data( 'autoscalesliderwidth' ),
1399		rs_autoScaleSliderHeight = $slider.data( 'autoscalesliderheight' ),
1400		rs_customArrows = typeof $slider.data( 'customarrows' ) !== "undefined",
1401		rs_slidesSpacing = typeof $slider.data( 'slidesspacing' ) !== "undefined" ? parseInt( $slider.data( 'slidesspacing' ) ) : 0,
1402		rs_keyboardNav = typeof $slider.data( 'fullscreen' ) !== "undefined",
1403		rs_imageScale = $slider.data( 'imagescale' ),
1404		rs_visibleNearby = typeof $slider.data( 'visiblenearby' ) !== "undefined",
1405		rs_imageAlignCenter = typeof $slider.data( 'imagealigncenter' ) !== "undefined",
1406		rs_transition = typeof $slider.data( 'slidertransition' ) !== "undefined" && $slider.data( 'slidertransition' ) !== '' ? $slider.data( 'slidertransition' ) : 'move',
1407		rs_autoPlay = typeof $slider.data( 'sliderautoplay' ) !== "undefined",
1408		rs_delay = typeof $slider.data( 'sliderdelay' ) !== "undefined" && $slider.data( 'sliderdelay' ) !== '' ? $slider.data( 'sliderdelay' ) : '1000',
1409		rs_drag = true,
1410		rs_globalCaption = typeof $slider.data( 'showcaptions' ) !== "undefined",
1411		is_headerSlider = $slider.hasClass( 'header--slideshow' ),
1412		hoverArrows = typeof $slider.data( 'hoverarrows' ) !== "undefined";
1413
1414	// Single slide case
1415	if ( $children.length === 1 ) {
1416		rs_arrows = false;
1417		rs_bullets = 'none';
1418		rs_customArrows = false;
1419		rs_keyboardNav = false;
1420		rs_drag = false;
1421		rs_transition = 'fade';
1422	}
1423	// make sure default arrows won't appear if customArrows is set
1424	if ( rs_customArrows ) {
1425		rs_arrows = false;
1426	}
1427
1428	//the main params for Royal Slider
1429	var royalSliderParams = {
1430		autoHeight: rs_autoheight,
1431		autoScaleSlider: rs_autoScaleSlider,
1432		loop: true,
1433		autoScaleSliderWidth: rs_autoScaleSliderWidth,
1434		autoScaleSliderHeight: rs_autoScaleSliderHeight,
1435		imageScaleMode: rs_imageScale,
1436		imageAlignCenter: rs_imageAlignCenter,
1437		slidesSpacing: rs_slidesSpacing,
1438		arrowsNav: rs_arrows,
1439		controlNavigation: rs_bullets,
1440		keyboardNavEnabled: rs_keyboardNav,
1441		arrowsNavAutoHide: false,
1442		sliderDrag: rs_drag,
1443		transitionType: rs_transition,
1444		autoPlay: {
1445			enabled: rs_autoPlay,
1446			stopAtAction: true,
1447			pauseOnHover: true,
1448			delay: rs_delay
1449		},
1450		globalCaption: rs_globalCaption,
1451		numImagesToPreload: 4
1452	};
1453
1454	if ( rs_visibleNearby ) {
1455		royalSliderParams['visibleNearby'] = {
1456			enabled: true,
1457			//centerArea: 0.8,
1458			center: true,
1459			breakpoint: 0,
1460			//breakpointCenterArea: 0.64,
1461			navigateByCenterClick: false
1462		}
1463	}
1464
1465
1466	// lets fire it up
1467
1468	$slider.royalSlider( royalSliderParams );
1469	$slider.addClass( 'slider--loaded' );
1470
1471	var royalSlider = $slider.data( 'royalSlider' );
1472	var slidesNumber = royalSlider.numSlides;
1473
1474	royalSlider.ev.on( 'rsAfterSlideChange rsAfterContentSet', function ( event ) {
1475		$( window ).trigger( 'rellax' );
1476	});
1477
1478	// create the markup for the customArrows
1479	if ( royalSlider && rs_customArrows ) {
1480
1481		var classes = 'slider__custom-arrows';
1482
1483		if ( is_headerSlider ) {
1484			classes = 'slider-arrows-header';
1485		}
1486
1487		if ( hoverArrows && ! Modernizr.touchevents ) {
1488			classes += ' arrows--hover ';
1489		}
1490
1491		$slider.find( '.slider__custom-arrows' ).off( 'click' ).remove();
1492
1493		var $gallery_control = $(
1494			'<div class="' + classes + '">' +
1495			'<div class="rsArrow rsArrowLeft js-arrow-left" style="display: block;"><div class="rsArrowIcn"></div></div>' +
1496			'<div class="rsArrow rsArrowRight js-arrow-right" style="display: block;"><div class="rsArrowIcn"></div></div>' +
1497			'</div>'
1498		);
1499
1500		if ( $slider.data( 'customarrows' ) === "left" ) {
1501			$gallery_control.addClass( 'gallery-control--left' );
1502		}
1503
1504		$gallery_control.insertBefore( $slider );
1505
1506		$gallery_control.on( 'click', '.js-arrow-left', function ( event ) {
1507			event.preventDefault();
1508			royalSlider.prev();
1509		} );
1510
1511		$gallery_control.on( 'click', '.js-arrow-right', function ( event ) {
1512			event.preventDefault();
1513			royalSlider.next();
1514		} );
1515	}
1516
1517	if ( hoverArrows && ! Modernizr.touchevents ) {
1518		hoverArrow( $gallery_control.find( '.rsArrow' ) );
1519
1520	}
1521
1522	if ( slidesNumber === 1 ) {
1523		$slider.addClass( 'single-slide' );
1524	}
1525
1526	$slider.addClass( 'slider--loaded' );
1527}
1528
1529/*
1530 * Wordpress Galleries to Sliders
1531 * Create the markup for the slider from the gallery shortcode
1532 * take all the images and insert them in the .gallery <div>
1533 */
1534function sliderMarkupGallery( $gallery ) {
1535	var $old_gallery = $gallery,
1536		gallery_data = $gallery.data(),
1537		$images = $old_gallery.find( 'img' ),
1538		$new_gallery = $( '<div class="pixslider js-pixslider">' );
1539
1540	$images.prependTo( $new_gallery ).addClass( 'rsImg' );
1541
1542	//add the data attributes
1543	$.each( gallery_data, function ( key, value ) {
1544		$new_gallery.attr( 'data-' + key, value );
1545	} )
1546
1547	$old_gallery.replaceWith( $new_gallery );
1548}
1549
1550/*
1551 Get slider arrows to hover, following the cursor
1552 */
1553
1554function hoverArrow( $arrow ) {
1555
1556	$arrow.each(function(i, obj) {
1557
1558		var $arrow = $(obj),
1559			update = false,
1560			offset = $arrow.offset(),
1561			$icon = $arrow.find( '.rsArrowIcn' ),
1562			mouseX,
1563			mouseY;
1564
1565		$arrow.mouseenter( function ( e ) {
1566			offset = $arrow.offset();
1567			$( this ).addClass( 'visible' );
1568			update = true;
1569		});
1570
1571		$arrow.mousemove( function ( e ) {
1572			mouseX = e.pageX - offset.left;
1573			mouseY = e.pageY - offset.top;
1574		});
1575
1576		$arrow.mouseleave( function ( e ) {
1577			$( this ).removeClass( 'visible' );
1578			update = false;
1579		});
1580
1581		function loop() {
1582			if ( update ) {
1583				TweenMax.to( $icon, 0, {x: mouseX, y: mouseY, z: 0.01, force3D: true} );
1584			}
1585			requestAnimationFrame(loop);
1586		}
1587
1588		loop();
1589	});
1590}
1591var ScrollToTop = (function() {
1592
1593    var start = 0,
1594        end = 0,
1595        timeline = null,
1596        played = false,
1597        footerHeight;
1598
1599    function initialize() {
1600
1601        var $button         = $('.btn--top'),
1602            offsetTop       = 0,
1603            start           = offsetTop - windowHeight + footerHeight * 3 / 4;
1604
1605        footerHeight = $('.copyright-area').outerHeight();
1606
1607        if (empty($button)) {
1608            return;
1609        }
1610
1611        offsetTop = $button.offset().top;
1612        $button.data('offsetTop', offsetTop);
1613
1614        this.timeline   = new TimelineMax({ paused: true });
1615
1616        this.timeline.fromTo('.blurp--bottom', .6, {
1617            y:          40,
1618            scale:      0.5
1619        }, {
1620            y:          0,
1621            scale:      1,
1622            ease:       Power3.easeOut,
1623            force3D:    true
1624
1625        });
1626
1627        this.timeline.fromTo($('.btn__arrow--top'), .4, {
1628            y: 15,
1629            opacity: 0
1630        }, {
1631            y: 0,
1632            scale: 1,
1633            opacity: 1,
1634            ease: Back.easeOut
1635        }, '-=0.1');
1636
1637        this.timeline.fromTo($('.btn__arrow--bottom'),.4, {
1638            y: 15,
1639            opacity: 0
1640        }, {
1641            y: 0,
1642            scale: 1,
1643            opacity: 1,
1644            ease: Back.easeOut
1645        }, '-=0.25');
1646
1647        $button.on('click', function (e) {
1648            e.preventDefault();
1649            smoothScrollTo(0);
1650        });
1651
1652        this.update();
1653    }
1654
1655    function update() {
1656
1657        var $button         = $('.btn--top'),
1658            offsetTop       = $button.data('offsetTop'),
1659            start           = offsetTop - windowHeight + footerHeight * 3 / 4,
1660            end             = start + windowHeight;
1661
1662        if (empty($button) || this.timeline == null) {
1663            return;
1664        }
1665
1666        if (Modernizr.touchevents && is_OSX) {
1667            this.timeline.progress(1);
1668            return;
1669        }
1670
1671        if (start < latestKnownScrollY) {
1672            if (!this.played) {
1673                this.timeline.play();
1674                this.played = true;
1675            }
1676        } else {
1677            if (this.played) {
1678                this.timeline.reverse();
1679                this.played = false;
1680            }
1681        }
1682    }
1683
1684    return {
1685        initialize: initialize,
1686        update: update
1687    }
1688
1689})();
1690
1691/* --- Sticky Header Init --- */
1692
1693var StickyHeader = (function() {
1694
1695	var headerSelector = '.site-header',
1696		$header = $( headerSelector ),
1697		headerHeight,
1698		$headers;
1699
1700	function init() {
1701		headerHeight = $header.outerHeight();
1702		$headers = $( '.article__header' ).first();
1703	}
1704
1705	function update() {
1706		var inversed = false,
1707			adminBarHeight = $( '#wpadminbar' ).outerHeight() || 0,
1708			headerHeight = $header.outerHeight() || 0;
1709
1710		$headers.each( function( i, obj ) {
1711			var $obj = $( obj ),
1712				start = $obj.offset().top,
1713				end = start + $obj.outerHeight();
1714
1715			if ( latestKnownScrollY >= start - adminBarHeight && latestKnownScrollY <= end - headerHeight - adminBarHeight ) {
1716				inversed = true;
1717			}
1718		} );
1719
1720		if ( ! inversed ) {
1721			$header.removeClass( 'headroom--top' ).addClass( 'headroom--not-top' );
1722		} else {
1723			$header.removeClass( 'headroom--not-top' ).addClass( 'headroom--top' );
1724		}
1725	}
1726
1727	return {
1728		init: init,
1729		update: update
1730	}
1731
1732})();
1733
1734
1735// http://paulirish.com/2011/requestanimationframe-for-smart-animating/
1736// http://my.opera.com/emoller/blog/2011/12/20/requestanimationframe-for-smart-er-animating
1737
1738// requestAnimationFrame polyfill by Erik Möller. fixes from Paul Irish and Tino Zijdel
1739
1740// MIT license
1741
1742(function() {
1743    var lastTime = 0;
1744    var vendors = ['ms', 'moz', 'webkit', 'o'];
1745    for(var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x) {
1746        window.requestAnimationFrame = window[vendors[x]+'RequestAnimationFrame'];
1747        window.cancelAnimationFrame = window[vendors[x]+'CancelAnimationFrame']
1748                                   || window[vendors[x]+'CancelRequestAnimationFrame'];
1749    }
1750
1751    if (!window.requestAnimationFrame)
1752        window.requestAnimationFrame = function(callback, element) {
1753            var currTime = new Date().getTime();
1754            var timeToCall = Math.max(0, 16 - (currTime - lastTime));
1755            var id = window.setTimeout(function() { callback(currTime + timeToCall); },
1756              timeToCall);
1757            lastTime = currTime + timeToCall;
1758            return id;
1759        };
1760
1761    if (!window.cancelAnimationFrame)
1762        window.cancelAnimationFrame = function(id) {
1763            clearTimeout(id);
1764        };
1765}());
1766
1767//here we change the link of the Edit button in the Admin Bar
1768//to make sure it reflects the current page
1769function adminBarEditFix(id) {
1770	//get the admin ajax url and clean it
1771	var baseURL = rosaStrings.ajaxurl.replace('admin-ajax.php', 'post.php');
1772
1773	$('#wp-admin-bar-edit a').attr('href', baseURL + '?post=' + id + '&action=edit');
1774}
1775
1776/* --- Load AddThis Async --- */
1777function loadAddThisScript() {
1778	if (window.addthis) {
1779		if (globalDebug) {
1780			console.log("AddThis Load Script");
1781		}
1782		// Listen for the ready event
1783		addthis.addEventListener('addthis.ready', addthisReady);
1784		addthis.init();
1785	}
1786}
1787
1788/* --- AddThis On Ready - The API is fully loaded --- */
1789//only fire this the first time we load the AddThis API - even when using ajax
1790function addthisReady() {
1791	if (globalDebug) {
1792		console.log("AddThis Ready");
1793	}
1794	addThisInit();
1795}
1796
1797/* --- AddThis Init --- */
1798function addThisInit() {
1799	if (window.addthis) {
1800		if (globalDebug) {
1801			console.log("AddThis Toolbox INIT");
1802		}
1803
1804		addthis.toolbox('.addthis_toolbox');
1805	}
1806}
1807
1808var HandleSubmenusOnTouch = (function() {
1809
1810	var isInitiated = false;
1811
1812	function init() {
1813		if( isInitiated ) return;
1814
1815		// Make sure there are no open menu items
1816		$('.menu-item-has-children').removeClass('hover');
1817
1818		// Add a class so we know the items to handle
1819		$('.menu-item-has-children > a').each(function () {
1820			$(this).addClass('prevent-one');
1821		});
1822
1823		$('a.prevent-one').on('click', function (e) {
1824			e.preventDefault();
1825			e.stopPropagation();
1826
1827			if( $(this).hasClass('active') ) {
1828				window.location.href = $(this).attr('href');
1829			}
1830
1831			$('a.prevent-one').removeClass('active');
1832			$(this).addClass('active');
1833
1834			// When a parent menu item is activated,
1835			// close other menu items on the same level
1836			$(this).parent().siblings().removeClass('hover');
1837
1838			// Open the sub menu of this parent item
1839			$(this).parent().addClass('hover');
1840		});
1841
1842		isInitiated = true;
1843	}
1844
1845	function release() {
1846		$('a.prevent-one').unbind();
1847		isInitiated = false;
1848	}
1849
1850	return {
1851		init: init,
1852		release: release
1853	}
1854}());
1855
1856function getIEversion() {
1857    var ua = window.navigator.userAgent;
1858
1859    // Test values; Uncomment to check result …
1860
1861    // IE 10
1862    // ua = 'Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; Trident/6.0)';
1863
1864    // IE 11
1865    // ua = 'Mozilla/5.0 (Windows NT 6.3; Trident/7.0; rv:11.0) like Gecko';
1866
1867    // Edge 12 (Spartan)
1868    // ua = 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.71 Safari/537.36 Edge/12.0';
1869
1870    // Edge 13
1871    // ua = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2486.0 Safari/537.36 Edge/13.10586';
1872
1873    var msie = ua.indexOf('MSIE ');
1874    if (msie > 0) {
1875        // IE 10 or older => return version number
1876        return parseInt(ua.substring(msie + 5, ua.indexOf('.', msie)), 10);
1877    }
1878
1879    var trident = ua.indexOf('Trident/');
1880    if (trident > 0) {
1881        // IE 11 => return version number
1882        var rv = ua.indexOf('rv:');
1883        return parseInt(ua.substring(rv + 3, ua.indexOf('.', rv)), 10);
1884    }
1885
1886    var edge = ua.indexOf('Edge/');
1887    if (edge > 0) {
1888        // Edge (IE 12+) => return version number
1889        return parseInt(ua.substring(edge + 5, ua.indexOf('.', edge)), 10);
1890    }
1891
1892    // other browser
1893    return false;
1894}
1895
1896/* ====== INTERNAL FUNCTIONS ====== */
1897
1898/* --- NICESCROLL --- */
1899
1900var $body = $( 'body' ),
1901	$html = $( 'html' ),
1902	$window = $( window ),
1903	$document = $( document ),
1904	documentHeight = $document.height(),
1905	aspectRatio = windowWidth / windowHeight,
1906	orientation = getOrientation(),
1907	isTouch = ! ! ( ( "ontouchstart" in window ) || window.DocumentTouch && document instanceof DocumentTouch );
1908
1909var $target = $( window.location.hash ).filter( '.article--page' );
1910
1911if ( $target.length ) {
1912	requestAnimationFrame( function() {
1913		window.scrollTo( 0, $target.offset().top - $( '.site-header' ).height() );
1914	} );
1915}
1916
1917function niceScrollInit() {
1918	if ( globalDebug ) {
1919		console.log( "NiceScroll Init" );
1920	}
1921
1922	var smoothScroll = $( 'body' ).data( 'smoothscrolling' ) !== undefined,
1923		root = document.documentElement;
1924
1925	if ( smoothScroll && ! is_EDGE && ! Modernizr.touchevents && ! is_mobile_ie && ! is_OSX ) {
1926
1927		var $window = $( window );		// Window object
1928
1929		$window.on( "mousewheel DOMMouseScroll", function( event ) {
1930
1931			var scrollTo,
1932				scrollDistance = 400,
1933				delta;
1934
1935			if ( event.type == 'mousewheel' ) {
1936				delta = event.originalEvent.wheelDelta / 120;
1937			}
1938			else if ( event.type == 'DOMMouseScroll' ) {
1939				delta = - event.originalEvent.detail / 3;
1940			}
1941
1942			scrollTo = latestKnownScrollY - delta * scrollDistance;
1943
1944			if ( scrollTo ) {
1945
1946				event.preventDefault();
1947
1948				TweenMax.to( $window, .6, {
1949					scrollTo: {
1950						y: scrollTo,
1951						autoKill: true
1952					},
1953					ease: Power1.easeOut,	// For more easing functions see http://api.greensock.com/js/com/greensock/easing/package-detail.html
1954					autoKill: true,
1955					overwrite: 5
1956				} );
1957
1958			}
1959
1960		} );
1961
1962	}
1963
1964}
1965
1966
1967function smoothScrollTo( y, speed ) {
1968
1969	speed = typeof speed === "undefined" ? 1 : speed;
1970
1971	var distance = Math.abs( latestKnownScrollY - y ),
1972		time = speed * distance / 2000;
1973
1974	TweenMax.to( $( window ), time, {scrollTo: {y: y, autoKill: false, ease: Quint.easeInOut}} );
1975}
1976
1977
1978function menuTrigger() {
1979
1980	$( '.js-nav-trigger' ).on( 'click', function( e ) {
1981
1982		e.preventDefault();
1983		e.stopPropagation();
1984
1985		var $html = $( 'html' );
1986
1987		if ( $html.hasClass( 'navigation--is-visible' ) ) {
1988			$html.removeClass( 'navigation--is-visible' );
1989		} else {
1990			$html.addClass( 'navigation--is-visible' );
1991
1992			if ( $html.is( '.is--ancient-android, .is--winmob, .is--ie' ) ) {
1993				$( '.navigation--main' ).height( windowHeight );
1994			}
1995		}
1996	} );
1997}
1998
1999function cartOnMobile() {
2000	if ( $('.js-open-cart').length) {
2001		var	cartNav = $('.mobile-cart'),
2002			cartMenu = $('.menu-item--cart'),
2003			icon = $('.js-open-cart').detach();
2004
2005		if ( windowWidth < 900 ) {
2006			icon.appendTo(cartNav);
2007		} else {
2008			icon.appendTo(cartMenu);
2009		}
2010	}
2011}
2012
2013/* --- $VIDEOS --- */
2014
2015function initVideos() {
2016
2017	var videos = $( 'iframe, video' );
2018
2019	// Figure out and save aspect ratio for each video
2020	videos.each( function() {
2021		$( this ).data( 'aspectRatio', this.width / this.height )
2022		         // and remove the hard coded width/height
2023		         .removeAttr( 'height' )
2024		         .removeAttr( 'width' );
2025	} );
2026
2027	// Firefox Opacity Video Hack
2028	$( '#page iframe' ).each( function() {
2029		var url = $( this ).attr( "src" );
2030		if ( ! empty( url ) ) {
2031			$( this ).attr( "src", setQueryParameter( url, "wmode", "transparent" ) );
2032		}
2033	} );
2034}
2035
2036
2037function resizeVideos() {
2038
2039	var videos = $( 'iframe, video' );
2040
2041	videos.each( function() {
2042		var video = $( this ),
2043			ratio = video.data( 'aspectRatio' ),
2044			w = video.css( 'width', '100%' ).width(),
2045			h = w / ratio;
2046		video.height( h );
2047	} );
2048}
2049
2050
2051/* ====== INTERNAL FUNCTIONS END ====== */
2052
2053function init() {
2054	if ( globalDebug ) {
2055		console.group( "Init" );
2056	}
2057
2058	// /* GLOBAL VARS */
2059	touch = false;
2060
2061	if ( typeof ( isIe ) !== 'undefined' || ( ! ( window.ActiveXObject ) && "ActiveXObject" in window ) ) {
2062		$( 'html' ).addClass( 'is--ie' );
2063	}
2064
2065	if ( is_EDGE ) {
2066		$( 'html' ).addClass( 'is--ie-edge' );
2067	}
2068
2069	//  GET BROWSER DIMENSIONS
2070	browserSize();
2071
2072	// /* DETECT PLATFORM */
2073	platformDetect();
2074
2075	loadAddThisScript();
2076
2077	if ( is_android || window.opera ) {
2078		$( 'html' ).addClass( 'android-browser' ).removeClass( 'no-android-browser' );
2079	}
2080
2081	/* ONE TIME EVENT HANDLERS */
2082	eventHandlersOnce();
2083
2084	/* INSTANTIATE EVENT HANDLERS */
2085	eventHandlers();
2086	updateHeaderPadding();
2087
2088	var $borderTemplate = $( '.border-waves-template' );
2089
2090	$( '.border-waves' ).each( function(i, obj) {
2091		var $obj = $(obj),
2092			$before = $borderTemplate.clone().removeClass( 'border-waves-template' ).addClass( 'border-waves-before' ),
2093			$after = $borderTemplate.clone().removeClass( 'border-waves-template' ).addClass( 'border-waves-after' );
2094
2095		$before.appendTo( $obj );
2096		$after.appendTo( $obj );
2097	});
2098
2099	$( '.navigation--main' ).on( 'DOMMouseScroll mousewheel', function( ev ) {
2100		var $this = $( this ),
2101			scrollTop = this.scrollTop,
2102			scrollHeight = this.scrollHeight,
2103			height = $this.height(),
2104			delta = (
2105				ev.type == 'DOMMouseScroll' ?
2106				ev.originalEvent.detail * - 40 :
2107					ev.originalEvent.wheelDelta
2108			),
2109			up = delta > 0;
2110
2111		var prevent = function() {
2112			ev.stopPropagation();
2113			ev.preventDefault();
2114			ev.returnValue = false;
2115			return false;
2116		};
2117
2118		if ( ! up && - delta > scrollHeight - height - scrollTop ) {
2119			// Scrolling down, but this will take us past the bottom.
2120			$this.scrollTop( scrollHeight );
2121			return prevent();
2122		} else if ( up && delta > scrollTop ) {
2123			// Scrolling up, but this will take us past the top.
2124			$this.scrollTop( 0 );
2125			return prevent();
2126		}
2127	} );
2128
2129	cartOnMobile();
2130
2131	if ( globalDebug ) {
2132		console.groupEnd();
2133	}
2134}
2135
2136/* ====== EVENT HANDLERS ====== */
2137
2138function eventHandlersOnce() {
2139	if ( globalDebug ) {
2140		console.group( "Event Handlers Once" );
2141	}
2142
2143	menuTrigger();
2144
2145	if ( globalDebug ) {
2146		console.groupEnd();
2147	}
2148}
2149
2150function eventHandlers() {
2151	if ( globalDebug ) {
2152		console.group( "Event Handlers" );
2153	}
2154
2155
2156	//Magnific Popup arrows
2157	$( 'body' ).off( 'click', '.js-arrow-popup-prev', magnificPrev ).on( 'click', '.js-arrow-popup-prev', magnificPrev );
2158	$( 'body' ).off( 'click', '.js-arrow-popup-next', magnificNext ).on( 'click', '.js-arrow-popup-next', magnificNext );
2159
2160	$( document ).on( 'spam.wpcf7 invalid.wpcf7 mailsent.wpcf7 mailfailed.wpcf7', function() {
2161		setTimeout( function() {
2162			CoverAnimation.initialize();
2163		}, 300 );
2164	} );
2165
2166	var filterHandler;
2167
2168	if ( touch ) {
2169		filterHandler = 'click';
2170	} else {
2171		filterHandler = 'hover';
2172	}
2173
2174	if ( touch && windowWidth < 900 ) {
2175		HandleSubmenusOnTouch.init();
2176	}
2177
2178	if ( ieMobile ) {
2179		filterHandler = 'click';
2180	}
2181
2182	$( '.categories__menu' ).on( filterHandler, function( e ) {
2183		e.stopPropagation();
2184
2185		$( this ).toggleClass( 'active' );
2186	} );
2187
2188	if ( globalDebug ) {
2189		console.groupEnd();
2190	}
2191}
2192
2193
2194/* --- GLOBAL EVENT HANDLERS --- */
2195
2196function magnificPrev( e ) {
2197	if ( globalDebug ) {
2198		console.log( "Magnific Popup Prev" );
2199	}
2200
2201	e.preventDefault();
2202	var magnificPopup = $.magnificPopup.instance;
2203	magnificPopup.prev();
2204	return false;
2205}
2206
2207function magnificNext( e ) {
2208	if ( globalDebug ) {
2209		console.log( "Magnific Popup Next" );
2210	}
2211
2212	e.preventDefault();
2213	var magnificPopup = $.magnificPopup.instance;
2214	magnificPopup.next();
2215	return false;
2216}
2217
2218
2219// $(window).bind('beforeunload', function(event) {
2220// 	if (globalDebug) {console.log("ON BEFORE UNLOAD");}
2221
2222// 	event.stopPropagation();
2223
2224// 	animateBlog('out');
2225// });
2226
2227
2228/* ====== ON DOCUMENT READY ====== */
2229
2230$( document ).ready( function() {
2231
2232	if ( globalDebug ) {
2233		console.group( "OnDocumentReady" );
2234	}
2235
2236	/* --- INITIALIZE --- */
2237	init();
2238
2239	if ( globalDebug ) {
2240		console.groupEnd();
2241	}
2242
2243} );
2244
2245
2246/* ====== ON WINDOW LOAD ====== */
2247
2248$( window ).on('load', function() {
2249
2250	if ( globalDebug ) {
2251		console.group( "OnWindowLoad" );
2252	}
2253
2254	StickyHeader.init();
2255
2256	if ( is_mobile_ie ) {
2257		$( "html" ).addClass( "mobile-ie" );
2258	}
2259
2260	//Set textarea from contact page to autoresize
2261	if ( $( "textarea" ).length ) {
2262		$( "textarea" ).autosize();
2263	}
2264
2265	if ( ! $( 'html' ).is( '.ie9, .lt-ie9' ) ) {
2266		setTimeout( function() {
2267			CoverAnimation.initialize();
2268		}, 600 );
2269	} else {
2270		setTimeout( function() {
2271			CoverAnimation.initialize();
2272		}, 400 );
2273	}
2274
2275	niceScrollInit();
2276
2277	magnificPopupInit();
2278	initVideos();
2279	resizeVideos();
2280
2281	var Map = new GMap();
2282	Map.init();
2283
2284	if ( ! empty( $( '#date-otreservations' ) ) ) {
2285		var dateFormat = $( '#date-otreservations' ).closest( '.otw-wrapper' ).children( '.txtDateFormat' ).attr( 'value' ).toUpperCase();
2286
2287		function disabledWeekends() {
2288
2289			if($('.pixcode--otreservations').hasClass('disable-weekends')) {
2290				return true;
2291			}
2292
2293			return false;
2294		}
2295
2296		// Pikaday
2297		var picker = new Pikaday( {
2298			field: document.getElementById( 'date-otreservations' ),
2299			format: dateFormat,
2300			minDate: moment().toDate(),
2301			defaultDate: moment().toDate(),
2302			setDefaultDate: true,
2303			disableWeekends: disabledWeekends()
2304		} )
2305	}
2306
2307	$( '.pixcode--tabs' ).organicTabs();
2308	DownArrow.initialize();
2309
2310	setTimeout( function() {
2311		ScrollToTop.initialize();
2312	}, 60 );
2313
2314	royalSliderInit();
2315	updateHeaderPadding();
2316
2317	loop();
2318
2319	var $bulletedSections = $('[data-bully]');
2320
2321	if ( $bulletedSections.length > 1 ) {
2322
2323		$bulletedSections.bully();
2324
2325		$('.c-bully__bullet').each(function (i, obj) {
2326
2327			var stagger = i * 400,
2328				$obj    = $(obj);
2329
2330			setTimeout(function () {
2331				$obj.addClass('c-bully__bullet--pop');
2332			}, stagger);
2333		});
2334	}
2335
2336	Rosa.Parallax.init();
2337	$html.addClass( 'is--loaded' );
2338} );
2339
2340function getOrientation() {
2341	return windowWidth > windowHeight ? "landscape" : "portrait";
2342}
2343
2344function updateHeaderPadding() {
2345	var $header = $( '.site-header' ),
2346		headerHeight = $header.outerHeight();
2347
2348	if ( ! $header.next().is( '.c-hero' ) ) {
2349		$('#page').css('paddingTop', headerHeight);
2350	}
2351}
2352
2353$window.on( 'resize', function() {
2354	windowWidth = window.innerWidth;
2355	windowHeight = window.innerHeight;
2356} );
2357
2358$( window ).on( "debouncedresize", onResize );
2359
2360$( window ).on( "rellax:restart", function() {
2361	$( '.js-pixslider' ).each(function(i, obj) {
2362		var rs = $(obj).data('royalSlider');
2363
2364		if (typeof rs !== "undefined") {
2365			rs.updateSliderSize(true);
2366		}
2367	});
2368});
2369
2370function onResize() {
2371	var neworientation = getOrientation();
2372
2373	if ( neworientation !== orientation ) {
2374		orientation = neworientation;
2375		$( window ).trigger( "debouncedorientationchange" );
2376	}
2377
2378	resizeVideos();
2379	cartOnMobile();
2380
2381	if ( touch && windowWidth < 900 ) {
2382		HandleSubmenusOnTouch.init();
2383	} else {
2384		HandleSubmenusOnTouch.release();
2385	}
2386
2387	requestAnimationFrame( refreshStuff );
2388}
2389
2390function refreshStuff() {
2391	CoverAnimation.initialize();
2392	ScrollToTop.initialize();
2393	$window.trigger( 'rellax' );
2394}
2395
2396
2397function updateStuff() {
2398	ScrollToTop.update();
2399	DownArrow.update();
2400	CoverAnimation.update();
2401
2402	if ( windowWidth >= 900 ) {
2403		StickyHeader.update();
2404	}
2405}
2406
2407$( window ).on( "organicTabsChange", function() {
2408	onResize();
2409	refreshStuff();
2410	$window.trigger( 'rellax' );
2411} );
2412
2413$window.scroll( function() {
2414	newScrollY = (window.pageYOffset || document.documentElement.scrollTop)  - (document.documentElement.clientTop || 0);
2415} );
2416
2417function loop() {
2418	// Avoid calculations if not needed
2419	if ( latestKnownScrollY !== newScrollY ) {
2420		latestKnownScrollY = newScrollY;
2421		updateStuff();
2422	}
2423	requestAnimationFrame( loop );
2424}
2425
2426if ( navigator.userAgent.match( /iPad;.*CPU.*OS 7_\d/i ) && window.innerHeight != document.documentElement.clientHeight ) {
2427
2428	var fixViewportHeight = function() {
2429		$( 'html, body' ).outerHeight( window.innerHeight );
2430	};
2431
2432	window.addEventListener( "scroll", fixViewportHeight, false );
2433	window.addEventListener( "orientationchange", fixViewportHeight, false );
2434	fixViewportHeight();
2435}
2436
2437function detectIE() {
2438	var ua = window.navigator.userAgent;
2439
2440	var msie = ua.indexOf( 'MSIE ' );
2441	if ( msie > 0 ) {
2442		// IE 10 or older => return version number
2443		return parseInt( ua.substring( msie + 5, ua.indexOf( '.', msie ) ), 10 );
2444	}
2445
2446	var trident = ua.indexOf( 'Trident/' );
2447	if ( trident > 0 ) {
2448		// IE 11 => return version number
2449		var rv = ua.indexOf( 'rv:' );
2450		return parseInt( ua.substring( rv + 3, ua.indexOf( '.', rv ) ), 10 );
2451	}
2452
2453	var edge = ua.indexOf( 'Edge/' );
2454	if ( edge > 0 ) {
2455		// IE 12 => return version number
2456		return parseInt( ua.substring( edge + 5, ua.indexOf( '.', edge ) ), 10 );
2457	}
2458
2459	// other browser
2460	return false;
2461}
2462
2463
2464// smooth scrolling to anchors
2465$( function() {
2466
2467	var $header = $( '.site-header' ),
2468		headerHeight = parseInt( $header.outerHeight(), 10 ),
2469		$html = $( 'html' );
2470
2471	$( '.site-header a[href*="#"]:not([href="#"])' ).click( function() {
2472
2473		var timeout = 0;
2474
2475		if ( $html.hasClass( 'navigation--is-visible' ) ) {
2476			$( 'body' ).css( 'overflow', '' );
2477			$html.removeClass( 'navigation--is-visible' );
2478			timeout = 600;
2479		}
2480
2481
2482		if ( location.pathname.replace( /^\//, '' ) == this.pathname.replace( /^\//, '' ) && location.hostname == this.hostname ) {
2483			var target = $( this.hash );
2484			target = target.length ? target : $( '[name=' + this.hash.slice( 1 ) + ']' );
2485			if ( target.length ) {
2486				setTimeout( function() {
2487					$( 'html,body' ).animate( {
2488						scrollTop: target.offset().top - headerHeight
2489					}, 1000 );
2490				}, timeout );
2491				return false;
2492			}
2493		}
2494
2495	} );
2496} );
2497
2498var ieVersion = getIEversion();
2499var Rosa = {};
2500
2501Rosa.Parallax = new Parallax( '[data-rellax]', {
2502	bleed: 60,
2503	container: '[data-rellax-container]'
2504} );
2505
2506Rosa.Parallax.disabled = is_mobile || ieVersion && ieVersion < 12;
2507
2508// returns the depth of the element "e" relative to element with id=id
2509// for this calculation only parents with classname = waypoint are considered
2510function getLevelDepth(e, id, waypoint, cnt) {
2511	cnt = cnt || 0;
2512	if (e.id.indexOf(id) >= 0) return cnt;
2513	if ($(e).hasClass(waypoint)) {
2514		++cnt;
2515	}
2516	return e.parentNode && getLevelDepth(e.parentNode, id, waypoint, cnt);
2517}
2518
2519// returns the closest element to 'e' that has class "classname"
2520function closest(e, classname) {
2521	if ($(e).hasClass(classname)) {
2522		return e;
2523	}
2524	return e.parentNode && closest(e.parentNode, classname);
2525}
2526
2527}) (jQuery, window);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.