PageSourceSearch

https://www.skischule-vasold.at/wp-content/themes/mounthood/fw/js/core.init.js

js skischule-vasold.at collected 2026-10-07 20:07:12 UTC 52,685 bytes, 1,521 lines download raw bytes

1/* global jQuery:false */
2/* global MOUNTHOOD_STORAGE:false */
3
4// Disable init VC prettyPhoto on the gallery images
5window.vc_prettyPhoto = function() {};
6
7jQuery(document).ready(function() {
8	"use strict";
9	MOUNTHOOD_STORAGE['theme_init_counter'] = 0;
10	mounthood_init_actions();
11	if (jQuery(window).width() > 767) {
12		setTimeout(function() {
13			setEqualHeight(jQuery(".footer_wrap .footer_wrap_inner .columns_wrap > .widget"));
14		}, 600);	
15	};
16	
17});
18
19jQuery(window).on('beforeunload', function() {
20	"use strict";
21	// Show preloader
22    if (jQuery.browser && !jQuery.browser.safari) jQuery('#page_preloader').css({display: 'block', opacity: 0}).animate({opacity:0.8}, 300);
23});
24
25function setEqualHeight(columns){
26	var tallestcolumn = 0;
27	columns.each(
28		function(){
29			currentHeight = jQuery(this).height();
30			if(currentHeight > tallestcolumn){
31				tallestcolumn = currentHeight;
32			}
33		}
34	);
35	columns.height(tallestcolumn);
36}
37
38// Theme init actions
39function mounthood_init_actions() {
40	"use strict";
41
42	if (MOUNTHOOD_STORAGE['vc_edit_mode'] && jQuery('.vc_empty-placeholder').length==0 && MOUNTHOOD_STORAGE['theme_init_counter']++ < 30) {
43		setTimeout(mounthood_init_actions, 200);
44		return;
45	}
46	
47	// Hide preloader
48	jQuery('#page_preloader').animate({opacity:0}
48, 500, function() { jQuery(this).css({display: 'none'}); });
49
50	// Check for Retina display
51	if (mounthood_is_retina()) {
52		mounthood_set_cookie('mounthood_retina', 1, 365);
53	}
54
55	mounthood_ready_actions();
56
57	// Add resize handlers after VC row stretch handlers on('resize.vcRowBehaviour', ...)
58	setTimeout(function() {
59		jQuery(window).on('resize.mounthood', function() {
60			mounthood_resize_actions();
61			mounthood_scroll_actions()
62		}).trigger('resize.mounthood');
63	}, 10);
64
65	// Add resize on VC action vc-full-width-row
66	jQuery(document).on('vc-full-width-row', function() {
67		mounthood_resize_actions();
68		mounthood_scroll_actions()
69	});
70
71	// Scroll handlers
72	jQuery(window).on('scroll.mounthood', function() {
73		"use strict";
74		mounthood_scroll_actions();
75	});
76}
77
78
79
80// Theme first load actions
81//==============================================
82function mounthood_ready_actions() {
83	"use strict";
84
85	// Call theme specific action (if exists)
86    //----------------------------------------------
87	if (window.mounthood_theme_ready_actions) mounthood_theme_ready_actions();
88
89
90	// Widgets decoration
91    //----------------------------------------------
92
93	// Decorate nested lists in widgets and side panels
94	jQuery('.widget ul > li').each(function() {
95		if (jQuery(this).find('ul').length > 0) {
96			jQuery(this).addClass('has_children');
97		}
98	});
99
100
101	// Archive widget decoration
102	jQuery('.widget_archive a').each(function() {
103		var val = jQuery(this).html().split(' ');
104		if (val.length > 1) {
105			val[val.length-1] = '<span>' + val[val.length-1] + '</span>';
106			jQuery(this).html(val.join(' '))
107		}
108	});
109
110
111	// Navigate on category change
112	jQuery('.widget_subcategories').on('change', 'select', function() {
113		var dropdown = jQuery(this).get(0);
114		if ( dropdown.options[dropdown.selectedIndex].value > 0 ) {
115			location.href = MOUNTHOOD_STORAGE['site_url'] + "/?cat="+dropdown.options[dropdown.selectedIndex].value;
116		}
117	});
118
119	
120	// Calendar handlers - change months
121	jQuery('.widget_calendar').on('click', '.month_prev a, .month_next a', function(e) {
122		"use strict";
123		var calendar = jQuery(this).parents('.wp-calendar');
124		var m = jQuery(this).data('month');
125		var y = jQuery(this).data('year');
126		var l = jQuery(this).data('letter');
127		var pt = jQuery(this).data('type');
128		jQuery.post(MOUNTHOOD_STORAGE['ajax_url'], {
129			action: 'calendar_change_month',
130			nonce: MOUNTHOOD_STORAGE['ajax_nonce'],
131			letter: l,
132			month: m,
133			year: y,
134			post_type: pt
135		}).done(function(response) {
136			var rez = {};
137			try {
138				rez = JSON.parse(response);
139			} catch (e) {
140				rez = { error: MOUNTHOOD_STORAGE['ajax_error'] };
141				console.log(response);
142			}
143			if (rez.error === '') {
144				calendar.parent().fadeOut(200, function() {
145					jQuery(this).find('.wp-calendar').remove();
146					jQuery(this).append(rez.data).fadeIn(200);
147				});
148			}
149		});
150		e.preventDefault();
151		return false;
152	});
153
154
155	// Media setup
156    //----------------------------------------------
157
158	// Video background init
159	jQuery('.video_bg').each(function() {
160		var youtube = jQuery(this).data('youtube-code');
161		if (youtube) {
162			jQuery(this).tubular({videoId: youtube});
163		}
164	});
165
166
167	// Main slider
168    //----------------------------------------------
169	jQuery('.slider_over_button,.slider_over_close').on('click', function(e) {
170		jQuery(this).parent().toggleClass('opened');
171		e.preventDefault();
172		return false;
173	});
174
175
176
177	// Menu
178    //----------------------------------------------
179
180	// Clone side menu for responsive
181	if (jQuery('ul#menu_side').length > 0) {
182		jQuery('ul#menu_side').clone().removeAttr('id').removeClass('menu_side_nav').addClass('menu_side_responsive').insertAfter('ul#menu_side');
183		mounthood_show_current_menu_item(jQuery('.menu_side_responsive'), jQuery('.sidebar_outer_menu_responsive_button'));
184	}
185	if (jQuery('.header_mobile').length > 0) {
186		jQuery('.header_mobile .menu_main_nav_area ul#menu_main').removeAttr('id');
187		jQuery('.header_mobile .menu_button').on('click', function(){
188			jQuery('.header_mobile .side_wrap').toggleClass('open');
189			jQuery('.header_mobile .mask').toggleClass('show');
190			jQuery('html').toggleClass('menu_mobile_open');
191			// Fix for Safari
192			if (mounthood_browser_is_ios() && jQuery('body').hasClass('menu_mobile')) {
193				jQuery('body').toggleClass('ios_fixed');
194			}
195		});
196		jQuery('.header_mobile .mask, .header_mobile .side_wrap .close').on('click', function(){
197			jQuery('.header_mobile .side_wrap').removeClass('open');
198			jQuery('.header_mobile .mask').removeClass('show');
199			jQuery('html').removeClass('menu_mobile_open');
200			// Fix for Safari
201			if (mounthood_browser_is_ios() && jQuery('body').hasClass('menu_mobile')) {
202				jQuery('body').removeClass('ios_fixed');
203			}
204		});
205	}
206
207	// Push menu button
208	jQuery('.menu_pushy_button').on('click', function(e){
209		"use strict";
210		jQuery('body').addClass('pushy-active').css('overflow', 'hidden');
211		jQuery('.site-overlay').fadeIn('fast');
212		e.preventDefault();
213		return false;
214	});
215	jQuery('.pushy .close-pushy,.site-overlay').on('click', function(e){
216		jQuery('body').removeClass('pushy-active').css('overflow', 'visible');
217		jQuery('.site-overlay').fadeOut('fast');
218		e.preventDefault();
219		return false;
220	});
221	
222	// Side menu widgets button
223	jQuery('.sidebar_outer_widgets_button').on('click', function(e){
224		"use strict";
225		jQuery('.sidebar_outer_widgets').slideToggle();
226		e.preventDefault();
227		return false;
228	});
229
230	// Add arrows in responsive menu
231	jQuery('.header_mobile .menu_main_nav .menu-item-has-children > a, .menu_side_responsive .menu-item-has-children > a, .menu_pushy_nav_area .menu-item-has-children > a, body:not(.woocommerce) .widget_area:not(.footer_wrap) .widget_product_categories ul.product-categories .has_children > a').prepend('<span class="open_child_menu"></span>');
232
233	// Submenu click handler for the responsive menu
234	jQuery('.header_mobile .menu_main_nav, .menu_side_responsive, .menu_pushy_nav_area, body:not(.woocommerce) .widget_area:not(.footer_wrap) .widget_product_categories').on('click', 'li a,li a .open_child_menu, ul.product-categories.plain li a .open_child_menu', function(e) {
235		"use strict";
236		var is_menu_main = jQuery(this).parents('.menu_main_nav').length > 0;
237		var $a = jQuery(this).hasClass('open_child_menu') ? jQuery(this).parent() : jQuery(this);
238		if ((!is_menu_main || jQuery('body').hasClass('menu_mobile')) && ($a.parent().hasClass('menu-item-has-children') || $a.parent().hasClass('has_children'))) {
239			if ($a.siblings('ul:visible').length > 0)
240				$a.siblings('ul').slideUp().parent().removeClass('opened');
241			else {
242				jQuery(this).parents('li').siblings('li').find('ul:visible').slideUp().parent().removeClass('opened');
243				$a.siblings('ul').slideDown().parent().addClass('opened');
244			}
245		}
246		// Ignore link for parent menu items
247		if (jQuery(this).hasClass('open_child_menu') || $a.attr('href')=='#') {
248			e.preventDefault();
249			return false;
250		}
251	});
252	
253	// Init superfish menus
254	mounthood_init_sfmenu('.menu_main_nav_area ul#menu_main, ul#menu_user, ul#menu_side, body:not(.woocommerce) .widget_area:not(.footer_wrap) .widget_product_categories ul.product-categories');
255
256	// Slide effect for main menu
257	if (MOUNTHOOD_STORAGE['menu_hover']=='slide_line' || MOUNTHOOD_STORAGE['menu_hover']=='slide_box') {
258		setTimeout(function() {
259			"use strict";
260			jQuery('#menu_main').spasticNav({
261				style: MOUNTHOOD_STORAGE['menu_hover']=='slide_line' ? 'line' : 'box',
262				color: MOUNTHOOD_STORAGE['accent1_hover'],
263				colorOverride: false
264			});
265		}, 500);
266	}
267
268	// Show table of contents for the current page
269	if (MOUNTHOOD_STORAGE['toc_menu'] != 'hide' && MOUNTHOOD_STORAGE['toc_menu'] != 'no') {
270		mounthood_build_page_toc();
271	}
272
273	// One page mode for menu links (scroll to anchor)
274	jQuery('#toc, ul#menu_main li, ul#menu_user li, ul#menu_side li, ul#menu_footer li, ul#menu_pushy li').on('click', 'a', function(e) {
275		"use strict";
276		var href = jQuery(this).attr('href');
277		if (href===undefined) return;
278		var pos = href.indexOf('#');
279		if (pos < 0 || href.length == 1) return;
280		if (jQuery(href.substr(pos)).length > 0) {
281			var loc = window.location.href;
282			var pos2 = loc.indexOf('#');
283			if (pos2 > 0) loc = loc.substring(0, pos2);
284			var now = pos==0;
285			if (!now) now = loc == href.substring(0, pos);
286			if (now) {
287				mounthood_document_animate_to(href.substr(pos));
288				mounthood_document_set_location(pos==0 ? loc + href : href);
289				e.preventDefault();
290				return false;
291			}
292		}
293	});
294	
295	
296	// Store height of the top and side panels
297	MOUNTHOOD_STORAGE['top_panel_height'] = 0;	//Math.max(0, jQuery('.top_panel_wrap').height());
298	MOUNTHOOD_STORAGE['side_panel_height'] = 0;
299
300
301	// Pagination
302    //----------------------------------------------
303
304	// Page navigation (style slider)
305	jQuery('.pager_cur').on('click', function(e) {
306		"use strict";
307		jQuery('.pager_slider').slideDown(300, function() {
308			mounthood_sc_init(jQuery('.pager_slider').eq(0));
309		});
310		e.preventDefault();
311		return false;
312	});
313
314
315	// View More button
316	jQuery('#viewmore_link').on('click', function(e) {
317		"use strict";
318		if (!MOUNTHOOD_STORAGE['viewmore_busy'] && !jQuery(this).hasClass('viewmore_empty')) {
319			jQuery(this).parent().addClass('loading');
320			MOUNTHOOD_STORAGE['viewmore_busy'] = true;
321			jQuery.post(MOUNTHOOD_STORAGE['ajax_url'], {
322				action: 'view_more_posts',
323				nonce: MOUNTHOOD_STORAGE['ajax_nonce'],
324				page: MOUNTHOOD_STORAGE['viewmore_page']+1,
325				data: MOUNTHOOD_STORAGE['viewmore_data'],
326				vars: MOUNTHOOD_STORAGE['viewmore_vars']
327			}).done(function(response) {
328				"use strict";
329				var rez = {};
330				try {
331					rez = JSON.parse(response);
332				} catch (e) {
333					rez = { error: MOUNTHOOD_STORAGE['ajax_error'] };
334					console.log(response);
335				}
336				jQuery('#viewmore_link').parent().removeClass('loading');
337				MOUNTHOOD_STORAGE['viewmore_busy'] = false;
338				if (rez.error === '') {
339					var posts_container = jQuery('.content').eq(0);
340					if (posts_container.find('.isotope_wrap').length > 0) posts_container = posts_container.find('.isotope_wrap').eq(0);
341					if (posts_container.hasClass('isotope_wrap')) {
342						posts_container.data('last-width', 0).append(rez.data);
343						MOUNTHOOD_STORAGE['isotope_init_counter'] = 0;
344						mounthood_init_appended_isotope(posts_container, rez.filters);
345					} else
346						jQuery('#viewmore').before(rez.data);
347
348					MOUNTHOOD_STORAGE['viewmore_page']++;
349					if (rez.no_more_data==1) {
350						jQuery('#viewmore_link').addClass('viewmore_empty').parent().hide();
351					}
352
353					mounthood_init_post_formats();
354					mounthood_sc_init(posts_container);
355					mounthood_scroll_actions();
356				}
357			});
358		}
359		e.preventDefault();
360		return false;
361	});
362
363
364	// WooCommerce
365    //----------------------------------------------
366
367	// Change display mode
368	jQuery('.woocommerce,.woocommerce-page').on('click', '.mode_buttons a', function(e) {
369		"use strict";
370		var mode = jQuery(this).hasClass('woocommerce_thumbs') ? 'thumbs' : 'list';
371		mounthood_set_cookie('mounthood_shop_mode', mode, 365);
372		jQuery(this).siblings('input').val(mode).parents('form').get(0).submit();
373		e.preventDefault();
374		return false;
375	});
376	// Added to cart
377	jQuery('body').bind('added_to_cart', function() {
378		"use strict";
379		// Update amount on the cart button
380		var total = jQuery('.widget_shopping_cart').eq(0).find('.total .amount').text();
381		if (total != undefined) {
382			jQuery('.top_panel_cart_button .cart_summa').text(total);
383		}
384		// Update count items on the cart button
385		var cnt = 0;
386		jQuery('.widget_shopping_cart_content').eq(0).find('.cart_list li').each(function() {
387			var q = jQuery(this).find('.quantity').html().split(' ', 2);
388			if (!isNaN(q[0]))
389				cnt += Number(q[0]);
390		});
391		var items = jQuery('.top_panel_cart_button .cart_items').eq(0).text().split(' ', 2);
392		items[0] = cnt;
393		jQuery('.top_panel_cart_button .cart_items').text(items[0]+' '+items[1]);
394		// Update data-attr on button
395		jQuery('.top_panel_cart_button').data({
396			'items': cnt ? cnt : 0,
397			'summa': total ? total : 0
398		});
399	});
400	// Show cart 
401	jQuery('.top_panel_middle .top_panel_cart_button, .header_mobile .top_panel_cart_button').on('click', function(e) {
402		"use strict";
403		jQuery(this).siblings('.sidebar_cart').slideToggle();
404		e.preventDefault();
405		return false;
406	});
407	// Add buttons to quantity
408	jQuery('.woocommerce div.quantity,.woocommerce-page div.quantity').append('<span class="q_inc"></span><span class="q_dec"></span>');
409	jQuery('.woocommerce div.quantity').on('click', '>span', function(e) {
410		"use strict";
411		var f = jQuery(this).siblings('input');
412		if (jQuery(this).hasClass('q_inc')) {
413			f.val(Math.max(0, parseInt(f.val()))+1);
414		} else {
415			f.val(Math.max(1, Math.max(0, parseInt(f.val()))-1));
416		}
417		e.preventDefault();
418		return false;
419	});
420	// Add stretch behaviour to WooC tabs area
421	// jQuery('.single-product .woocommerce-tabs')
422	// 	.addClass('trx-stretch-width scheme_light')
423	// 	.after('<div class="trx-stretch-width-original"></div>');
424	// mounthood_stretch_width();
425
426
427	// Popup windows
428    //----------------------------------------------
429	jQuery('.popup_link,.popup_login_link,.popup_register_link').addClass('inited').on('click', function(e){
430		var popup = jQuery(jQuery(this).attr('href'));
431		if (popup.length === 1) {
432			mounthood_hide_popup(jQuery(popup.hasClass('popup_login') ? '.popup_registration' : '.popup_login' ));
433			mounthood_show_popup(popup);
434		}
435		e.preventDefault();
436		return false;
437	});
438	jQuery('.popup_wrap').on('click', '.popup_close', function(e){
439		var popup = jQuery(this).parent();
440		if (popup.length === 1) {
441			mounthood_hide_popup(popup);
442		}
443		e.preventDefault();
444		return false;
445	});
446
447
448	// Bookmarks
449    //----------------------------------------------
450
451	// Add bookmark
452	jQuery('.bookmarks_add').on('click', function(e) {
453		"use strict";
454		var title = window.document.title.split('|')[0];
455		var url = window.location.href;
456		var list = mounthood_get_cookie('mounthood_bookmarks');
457		var exists = false;
458		if (list) {
459			try {
460				list = JSON.parse(list);
461			} catch (e) {}
462			if (list.length) {
463				for (var i=0; i<list.length; i++) {
464					if (list[i].url == url) {
465						exists = true;
466						break;
467					}
468				}
469			}
470		} else
471			list = new Array();
472		if (!exists) {
473			var message_popup = mounthood_message_dialog('<label for="bookmark_title">'+MOUNTHOOD_STORAGE['strings']['bookmark_title']+'</label><br><input type="text" id="bookmark_title" name="bookmark_title" value="'+title+'">', MOUNTHOOD_STORAGE['strings']['bookmark_add'], null,
474				function(btn, popup) {
475					"use strict";
476					if (btn != 1) return;
477					title = message_popup.find('#bookmark_title').val();
478					list.push({title: title, url: url});
479					jQuery('.bookmarks_list').append('<li><a href="'+url+'" class="bookmarks_item">'+title+'<span class="bookmarks_delete icon-cancel" title="'+MOUNTHOOD_STORAGE['strings']['bookmark_del']+'"></span></a></li>');
480                    mounthood_set_cookie('mounthood_bookmarks', JSON.stringify(list), 365);
481					setTimeout(function () {mounthood_message_success(MOUNTHOOD_STORAGE['strings']['bookmark_added'], MOUNTHOOD_STORAGE['strings']['bookmark_add']);}, MOUNTHOOD_STORAGE['message_timeout']/4);
482				});
483		} else
484			mounthood_message_warning(MOUNTHOOD_STORAGE['strings']['bookmark_exists'], MOUNTHOOD_STORAGE['strings']['bookmark_add']);
485		e.preventDefault();
486		return false;
487	});
488
489	// Delete bookmark
490	jQuery('.bookmarks_list').on('click', '.bookmarks_delete', function(e) {
491		"use strict";
492		var idx = jQuery(this).parent().index();
493		var list = mounthood_get_cookie('mounthood_bookmarks');
494		if (list) {
495			try {
496				list = JSON.parse(list);
497			} catch (e) {}
498			if (list.length) {
499				list.splice(idx, 1);
500                mounthood_set_cookie('mounthood_bookmarks', JSON.stringify(list), 365);
501			}
502		}
503		jQuery(this).parent().remove();
504		e.preventDefault();
505		return false;
506	});
507
508
509	// Other settings
510    //------------------------------------
511
512	// Scroll to top button
513	jQuery('.scroll_to_top').on('click', function(e) {
514		"use strict";
515		jQuery('html,body').animate({
516			scrollTop: 0
517		}, 'slow');
518		e.preventDefault();
519		return false;
520	});
521
522	// AJAX views counter
523	if (MOUNTHOOD_STORAGE['ajax_views_counter'] !== undefined) {
524		setTimeout(function(){
525			jQuery.post(MOUNTHOOD_STORAGE['ajax_url'], {
526				action: 'post_counter',
527				nonce: MOUNTHOOD_STORAGE['ajax_nonce'],
528				post_id: MOUNTHOOD_STORAGE['ajax_views_counter']['post_id'],
529				views: MOUNTHOOD_STORAGE['ajax_views_counter']['post_views']
530			});
531			}, 10);
532	}
533
534    // Show system message
535	mounthood_show_system_message();
536
537	// Init post format specific scripts
538	mounthood_init_post_formats();
539
540	// Call sc init action (if exists)
541	if (window.mounthood_sc_init_actions) mounthood_sc_init_actions();
542
543	// Init hidden elements (if exists)
544	if (window.mounthood_init_hidden_elements) mounthood_init_hidden_elements(jQuery('body').eq(0));
545	
546} //end ready
547
548
549
550
551// Scroll actions
552//==============================================
553
554// Do actions when page scrolled
555function mounthood_scroll_actions() {
556	"use strict";
557	
558	// Call theme specific action (if exists)
559    //----------------------------------------------
560	if (window.mounthood_theme_scroll_actions) mounthood_theme_scroll_actions();
561
562	var scroll_offset = jQuery(window).scrollTop();
563	var scroll_to_top_button = jQuery('.scroll_to_top');
564	var adminbar_height = Math.max(0, jQuery('#wpadminbar').height());
565
566	if (MOUNTHOOD_STORAGE['top_panel_height'] < 1) {
567		MOUNTHOOD_STORAGE['top_panel_height'] = Math.max(0, jQuery('.top_panel_wrap').height());
568	}
569	
570	// Scroll to top button show/hide
571	if (scroll_offset > MOUNTHOOD_STORAGE['top_panel_height'])
572		scroll_to_top_button.addClass('show');
573	else
574		scroll_to_top_button.removeClass('show');
575	
576	// Fix/unfix top panel
577	if (!jQuery('body').hasClass('menu_mobile') && MOUNTHOOD_STORAGE['menu_fixed']) {
578		var slider_height = 0;
579		if (jQuery('.top_panel_below .slider_wrap').length > 0) {
580			slider_height = jQuery('.top_panel_below .slider_wrap').height();
581			if (slider_height < 10) {
582				slider_height = jQuery('.slider_wrap').hasClass('.slider_fullscreen') ? jQuery(window).height() : MOUNTHOOD_STORAGE['slider_height'];
583			}
584		}
585		if (scroll_offset <= slider_height + MOUNTHOOD_STORAGE['top_panel_height']) {
586			if (jQuery('body').hasClass('top_panel_fixed')) {
587				jQuery('body').removeClass('top_panel_fixed');
588			}
589		} else if (scroll_offset > slider_height + MOUNTHOOD_STORAGE['top_panel_height']) {
590			if (!jQuery('body').hasClass('top_panel_fixed') && jQuery(document).height() > jQuery(window).height()*1.5) {
591				jQuery('.top_panel_fixed_wrap').height(MOUNTHOOD_STORAGE['top_panel_height']);
592				jQuery('.top_panel_wrap').css('marginTop', '-150px').animate({'marginTop': 0}, 500);
593				jQuery('body').addClass('top_panel_fixed');
594			}
595		}
596	}
597	
598	// Fix/unfix side panel
599	if (jQuery('.sidebar_outer').length > 0) {
600		if (MOUNTHOOD_STORAGE['side_panel_height'] == 0)	
601			MOUNTHOOD_STORAGE['side_panel_height'] = jQuery('.sidebar_outer_logo_wrap').outerHeight() + jQuery('.sidebar_outer_menu').outerHeight() + jQuery('.sidebar_outer_widgets').outerHeight();
602		if (scroll_offset + jQuery(window).height() > MOUNTHOOD_STORAGE['side_panel_height'] + 100) {
603			if (jQuery('.sidebar_outer').css('position')!=='fixed') {
604				jQuery('.sidebar_outer').css({
605					'position': 'fixed',
606					'top': Math.min(0, jQuery(window).height() - MOUNTHOOD_STORAGE['side_panel_height'] - 100) + 'px',
607				});
608			}
609		} else {
610			if (jQuery('.sidebar_outer').css('position')=='fixed') {
611				jQuery('.sidebar_outer').css({
612					'position': 'absolute',
613					'top': 0
614				});
615			}
616		}
617	}
618
619	// TOC current items
620	jQuery('#toc .toc_item').each(function() {
621		"use strict";
622		var id = jQuery(this).find('a').attr('href');
623		var pos = id.indexOf('#');
624		if (pos < 0 || id.length == 1) return;
625		var loc = window.location.href;
626		var pos2 = loc.indexOf('#');
627		if (pos2 > 0) loc = loc.substring(0, pos2);
628		var now = pos==0;
629		if (!now) now = loc == href.substring(0, pos);
630		if (!now) return;
631		var off = jQuery(id).offset().top;
632		var id_next  = jQuery(this).next().find('a').attr('href');
633		var off_next = id_next ? jQuery(id_next).offset().top : 1000000;
634		if (off < scroll_offset + jQuery(window).height()*0.8 && scroll_offset + MOUNTHOOD_STORAGE['top_panel_height'] < off_next)
635			jQuery(this).addClass('current');
636		else
637			jQuery(this).removeClass('current');
638	});
639	
640	// Infinite pagination
641	mounthood_infinite_scroll()
642	
643	// Parallax scroll
644	mounthood_parallax_scroll();
645
646	// Call sc scroll actions (if exists)
647	if (window.mounthood_sc_scroll_actions) mounthood_sc_scroll_actions();
648}
649
650
651// Infinite Scroll
652function mounthood_infinite_scroll() {
653	"use strict";
654	if (MOUNTHOOD_STORAGE['viewmore_busy']) return;
655	var infinite = jQuery('#viewmore.pagination_infinite');
656	if (infinite.length > 0) {
657		var viewmore = infinite.find('#viewmore_link:not(.viewmore_empty)');
658		if (viewmore.length > 0) {
659			if (jQuery(window).scrollTop() + jQuery(window).height() + 100 >= infinite.offset().top) {
660				viewmore.eq(0).trigger('click');
661			}
662		}
663	}
664}
665
666// Parallax scroll
667function mounthood_parallax_scroll(){
668	jQuery('.sc_parallax').each(function(){
669		var windowHeight = jQuery(window).height();
670		var scrollTops = jQuery(window).scrollTop();
671		var offsetPrx = Math.max(jQuery(this).offset().top, windowHeight);
672		if ( offsetPrx <= scrollTops + windowHeight ) {
673			var speed  = Number(jQuery(this).data('parallax-speed'));
674			var xpos   = jQuery(this).data('parallax-x-pos');  
675			var ypos   = Math.round((offsetPrx - scrollTops - windowHeight) * speed + (speed < 0 ? windowHeight*speed : 0));
676			jQuery(this).find('.sc_parallax_content').css('backgroundPosition', xpos+' '+ypos+'px');
677			// Uncomment next line if you want parallax video (else - video position is static)
678			jQuery(this).find('div.sc_video_bg').css('top', ypos+'px');
679		} 
680	});
681}
682
683
684
685
686
687// Resize actions
688//==============================================
689
690// Do actions when page scrolled
691function mounthood_resize_actions() {
692	"use strict";
693
694	// Call theme specific action (if exists)
695    //----------------------------------------------
696	if (window.mounthood_theme_resize_actions) mounthood_theme_resize_actions();
697
698	// Reset stored value
699	if (!jQuery('body').hasClass('top_panel_fixed')) MOUNTHOOD_STORAGE['top_panel_height'] = 0;
700
701	mounthood_responsive_menu();
702	mounthood_vc_row_fullwidth_to_boxed();
703	mounthood_video_dimensions();
704	mounthood_resize_video_background();
705	mounthood_resize_fullscreen_slider();
706	mounthood_resize_alter_portfolio();
707	mounthood_stretch_width();
708
709	// Call sc resize actions (if exists)
710	if (window.mounthood_sc_resize_actions) mounthood_sc_resize_actions();
711}
712
713// Stretch area to full window width
714function mounthood_stretch_width() {
715	jQuery('.trx-stretch-width').each(function() {
716		var $el = jQuery(this);
717		var $el_full = $el.next('.trx-stretch-width-original');
718		var el_margin_left = parseInt( $el.css( 'margin-left' ), 10 );
719		var el_margin_right = parseInt( $el.css( 'margin-right' ), 10 );
720		var offset = 0 - $el_full.offset().left - el_margin_left;
721		var width = jQuery( window ).width();
722		if (!$el.hasClass('inited')) {
723			$el.addClass('inited invisible');
724			$el.css({
725				'position': 'relative',
726				'box-sizing': 'border-box'
727			});
728		}
729		$el.css({
730			'left': offset,
731			'width': jQuery( window ).width()
732		});
733		if ( !$el.hasClass('trx-stretch-content') ) {
734			var padding = Math.max(0, -1*offset);
735			var paddingRight = Math.max(0, width - padding - $el_full.width() + el_margin_left + el_margin_right);
736			$el.css( { 'padding-left': padding + 'px', 'padding-right': paddingRight + 'px' } );
737		}
738		$el.removeClass('invisible');
739	});
740}
741
742// Width vc_row when content boxed
743function mounthood_vc_row_fullwidth_to_boxed(){
744	"use strict";
745   if (jQuery('body').hasClass('body_style_boxed')) {
746       var width_body = jQuery('body').width();
747       var width_content = jQuery('.page_wrap').width();
748       var width_content_wrap = jQuery('.page_content_wrap  .content_wrap').width();
749       var indent = ( width_content - width_content_wrap ) / 2;
750	   if ( width_body > width_content ){
751		   jQuery('.vc_row[data-vc-full-width="true"]').each( function() {
752				"use strict";
753				var mrg = parseInt(jQuery(this).css('marginLeft'));
754				jQuery(this).css({
755					'width': width_content,
756					'left': -indent-mrg,
757					'padding-left': indent+mrg,
758					'padding-right': indent+mrg
759				});
760				if (jQuery(this).attr('data-vc-stretch-content')) {
761				   jQuery(this).css({
762					   'padding-left': 0,
763					   'padding-right': 0
764				   });
765				}
766		   });
767	   }
768   }
769}
770
771// Check window size and do responsive menu
772function mounthood_responsive_menu() {
773	"use strict";
774	if (mounthood_is_responsive_need(MOUNTHOOD_STORAGE['menu_mobile'])) {
775		if (!jQuery('body').hasClass('menu_mobile')) {
776			jQuery('body').removeClass('top_panel_fixed').addClass('menu_mobile');
777			jQuery('header.top_panel_wrap ').hide();
778			jQuery('.header_mobile').show();
779			
780			jQuery('header #popup_login').attr('id', 'popup_login_1');
781			jQuery('header #popup_registration').attr('id', 'popup_registration_1');
782			jQuery('.header_mobile #popup_login_1').attr('id', 'popup_login');
783			jQuery('.header_mobile #popup_registration_1').attr('id', 'popup_registration');
784		}
785	} else {
786		if (jQuery('body').hasClass('menu_mobile')) {
787			jQuery('body').removeClass('menu_mobile');
788			jQuery('header.top_panel_wrap ').show();
789			jQuery('.header_mobile').hide();
790			
791			jQuery('header #popup_login_1').attr('id', 'popup_login');
792			jQuery('header #popup_registration_1').attr('id', 'popup_registration');
793			jQuery('.header_mobile #popup_login').attr('id', 'popup_login_1');
794			jQuery('.header_mobile #popup_registration').attr('id', 'popup_registration_1');
795		}
796	}
797	
798	if (jQuery(window).width() < 640) {
799		var pass = jQuery('.header_mobile .popup_wrap.popup_registration .registration_form > .form_right');
800		if (pass.length > 0){ 
801			jQuery('.header_mobile .popup_wrap.popup_registration .form_left .popup_form_field.email_field').after(pass);
802		}
803	}
804	else{
805		var pass = jQuery('.header_mobile .popup_wrap.popup_registration .form_left > .form_right');
806		if (pass.length > 0){ 
807			jQuery('.header_mobile .popup_wrap.popup_registration .registration_form').append(pass);
808		}
809	}
810
811	if (!jQuery('.top_panel_wrap').hasClass('menu_show')) jQuery('.top_panel_wrap').addClass('menu_show');
812	// Show widgets block on the sidebar outer (if sidebar not responsive and widgets are hidden)
813	if (jQuery('.sidebar_outer').length > 0 && jQuery('.sidebar_outer').css('position')=='absolute' && jQuery('.sidebar_outer_widgets:visible').length==0) 
814		jQuery('.sidebar_outer_widgets').show();
815	// Switch popup menu / hierarchical list on product categories list placed in sidebar
816	var cat_menu = jQuery('body:not(.woocommerce) .widget_area:not(.footer_wrap) .widget_product_categories ul.product-categories');
817	var sb = cat_menu.parents('.widget_area');
818	if (sb.length > 0 && cat_menu.length > 0) {
819		if (sb.width() == sb.parents('.content_wrap').width()) {
820			if (cat_menu.hasClass('inited')) {
821				cat_menu.removeClass('inited').addClass('plain').superfish('destroy');
822				cat_menu.find('ul.animated').removeClass('animated').addClass('no_animated');
823			}
824		} else {
825			if (!cat_menu.hasClass('inited')) {
826				cat_menu.removeClass('plain').addClass('inited');
827				cat_menu.find('ul.no_animated').removeClass('no_animated').addClass('animated');
828				mounthood_init_sfmenu('body:not(.woocommerce) .widget_area:not(.footer_wrap) .widget_product_categories ul.product-categories');
829			}
830		}
831	}
832}
833
834
835// Check if responsive menu need
836function mounthood_is_responsive_need(max_width) {
837	"use strict";
838	var rez = false;
839	if (max_width > 0) {
840		var w = window.innerWidth;
841		if (w == undefined) {
842			w = jQuery(window).width()+(jQuery(window).height() < jQuery(document).height() || jQuery(window).scrollTop() > 0 ? 16 : 0);
843		}
844		rez = max_width > w;
845	}
846	return rez;
847}
848
849
850// Fit video frames to document width
851function mounthood_video_dimensions() {
852	jQuery('.sc_video_frame').each(function() {
853		"use strict";
854		if (jQuery(this).parents('div:hidden,article:hidden').length > 0) return;
855		var frame  = jQuery(this).eq(0);
856		var player = frame.parent();
857		var ratio = (frame.data('ratio') ? frame.data('ratio').split(':') : (frame.find('[data-ratio]').length>0 ? frame.find('[data-ratio]').data('ratio').split(':') : [16,9]));
858		ratio = ratio.length!=2 || ratio[0]==0 || ratio[1]==0 ? 16/9 : ratio[0]/ratio[1];
859		var w_attr = frame.data('width');
860		var h_attr = frame.data('height');
861		if (!w_attr || !h_attr) return;
862		var percent = (''+w_attr).substr(-1)=='%';
863		w_attr = parseInt(w_attr);
864		h_attr = parseInt(h_attr);
865		var w_real = Math.min(percent || frame.parents('.columns_wrap').length>0 ? 10000 : w_attr, frame.parents('div,article').width()), //player.width();
866			h_real = Math.round(percent ? w_real/ratio : w_real/w_attr*h_attr);
867		if (parseInt(frame.attr('data-last-width'))==w_real) return;
868		if (percent) {
869			frame.height(h_real);
870		} else {
871			frame.css({'width': w_real+'px', 'height': h_real+'px'});
872		}
873		frame.attr('data-last-width', w_real);
874	});
875	jQuery('video.sc_video,video.wp-video-shortcode').each(function() {
876		"use strict";
877		if (jQuery(this).parents('div:hidden,article:hidden').length > 0) return;
878		var video = jQuery(this).eq(0);
879		var ratio = (video.data('ratio')!=undefined ? video.data('ratio').split(':') : [16,9]);
880		ratio = ratio.length!=2 || ratio[0]==0 || ratio[1]==0 ? 16/9 : ratio[0]/ratio[1];
881		var mejs_cont = video.parents('.mejs-video');
882		var frame = video.parents('.sc_video_frame');
883		var w_attr = frame.length>0 ? frame.data('width') : video.data('width');
884		var h_attr = frame.length>0 ? frame.data('height') : video.data('height');
885		if (!w_attr || !h_attr) {
886			w_attr = video.attr('width');
887			h_attr = video.attr('height');
888			if (!w_attr || !h_attr) return;
889			video.data({'width': w_attr, 'height': h_attr});
890		}
891		var percent = (''+w_attr).substr(-1)=='%';
892		w_attr = parseInt(w_attr);
893		h_attr = parseInt(h_attr);
894		var w_real = Math.round(mejs_cont.length > 0 ? Math.min(percent ? 10000 : w_attr, mejs_cont.parents('div,article').width()) : video.width()),
895			h_real = Math.round(percent ? w_real/ratio : w_real/w_attr*h_attr);
896		if (parseInt(video.attr('data-last-width'))==w_real) return;
897		if (mejs_cont.length > 0 && mejs) {
898			mounthood_set_mejs_player_dimensions(video, w_real, h_real);
899		}
900		if (percent) {
901			video.height(h_real);
902		} else {
903			video.attr({'width': w_real, 'height': h_real}).css({'width': w_real+'px', 'height': h_real+'px'});
904		}
905		video.attr('data-last-width', w_real);
906	});
907	jQuery('video.sc_video_bg').each(function() {
908		"use strict";
909		if (jQuery(this).parents('div:hidden,article:hidden').length > 0) return;
910		var video = jQuery(this).eq(0);
911		var ratio = (video.data('ratio')!=undefined ? video.data('ratio').split(':') : [16,9]);
912		ratio = ratio.length!=2 || ratio[0]==0 || ratio[1]==0 ? 16/9 : ratio[0]/ratio[1];
913		var mejs_cont = video.parents('.mejs-video');
914		var container = mejs_cont.length>0 ? mejs_cont.parent() : video.parent();
915		var w = container.width();
916		var h = container.height();
917		var w1 = Math.ceil(h*ratio);
918		var h1 = Math.ceil(w/ratio);
919		if (video.parents('.sc_parallax').length > 0) {
920			var windowHeight = jQuery(window).height();
921			var speed = Number(video.parents('.sc_parallax').data('parallax-speed'));
922			var h_add = Math.ceil(Math.abs((windowHeight-h)*speed));
923			if (h1 < h + h_add) {
924				h1 = h + h_add;
925				w1 = Math.ceil(h1 * ratio);
926			}
927		}
928		if (h1 < h) {
929			h1 = h;
930			w1 = Math.ceil(h1 * ratio);
931		}
932		if (w1 < w) { 
933			w1 = w;
934			h1 = Math.ceil(w1 / ratio);
935		}
936		var l = Math.round((w1-w)/2);
937		var t = Math.round((h1-h)/2);
938		if (parseInt(video.attr('data-last-width'))==w1) return;
939		if (mejs_cont.length > 0) {
940			mounthood_set_mejs_player_dimensions(video, w1, h1);
941			mejs_cont.css({
942				//'left': -l+'px',
943				'top': -t+'px'
944			});
945		} else
946			video.css({
947				//'left': -l+'px',
948				'top': -t+'px'
949			});
950		video.attr({'width': w1, 'height': h1, 'data-last-width':w1}).css({'width':w1+'px', 'height':h1+'px'});
951		if (video.css('opacity')==0) video.animate({'opacity': 1}, 3000);
952	});
953	jQuery('iframe').each(function() {
954		"use strict";
955		if (jQuery(this).parents('div:hidden,article:hidden').length > 0) return;
956		var iframe = jQuery(this).eq(0);
957		var ratio = (iframe.data('ratio')!=undefined ? iframe.data('ratio').split(':') : (iframe.find('[data-ratio]').length>0 ? iframe.find('[data-ratio]').data('ratio').split(':') : [16,9]));
958		ratio = ratio.length!=2 || ratio[0]==0 || ratio[1]==0 ? 16/9 : ratio[0]/ratio[1];
959		var w_attr = iframe.attr('width');
960		var h_attr = iframe.attr('height');
961		var frame = iframe.parents('.sc_video_frame');
962		if (frame.length > 0) {
963			w_attr = frame.data('width');
964			h_attr = frame.data('height');
965		}
966		if (!w_attr || !h_attr) {
967			return;
968		}
969		var percent = (''+w_attr).substr(-1)=='%';
970		w_attr = parseInt(w_attr);
971		h_attr = parseInt(h_attr);
972		var w_real = frame.length > 0 ? frame.width() : iframe.width(),
973			h_real = Math.round(percent ? w_real/ratio : w_real/w_attr*h_attr);
974		if (parseInt(iframe.attr('data-last-width'))==w_real) return;
975		iframe.css({'width': w_real+'px', 'height': h_real+'px'});
976	});
977}
978
979// Resize fullscreen video background
980function mounthood_resize_video_background() {
981	"use strict";
982	var bg = jQuery('.video_bg');
983	if (bg.length < 1) 
984		return;
985	if (MOUNTHOOD_STORAGE['media_elements_enabled'] && bg.find('.mejs-video').length == 0)  {
986		setTimeout(mounthood_resize_video_background, 100);
987		return;
988	}
989	var video = bg.find('video');
990	var ratio = (video.data('ratio')!=undefined ? video.data('ratio').split(':') : [16,9]);
991	ratio = ratio.length!=2 || ratio[0]==0 || ratio[1]==0 ? 16/9 : ratio[0]/ratio[1];
992	var w = bg.width();
993	var h = bg.height();
994	var w1 = Math.ceil(h*ratio);
995	var h1 = Math.ceil(w/ratio);
996	if (h1 < h) {
997		h1 = h;
998		w1 = Math.ceil(h1 * ratio);
999	}
1000	if (w1 < w) { 
1001		w1 = w;
1002		h1 = Math.ceil(w1 / ratio);
1003	}
1004	var l = Math.round((w1-w)/2);
1005	var t = Math.round((h1-h)/2);
1006	if (bg.find('.mejs-container').length > 0) {
1007		mounthood_set_mejs_player_dimensions(bg.find('video'), w1, h1);
1008		bg.find('.mejs-container').css({'left': -l+'px', 'top': -t+'px'});
1009	} else
1010		bg.find('video').css({'left': -l+'px', 'top': -t+'px'});
1011	bg.find('video').attr({'width': w1, 'height': h1}).css({'width':w1+'px', 'height':h1+'px'});
1012}
1013
1014// Set Media Elements player dimensions
1015function mounthood_set_mejs_player_dimensions(video, w, h) {
1016	"use strict";
1017	if (mejs) {
1018		for (var pl in mejs.players) {
1019			if (mejs.players[pl].media.src == video.attr('src')) {
1020				if (mejs.players[pl].media.setVideoSize) {
1021					mejs.players[pl].media.setVideoSize(w, h);
1022				}
1023				mejs.players[pl].setPlayerSize(w, h);
1024				mejs.players[pl].setControlsSize();
1025			}
1026		}
1027	}
1028}
1029
1030// Resize Fullscreen Slider
1031function mounthood_resize_fullscreen_slider() {
1032	"use strict";
1033	var slider_wrap = jQuery('.slider_wrap.slider_fullscreen');
1034	if (slider_wrap.length < 1) 
1035		return;
1036	var slider = slider_wrap.find('.sc_slider_swiper');
1037	if (slider.length < 1) 
1038		return;
1039	var h = jQuery(window).height() - jQuery('#wpadminbar').height() - (jQuery('body').hasClass('top_panel_above') && !jQuery('body').hasClass('.top_panel_fixed') ? jQuery('.top_panel_wrap').height() : 0);
1040	slider.height(h);
1041}
1042
1043// Resize Alter portfolio elements
1044function mounthood_resize_alter_portfolio() {
1045	"use strict";
1046	var wrap = jQuery('.isotope_wrap.inited');
1047	if (wrap.length==0) return;
1048	wrap.each(function() {
1049		"use strict";
1050		var alter = jQuery(this).find('.post_item_alter');
1051		if (alter.length==0) return;
1052		var single = alter.find('.post_featured img[data-alter-items-w="1"]').eq(0);
1053		if (single.length != 1) return;
1054		var w_real = single.width();
1055		var h_real = single.height();
1056		var space = Number(single.data('alter-item-space'));
1057		var relayout = false;
1058		alter.find('.post_featured img').each(function() {
1059			"use strict";
1060			var items_w = Number(jQuery(this).data('alter-items-w'));
1061			var items_h = Number(jQuery(this).data('alter-items-h'));
1062			if (items_h > 1) {
1063				jQuery(this).height(Math.round(items_h*h_real+(items_h-1)*(space+1)));
1064				relayout = true;
1065			} else if (items_w > 1) {
1066				jQuery(this).height(h_real);
1067				relayout = true;
1068			}
1069		});
1070		if (relayout) {
1071			jQuery(this).isotope('layout');
1072		}
1073	});
1074}
1075
1076
1077
1078
1079
1080// Navigation
1081//==============================================
1082
1083// Init Superfish menu
1084function mounthood_init_sfmenu(selector) {
1085	jQuery(selector).show().each(function() {
1086		if (mounthood_is_responsive_need() && (jQuery(this).attr('id')=='menu_main' || jQuery(this).attr('id')=='menu_side')) return;
1087		jQuery(this).addClass('inited').superfish({
1088			delay: 500,
1089			animation: {
1090				opacity: 'show'
1091			},
1092			animationOut: {
1093				opacity: 'hide'
1094			},
1095			speed: 		MOUNTHOOD_STORAGE['css_animation'] ? 500 : 200,
1096			speedOut:	MOUNTHOOD_STORAGE['css_animation'] ? 500 : 200,
1097			autoArrows: false,
1098			dropShadows: false,
1099			onBeforeShow: function(ul) {
1100				if (jQuery(this).parents("ul").length > 1){
1101					var w = jQuery(window).width();  
1102					var par_offset = jQuery(this).parents("ul").offset().left;
1103					var par_width  = jQuery(this).parents("ul").outerWidth();
1104					var ul_width   = jQuery(this).outerWidth();
1105					if (par_offset+par_width+ul_width > w-20 && par_offset-ul_width > 0)
1106						jQuery(this).addClass('submenu_left');
1107					else
1108						jQuery(this).removeClass('submenu_left');
1109				}
1110				if (MOUNTHOOD_STORAGE['css_animation']) {
1111					jQuery(this).removeClass('animated fast '+MOUNTHOOD_STORAGE['menu_animation_out']);
1112					jQuery(this).addClass('animated fast '+MOUNTHOOD_STORAGE['menu_animation_in']);
1113				}
1114			},
1115			onBeforeHide: function(ul) {
1116				if (MOUNTHOOD_STORAGE['css_animation']) {
1117					jQuery(this).removeClass('animated fast '+MOUNTHOOD_STORAGE['menu_animation_in']);
1118					jQuery(this).addClass('animated fast '+MOUNTHOOD_STORAGE['menu_animation_out']);
1119				}
1120			}
1121		});
1122	});
1123}
1124
1125
1126// Build page TOC from the tag's id
1127function mounthood_build_page_toc() {
1128	"use strict";
1129	var toc = '', toc_count = 0;
1130	jQuery('[id^="toc_"],.sc_anchor').each(function(idx) {
1131		"use strict";
1132		var obj = jQuery(this);
1133		var id = obj.attr('id');
1134		var url = obj.data('url');
1135		var icon = obj.data('icon');
1136		if (!icon) icon = 'icon-circle-dot';
1137		var title = obj.attr('title');
1138		var description = obj.data('description');
1139		var separator = obj.data('separator');
1140		toc_count++;
1141		toc += '<div class="toc_item'+(separator=='yes' ? ' toc_separator' : '')+'">'
1142			+(description ? '<div class="toc_description">'+description+'</div>' : '')
1143			+'<a href="'+(url ? url : '#'+id)+'" class="toc_icon'+(title ? ' with_title' : '')+' '+icon+'">'+(title ? '<span class="toc_title">'+title+'</span>' : '')+'</a>'
1144			+'</div>';
1145	});
1146	if (toc_count > (MOUNTHOOD_STORAGE['toc_menu_home'] ? 1 : 0) + (MOUNTHOOD_STORAGE['toc_menu_top'] ? 1 : 0)) {
1147		if (jQuery('#toc').length > 0)
1148			jQuery('#toc .toc_inner').html(toc);
1149		else
1150			jQuery('body').append('<div id="toc" class="toc_'+MOUNTHOOD_STORAGE['toc_menu']+'"><div class="toc_inner">'+toc+'</div></div>');
1151	}
1152}
1153
1154
1155// Show current page title on the responsive menu button
1156function mounthood_show_current_menu_item(menu, button) {
1157	"use strict";
1158	menu.find('a').each(function () {
1159		var menu_link = jQuery(this);
1160		if (menu_link.text() == "") {
1161			return;
1162		}
1163		if (menu_link.attr('href') == window.location.href)
1164			button.text(menu_link.text());
1165	});
1166}
1167
1168
1169// Isotope
1170//=====================================================
1171
1172// First init isotope containers
1173function mounthood_init_isotope() {
1174	"use strict";
1175
1176	var all_images_complete = true;
1177
1178	// Check if all images in isotope wrapper are loaded
1179	jQuery('.isotope_wrap:not(.inited)').each(function () {
1180		"use strict";
1181		all_images_complete = all_images_complete && mounthood_check_images_complete(jQuery(this));
1182	});
1183	// Wait for images loading
1184	if (!all_images_complete && MOUNTHOOD_STORAGE['isotope_init_counter']++ < 30) {
1185		setTimeout(mounthood_init_isotope, 200);
1186		return;
1187	}
1188
1189	// Isotope filters handler
1190	jQuery('.isotope_filters:not(.inited)').addClass('inited').on('click', 'a', function(e) {
1191		"use strict";
1192		jQuery(this).parents('.isotope_filters').find('a').removeClass('active');
1193		jQuery(this).addClass('active');
1194	
1195		var selector = jQuery(this).data('filter');
1196		jQuery(this).parents('.isotope_filters').siblings('.isotope_wrap').eq(0).isotope({
1197			filter: selector
1198		});
1199
1200		if (selector == '*')
1201			jQuery('#viewmore_link').fadeIn();
1202		else
1203			jQuery('#viewmore_link').fadeOut();
1204
1205		e.preventDefault();
1206		return false;
1207	});
1208
1209	// Init isotope script
1210	jQuery('.isotope_wrap:not(.inited)').each(function() {
1211		"use strict";
1212
1213		var isotope_container = jQuery(this);
1214
1215		// Init shortcodes
1216		mounthood_sc_init(isotope_container);
1217
1218		// If in scroll container - no init isotope
1219		if (isotope_container.parents('.sc_scroll').length > 0) {
1220			isotope_container.addClass('inited').find('.isotope_item').animate({opacity: 1}, 200, function () { jQuery(this).addClass('isotope_item_show'); });
1221			return;
1222		}
1223
1224		// If in hidden container (in the inactive tab) - return without init
1225		if (jQuery(this).parents('div:hidden,article:hidden').length > 0) return;
1226				
1227		// Init isotope with timeout
1228		setTimeout(function() {
1229			isotope_container.addClass('inited').isotope({
1230				itemSelector: '.isotope_item',
1231				animationOptions: {
1232					duration: 750,
1233					easing: 'linear',
1234					queue: false
1235				}
1236			});
1237	
1238			// Show elements
1239			isotope_container.find('.isotope_item').animate({opacity: 1}, 200, function () { 
1240				jQuery(this).addClass('isotope_item_show'); 
1241			});
1242			
1243			// Resize Alter portfolio elements
1244			mounthood_resize_alter_portfolio();
1245			
1246		}, 500);
1247
1248	});		
1249}
1250
1251function mounthood_init_appended_isotope(posts_container, filters) {
1252	"use strict";
1253	
1254	if (posts_container.parents('.sc_scroll_horizontal').length > 0) return;
1255	
1256	if (!mounthood_check_images_complete(posts_container) && MOUNTHOOD_STORAGE['isotope_init_counter']++ < 30) {
1257		setTimeout(function() { mounthood_init_appended_isotope(posts_container, filters); }, 200);
1258		return;
1259	}
1260	// Add filters
1261	var flt = posts_container.siblings('.isotope_filter');
1262	for (var i in filters) {
1263		if (flt.find('a[data-filter=".flt_'+i+'"]').length == 0) {
1264			flt.append('<a href="#" class="isotope_filters_button" data-filter=".flt_'+i+'">'+filters[i]+'</a>');
1265		}
1266	}
1267	// Init shortcodes in added elements
1268	mounthood_sc_init(posts_container);
1269	// Get added elements
1270	var elems = posts_container.find('.isotope_item:not(.isotope_item_show)');
1271	// Notify isotope about added elements with timeout
1272	setTimeout(function() {
1273		posts_container.isotope('appended', elems);
1274		// Show appended elements
1275		elems.animate({opacity: 1}, 200, function () { jQuery(this).addClass('isotope_item_show'); });
1276	}, 500);
1277}
1278
1279
1280
1281// Post formats init
1282//=====================================================
1283
1284function mounthood_init_post_formats() {
1285	"use strict";
1286
1287	// Call theme specific action (if exists)
1288	if (window.mounthood_theme_init_post_formats) mounthood_theme_init_post_formats();
1289
1290	// MediaElement init
1291	mounthood_init_media_elements(jQuery('body'));
1292	
1293	// Isotope first init
1294	if (jQuery('.isotope_wrap:not(.inited)').length > 0) {
1295		MOUNTHOOD_STORAGE['isotope_init_counter'] = 0;
1296		mounthood_init_isotope();
1297	}
1298
1299	// Hover Effect 'Dir'
1300	if (jQuery('.isotope_wrap .isotope_item_content.square.effect_dir:not(.inited)').length > 0) {
1301		jQuery('.isotope_wrap .isotope_item_content.square.effect_dir:not(.inited)').each(function() {
1302			jQuery(this).addClass('inited').hoverdir();
1303		});
1304	}
1305
1306	// Popup init
1307	if (MOUNTHOOD_STORAGE['popup_engine'] == 'pretty') {
1308		jQuery("a[href$='jpg'],a[href$='jpeg'],a[href$='png'],a[href$='gif']").attr('rel', 'prettyPhoto[slideshow]');
1309		var images = jQuery("a[rel*='prettyPhoto']:not(.inited):not(.esgbox):not([data-rel*='pretty']):not([rel*='magnific']):not([data-rel*='magnific'])").addClass('inited');
1310		try {
1311			images.prettyPhoto({
1312				social_tools: '',
1313				theme: 'facebook',
1314				deeplinking: false
1315			});
1316		} catch (e) {};
1317	} else if (MOUNTHOOD_STORAGE['popup_engine']=='magnific') {
1318		jQuery("a[href$='jpg'],a[href$='jpeg'],a[href$='png'],a[href$='gif']").each(function() {
1319            if (!jQuery(this).parent().hasClass('woocommerce-product-gallery__image'))
1320                jQuery(this).attr('rel', 'magnific');
1321        });
1322		var images = jQuery("a[rel*='magnific']:not(.inited):not(.esgbox):not(.prettyphoto):not([rel*='pretty']):not([data-rel*='pretty'])").addClass('inited');
1323		try {
1324			images.magnificPopup({
1325				type: 'image',
1326				mainClass: 'mfp-img-mobile',
1327				closeOnContentClick: true,
1328				closeBtnInside: true,
1329				fixedContentPos: true,
1330				midClick: true,
1331				//removalDelay: 500, 
1332				preloader: true,
1333				tLoading: MOUNTHOOD_STORAGE['strings']['magnific_loading'],
1334				gallery:{
1335					enabled: true
1336				},
1337				image: {
1338					tError: MOUNTHOOD_STORAGE['strings']['magnific_error'],
1339					verticalFit: true
1340				}
1341			});
1342		} catch (e) {};
1343	}
1344
1345
1346	// Add hover icon to products thumbnails
1347	jQuery(".post_item_product .product .images .woocommerce-product-gallery__image:first a:not(.hover_icon)").addClass('hover_icon hover_icon_view');
1348
1349
1350	// Likes counter
1351	if (jQuery('.post_counters_likes:not(.inited)').length > 0) {
1352		jQuery('.post_counters_likes:not(.inited)')
1353			.addClass('inited')
1354			.on('click', function(e) {
1355				var button = jQuery(this);
1356				var inc = button.hasClass('enabled') ? 1 : -1;
1357				var post_id = button.data('postid');
1358				var likes = Number(button.data('likes'))+inc;
1359				var cookie_likes = mounthood_get_cookie('mounthood_likes');
1360				if (cookie_likes === undefined || cookie_likes===null) cookie_likes = '';
1361				jQuery.post(MOUNTHOOD_STORAGE['ajax_url'], {
1362					action: 'post_counter',
1363					nonce: MOUNTHOOD_STORAGE['ajax_nonce'],
1364					post_id: post_id,
1365					likes: likes
1366				}).done(function(response) {
1367					var rez = {};
1368					try {
1369						rez = JSON.parse(response);
1370					} catch (e) {
1371						rez = { error: MOUNTHOOD_STORAGE['ajax_error'] };
1372						console.log(response);
1373					}
1374					if (rez.error === '') {
1375						if (inc == 1) {
1376							var title = button.data('title-dislike');
1377							button.removeClass('enabled').addClass('disabled');
1378							cookie_likes += (cookie_likes.substr(-1)!=',' ? ',' : '') + post_id + ',';
1379						} else {
1380							var title = button.data('title-like');
1381							button.removeClass('disabled').addClass('enabled');
1382							cookie_likes = cookie_likes.replace(','+post_id+',', ',');
1383						}
1384						button.data('likes', likes).attr('title', title).find('.post_counters_number').html(likes);
1385						mounthood_set_cookie('mounthood_likes', cookie_likes, 365);
1386					} else {
1387						mounthood_message_warning(MOUNTHOOD_STORAGE['strings']['error_like']);
1388					}
1389				});
1390				e.preventDefault();
1391				return false;
1392			});
1393	}
1394
1395	// Social share links
1396	if (jQuery('.sc_socials_share:not(.inited)').length > 0) {
1397		jQuery('.sc_socials_share:not(.inited)').each(function() {
1398			"use strict";
1399			jQuery(this).addClass('inited').on('click', '.social_item_popup > a.social_icons', function(e) {
1400				"use strict";
1401				var url = jQuery(this).data('link');
1402				window.open(url, '_blank', 'scrollbars=0, resizable=1, menubar=0, left=100, top=100, width=480, height=400, toolbar=0, status=0');
1403				e.preventDefault();
1404				return false;
1405			});
1406		});
1407	}
1408
1409	// Add video on thumb click
1410	if (jQuery('.sc_video_play_button:not(.inited)').length > 0) {
1411		jQuery('.sc_video_play_button:not(.inited)').each(function() {
1412			"use strict";
1413			jQuery(this)
1414				.addClass('inited')
1415				.animate({opacity: 1}, 1000)
1416				.on('click', function (e) {
1417					"use strict";
1418					if (!jQuery(this).hasClass('sc_video_play_button')) return;
1419					var video = jQuery(this).removeClass('sc_video_play_button hover_icon icon-play-outline').data('video');
1420					if (video!=='') {
1421						jQuery(this).empty().html(video);
1422						mounthood_video_dimensions();
1423						var video_tag = jQuery(this).find('video');
1424						var w = video_tag.width();
1425						var h = video_tag.height();
1426						mounthood_init_media_elements(jQuery(this));
1427						// Restore WxH attributes, because Chrome broke it!
1428						jQuery(this).find('video').css({'width':w, 'height': h}).attr({'width':w, 'height': h});
1429					}
1430					e.preventDefault();
1431					return false;
1432				});
1433		});
1434	}
1435}
1436
1437
1438function mounthood_init_media_elements(cont) {
1439	if (MOUNTHOOD_STORAGE['media_elements_enabled'] && cont.find('audio,video').length > 0) {
1440		if (window.mejs) {
1441			window.mejs.MepDefaults.enableAutosize = false;
1442			window.mejs.MediaElementDefaults.enableAutosize = false;
1443			cont.find('audio:not(.wp-audio-shortcode),video:not(.wp-video-shortcode)').each(function() {
1444				if (jQuery(this).parents('.mejs-mediaelement').length == 0) {
1445					var media_tag = jQuery(this);
1446					var settings = {
1447						enableAutosize: true,
1448						videoWidth: -1,		// if set, overrides <video width>
1449						videoHeight: -1,	// if set, overrides <video height>
1450						audioWidth: '100%',	// width of audio player
1451						audioHeight: 30,	// height of audio player
1452						success: function(mejs) {
1453							var autoplay, loop;
1454							if ( 'flash' === mejs.pluginType ) {
1455								autoplay = mejs.attributes.autoplay && 'false' !== mejs.attributes.autoplay;
1456								loop = mejs.attributes.loop && 'false' !== mejs.attributes.loop;
1457								autoplay && mejs.addEventListener( 'canplay', function () {
1458									mejs.play();
1459								}, false );
1460								loop && mejs.addEventListener( 'ended', function () {
1461									mejs.play();
1462								}, false );
1463							}
1464							media_tag.parents('.sc_audio,.sc_video').addClass('inited sc_show');
1465						}
1466					};
1467					jQuery(this).mediaelementplayer(settings);
1468				}
1469			});
1470		} else
1471			setTimeout(function() { mounthood_init_media_elements(cont); }, 400);
1472	}
1473}
1474
1475
1476
1477
1478
1479
1480// Popups and system messages
1481//==============================================
1482
1483// Show system message (bubble from previous page)
1484function mounthood_show_system_message() {
1485	if (MOUNTHOOD_STORAGE['system_message'] && MOUNTHOOD_STORAGE['system_message']['message']) {
1486		if (MOUNTHOOD_STORAGE['system_message']['status'] == 'success')
1487			mounthood_message_success(MOUNTHOOD_STORAGE['system_message']['message'], MOUNTHOOD_STORAGE['system_message']['header']);
1488		else if (MOUNTHOOD_STORAGE['system_message']['status'] == 'info')
1489			mounthood_message_info(MOUNTHOOD_STORAGE['system_message']['message'], MOUNTHOOD_STORAGE['system_message']['header']);
1490		else if (MOUNTHOOD_STORAGE['system_message']['status'] == 'error' || MOUNTHOOD_STORAGE['system_message']['status'] == 'warning')
1491			mounthood_message_warning(MOUNTHOOD_STORAGE['system_message']['message'], MOUNTHOOD_STORAGE['system_message']['header']);
1492	}
1493}
1494
1495// Toggle popups
1496function mounthood_toggle_popup(popup) {
1497	if (popup.css('display')!='none')
1498		mounthood_hide_popup(popup);
1499	else
1500		mounthood_show_popup(popup);
1501}
1502
1503// Show popups
1504function mounthood_show_popup(popup) {
1505	if (popup.css('display')=='none') {
1506		if (false && MOUNTHOOD_STORAGE['css_animation'])
1507			popup.show().removeClass('animated fast '+MOUNTHOOD_STORAGE['menu_animation_out']).addClass('animated fast '+MOUNTHOOD_STORAGE['menu_animation_in']);
1508		else
1509			popup.slideDown();
1510	}
1511}
1512
1513// Hide popups
1514function mounthood_hide_popup(popup) {
1515	if (popup.css('display')!='none') {
1516		if (false && MOUNTHOOD_STORAGE['css_animation'])
1517			popup.removeClass('animated fast '+MOUNTHOOD_STORAGE['menu_animation_in']).addClass('animated fast '+MOUNTHOOD_STORAGE['menu_animation_out']).delay(500).hide();
1518		else
1519			popup.fadeOut();
1520	}
1521}

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.