PageSourceSearch

https://biloskimiller.com/wp-content/themes/lawoffice/js/_front.js

js biloskimiller.com collected 2026-10-09 04:12:45 UTC 63,876 bytes, 1,849 lines download raw bytes

1/* global jQuery:false */
2
3// Max scale factor for the portfolio and other isotope elements before relayout
4var THEMEREX_isotope_resize_delta = 0.3;
5
6
7// Internal vars - do not change it!
8var THEMEREX_ADMIN_MODE    = false;
9var THEMEREX_error_msg_box = null;
10var THEMEREX_VIEWMORE_BUSY = false;
11var THEMEREX_video_resize_inited = false;
12var THEMEREX_top_height = 0;
13var THEMEREX_use_fixed_wrapper = true;
14var THEMEREX_theme_init_counter = 0;
15
16jQuery(document).ready(function () {
17		"use strict";
18	themerex_init_actions();
19});
20
21function themerex_init_actions() {
22	"use strict";
23
24	if (THEMEREX_vc_edit_mode && jQuery('.vc_empty-placeholder').length==0 && THEMEREX_theme_init_counter++ < 30) {
25		setTimeout(themerex_init_actions, 200);
26		return;
27	}
28
29		timelineResponsive();
30		ready();
31		timelineScrollFix();
32		itemPageFull();
33		mainMenuResponsive();
34		scrollAction();
35		calcMenuColumnsWidth();
36		resizeVideoBackground();
37		REX_parallax();
38		InitPopupMenu();
39		smLeftPos();
40        setTimeout(TeamColHeight(),300);
41
42	// Resize handlers
43	jQuery(window).resize(function () {
44		"use strict";
45		timelineResponsive();
46		fullSlider();
47		resizeSliders();
48		itemPageFull();
49		mainMenuResponsive();
50		scrollAction();
51		resizeVideoBackground();
52		REX_parallax();
53		InitPopupMenu();
54		smLeftPos();
55		maxHeightSidemenuUL();
56	});
57
58	// Scroll handlers
59	jQuery(window).scroll(function () {
60		"use strict";
61		timelineScrollFix();
62		scrollAction();
63		REX_parallax();
64	});
65};
66
67
68
69function ready() {
70	"use strict";
71
72	// Show system message
73	if (THEMEREX_systemMessage.message) {
74		if (THEMEREX_systemMessage.status == 'success')
75			themerex_message_success(THEMEREX_systemMessage.message, THEMEREX_systemMessage.header);
76		else if (THEMEREX_systemMessage.status == 'info')
77			themerex_message_info(THEMEREX_systemMessage.message, THEMEREX_systemMessage.header);
78		else if (THEMEREX_systemMessage.status == 'error' || THEMEREX_systemMessage.status == 'warning')
79			themerex_message_warning(THEMEREX_systemMessage.message, THEMEREX_systemMessage.header);
80	}
81	
82	// Top menu height
83	THEMEREX_top_height = jQuery('header .topWrap').height();
84	jQuery('.topWrapFixed').css('backgroundColor', jQuery('.topWrap').css('backgroundColor'));
85	THEMEREX_use_fixed_wrapper = jQuery('.topWrapFixed').parents('.fullScreenSlider').length == 0 || !jQuery('.topWrapFixed').parent().next().hasClass('sliderHomeBullets');
86	
87	// Close all dropdown elements
88	jQuery(document).click(function (e) {
89		"use strict";
90		jQuery('.pageFocusBlock').slideUp();
91		jQuery('.inputSubmitAnimation:not(.opened)').removeClass('sFocus rad4').addClass('radCircle', 100);
92		jQuery('ul.shareDrop').slideUp().siblings('a.shareDrop').removeClass('selected');
93	});
94
95	// Calendar handlers - change months
96	jQuery('.widget_calendar').on('click', '.prevMonth a, .nextMonth a', function(e) {
97		"use strict";
98		var calendar = jQuery(this).parents('.wp-calendar');
99		var m = jQuery(this).data('month');
100		var y = jQuery(this).data('year');
101		var pt = jQuery(this).data('type');
102		jQuery.post(THEMEREX_ajax_url, {
103			action: 'calendar_change_month',
104			nonce: THEMEREX_ajax_nonce,
105			month: m,
106			year: y,
107			post_type: pt
108		}).done(function(response) {
109			var rez = JSON.parse(response);
110			if (rez.error === '') {
111				calendar.parent().fadeOut(200, function() {
112					jQuery(this).empty().append(rez.data).fadeIn(200);
113				});
114			}
115		});
116		e.preventDefault();
117		return false;
118	});
119
120	// Tabs for top widgets
121	if (jQuery('.widgetTabs').length > 0) {
122
123		// Collect widget's headers into tabs
124		var THEMEREX_top_tabs = '';
125		var THEMEREX_top_tabs_counter = 0;
126		jQuery('.widgetTop .titleHide').each(function () {
127			"use strict";
128			THEMEREX_top_tabs_counter++;
129			var id = jQuery(this).parents('.widgetTop').attr('id');
130			var title = jQuery(this).text();
131			if (title=='') title = '#'+THEMEREX_top_tabs_counter;
132			THEMEREX_top_tabs += '<li><a href="#'+id+'"><span>'+title+'</span></a></li>';
133		});
134		jQuery('.widgetTabs .tabsButton ul').append(THEMEREX_top_tabs);
135	
136		// Break lists in top widgets on two parts
137		jQuery('.widgetTop > ul:not(.tabs),.widgetTop > div > ul:not(.tabs)').each(function () {
138			"use strict";
139			var ul2 = jQuery(this).clone();
140			var li = jQuery(this).find('>li');
141			var middle = Math.ceil(li.length/2)-1;
142			li.eq(middle).nextAll().remove();
143			ul2.find('>li').eq(middle+1).prevAll().remove();
144			jQuery(this).after(ul2);
145		});
146		
147		// Init tabs
148		jQuery('.widgetTabs').tabs({
149			show: {
150				effect: 'drop',
151				direction: 'right',
152				duration: 500
153			},
154			hide: {
155				effect: 'drop',
156				direction: 'left',
157				duration: 500
158			},
159			activate: function (event, ui) {
160				"use strict";
161				initShortcodes(ui.newPanel);
162			}
163		});
164	}
165
166	// Add bookmarks
167	if (jQuery('#tabsFavorite').length > 0) {
168		jQuery('.addBookmark').click(function(e) {
169			"use strict";
170			var title = window.document.title.split('|')[0];
171			var url = window.location.href;
172			var list = jQuery.cookie('themerex_bookmarks');
173			var exists = false;
174			if (list) {
175				list = JSON.parse(list);
176				for (var i=0; i<list.length; i++) {
177					if (list[i].url == url) {
178						exists = true;
179						break;
180					}
181				}
182			} else
183				list = new Array();
184			if (!exists) {
185				var THEMEREX_message_popup = themerex_message_dialog('<label for="bookmark_title">'+THEMEREX_MESSAGE_BOOKMARK_TITLE+'</label><br><input type="text" id="bookmark_title" name="bookmark_title" value="'+title+'">', THEMEREX_MESSAGE_BOOKMARK_ADD, null,
186					function(btn, popup) {
187						"use strict";
188						if (btn != 1) return;
189						title = THEMEREX_message_popup.find('#bookmark_title').val();
190						list.push({title: title, url: url});
191						jQuery('.listBookmarks').append('<li><a href="'+url+'">'+title+'</a><a href="#" class="delBookmark icon-cancel"></a></li>');
192						jQuery.cookie('themerex_bookmarks', JSON.stringify(list), {expires: 365, path: '/'});
193						if (THEMEREX_Swipers['bookmarks_scroll']!==undefined) THEMEREX_Swipers['bookmarks_scroll'].reInit();
194						setTimeout(function () {themerex_message_success(THEMEREX_MESSAGE_BOOKMARK_ADDED, THEMEREX_MESSAGE_BOOKMARK_ADD);}, THEMEREX_MESSAGE_TIMEOUT/4);
195					});
196			} else
197				themerex_message_warning(THEMEREX_MESSAGE_BOOKMARK_EXISTS, THEMEREX_MESSAGE_BOOKMARK_ADD);
198			e.preventDefault();
199			return false;
200		});
201		// Delete bookmarks
202		jQuery('.listBookmarks').on('click', '.delBookmark', function(e) {
203			"use strict";
204			var idx = jQuery(this).parent().index();
205			var list = jQuery.cookie('themerex_bookmarks');
206			if (list) {
207				list = JSON.parse(list);
208				list.splice(idx, 1);
209				jQuery.cookie('themerex_bookmarks', JSON.stringify(list), {expires: 365, path: '/'});
210			}
211			jQuery(this).parent().remove();
212			e.preventDefault();
213			return false;
214		});
215		// Sort bookmarks
216		jQuery('.listBookmarks').sortable({
217			items: "li",
218			update: function(event, ui) {
219				"use strict";
220				var list = new Array();
221				ui.item.parent().find('li').each(function() {
222					var a = jQuery(this).find('a:not(.delBookmark)').eq(0);
223					list.push({title: a.text(), url: a.attr('href')});
224				});
225				jQuery.cookie('themerex_bookmarks', JSON.stringify(list), {expires: 365, path: '/'});
226			}
227		}).disableSelection();
228	}
229
230
231	// Scroll to top
232	jQuery('.upToScroll .scrollToTop').click(function(e) {
233		"use strict";
234		jQuery('html,body').animate({
235			scrollTop: 0
236		}, 'slow');
237		e.preventDefault();
238		return false;
239	});
240
241
242	// Decorate nested lists in widgets and sidemenu
243	jQuery('.widgetWrap ul > li,.panelmenu_area ul > li,.widgetTop ul > li').each(function () {
244		if (jQuery(this).find('ul').length > 0) {
245			jQuery(this).addClass('dropMenu');
246		}
247	});
248	jQuery('.widgetWrap ul > li.dropMenu,.panelmenu_area ul > li.dropMenu,.widgetTop ul > li.dropMenu').click(function (e) {
249		"use strict";
250		jQuery(this).toggleClass('dropOpen');
251		jQuery(this).find('ul').first().slideToggle(200, function() {
252			if (jQuery(this).parents('.sidemenu_area').length > 0) {
253				THEMEREX_Swipers['sidemenu_scroll'].reInit();
254			}
255			else if (jQuery(this).parents('.panelmenu_area').length > 0)
256				THEMEREX_Swipers['panelmenu_scroll'].reInit();
257		});
258		e.preventDefault();
259		return false;
260	});
261	jQuery('.widgetWrap ul:not(.tabs) li > a,.sidemenu_area ul:not(.tabs) li > a,.panelmenu_area ul:not(.tabs) li > a,.widgetTop ul:not(.tabs) li > a').click(function (e) {
262		"use strict";
263		if (jQuery(this).attr('href')!='#') {
264			e.stopImmediatePropagation();
265			if (jQuery(this).parent().hasClass('menu-item-has-children') && jQuery(this).parents('.sidemenu_area,.panelmenu_area').length > 0) {
266				jQuery(this).parent().trigger('click');
267				e.preventDefault();
268				return false;
269			}
270		}
271	});
272
273
274	// Archive widget decoration
275	jQuery('.widget_archive a').each(function () {
276		var val = jQuery(this).html().split(' ');
277		if (val.length > 1) {
278			val[val.length-1] = '<span>' + val[val.length-1] + '</span>';
279			jQuery(this).html(val.join(' '))
280		}
281	});
282
283	//video bg
284	if (jQuery('.videoBackground').length > 0) {
285		jQuery('.videoBackground').each(function () {
286			var youtube = jQuery(this).data('youtube-code');
287			if (youtube) {
288				jQuery(this).tubular({videoId: youtube});
289			}
290		});
291	}
292	
293	//isotope
294	if (jQuery('.isotopeNOanim,.isotope').length > 0) {
295
296		initIsotope();
297
298		try {
299			jQuery(window).smartresize(resizeIsotope);
300		} catch (e) {
301			jQuery(window).resize(resizeIsotope);
302		}
303
304		//isotope filter
305		jQuery('.isotopeFiltr').on('click', 'li a', function (e) {
306			"use strict";
307			jQuery(this).parents('.isotopeFiltr').find('li').removeClass('active');
308			jQuery(this).parent().addClass('active');
309	
310			var selector = jQuery(this).data('filter');
311			jQuery(this).parents('.isotopeFiltr').siblings('.isotope').eq(0).isotope({
312				filter: selector
313			});
314			
315			if (selector == '*')
316				jQuery('#viewmore_link').fadeIn();
317			else
318				jQuery('#viewmore_link').fadeOut();
319
320			e.preventDefault();
321			return false;
322		});
323
324	}
325
326	// main Slider
327	if (jQuery('.sliderBullets, .sliderHomeBullets').length > 0) {
328		if (jQuery.rsCSS3Easing!=undefined && jQuery.rsCSS3Easing!=null) {
329			jQuery.rsCSS3Easing.easeOutBack = 'cubic-bezier(0.175, 0.885, 0.320, 1.275)';
330		}
331		// Show Slider
332		jQuery('.sliderHomeBullets').slideDown(200, function () {
333			"use strict";
334			REX_parallax();
335			fullSlider();
336			initShortcodes(jQuery(this));
337			// Hack for the Royal Slider
338			if (jQuery('body').hasClass('boxed')) { jQuery(this).trigger('resize'); }
339		});
340	}
341
342	//fullScreen effect for Main Slider
343	var homeSlider = jQuery('.sliderHomeBullets');
344	if (homeSlider.length > 0 && homeSlider.hasClass('slider_engine_royal')) {
345		var slideContent = homeSlider.find('.slideContent').eq(0);
346		slideContent.addClass('sliderBGanima ' + slideContent.data('effect'));
347		setTimeout(checkFullSlider, 500);
348	}
349
350	// Page Navigation
351	jQuery('.pageFocusBlock').click(function (e) {
352		"use strict";
353		if (e.target.nodeName.toUpperCase()!='A') {
354			e.preventDefault();
355			return false;
356		}
357	});
358	jQuery('.navInput').click(function (e) {
359		"use strict";
360		jQuery('.pageFocusBlock').slideDown(300, function () {
361			initShortcodes(jQuery('.pageFocusBlock').eq(0));
362		});
363		e.preventDefault();
364		return false;
365	});
366
367
368	// Responsive Show menu
369	jQuery('.openResponsiveMenu').click(function(e){
370		"use strict";
371		jQuery('.menuTopWrap').slideToggle()
372		e.preventDefault();
373		return false;
374	});
375
376
377	// Main Menu
378	initSfMenu('.menuTopWrap > ul#mainmenu, .usermenu_area ul.usermenu_list');
379	// Enable click on root menu items (without submenu) in iOS
380	if (isiOS()) {
381		jQuery('#mainmenu li:not(.menu-item-has-children) > a').on('click touchend', function (e) {
382			"use strict";
383			if (jQuery(this).attr('href')!='#') {
384				window.location.href = jQuery(this).attr('href');
385			}
386		});
387		jQuery('#mainmenu li.menu-item-has-children > a').hover(
388			function (e) {
389				"use strict";
390				if (jQuery('body').hasClass('responsive_menu')) {
391					jQuery(this).trigger('click');
392				}
393			},
394			function () {}
395			);
396	}
397	// Submenu click handler
398	jQuery('.menuTopWrap ul li a, .usermenu_area ul.usermenu_list li a').click(function(e) {
399		"use strict";
400		if ((THEMEREX_responsive_menu_click || isMobile()) && jQuery('body').hasClass('responsive_menu') && jQuery(this).parent().hasClass('menu-item-has-children')) {
401			if (jQuery(this).siblings('ul:visible').length > 0)
402				jQuery(this).siblings('ul').slideUp();
403			else
404				jQuery(this).siblings('ul').slideDown();
405		}
406		if (jQuery(this).attr('href')=='#' || (jQuery('body').hasClass('responsive_menu') && jQuery(this).parent().hasClass('menu-item-has-children'))) {
407			e.preventDefault();
408			return false;
409		}
410	});
411	
412	// Show table of contents for the current page
413	if (THEMEREX_menu_toc!='no') {
414		buildPageTOC();
415	}
416	// One page mode for menu links (scroll to anchor)
417	jQuery('#toc, .menuTopWrap ul li, .usermenu_area ul.usermenu_list li').on('click', 'a', function(e) {
418		"use strict";
419		var href = jQuery(this).attr('href');
420		var pos = href.indexOf('#');
421		if (pos < 0 || href.length == 1) return;
422		var loc = window.location.href;
423		var pos2 = loc.indexOf('#');
424		if (pos2 > 0) loc = loc.substring(0, pos2);
425		var now = pos==0;
426		if (!now) now = loc == href.substring(0, pos);
427		if (now) {
428			animateTo(href.substr(pos));
429			setLocation(pos==0 ? loc + href : href);
430			e.preventDefault();
431			return false;
432		}
433	});
434
435	// Open sidemenu
436	jQuery('.sidemenu_button, #sidemenu_button').click(function (e) {
437		"use strict";
438		jQuery('body').addClass('openMenuFix');
439
440		if (jQuery(this).length > 0) THEMEREX_Swipers['sidemenu_scroll'].reInit();
441
442		setTimeout(function(){},200);
443
444		maxHeightSidemenuUL();
445
446		e.preventDefault();
447		return false;
448	});
449
450	// Close sidemenu and right panel
451	jQuery(document).on('click', '.sidemenu_overflow', function (e) {
452		"use strict";
453		jQuery('body').removeClass('openMenuFixRight openMenuFix');
454		if (!isMobile()) jQuery('.swpRightPosButton').fadeIn(400);
455		jQuery('.sidemenu_overflow').fadeOut(400);
456	});
457
458	jQuery(document).on('click', '.sidemenu_close', function (e) {
459		"use strict";
460		jQuery('body').removeClass('openMenuFix');
461	});
462
463	// Open right menu
464	jQuery('.openRightMenu,.swpRightPosButton').click(function (e) {
465		"use strict";
466		if (jQuery('body').hasClass('openMenuFixRight')) {
467			jQuery('body').removeClass('openMenuFixRight');
468			if (!isMobile()) jQuery('.swpRightPosButton').fadeIn(400);
469			jQuery('.sidemenu_overflow').fadeOut(400);
470		} else {
471			jQuery('body').addClass('openMenuFixRight');
472			if (jQuery('.sidemenu_overflow').length == 0) {
473				jQuery('body').append('<div class="sidemenu_overflow"></div>')
474			}
475			if (!isMobile()) jQuery('.swpRightPosButton').fadeOut(400);
476			jQuery('.sidemenu_overflow').fadeIn(400);
477		}
478		e.preventDefault();
479		return false;
480	});
481
482	// Demo right panel
483	var showed = false;
484	if (!showed && THEMEREX_demo_time > 0 && jQuery(window).width() > 800 && jQuery('.openRightMenu,.swpRightPosButton').length > 0) {
485		showed = jQuery.cookie('themerex_demo_rightpanel');
486		if (!showed) {
487			var btn = '';
488			if (jQuery('.openRightMenu').length > 0)
489				btn = '.openRightMenu';
490			else if (jQuery('.swpRightPosButton').length > 0)
491				btn = '.swpRightPosButton';
492			if (btn) {
493				jQuery.cookie('themerex_demo_rightpanel', "1", {expires: 7, path: '/'});
494				setTimeout(function () {
495					jQuery(btn).trigger('click');
496					setTimeout(function() { jQuery('.sidemenu_overflow').trigger('click'); }, THEMEREX_demo_time);
497				}, THEMEREX_demo_time);
498			}
499
500			jQuery('body').removeClass('openMenuFixRight openMenuFix');
501			if (!isMobile()) jQuery('.swpRightPosButton').fadeIn(400);
502			jQuery('.sidemenu_overflow').fadeOut(400);
503		}
504	}
505
506
507	// search
508	jQuery('.topWrap .search').click(function (e) {
509		"use strict";
510		if (jQuery(this).hasClass('searchOpen')) {
511			if (e.target.nodeName.toUpperCase()!='INPUT' && e.target.nodeName.toUpperCase()!='A') {
512				jQuery('.topWrap .search .searchForm').animate({'width': 'hide'}, 200);
513				jQuery('.topWrap .ajaxSearchResults').fadeOut();
514				setTimeout(function() {
515					jQuery('header').removeClass('topSearchShow');
516				},250);
517				jQuery('.topWrap .search').removeClass('searchOpen');
518				e.preventDefault();
519				return false;
520			}
521		} else {
522			jQuery(this).find('.searchForm').animate({'width': 'show'}, 200);
523			jQuery('header').delay(200).addClass('topSearchShow')
524			jQuery(this).delay(200).toggleClass('searchOpen');
525			e.preventDefault();
526			return false;
527		}
528	});
529	jQuery('.topWrap .search').on('click', '.searchSubmit,.post_more', function (e) {
530		"use strict";
531		if (jQuery('.topWrap .searchField').val() != '')
532			jQuery('.topWrap .searchForm form').get(0).submit();
533		e.preventDefault();
534		return false;
535	});
536	jQuery('.search-form').on('click', '.search-button a', function (e) {
537		"use strict";
538		if (jQuery(this).parents('.search-form').find('input[name="s"]').val() != '')
539			jQuery(this).parents('.search-form').get(0).submit();
540		e.preventDefault();
541		return false;
542	});
543	// AJAX search
544	if (THEMEREX_useAJAXSearch) {
545		var THEMEREX_ajax_timer = null;
546		jQuery('.topWrap .searchField').keyup(function (e) {
547			"use strict";
548			var s = jQuery(this).val();
549			if (THEMEREX_ajax_timer) {
550				clearTimeout(THEMEREX_ajax_timer);
551				THEMEREX_ajax_timer = null;
552			}
553			if (s.length >= THEMEREX_AJAXSearch_min_length) {
554				THEMEREX_ajax_timer = setTimeout(function () {
555					jQuery.post(THEMEREX_ajax_url, {
556						action: 'ajax_search',
557						nonce: THEMEREX_ajax_nonce,
558						text: s
559					}).done(function(response) {
560						clearTimeout(THEMEREX_ajax_timer);
561						THEMEREX_ajax_timer = null;
562						var rez = JSON.parse(response);
563						if (rez.error === '') {
564							jQuery('.topWrap .ajaxSearchResults').empty().append(rez.data).fadeIn();
565						} else {
566							themerex_message_warning(THEMEREX_MESSAGE_SEARCH_ERROR);
567						}
568					});
569				}, THEMEREX_AJAXSearch_delay);
570			}
571		});
572	}
573
574	// search 404
575	jQuery('.inputSubmitAnimation').click(function (e) {
576		"use strict";
577		e.preventDefault();
578		return false;
579	});
580	jQuery('.inputSubmitAnimation a').click(function (e) {
581		"use strict";
582		var form = jQuery(this).siblings('form');
583		var parent = jQuery(this).parents('.inputSubmitAnimation');
584		if (parent.hasClass('sFocus')) {
585			if (form.length>0 && form.find('input').val()!='') {
586				if (jQuery(this).hasClass('sc_emailer_button')) {
587					var group = jQuery(this).data('group');
588					var email = form.find('input').val();
589					var regexp = new RegExp(THEMEREX_EMAIL_MASK);
590					if (!regexp.test(email)) {
591						form.find('input').get(0).focus();
592						themerex_message_warning(THEMEREX_EMAIL_NOT_VALID);
593					} else {
594						jQuery.post(THEMEREX_ajax_url, {
595							action: 'emailer_submit',
596							nonce: THEMEREX_ajax_nonce,
597							group: group,
598							email: email
599						}).done(function(response) {
600							var rez = JSON.parse(response);
601							if (rez.error === '') {
602								themerex_message_info(THEMEREX_MESSAGE_EMAIL_CONFIRM.replace('%s', email));
603								form.find('input').val('');
604							} else {
605								themerex_message_warning(rez.error);
606							}
607						});
608					}
609				} else
610					form.get(0).submit();
611			} else
612				jQuery(document).trigger('click');
613		} else {
614			parent.addClass('sFocus rad4').removeClass('radCircle');
615		}
616		e.preventDefault();
617		return false;
618	});
619
620	//Portfolio item Description
621	if (isMobile()) {	// if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) {
622		jQuery('.toggleButton').show();
623		jQuery('.itemDescriptionWrap,.toggleButton').click(function (e) {
624			"use strict";
625			jQuery(this).toggleClass('descriptionShow');
626			jQuery(this).find('.toggleDescription').slideToggle();
627			e.preventDefault();
628			return false;
629		});
630	} else {
631		jQuery('.itemDescriptionWrap').hover(function () {
632			"use strict";
633			jQuery(this).toggleClass('descriptionShow');
634			jQuery(this).find('.toggleDescription').slideToggle();
635		});
636	}
637
638	// Save placeholder for input fields
639	jQuery('.formList input[type="text"], .formList input[type="password"]')
640		.focus(function () {
641			"use strict";
642			jQuery(this).attr('data-placeholder', jQuery(this).attr('placeholder')).attr('placeholder', '')
643			jQuery(this).parent('li').addClass('iconFocus');
644		})
645		.blur(function () {
646			"use strict";
647			jQuery(this).attr('placeholder', jQuery(this).attr('data-placeholder'))
648			jQuery(this).parent('li').removeClass('iconFocus');
649		});
650
651	// Hide empty pagination
652	if (jQuery('#nav_pages > ul > li').length < 3) {
653		jQuery('#nav_pages').remove();
654	} else {
655		jQuery('.theme_paginaton a').addClass('theme_button');
656	}
657
658	// View More button
659	jQuery('#viewmore_link').click(function(e) {
660		"use strict";
661		if (!THEMEREX_VIEWMORE_BUSY) {
662			jQuery(this).addClass('loading');
663			THEMEREX_VIEWMORE_BUSY = true;
664			jQuery.post(THEMEREX_ajax_url, {
665				action: 'view_more_posts',
666				nonce: THEMEREX_ajax_nonce,
667				page: THEMEREX_VIEWMORE_PAGE+1,
668				data: THEMEREX_VIEWMORE_DATA,
669				vars: THEMEREX_VIEWMORE_VARS
670			}).done(function(response) {
671				"use strict";
672				var rez = JSON.parse(response);
673				jQuery('#viewmore_link').removeClass('loading');
674				THEMEREX_VIEWMORE_BUSY = false;
675				if (rez.error === '') {
676					var posts_container = jQuery('.content').eq(0);
677					if (posts_container.find('aside#tabBlog').length > 0)		posts_container = posts_container.find('aside#tabBlog').eq(0);
678					if (posts_container.find('section.masonry').length > 0)		posts_container = posts_container.find('section.masonry').eq(0);
679					if (posts_container.find('section.portfolio').length > 0)	posts_container = posts_container.find('section.portfolio').eq(0);
680					if (posts_container.hasClass('masonry') || posts_container.hasClass('portfolio')) {
681						posts_container.data('last-width', 0).append(rez.data);
682						THEMEREX_isotopeInitCounter = 0;
683						initAppendedIsotope(posts_container, rez.filters);
684					} else
685						jQuery('#viewmore').before(rez.data);
686
687					timelineResponsive();
688					timelineScrollFix();
689					itemPageFull();
690					initPostFormats();
691					initShortcodes(posts_container);
692					scrollAction();
693
694					THEMEREX_VIEWMORE_PAGE++;
695					if (rez.no_more_data==1) {
696						jQuery('#viewmore').hide();
697					}
698					if (jQuery('#nav_pages ul li').length >= THEMEREX_VIEWMORE_PAGE) {
699						jQuery('#nav_pages ul li').eq(THEMEREX_VIEWMORE_PAGE).toggleClass('pager_current', true);
700					}
701				}
702			});
703		}
704		e.preventDefault();
705		return false;
706	});
707
708	// Infinite pagination
709	if (jQuery('#viewmore.pagination_infinite').length > 0) {
710		jQuery(window).scroll(infiniteScroll);
711	}
712
713
714	// WooCommerce handlers
715	jQuery('.woocommerce .mode_buttons a,.woocommerce-page .mode_buttons a').click(function(e) {
716		"use strict";
717		var mode = jQuery(this).hasClass('woocommerce_thumbs') ? 'thumbs' : 'list';
718		jQuery.cookie('themerex_shop_mode', mode, {expires: 365, path: '/'});
719		jQuery(this).siblings('input').val(mode).parents('form').get(0).submit();
720		e.preventDefault();
721		return false;
722	});
723	// Added to cart
724	jQuery('body').bind('added_to_cart', function() {
725		// Update amount on the cart button
726		var total = jQuery('.usermenu_cart .total .amount').text()
727		if (total != undefined) {
728			jQuery('.cart_button .cart_total').text(total);
729		}
730	});
731		
732	// Sound effects init
733	if (THEMEREX_sound_enable) {
734		// Load state
735		var snd = jQuery.cookie('themerex_sounds');
736		if (snd != undefined) {
737			try {
738				snd = JSON.parse(snd);
739			} catch (e) {}
740			if (typeof snd == 'object') {
741				THEMEREX_sound_state = snd;
742			}
743		}
744		if (!THEMEREX_sound_state.all)			jQuery('.usermenu_sound > a').removeClass('icon-volume').addClass('icon-volume-off-1');
745		if (!THEMEREX_sound_state.mainmenu)		jQuery('.usermenu_sound > ul > li > a.sound_mainmenu').removeClass('icon-check').addClass('icon-dot');
746		if (!THEMEREX_sound_state.othermenu)	jQuery('.usermenu_sound > ul > li > a.sound_othermenu').removeClass('icon-check').addClass('icon-dot');
747		if (!THEMEREX_sound_state.buttons)		jQuery('.usermenu_sound > ul > li > a.sound_buttons').removeClass('icon-check').addClass('icon-dot');
748		if (!THEMEREX_sound_state.links)		jQuery('.usermenu_sound > ul > li > a.sound_links').removeClass('icon-check').addClass('icon-dot');
749		// Init sounds
750		var THEMEREX_sounds = [];
751		soundManager.setup({
752			// location: path to SWF files, as needed (SWF file name is appended later.)
753			url: THEMEREX_sound_folder,
754			
755			// optional: version of SM2 flash audio API to use (8 or 9; default is 8 if omitted, OK for most use cases.)
756			// flashVersion: 9,
757			
758			// optional: use Flash for MP3/MP4/AAC formats, even if HTML5 support present. useful if HTML5 is quirky.
759			//preferFlash: true,
760			
761			// use soundmanager2-nodebug-jsmin.js, or disable debug mode (enabled by default) after development/testing
762			debugMode: false,
763			
764			// good to go: the onready() callback
765			onready: function() {
766				"use strict";
767				// SM2 has started - now you can create and play sounds!
768				if (THEMEREX_sound_mainmenu) {
769					THEMEREX_sounds['mainmenu'] = soundManager.createSound({
770						id: 'sound_mainmenu', // optional: an id will be generated if not provided.
771						url: THEMEREX_sound_mainmenu
772						// onload: function() { console.log('sound loaded!', this); }
773						// other options here..
774					});
775				}
776				if (THEMEREX_sound_othermenu) {
777					THEMEREX_sounds['othermenu'] = soundManager.createSound({
778						id: 'sound_othermenu', // optional: an id will be generated if not provided.
779						url: THEMEREX_sound_othermenu
780					});
781				}
782				if (THEMEREX_sound_buttons) {
783					THEMEREX_sounds['buttons'] = soundManager.createSound({
784						id: 'sound_buttons', // optional: an id will be generated if not provided.
785						url: THEMEREX_sound_buttons
786					});
787				}
788				if (THEMEREX_sound_links) {
789					THEMEREX_sounds['links'] = soundManager.createSound({
790						id: 'sound_links', // optional: an id will be generated if not provided.
791						url: THEMEREX_sound_links
792					});
793				}
794			},
795			
796			// optional: ontimeout() callback for handling start-up failure, flash required but blocked, etc.
797			ontimeout: function() {
798				"use strict";
799				// Hrmm, SM2 could not start. Missing SWF? Flash blocked? Show an error, etc.?
800				// See the flashblock demo when you want to start getting fancy.
801			}
802		});
803		var sounded_objects = 'a,button,.sc_accordion_title,.sc_toggles_title,.tabsButton > ul > li,.topWrap .search,.topWrap .openRightMenu';
804		var last_time = 0;
805		jQuery(sounded_objects).hover(
806			function () {
807				"use strict";
808				if (!THEMEREX_sound_state.all) return;
809				var dt = new Date();
810				var tm = dt.getTime();
811				if (tm - last_time < 50) return;
812				last_time = tm;
813				if (jQuery(this).parents('#mainmenu,.tabsButton').length > 0) {
814					if (THEMEREX_sound_state.mainmenu && THEMEREX_sound_mainmenu && typeof THEMEREX_sounds['mainmenu'] != 'undefined')
815						THEMEREX_sounds['mainmenu'].play();
816				} else if (jQuery(this).parents('#panelmenu,#sidemenu,.usermenu_area').length > 0) {
817					if (THEMEREX_sound_state.othermenu && THEMEREX_sound_othermenu && typeof THEMEREX_sounds['othermenu'] != 'undefined')
818						THEMEREX_sounds['othermenu'].play();
819				} else if (jQuery(this).parents('.squareButton,.roundButton,.flex-direction-nav,.sc_accordion,.sc_toggles,.tab_names,.topWrap,.tabsMenuHead,#co_bg_pattern_list,#co_bg_images_list,.addBookmarkArea,.socPage,.page-numbers,.upToScroll').length > 0 || jQuery(this).hasClass('button')) {
820					if (THEMEREX_sound_state.buttons && THEMEREX_sound_buttons && typeof THEMEREX_sounds['buttons'] != 'undefined')
821						THEMEREX_sounds['buttons'].play();
822				} else {
823					if (THEMEREX_sound_state.links && THEMEREX_sound_links && typeof THEMEREX_sounds['links'] != 'undefined')
824						THEMEREX_sounds['links'].play();
825				}
826			},
827			function () {}
828		);
829		// Main sound on/off
830		jQuery('.usermenu_sound > a').click(function(e) {
831			"use strict";
832			THEMEREX_sound_state.all = 1-THEMEREX_sound_state.all;
833			jQuery.cookie('themerex_sounds', JSON.stringify(THEMEREX_sound_state), {expires: 365, path: '/'});
834			jQuery(this).removeClass(THEMEREX_sound_state.all ? 'icon-volume-off-1' : 'icon-volume').addClass(THEMEREX_sound_state.all ? 'icon-volume' : 'icon-volume-off-1');
835			e.preventDefault();
836			return false;
837		});
838		// Sound parts on/off
839		jQuery('.usermenu_sound > ul > li > a').click(function(e) {
840			"use strict";
841			if (jQuery(this).hasClass('sound_mainmenu')) {
842				THEMEREX_sound_state.mainmenu = 1 - THEMEREX_sound_state.mainmenu;
843				jQuery(this).removeClass(THEMEREX_sound_state.mainmenu ? 'icon-dot' : 'icon-check').addClass(THEMEREX_sound_state.mainmenu ? 'icon-check' : 'icon-dot');
844			} else if (jQuery(this).hasClass('sound_othermenu')) {
845				THEMEREX_sound_state.othermenu = 1 - THEMEREX_sound_state.othermenu;
846				jQuery(this).removeClass(THEMEREX_sound_state.othermenu ? 'icon-dot' : 'icon-check').addClass(THEMEREX_sound_state.othermenu ? 'icon-check' : 'icon-dot');
847			} else if (jQuery(this).hasClass('sound_buttons')) {
848				THEMEREX_sound_state.buttons = 1 - THEMEREX_sound_state.buttons;
849				jQuery(this).removeClass(THEMEREX_sound_state.buttons ? 'icon-dot' : 'icon-check').addClass(THEMEREX_sound_state.buttons ? 'icon-check' : 'icon-dot');
850			} else if (jQuery(this).hasClass('sound_links')) {
851				THEMEREX_sound_state.links = 1 - THEMEREX_sound_state.links;
852				jQuery(this).removeClass(THEMEREX_sound_state.links ? 'icon-dot' : 'icon-check').addClass(THEMEREX_sound_state.links ? 'icon-check' : 'icon-dot');
853			}
854			jQuery.cookie('themerex_sounds', JSON.stringify(THEMEREX_sound_state), {expires: 365, path: '/'});
855			e.preventDefault();
856			return false;
857		});		
858	}
859
860	// Add placeholders to WP booking calendar
861	if (jQuery('#slot_reservation').length > 0) {
862		var $cont = jQuery('#form_container_all > div');
863		var $i = 0;
864		$cont.each(function() {
865			if ($i < 4)
866				jQuery(this).find('input').attr('placeholder', jQuery(this).find('div').text());
867			if ($i == 4)
868				jQuery(this).find('textarea').attr('placeholder', jQuery(this).find('div').text());
869			$i++;
870		});
871
872
873	}
874
875	if ((jQuery('#toc').length > 0) && (jQuery('.upToScroll').length > 0)) {
876		jQuery('.upToScroll').css('display','none');
877	}
878
879	initPostFormats();
880	initShortcodes(jQuery('body').eq(0));
881	
882} //end ready
883
884// set sidemenu_button left pos if main menu is hidden
885function smLeftPos() {
886	if(jQuery('#sidemenu_button').length > 0) {
887		var mainW = jQuery('.main').width();
888		var windowW = jQuery(window).width();
889		var leftPos = windowW/2 - mainW/2;
890		jQuery('#sidemenu_button').css('left',leftPos);
891	}
892}
893
894
895// Init Superfish menu
896function initSfMenu(selector) {
897	jQuery(selector).show().each(function () {
898		if (isResponsiveNeed() && jQuery(this).attr('id')=='mainmenu' && (THEMEREX_responsive_menu_click || isMobile())) return;
899		jQuery(this).addClass('inited').superfish({
900			delay: 500,
901			animation: {
902				opacity: 'show',
903				height: 'show'
904			},
905			speed: 'fast',
906			autoArrows: false,
907			dropShadows: false,
908			onBeforeShow: function(ul) {
909				if (jQuery(this).parents("ul").length > 1){
910					var w = jQuery(window).width();  
911					var par_offset = jQuery(this).parents("ul").offset().left;
912					var par_width  = jQuery(this).parents("ul").outerWidth();
913					var ul_width   = jQuery(this).outerWidth();
914					if (par_offset+par_width+ul_width > w-20 && par_offset-ul_width > 0)
915						jQuery(this).addClass('submenu_left');
916					else
917						jQuery(this).removeClass('submenu_left');
918				}
919			}
920		});
921	});
922}
923
924
925// Main Menu responsive
926function mainMenuResponsive() {
927	if (THEMEREX_menuResponsive > 0) {
928		if (isResponsiveNeed()) {
929			if (!jQuery('body').hasClass('responsive_menu')) {
930				jQuery('body').addClass('responsive_menu');
931				jQuery('.topMenuStyleFon').removeClass('topMenuStyleFon').addClass('topMenuStyleFon2 topMenuStyleLine');
932				jQuery('header').removeClass('fixedTopMenu').addClass('noFixMenu');
933				if ((THEMEREX_responsive_menu_click || isMobile()) && jQuery('.menuTopWrap > ul#mainmenu').hasClass('inited')) {
934					jQuery('.menuTopWrap > ul#mainmenu').removeClass('inited').superfish('destroy');
935				}
936			}
937		} else {
938			if (jQuery('body').hasClass('responsive_menu')) {
939				jQuery('body').removeClass('responsive_menu');
940				jQuery('.topMenuStyleFon2').removeClass('topMenuStyleFon2 topMenuStyleLine').addClass('topMenuStyleFon');
941				jQuery('.menuTopWrap').show();
942				if (THEMEREX_responsive_menu_click || isMobile()) {
943					initSfMenu('.menuTopWrap > ul#mainmenu');
944				}
945				calcMenuColumnsWidth();
946			}
947		}
948	}
949}
950
951
952// Make all columns (in custom menu) equal height
953function calcMenuColumnsWidth() {
954	"use strict";
955	jQuery('#mainmenu li.custom_view_item ul.menu-panel ul.columns').each(function() {
956		"use strict";
957		if (jQuery('body').hasClass('responsive_menu')) return;
958		jQuery(this).parents('.menu-panel').css({display:'block', visibility: 'hidden'});
959		var h = 0, w = 0;
960		jQuery(this).find('>li').css('height', 'auto').each(function () {
961			var li = jQuery(this);
962			var mt = parseInt(li.css('marginTop')), mb = parseInt(li.css('marginBottom')), mh = li.height() + (isNaN(mt) ? 0 : mt) + (isNaN(mb) ? 0 : mb);
963			if (h < mh) h = mh;
964			var bl = parseInt(li.css('borderLeft')), pl = parseInt(li.css('paddingLeft')), br = parseInt(li.css('borderRight')), pr = parseInt(li.css('paddingRight'));
965			w += li.width() + (isNaN(bl) ? 0: bl) + (isNaN(pl) ? 0 : pl) + (isNaN(pr) ? 0 : pr) + (isNaN(br) ? 0 : br);
966		});
967		jQuery(this).parents('.menu-panel').css({display:'none', visibility: 'visible'});
968		if (w > jQuery('#mainmenu').width()) jQuery(this).width(w+8);
969
970		jQuery(this).find('>li').height(h);
971	});
972}
973
974// Check if responsive menu need
975function isResponsiveNeed() {
976	"use strict";
977	var rez = false;
978	if (THEMEREX_menuResponsive > 0) {
979		var w = window.innerWidth;
980		if (w == undefined) {
981			w = jQuery(window).width()+(jQuery(window).height() < jQuery(document).height() || jQuery(window).scrollTop() > 0 ? 16 : 0);
982		}
983		rez = THEMEREX_menuResponsive > w;
984	}
985	return rez;
986}
987
988
989// Infinite Scroll
990function infiniteScroll() {
991	"use strict";
992	var v = jQuery('#viewmore.pagination_infinite').offset();
993	if (jQuery(this).scrollTop() + jQuery(this).height() + 100 >= v.top && !THEMEREX_VIEWMORE_BUSY) {
994		jQuery('#viewmore_link').eq(0).trigger('click');
995	}
996}
997
998//itemPageFull
999function itemPageFull() {
1000	"use strict";
1001	var bodyHeight = jQuery(window).height();
1002	var st = jQuery(window).scrollTop();
1003	if (st > jQuery('.noFixMenu .topWrap').height()+jQuery('.topTabsWrap').height()) st = 0;
1004	var thumbHeight = Math.min(jQuery('.itemPageFull').width()/16*9, bodyHeight - jQuery('#wpadminbar').height() - jQuery('.noFixMenu .topWrap').height() - jQuery('.topTabsWrap').height() + st);
1005	jQuery('.itemPageFull').height(thumbHeight);
1006	var padd1 = parseInt(jQuery('.sidemenu_wrap').css('paddingTop'));
1007	if (isNaN(padd1)) padd1 = parseInt(jQuery('.swpRightPos').css('paddingTop'));
1008	if (isNaN(padd1)) padd1 = 0;
1009	var padd2 = parseInt(jQuery('.swpRightPos .sc_tabs .tabsMenuBody').css('paddingTop'))*2;
1010	if (isNaN(padd2)) padd2 = 0;
1011	var tabs_h = jQuery('.swpRightPos .sc_tabs .tabsMenuHead').height();
1012	if (isNaN(tabs_h)) tabs_h = 0;
1013	var butt_h = jQuery('.swpRightPos .sc_tabs .tabsMenuBody .addBookmarkArea').height();
1014	if (isNaN(butt_h)) butt_h = 0;
1015	jQuery('#sidemenu_scroll').height(bodyHeight - padd1);
1016	jQuery('.swpRightPos .sc_tabs .tabsMenuBody').height(bodyHeight -  - padd1 - padd2 - tabs_h);
1017	jQuery('#custom_options_scroll').height(bodyHeight - padd1 - padd2 - tabs_h);
1018	jQuery('#sidebar_panel_scroll').height(bodyHeight - padd1 - padd2 - tabs_h);
1019	jQuery('#panelmenu_scroll').height(bodyHeight - padd1 - padd2 - tabs_h);
1020	jQuery('#bookmarks_scroll').height(bodyHeight - padd1 - padd2 - tabs_h - butt_h);
1021}
1022
1023//scroll Action
1024function scrollAction() {
1025	"use strict";
1026
1027	var buttonScrollTop = jQuery('.upToScroll');
1028	var scrollPositions = jQuery(window).scrollTop();
1029	var topMenuHeight   = jQuery('header').height();
1030	var adminbarHeight  = jQuery('#wpadminbar').height();
1031
1032	if (scrollPositions > topMenuHeight) {
1033		buttonScrollTop.addClass('buttonShow');
1034	} else {
1035		buttonScrollTop.removeClass('buttonShow');
1036	}
1037	
1038	if (!jQuery('body').hasClass('responsive_menu') && THEMEREX_menuFixed) {
1039		var slider_height = 0;
1040		if (jQuery('.top_panel_below .sliderHomeBullets').length > 0) {
1041			slider_height = jQuery('.top_panel_below .sliderHomeBullets').height();
1042			if (slider_height < 10) {
1043				slider_height = jQuery('.sliderHomeBullets').parents('.fullScreenSlider').length > 0 ? jQuery(window).height() : THEMEREX_slider_height;
1044			}
1045		}
1046		var topFixedHeight = Math.max(0, jQuery('.fixedTopMenu .topWrap').height());
1047		if (scrollPositions <= THEMEREX_top_height - topFixedHeight - 20 + slider_height) {
1048			if (jQuery('header').hasClass('fixedTopMenu')) {
1049				jQuery('header').removeClass('fixedTopMenu').addClass('noFixMenu');
1050				if (THEMEREX_use_fixed_wrapper) jQuery('.topWrapFixed').hide();
1051			}
1052		} else if (scrollPositions > THEMEREX_top_height + slider_height) {
1053			if (!jQuery('header').hasClass('fixedTopMenu')) {
1054				if (THEMEREX_use_fixed_wrapper) jQuery('.topWrapFixed').height(THEMEREX_top_height).show();
1055				jQuery('header').addClass('fixedTopMenu').removeClass('noFixMenu');
1056			}
1057		}
1058	}
1059	// window.width < 1024 - > height = 0;
1060	jQuery(window).on('resize',function(){
1061		if(jQuery(window).width() < 1024)
1062		if (!jQuery('header').hasClass('fixedTopMenu')) {
1063			if (THEMEREX_use_fixed_wrapper) jQuery('.topWrapFixed').height('0');
1064		}
1065	});
1066
1067	// TOC current items
1068	jQuery('#toc .toc_item').each(function () {
1069		"use strict";
1070		var id = jQuery(this).find('a').attr('href');
1071		var pos = id.indexOf('#');
1072		if (pos < 0 || id.length == 1) return;
1073		var loc = window.location.href;
1074		var pos2 = loc.indexOf('#');
1075		if (pos2 > 0) loc = loc.substring(0, pos2);
1076		var now = pos==0;
1077		if (!now) now = loc == href.substring(0, pos);
1078		if (!now) return;
1079		var off = jQuery(id).offset().top;
1080		var id_next  = jQuery(this).next().find('a').attr('href');
1081		var off_next = id_next ? jQuery(id_next).offset().top : 1000000;
1082		if (off < scrollPositions + jQuery(window).height()*0.8 && scrollPositions + topMenuHeight < off_next)
1083			jQuery(this).addClass('current');
1084		else
1085			jQuery(this).removeClass('current');
1086	});
1087}
1088
1089
1090// Build page TOC from the tag's id
1091function buildPageTOC() {
1092	"use strict";
1093	var toc = '', toc_count = 0;
1094	jQuery('[id^="toc_"],.sc_anchor').each(function(idx) {
1095		"use strict";
1096		var obj = jQuery(this);
1097		var id = obj.attr('id');
1098		var url = obj.data('url');
1099		var icon = obj.data('icon');
1100		if (!icon) icon = 'icon-record';
1101		var title = obj.attr('title');
1102		var description = obj.data('description');
1103		var separator = obj.data('separator');
1104		toc_count++;
1105		toc += '<div class="toc_item'+(separator=='yes' ? ' toc_separator' : '')+'">'
1106			+(description ? '<div class="toc_description">'+description+'</div>' : '')
1107			+'<a href="'+(url ? url : '#'+id)+'" class="toc_icon'+(title ? ' with_title' : '')+' '+icon+'">'+(title ? '<span class="toc_title">'+title+'</span>' : '')+'</a>'
1108			+'</div>';
1109	});
1110	if (toc_count > (THEMEREX_menu_toc_home ? 1 : 0) + (THEMEREX_menu_toc_top ? 1 : 0)) {
1111		if (jQuery('#toc').length > 0)
1112			jQuery('#toc .toc_inner').html(toc);
1113		else
1114			jQuery('body').append('<div id="toc" class="toc_'+THEMEREX_menu_toc+'"><div class="toc_inner">'+toc+'</div></div>');
1115	}
1116}
1117
1118// Fullscreen slider
1119function fullSlider() {
1120	"use strict";
1121	var fullSlider = jQuery('.fullScreenSlider');
1122	if (fullSlider.length > 0) {
1123		var h = jQuery(window).height() - jQuery('#wpadminbar').height() - (jQuery('.top_panel_above .fullScreenSlider header').css('position')=='static' ? jQuery('.topWrap').height() : 0);
1124		// Slider Container
1125		fullSlider.find('.sliderHomeBullets').css('height', h);
1126		// Royal slider
1127		fullSlider.find('.sliderHomeBullets.slider_engine_royal > div,.sliderHomeBullets.slider_engine_royal .rsOverflow,.sliderHomeBullets.slider_engine_royal .rsContent,.sliderHomeBullets .slideContent,.sliderHomeBullets .sc_slider,.sliderHomeBullets .sc_slider .slides,.sliderHomeBullets .sc_slider .slides li').css('height', h);
1128		// Revolution slider
1129		fullSlider.find('.sliderHomeBullets.slider_engine_revo .rev_slider_wrapper,.sliderHomeBullets.slider_engine_revo .rev_slider').css({'height': h+'px', 'maxHeight': h+'px'});
1130		fullSlider.find('.sliderHomeBullets.slider_engine_revo .rev_slider > ul').css({'maxHeight': h+'px'});
1131		fullSlider.find('.sliderHomeBullets.slider_engine_revo .rev_slider .defaultimg').css({'height': h+'px', 'maxWidth': 'none'});
1132	} else {
1133		setTimeout(SetNewH,300);
1134	}
1135
1136	function SetNewH() {
1137		var slider = jQuery('.sliderHomeBullets.slider_engine_revo');
1138		if (slider.length > 0) {
1139			var h = slider.find('.rev_slider_wrapper').height();
1140			if (slider.height() != h) slider.css('height', h);
1141		}
1142	}
1143}
1144
1145
1146// Resize sliders
1147function resizeSliders() {
1148	if (jQuery('.sc_slider_flex,.sc_slider_chop,.sc_slider_swiper').length > 0) {
1149		jQuery('.sc_slider_flex,.sc_slider_chop,.sc_slider_swiper').each(function () {
1150			if (jQuery(this).parents('.isotope, .isotopeNOanim').length == 0) calcSliderDimensions(jQuery(this));
1151		});
1152	}
1153}
1154
1155//Time Line
1156function timelineResponsive() {
1157	"use strict";
1158	var tl = jQuery('#timeline_slider:not(.fixed)').eq(0);
1159	if (tl.length > 0) {
1160		if (jQuery(window).width() <= 1023) {
1161			tl.addClass('fixed');
1162		} else {
1163			var bodyHeight = jQuery(window).height();
1164			var tlHeight = jQuery(window).height() - tl.find('h2').height() - 150;
1165			tl.find('.sc_blogger').css('height', tlHeight).find('.sc_scroll').css('height', tlHeight);
1166		}
1167	}
1168}
1169
1170
1171//Set team column height
1172function TeamColHeight() {
1173	"use strict";
1174	var handle = jQuery('.sc_team div[class^="columns1_"]');
1175    handle.each(function() {
1176            jQuery(this).css('height', jQuery(this).height());
1177        }
1178        
1179    );
1180}
1181
1182//time line Scroll
1183function timelineScrollFix() {
1184	"use strict";
1185	var tl = jQuery('#timeline_slider:not(.fixed)').eq(0);
1186	if (tl.length > 0) {
1187		var scrollWind = jQuery(window).scrollTop();
1188		var headerHeight = jQuery('header').height() + jQuery('.topTabsWrap').height() - 20;
1189		var footerHeight = jQuery('.footerContentWrap').height();
1190		var footerVisible = jQuery(document).height() - footerHeight <= scrollWind + jQuery(window).height();
1191
1192		if (jQuery(window).scrollTop() <= headerHeight) {
1193			if (parseFloat(tl.css('marginTop')) > 0) {
1194				tl.animate({
1195					marginTop: 0
1196				}, {
1197					queue: false,
1198					duration: 350
1199				});
1200			}
1201		} else {
1202			if (headerHeight <= scrollWind - 10 && !footerVisible) {
1203				tl.animate({
1204					marginTop: (scrollWind - headerHeight) + "px"
1205				}, {
1206					queue: false,
1207					duration: 350
1208				});
1209			}
1210		}
1211	}
1212}
1213
1214// Init isotope
1215var THEMEREX_isotopeInitCounter = 0;
1216function initIsotope() {
1217	if (jQuery('.isotopeNOanim,.isotope').length > 0) {
1218
1219		jQuery('.isotopeNOanim,.isotope').each(function () {
1220			"use strict";
1221			if (!isotopeImagesComplete(jQuery(this)) && THEMEREX_isotopeInitCounter++ < 30) {
1222				setTimeout(initIsotope, 200);
1223				return;
1224			}
1225			jQuery(this).addClass('inited').find('.isotopeElement').animate({opacity: 1}, 200, function () { jQuery(this).addClass('isotopeElementShow'); });
1226			var w = calcSizeIsotope(jQuery(this));
1227			jQuery(this).isotope({
1228				resizable: jQuery(this).parents('.fullscreen,.sc_gap').length > 0 && !jQuery(this).hasClass('folio1col'),
1229				masonry: {
1230					columnWidth: w
1231				},
1232				itemSelector: '.isotopeElement',
1233				animationOptions: {
1234					duration: 750,
1235					easing: 'linear',
1236					queue: false
1237				}
1238			});
1239			// Init shortcodes in isotope
1240			initShortcodes(jQuery(this));
1241		});		
1242	}
1243}
1244
1245function initAppendedIsotope(posts_container, filters) {
1246	"use strict";
1247	if (!isotopeImagesComplete(posts_container) && THEMEREX_isotopeInitCounter++ < 30) {
1248		setTimeout(function() { initAppendedIsotope(posts_container, filters); }, 200);
1249		return;
1250	}
1251	calcSizeIsotope(posts_container);
1252	var flt = posts_container.siblings('.isotopeFiltr');
1253	var elems = posts_container.find('.isotopeElement:not(.isotopeElementShow)').animate({opacity: 1}, 200, function () { jQuery(this).addClass('isotopeElementShow'); });
1254	posts_container.isotope('appended', elems);
1255	for (var i in filters) {
1256		if (flt.find('a[data-filter=".flt_'+i+'"]').length == 0) {
1257			flt.find('ul').append('<li class="squareButton"><a href="#" data-filter=".flt_'+i+'">'+filters[i]+'</a></li>');
1258		}
1259	}
1260}
1261
1262function isotopeImagesComplete(cont) {
1263	var complete = true;
1264	cont.find('img').each(function() {
1265		if (!complete) return;
1266		if (!jQuery(this).get(0).complete) complete = false;
1267	});
1268	return complete;
1269}
1270
1271function calcSizeIsotope(cont) {
1272	"use strict";
1273	var columns = Math.max(1, Number(cont.data('columns')));
1274	var element = cont.find('.isotopeElement:not(.isotope-item)');
1275	var elementWidth=0, elementWidthNew=0, elementHeight=0, elementHeightNew=0;
1276	if (columns > 1) {
1277		if (cont.data('last-width') == cont.width()) return elementWidthNew;
1278		var changeHeight = cont.hasClass('portfolio');
1279		var m1 = parseInt(cont.css('marginRight'));
1280		if (isNaN(m1)) m1 = 0;
1281		var m2 = parseInt(element.find('.isotopePadding').css('marginRight'));
1282		if (isNaN(m2)) m2 = 0;
1283		var lastWidth = cont.width() + (changeHeight ? 0 : m1+m2);
1284		cont.data('last-width', lastWidth);
1285		elementWidth = changeHeight ? element.width() : Math.max(240, Math.floor(lastWidth/columns - m2));
1286		cont.data('element-width', elementWidth);
1287		elementWidthNew = Math.floor(lastWidth / columns);
1288		var dir = elementWidthNew > elementWidth ? 1 : -1;
1289		while (dir*(elementWidthNew-elementWidth)/elementWidth > THEMEREX_isotope_resize_delta) {
1290			columns += dir;
1291			if (columns==0) break;
1292			elementWidthNew = Math.floor(lastWidth / columns);
1293		}
1294		element.css({
1295			width: elementWidthNew
1296		});
1297		if (changeHeight) {
1298			elementHeight = element.height();
1299			cont.data('element-height', elementHeight);
1300			elementHeightNew = Math.floor(elementWidthNew/elementWidth*elementHeight);
1301			element.css({
1302				height: elementHeightNew
1303			});
1304		}
1305	}
1306	//element.fadeIn();
1307	return elementWidthNew;
1308}
1309
1310// Resize new Isotope elements
1311function resizeIsotope() {
1312	jQuery('.isotope, .isotopeNOanim').each(function() {
1313		"use strict";
1314		var cont = jQuery(this);
1315		var columns = Math.max(1, Number(cont.data('columns')));
1316		if (columns == 1 || cont.data('last-width') == cont.width()) return;
1317		var changeHeight = cont.hasClass('portfolio');
1318		var element = cont.find('.isotopeElement');
1319		var m1 = parseInt(cont.css('marginRight'));
1320		if (isNaN(m1)) m1 = 0;
1321		var m2 = parseInt(element.find('.isotopePadding').css('marginRight'));
1322		if (isNaN(m2)) m2 = 0;
1323		var lastWidth = cont.width() + (changeHeight ? 0 : m1+m2);
1324		cont.data('last-width', lastWidth);
1325		var elementWidth = parseFloat(cont.data('element-width'));
1326		var elementWidthNew = Math.floor(lastWidth / columns);
1327		var dir = elementWidthNew > elementWidth ? 1 : -1;
1328		while (dir*(elementWidthNew-elementWidth)/elementWidth > THEMEREX_isotope_resize_delta) {
1329			columns += dir;
1330			if (columns == 0) break;
1331			//jQuery(this).data('columns', columns);
1332			elementWidthNew = Math.floor(lastWidth / columns);
1333		}
1334		element.css({
1335			width: elementWidthNew
1336		});
1337		if (changeHeight) {
1338			var elementHeight = parseFloat(cont.data('element-height'));
1339			var elementHeightNew = Math.floor(elementWidthNew/elementWidth*elementHeight);
1340			element.css({
1341				height: elementHeightNew
1342			});
1343		}
1344		jQuery(this).isotope({
1345			masonry: {
1346				columnWidth: elementWidthNew
1347			}
1348		});
1349		cont.find('.sc_slider_flex,.sc_slider_chop,.sc_slider_swiper').each(function () {
1350			calcSliderDimensions(jQuery(this));
1351		});
1352	});
1353}
1354
1355function initPostFormats() {
1356	"use strict";
1357
1358	// MediaElement init
1359	initMediaElements(jQuery('body'));
1360
1361	//hoverZoom img effect
1362	if (jQuery('.hoverIncrease:not(.inited)').length > 0) {
1363		jQuery('.hoverIncrease:not(.inited)')
1364			.addClass('inited')
1365			.each(function () {
1366				"use strict";
1367				var img = jQuery(this).data('image');
1368				var title = jQuery(this).data('title');
1369				if (img) {
1370					jQuery(this).append('<span class="hoverShadow"></span><a href="'+img+'" title="'+title+'"><span class="hoverIcon"></span></a>');
1371				}
1372			});
1373	}
1374
1375	// Popup init
1376	if (THEMEREX_popupEngine == 'pretty' && typeof jQuery.prettyPhoto != 'undefined') {
1377		jQuery("a[href$='jpg'],a[href$='jpeg'],a[href$='png'],a[href$='gif']").attr('rel', 'prettyPhoto'+(THEMEREX_popupGallery ? '[slideshow]' : ''));
1378		jQuery("a[rel*='prettyPhoto']:not(.inited):not([rel*='magnific']):not([data-rel*='magnific'])")
1379			.addClass('inited')
1380			.prettyPhoto({
1381				social_tools: '',
1382				theme: 'facebook',
1383				deeplinking: false
1384			})
1385			.click(function(e) {
1386				"use strict";
1387				if (jQuery(window).width()<480)	{
1388					e.stopImmediatePropagation();
1389					window.location = jQuery(this).attr('href');
1390				}
1391				e.preventDefault();
1392				return false;
1393			});
1394	} else if (typeof jQuery.magnificPopup != 'undefined') {
1395		jQuery("a[href$='jpg'],a[href$='jpeg'],a[href$='png'],a[href$='gif']").attr('rel', 'magnific');	//.toggleClass('magnific', true);
1396		jQuery("a[rel*='magnific']:not(.inited):not(.prettyphoto):not([rel*='pretty']):not([data-rel*='pretty'])")
1397			.addClass('inited')
1398			.magnificPopup({
1399				type: 'image',
1400				mainClass: 'mfp-img-mobile',
1401				closeOnContentClick: true,
1402				closeBtnInside: true,
1403				fixedContentPos: true,
1404				midClick: true,
1405				//removalDelay: 500, 
1406				preloader: true,
1407				tLoading: THEMEREX_MAGNIFIC_LOADING,
1408				gallery:{
1409					enabled:THEMEREX_popupGallery
1410				},
1411				image: {
1412					tError: THEMEREX_MAGNIFIC_ERROR,
1413					verticalFit: true
1414				}
1415			});
1416	}
1417
1418	// Popup windows with any html content
1419	if (typeof jQuery.magnificPopup != 'undefined') {
1420		jQuery('.user-popup-link:not(.inited),a[href="#openLogin"]:not(.inited)')
1421			.addClass('inited')
1422			.magnificPopup({
1423				type: 'inline',
1424				removalDelay: 500,
1425				callbacks: {
1426					beforeOpen: function () {
1427						this.st.mainClass = 'mfp-zoom-in';
1428					},
1429					open: function () {
1430						jQuery('html').css({
1431							overflow: 'visible',
1432							margin: 0
1433						});
1434					},
1435					close: function () {
1436					}
1437				},
1438				midClick: true
1439			});
1440	}
1441	//textarea Autosize
1442	if (jQuery('textarea.textAreaSize:not(.inited)').length > 0) {
1443		jQuery('textarea.textAreaSize:not(.inited)')
1444			.addClass('inited')
1445			.autosize({
1446				append: "\n"
1447			});
1448	}
1449
1450	// Share button
1451	if (jQuery('ul.shareDrop:not(.inited)').length > 0) {
1452		jQuery('ul.shareDrop:not(.inited)')
1453			.addClass('inited')
1454			.siblings('a').click(function (e) {
1455				"use strict";
1456				if (jQuery(this).hasClass('selected')) {
1457					jQuery(this).removeClass('selected').siblings('ul.shareDrop').slideUp();
1458				} else {
1459					jQuery(this).addClass('selected').siblings('ul.shareDrop').slideDown();
1460				}
1461				e.preventDefault();
1462				return false;
1463			}).end()
1464			.find('li a').click(function (e) {
1465				jQuery(this).parents('ul.shareDrop').slideUp().siblings('a.shareDrop').removeClass('selected');
1466				e.preventDefault();
1467				return false;
1468			});
1469	}
1470
1471	// Like button
1472	if (jQuery('.postSharing:not(.inited),.masonryMore:not(.inited)').length > 0) {
1473		jQuery('.postSharing:not(.inited),.masonryMore:not(.inited)')
1474			.addClass('inited')
1475			.find('.likeButton a')
1476			.click(function(e) {
1477				var button = jQuery(this).parent();
1478				var inc = button.hasClass('like') ? 1 : -1;
1479				var post_id = button.data('postid');
1480				var likes = Number(button.data('likes'))+inc;
1481				var cookie_likes = jQuery.cookie('themerex_likes');
1482				if (cookie_likes === undefined) cookie_likes = '';
1483				jQuery.post(THEMEREX_ajax_url, {
1484					action: 'post_counter',
1485					nonce: THEMEREX_ajax_nonce,
1486					post_id: post_id,
1487					likes: likes
1488				}).done(function(response) {
1489					var rez = JSON.parse(response);
1490					if (rez.error === '') {
1491						if (inc == 1) {
1492							var title = button.data('title-dislike');
1493							button.removeClass('like').addClass('likeActive');
1494							cookie_likes += (cookie_likes.substr(-1)!=',' ? ',' : '') + post_id + ',';
1495						} else {
1496							var title = button.data('title-like');
1497							button.removeClass('likeActive').addClass('like');
1498							cookie_likes = cookie_likes.replace(','+post_id+',', ',');
1499						}
1500						button.data('likes', likes).find('a').attr('title', title).find('.likePost').html(likes);
1501						jQuery.cookie('themerex_likes', cookie_likes, {expires: 365, path: '/'});
1502					} else {
1503						themerex_message_warning(THEMEREX_MESSAGE_ERROR_LIKE);
1504					}
1505				});
1506				e.preventDefault();
1507				return false;
1508			});
1509	}
1510
1511	//Hover DIR
1512	if (jQuery('.portfolio > .isotopeElement:not(.inited)').length > 0) {
1513		jQuery('.portfolio > .isotopeElement:not(.inited)')
1514			.addClass('inited')
1515			.find('> .hoverDirShow').each(function () {
1516				"use strict";
1517				jQuery(this).hoverdir();
1518			});
1519	}
1520
1521	// Add video on thumb click
1522	if (jQuery('.sc_video_play_button:not(.inited)').length > 0) {
1523		jQuery('.sc_video_play_button:not(.inited)').each(function() {
1524			"use strict";
1525			var video = jQuery(this).data('video');
1526			var pos = video.indexOf('height=');
1527			if (pos > 0) {
1528				pos += 8;
1529				var pos2 = video.indexOf('"', pos);
1530				var h = parseInt(video.substring(pos, pos2));
1531				if (!isNaN(h))
1532					jQuery(this).find('img').height(h);
1533			}
1534			jQuery(this)
1535				.addClass('inited')
1536				.animate({opacity: 1}, 1000)
1537				.click(function (e) {
1538					"use strict";
1539					if (!jQuery(this).hasClass('sc_video_play_button')) return;
1540					var video = jQuery(this).removeClass('sc_video_play_button').data('video');
1541					if (video!=='') {
1542						jQuery(this).empty().html(video);
1543						videoDimensions();
1544						var video_tag = jQuery(this).find('video');
1545						var w = video_tag.width();
1546						var h = video_tag.height();
1547						initMediaElements(jQuery(this));
1548						// Restore WxH attributes, because Chrome broke it!
1549						jQuery(this).find('video').css({'width':w, 'height': h}).attr({'width':w, 'height': h});
1550					}
1551					e.preventDefault();
1552					return false;
1553				});
1554		});
1555	}
1556
1557	// IFRAME width and height constrain proportions 
1558	if (jQuery('iframe,.sc_video_player,video.sc_video').length > 0) {
1559		if (!THEMEREX_video_resize_inited) {
1560			THEMEREX_video_resize_inited = true;
1561			jQuery(window).resize(function() {
1562				"use strict";
1563				videoDimensions();
1564			});
1565		}
1566		videoDimensions();
1567	}
1568	
1569	// Tribe Events buttons
1570	jQuery('.tribe-events-nav-previous,.tribe-events-nav-next,.tribe-events-widget-link,.tribe-events-viewmore').addClass('squareButton');
1571	jQuery('a.tribe-events-read-more').wrap('<span class="squareButton"></span>');
1572}
1573
1574
1575function initMediaElements(cont) {
1576	if (THEMEREX_useMediaElement && cont.find('audio,video').length > 0) {
1577		if (window.mejs) {
1578			window.mejs.MepDefaults.enableAutosize = false;
1579			window.mejs.MediaElementDefaults.enableAutosize = false;
1580			cont.find('audio:not(.wp-audio-shortcode),video:not(.wp-video-shortcode)').each(function() {
1581				if (jQuery(this).parents('.mejs-mediaelement').length == 0) {
1582					var settings = {
1583						enableAutosize: false,
1584						videoWidth: -1,		// if set, overrides <video width>
1585						videoHeight: -1,	// if set, overrides <video height>
1586						audioWidth: '100%',	// width of audio player
1587						audioHeight: 30		// height of audio player
1588					};
1589				
1590					settings.success = function (mejs) {
1591						var autoplay, loop;
1592	
1593						if ( 'flash' === mejs.pluginType ) {
1594	
1595							autoplay = mejs.attributes.autoplay && 'false' !== mejs.attributes.autoplay;
1596							loop = mejs.attributes.loop && 'false' !== mejs.attributes.loop;
1597	
1598							autoplay && mejs.addEventListener( 'canplay', function () {
1599								mejs.play();
1600							}, false );
1601			
1602							loop && mejs.addEventListener( 'ended', function () {
1603								mejs.play();
1604							}, false );
1605						}
1606					}
1607
1608					jQuery(this).mediaelementplayer(settings);
1609				}
1610			});
1611		} else
1612			setTimeout(function() { initMediaElements(cont); }, 400);
1613	}
1614}
1615
1616
1617
1618// Fit video frames to document width
1619function videoDimensions() {
1620	jQuery('.sc_video_player').each(function() {
1621		"use strict";
1622		var player = jQuery(this).eq(0);
1623		var ratio = (player.data('ratio') ? player.data('ratio').split(':') : (player.find('[data-ratio]').length>0 ? player.find('[data-ratio]').data('ratio').split(':') : [16,9]));
1624		ratio = ratio.length!=2 || ratio[0]==0 || ratio[1]==0 ? 16/9 : ratio[0]/ratio[1];
1625		var cover = jQuery(this).find('.sc_video_play_button img');
1626		var ht = player.find('.sc_video_player_title').height();
1627		var w_attr = player.data('width');
1628		var h_attr = player.data('height');
1629		if (!w_attr || !h_attr) {
1630			return;
1631		}
1632		var percent = (''+w_attr).substr(-1)=='%';
1633		w_attr = parseInt(w_attr);
1634		h_attr = parseInt(h_attr);
1635		var w_real = Math.min(percent ? 10000 : w_attr, player.parents('div,article').width()), //player.width();
1636			h_real = Math.round(percent ? w_real/ratio : w_real/w_attr*h_attr);
1637		if (parseInt(player.attr('data-last-width'))==w_real) return;
1638		if (percent) {
1639			player.height(h_real + (isNaN(ht) ? 0 : ht));
1640			if (cover.length > 0) cover.height(h_real);
1641		} else {
1642			player.css({'width': w_real+'px', 'height': h_real + (isNaN(ht) ? 0 : ht)+'px'});
1643			if (cover.length > 0) cover.height(h_real);
1644		}
1645		player.attr('data-last-width', w_real);
1646	});
1647	jQuery('video.sc_video').each(function() {
1648		"use strict";
1649		var video = jQuery(this).eq(0);
1650		var ratio = (video.data('ratio')!=undefined ? video.data('ratio').split(':') : [16,9]);
1651		ratio = ratio.length!=2 || ratio[0]==0 || ratio[1]==0 ? 16/9 : ratio[0]/ratio[1];
1652		var mejs_cont = video.parents('.mejs-video');
1653		var player = video.parents('.sc_video_player');
1654		var w_attr = player.length>0 ? player.data('width') : video.data('width');
1655		var h_attr = player.length>0 ? player.data('height') : video.data('height');
1656		if (!w_attr || !h_attr) {
1657			return;
1658		}
1659		var percent = (''+w_attr).substr(-1)=='%';
1660		w_attr = parseInt(w_attr);
1661		h_attr = parseInt(h_attr);
1662		var w_real = Math.round(mejs_cont.length > 0 ? Math.min(percent ? 10000 : w_attr, mejs_cont.parents('div,article').width()) : video.width()),
1663			h_real = Math.round(percent ? w_real/ratio : w_real/w_attr*h_attr);
1664		if (parseInt(video.attr('data-last-width'))==w_real) return;
1665		if (mejs_cont.length > 0 && mejs) {
1666			setMejsPlayerDimensions(video, w_real, h_real);
1667		}
1668		if (percent) {
1669			video.height(h_real);
1670		} else {
1671			video.attr({'width': w_real, 'height': h_real}).css({'width': w_real+'px', 'height': h_real+'px'});
1672		}
1673		video.attr('data-last-width', w_real);
1674	});
1675	jQuery('video.sc_video_bg').each(function() {
1676		"use strict";
1677		var video = jQuery(this).eq(0);
1678		var ratio = (video.data('ratio')!=undefined ? video.data('ratio').split(':') : [16,9]);
1679		ratio = ratio.length!=2 || ratio[0]==0 || ratio[1]==0 ? 16/9 : ratio[0]/ratio[1];
1680		var mejs_cont = video.parents('.mejs-video');
1681		var container = mejs_cont.length>0 ? mejs_cont.parent() : video.parent();
1682		var w = container.width();
1683		var h = container.height();
1684		var w1 = Math.ceil(h*ratio);
1685		var h1 = Math.ceil(w/ratio);
1686		if (video.parents('.sc_parallax').length > 0) {
1687			var windowHeight = jQuery(window).height();
1688			var speed = Number(video.parents('.sc_parallax').data('parallax-speed'));
1689			var h_add = Math.ceil(Math.abs((windowHeight-h)*speed));
1690			if (h1 < h + h_add) {
1691				h1 = h + h_add;
1692				w1 = Math.ceil(h1 * ratio);
1693			}
1694		}
1695		if (h1 < h) {
1696			h1 = h;
1697			w1 = Math.ceil(h1 * ratio);
1698		}
1699		if (w1 < w) { 
1700			w1 = w;
1701			h1 = Math.ceil(w1 / ratio);
1702		}
1703		var l = Math.round((w1-w)/2);
1704		var t = Math.round((h1-h)/2);
1705		if (parseInt(video.attr('data-last-width'))==w1) return;
1706		if (mejs_cont.length > 0) {
1707			setMejsPlayerDimensions(video, w1, h1);
1708			mejs_cont.css({'left': -l+'px', 'top': -t+'px'});
1709		} else
1710			video.css({'left': -l+'px', 'top': -t+'px'});
1711		video.attr({'width': w1, 'height': h1, 'data-last-width':w1}).css({'width':w1+'px', 'height':h1+'px'});
1712		if (video.css('opacity')==0) video.animate({'opacity': 1}, 3000);
1713	});
1714	jQuery('iframe').each(function() {
1715		"use strict";
1716		var iframe = jQuery(this).eq(0);
1717		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]));
1718		ratio = ratio.length!=2 || ratio[0]==0 || ratio[1]==0 ? 16/9 : ratio[0]/ratio[1];
1719		var w_attr = iframe.attr('width');
1720		var h_attr = iframe.attr('height');
1721		var player = iframe.parents('.sc_video_player');
1722		if (player.length > 0) {
1723			w_attr = player.data('width');
1724			h_attr = player.data('height');
1725		}
1726		if (!w_attr || !h_attr) {
1727			return;
1728		}
1729		var percent = (''+w_attr).substr(-1)=='%';
1730		w_attr = parseInt(w_attr);
1731		h_attr = parseInt(h_attr);
1732		var w_real = player.length > 0 ? player.width() : iframe.width(),
1733			h_real = Math.round(percent ? w_real/ratio : w_real/w_attr*h_attr);
1734		if (parseInt(iframe.attr('data-last-width'))==w_real) return;
1735		iframe.css({'width': w_real+'px', 'height': h_real+'px'});
1736	});
1737}
1738
1739// Resize fullscreen video background
1740function resizeVideoBackground() {
1741	var bg = jQuery('.videoBackgroundFullscreen');
1742	if (bg.length < 1) 
1743		return;
1744	if (THEMEREX_useMediaElement && bg.find('.mejs-video').length == 0)  {
1745		setTimeout(resizeVideoBackground, 100);
1746		return;
1747	}
1748	if (!bg.hasClass('inited')) {
1749		bg.addClass('inited');
1750	}
1751	var video = bg.find('video');
1752	var ratio = (video.data('ratio')!=undefined ? video.data('ratio').split(':') : [16,9]);
1753	ratio = ratio.length!=2 || ratio[0]==0 || ratio[1]==0 ? 16/9 : ratio[0]/ratio[1];
1754	var w = bg.width();
1755	var h = bg.height();
1756	var w1 = Math.ceil(h*ratio);
1757	var h1 = Math.ceil(w/ratio);
1758	if (h1 < h) {
1759		h1 = h;
1760		w1 = Math.ceil(h1 * ratio);
1761	}
1762	if (w1 < w) { 
1763		w1 = w;
1764		h1 = Math.ceil(w1 / ratio);
1765	}
1766	var l = Math.round((w1-w)/2);
1767	var t = Math.round((h1-h)/2);
1768	if (bg.find('.mejs-container').length > 0) {
1769		setMejsPlayerDimensions(bg.find('video'), w1, h1);
1770		bg.find('.mejs-container').css({'left': -l+'px', 'top': -t+'px'});
1771	} else
1772		bg.find('video').css({'left': -l+'px', 'top': -t+'px'});
1773	bg.find('video').attr({'width': w1, 'height': h1}).css({'width':w1+'px', 'height':h1+'px'});
1774}
1775
1776// Set Media Elements player dimensions
1777function setMejsPlayerDimensions(video, w, h) {
1778	if (mejs) {
1779		for (var pl in mejs.players) {
1780			if (mejs.players[pl].media.src == video.attr('src')) {
1781				if (mejs.players[pl].media.setVideoSize) {
1782					mejs.players[pl].media.setVideoSize(w, h);
1783				}
1784				mejs.players[pl].setPlayerSize(w, h);
1785				mejs.players[pl].setControlsSize();
1786			}
1787		}
1788	}
1789}
1790
1791// Parallax scroll
1792function REX_parallax(){
1793	jQuery('.sc_parallax').each(function(){
1794		var windowHeight = jQuery(window).height();
1795		var scrollTops = jQuery(window).scrollTop();
1796		var offsetPrx = Math.max(jQuery(this).offset().top, windowHeight);
1797		if ( offsetPrx <= scrollTops + windowHeight ) {
1798			var speed  = Number(jQuery(this).data('parallax-speed'));
1799			var xpos   = jQuery(this).data('parallax-x-pos');  
1800			var ypos   = Math.round((offsetPrx - scrollTops - windowHeight) * speed + (speed < 0 ? windowHeight*speed : 0));
1801			jQuery(this).find('.sc_parallax_content').css('backgroundPosition', xpos+' '+ypos+'px');
1802			// Uncomment next line if you want parallax video (else - video position is static)
1803			jQuery(this).find('div.sc_video_bg').css('top', ypos+'px');
1804		} 
1805	});
1806}
1807
1808// Init Popup Menu
1809function InitPopupMenu(){
1810	var padd1 = parseInt(jQuery('.sidemenu_wrap').css('paddingTop'));
1811	var bodyHeight = jQuery(window).height();
1812	jQuery('#popup_menu').width(jQuery('.main').width());
1813	jQuery('#sidemnu_scroll .sc_scroll_wrapper.swiper-wrapper').width(jQuery(window).width());
1814
1815	var menu = jQuery('.sidemenu_wrap .sidemenu_area ul.sub-menu > li > ul.sub-menu');
1816	var topmenu = menu.parent().parent();
1817	var maxH = 0;
1818	var menuCounter = 0;
1819	menu.each(function() {
1820		var elemH = 0;
1821		jQuery(this).find('a').each(function() {
1822			elemH = elemH + jQuery(this).height();
1823		});
1824
1825		maxH = maxH >= elemH ? maxH : elemH;
1826		menuCounter++;
1827	});
1828
1829	if(jQuery(window).width() < 800) maxH = maxH * menuCounter / jQuery('#sidemenu > li').length;
1830	topmenu.height(maxH);
1831}
1832
1833
1834// set max ul height to all ".sub-menu .sub-menu"s
1835function maxHeightSidemenuUL() {
1836	if (jQuery('.sidemenu_wrap').length > 0) {
1837		var menu = jQuery("#sidemenu .sub-menu .sub-menu");
1838		if (jQuery(window).width() > 768) {
1839			var maxH = Math.max.apply(null, menu.map(function ()
1840			{
1841				return jQuery(this).height();
1842			}).get());
1843
1844			menu.height(maxH);
1845		} else {
1846			menu.css('height','');
1847		}
1848	}
1849}

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.