PageSourceSearch

https://www.atleticaalba.it/wp-content/plugins/trx_utils/shortcodes/theme.shortcodes.js

js atleticaalba.it collected 2026-09-27 05:06:03 UTC 44,054 bytes, 1,285 lines download raw bytes

1// Init actions
2function runcrew_sc_init_actions() {
3	"use strict";
4	setTimeout(function() {
5		runcrew_sc_animation();
6	}, 600);
7	
8	// MenuItems - init once
9	jQuery('body')
10		.on('click', '.show_popup_menuitem', function(e) {
11			"use strict";
12			runcrew_menuitems_show_popup(jQuery(this));
13			e.preventDefault();
14			return false;
15		})
16		.on('click', '.close_menuitem, .popup_menuitem', function(e) {
17			"use strict";
18			var target = jQuery(e.target);
19			if (target.hasClass('popup_menuitem') || target.hasClass('close_menuitem') || target.parent().hasClass('close_menuitem')) {
20				runcrew_menuitems_hide_popup();
21				e.preventDefault();
22				return false;
23			}
24		});
25
26	// Init sc in container
27	runcrew_sc_init(jQuery('body').eq(0));
28}
29
30
31// Resize actions
32function runcrew_sc_resize_actions() {
33	"use strict";
34	runcrew_sc_sliders_resize();
35}
36
37
38// Scroll actions
39function runcrew_sc_scroll_actions() {
40	"use strict";
41	runcrew_sc_animation();
42}
43
44
45// Animation
46function runcrew_sc_animation() {
47	jQuery('[data-animation^="animated"]:not(.animated)').each(function() {
48		"use strict";
49		if (jQuery(this).offset().top < jQuery(window).scrollTop() + jQuery(window).height())
50			jQuery(this).addClass(jQuery(this).data('animation'));
51	});
52}
53
54
55// Shortcodes init
56function runcrew_sc_init(container) {
57
58	// Call theme specific action (if exists)
59	if (window.runcrew_theme_sc_init) runcrew_theme_sc_init(container);
60
61	// Accordion
62	if (container.find('.sc_accordion:not(.inited)').length > 0) {
63		container.find(".sc_accordion:not(.inited)").each(function () {
64			"use strict";
65			var init = jQuery(this).data('active');
66			if (isNaN(init)) init = 0;
67			else init = Math.max(0, init);
68			jQuery(this)
69				.addClass('inited')
70				.accordion({
71					active: init,
72					heightStyle: "content",
73					header: "> .sc_accordion_item > .sc_accordion_title",
74					create: function (event, ui) {
75						"use strict";
76						runcrew_sc_init(ui.panel);
77						if (window.runcrew_init_hidden_elements) runcrew_init_hidden_elements(ui.panel);
78						ui.header.each(function () {
79							"use strict";
80							jQuery(this).parent().addClass('sc_active');
81						});
82					},
83					activate: function (event, ui) {
84						"use strict";
85						runcrew_sc_init(ui.newPanel);
86						if (window.runcrew_init_hidden_elements) runcrew_init_hidden_elements(ui.newPanel);
87						ui.newHeader.each(function () {
88							"use strict";
89							jQuery(this).parent().addClass('sc_active');
90						});
91						ui.oldHeader.each(function () {
92							"use strict";
93							jQuery(this).parent().removeClass('sc_active');
94						});
95					}
96				});
97		});
98	}
99
100	// Blogger: style Polaroid
101	if (container.find('.sc_blogger.layout_polaroid .photostack:not(.inited)').length > 0) {
102		container.find(".sc_blogger.layout_polaroid .photostack:not(.inited)").each(function () {
103			"use strict";
104			var obj = jQuery(this);
105			var id = obj.attr('id');
106			if (id == undefined) {
107				id = 'photostack_'+Math.random();
108				id = id.replace('.', '');
109				obj.attr('id', id);
110			}
111			setTimeout(function() {
112				"use strict";
113				obj.addClass('inited').parent().height("auto");
114				new Photostack( obj.get(0), {
115					callback: function( item ) {
116					}
117				} );
118			}, 10);
119		});
120	}
121
122	// Blogger: Scroll horizontal
123	if (container.find('.sc_blogger .sc_scroll_horizontal .sc_scroll_wrapper:not(.inited)').length > 0) {
124		container.find(".sc_blogger .sc_scroll_horizontal .sc_scroll_wrapper:not(.inited)").each(function () {
125			"use strict";
126			var obj = jQuery(this);
127			var width = 0;
128			obj.find('.isotope_item').each(function(){
129				"use strict";
130				width += jQuery(this).outerWidth();
131			});
132			obj.addClass('inited').width(width);
133		});
134	}
135
136	// Form
137	if (container.find('.sc_form:not(.inited) form').length > 0) {
138		container.find(".sc_form:not(.inited) form").each(function() {
139			"use strict";
140			jQuery(this).addClass('inited');
141			jQuery(this).submit(function(e) {
142				"use strict";
143				runcrew_sc_form_validate(jQuery(this));
144				e.preventDefault();
145				return false;
146			});
147			if (jQuery(this).find('.js__datepicker').length > 0) {
148				jQuery(this).find('.js__datepicker').pickadate({
149					// Work-around for some mobile browsers clipping off the picker.
150					onOpen: function() {
151						"use strict";
152						jQuery('pre').css('overflow', 'hidden');
153						},
154					onClose: function() {
155						"use strict";
156						jQuery('pre').css('overflow', '');
157					},
158					monthsShort: [ 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'June', 'July', 'Aug', 'Sept', 'Oct', 'Nov', 'Dec' ],
159					showMonthsShort: true,
160					format: 'dd.mm.yyyy',
161					formatSubmit: 'yyyy-mm-dd',
162					min: true
163				});
164			}
165			if (jQuery(this).find('.js__timepicker').length > 0) {
166				jQuery(this).find('.js__timepicker').pickatime();
167			}
168		});
169	}
170
171	//Countdown
172	if (container.find('.sc_countdown:not(.inited)').length > 0) {
173		container.find('.sc_countdown:not(.inited)')
174			.each(function () {
175				"use strict";
176				jQuery(this).addClass('inited');
177				var id = jQuery(this).attr('id');
178				var curDate = new Date(); 
179				var curDateTimeStr = curDate.getFullYear()+'-'+(curDate.getMonth()<9 ? '0' : '')+(curDate.getMonth()+1)+'-'+(curDate.getDate()<10 ? '0' : '')+curDate.getDate()
180					+' '+(curDate.getHours()<10 ? '0' : '')+curDate.getHours()+':'+(curDate.getMinutes()<10 ? '0' : '')+curDate.getMinutes()+':'+(curDate.getSeconds()<10 ? '0' : '')+curDate.getSeconds(); 
181				var interval = 1;	//jQuery(this).data('interval');
182				var endDateStr = jQuery(this).data('date');
183				var endDateParts = endDateStr.split('-');
184				var endTimeStr = jQuery(this).data('time');
185				var endTimeParts = endTimeStr.split(':');
186				if (endTimeParts.length < 3) endTimeParts[2] = '00';
187				var endDateTimeStr = endDateStr+' '+endTimeStr;
188				if (curDateTimeStr < endDateTimeStr) {
189					jQuery(this).find('.sc_countdown_placeholder').countdown({
190						until: new Date(endDateParts[0], endDateParts[1]-1, endDateParts[2], endTimeParts[0], endTimeParts[1], endTimeParts[2]), 
191						tickInterval: interval,
192						onTick: runcrew_countdown
193					}); 
194				} else {
195					jQuery(this).find('.sc_countdown_placeholder').countdown({
196						since: new Date(endDateParts[0], endDateParts[1]-1, endDateParts[2], endTimeParts[0], endTimeParts[1], endTimeParts[2]), 
197						tickInterval: interval,
198						onTick: runcrew_countdown
199					}); 
200				}
201			});
202	}
203
204	// Emailer form
205	if (container.find('.sc_emailer:not(.inited)').length > 0) {
206		container.find(".sc_emailer:not(.inited)")
207			.addClass('inited')
208			.on('click', '.sc_emailer_button', function(e) {
209				"use strict";
210				var form = jQuery(this).parents('form');
211				var parent = jQuery(this).parents('.sc_emailer');
212				if (parent.hasClass('sc_emailer_opened')) {
213					if (form.length>0 && form.find('input').val()!='') {
214						var group = jQuery(this).data('group');
215						var email = form.find('input').val();
216						var regexp = new RegExp(RUNCREW_STORAGE['email_mask']);
217						if (!regexp.test(email)) {
218							form.find('input').get(0).focus();
219							runcrew_message_warning(RUNCREW_STORAGE['strings']['email_not_val
219id']);
220						} else {
221							jQuery.post(RUNCREW_STORAGE['ajax_url'], {
222								action: 'emailer_submit',
223								nonce: RUNCREW_STORAGE['ajax_nonce'],
224								group: group,
225								email: email
226							}).done(function(response) {
227								"use strict";
228								var rez = {};
229								try {
230									rez = JSON.parse(response);
231								} catch (e) {
232									rez = { error: RUNCREW_STORAGE['ajax_error'] };
233									console.log(response);
234								}
235								if (rez.error === '') {
236									runcrew_message_info(RUNCREW_STORAGE['strings']['email_confirm'].replace('%s', email));
237									form.find('input').val('');
238								} else {
239									runcrew_message_warning(rez.error);
240								}
241							});
242						}
243					} else
244						form.get(0).submit();
245				} else {
246					parent.addClass('sc_emailer_opened');
247				}
248				e.preventDefault();
249				return false;
250			});
251	}
252	
253	// Googlemap init
254	if (container.find('.sc_googlemap:not(.inited)').length > 0 && window.runcrew_googlemap_init) {
255		container.find('.sc_googlemap:not(.inited)')
256			.each(function () {
257				"use strict";
258				if (jQuery(this).parents('div:hidden,article:hidden').length > 0) return;
259				var map = jQuery(this).addClass('inited');
260				var map_id		= map.attr('id');
261				var map_zoom	= map.data('zoom');
262				var map_style	= map.data('style');
263				var map_markers = [];
264				map.find('.sc_googlemap_marker').each(function() {
265					"use strict";
266					var marker = jQuery(this);
267					map_markers.push({
268						point:			marker.data('point'),
269						address:		marker.data('address'),
270						latlng:			marker.data('latlng'),
271						description:	marker.data('description'),
272						title:			marker.data('title')
273					});
274				});
275				runcrew_googlemap_init( jQuery('#'+map_id).get(0), {style: map_style, zoom: map_zoom, markers: map_markers});
276			});
277	}
278
279	// Infoboxes
280	if (container.find('.sc_infobox.sc_infobox_closeable:not(.inited)').length > 0) {
281		container.find('.sc_infobox.sc_infobox_closeable:not(.inited)')
282			.addClass('inited')
283			.on('click', function (e) {
284				"use strict";
285				jQuery(this).slideUp();
286				e.preventDefault();
287				return false;
288			});
289	}
290
291	// Matches
292	if (container.find('.sc_matches:not(.inited)').length > 0) {
293		container.find('.sc_matches:not(.inited)')
294			.each(function () {
295				"use strict";
296				jQuery(this).find('.sc_matches_next .sc_matches_list .sc_match').on('click', function () {
297					"use strict";
298					jQuery(this).parents('.sc_matches').find('.sc_matches_current .sc_match').hide();
299					var item = jQuery(this).data('item');
300					jQuery(item).fadeIn();
301				});
302			});
303	}
304
305	// Matches & Players: Sort players by points
306	if (container.find('.sc_players_table:not(.inited)').length > 0) {
307		container.find('.sc_players_table:not(.inited)')
308			.addClass('inited')
309			.on('click', '.sort', function (e) {
310				"use strict";
311				var table = jQuery(this).parents('.sc_players_table');
312				var id = jQuery(table).attr('id')
313				var sort = jQuery(table).data('sort') == 'asc' ? 'desc' : 'asc';
314				jQuery.post(RUNCREW_STORAGE['ajax_url'], {
315					action: 'sort_by_points',
316					nonce: RUNCREW_STORAGE['ajax_nonce'],
317					sort: sort,
318					table: RUNCREW_STORAGE['ajax_' + id]
319				}).done(function(response) {
320					var rez = {};
321					try {
322						rez = JSON.parse(response);
323					} catch (e) {
324						rez = { error: RUNCREW_STORAGE['ajax_error'] };
325						console.log(response);
326					}
327					if (rez.error === '') { 
328						jQuery(table).find('.sc_table').remove();
329						jQuery(table).find('script').after(rez.data);
330						jQuery(table).data('sort', sort);
331						runcrew_select_players_category(jQuery(table).find('.sc_players_table_category select'));		
332					}
333				});
334				e.preventDefault();
335				return false;
336			});
337	}
338	
339	// Matches & Players: Select category in the points table
340	if (container.find('.sc_players_table_category:not(.inited)').length > 0) {
341		container.find('.sc_players_table_category:not(.inited)')
342			.addClass('inited')
343			.on('change', function () {
344				"use strict";
345				runcrew_select_players_category(jQuery(this));		
346			});
347	}
348
349	// Popup links
350	if (container.find('.sc_popup_link:not(.inited)').length > 0) {
351		container.find('.sc_popup_link:not(.inited)').each(function() {
352			var popup_id = jQuery(this).attr('href');
353			jQuery(this)
354				.addClass('inited')
355				.magnificPopup({
356					type: 'inline',
357					removalDelay: 500,
358					midClick: true,
359					callbacks: {
360						beforeOpen: function () {
361							this.st.mainClass = 'mfp-zoom-in';
362						},
363						open: function() {
364							"use strict";
365							runcrew_sc_init(jQuery(popup_id));
366							runcrew_resize_actions();
367							if (window.runcrew_init_hidden_elements) runcrew_init_hidden_elements(jQuery(popup_id));
368						},
369						close: function() {}
370					}
371				});
372		});
373	}
374
375	// Recent news widget and sc
376	if (container.find('.sc_recent_news_header_category_item_more:not(.inited)').length > 0) {
377		container.find('.sc_recent_news_header_category_item_more:not(.inited)').each(function() {
378			"use strict";
379			jQuery(this)
380				.addClass('inited')
381				.on('click', function(e) {
382					"use strict";
383					jQuery(this).toggleClass('opened').find('.sc_recent_news_header_more_categories').slideToggle();
384					e.preventDefault();
385					return false;
386				});
387		});
388	}
389
390	// Search form
391	if (container.find('.search_wrap:not(.inited)').length > 0) {
392		container.find('.search_wrap:not(.inited)').each(function() {
393			"use strict";
394			jQuery(this)
395				.addClass('inited')
396				.on('click', '.search_submit', function(e) {
397					"use strict";
398					var search_wrap = jQuery(this).parents('.search_wrap');
399					if (!search_wrap.hasClass('search_state_fixed')) {
400						if (search_wrap.hasClass('search_state_opened')) {
401							if (search_wrap.find('.search_field').val() != '')
402								search_wrap.find('form').get(0).submit();
403							else
404								search_wrap.removeClass('search_state_opened').addClass('search_state_closed').find('.search_results').fadeOut();
405						} else
406							search_wrap.removeClass('search_state_closed').addClass('search_state_opened').find('.search_field').get(0).focus();
407					} else {
408						if (search_wrap.find('.search_field').val() != '')
409							search_wrap.find('form').get(0).submit();
410						else {
411							search_wrap.find('.search_field').val('');
412							search_wrap.find('.search_results').fadeOut();
413						}
414					}
415					e.preventDefault();
416					return false;
417				})
418				.on('click', '.search_results_close', function(e) {
419					"use strict";
420					jQuery(this).parent().fadeOut();
421					e.preventDefault();
422					return false;
423				})
424				.on('click', '.search_more', function(e) {
425					"use strict";
426					if (jQuery(this).parents('.search_wrap').find('.search_field').val() != '')
427						jQuery(this).parents('.search_wrap').find('form').get(0).submit();
428					e.preventDefault();
429					return false;
430				});
431			if (jQuery(this).hasClass('search_ajax')) {
432				var ajax_timer = null;
433				jQuery(this).find('.search_field').keyup(function(e) {
434					"use strict";
435					var search_field = jQuery(this);
436					var s = search_field.val();
437					if (ajax_timer) {
438						clearTimeout(ajax_timer);
439						ajax_timer = null;
440					}
441					if (s.length >= RUNCREW_STORAGE['ajax_search_min_length']) {
442						ajax_timer = setTimeout(function() {
443							"use strict";
444							jQuery.post(RUNCREW_STORAGE['ajax_url'], {
445								action: 'ajax_search',
446								nonce: RUNCREW_STORAGE['ajax_nonce'],
447								text: s
448							}).done(function(response) {
449								"use strict";
450								clearTimeout(ajax_timer);
451								ajax_timer = null;
452								var rez = {};
453								try {
454									rez = JSON.parse(response);
455								} catch (e) {
456									rez = { error: RUNCREW_STORAGE['ajax_error'] };
457									console.log(response);
458								}
459								if (rez.error === '') {
460									search_field.parents('.search_ajax').find('.search_results_content').empty().append(rez.data);
461									search_field.parents('.search_ajax').find('.search_results').fadeIn();
462								} else {
463									runcrew_message_warning(RUNCREW_STORAGE['strings']['search_error']);
464								}
465							});
466						}, RUNCREW_STORAGE['ajax_search_delay']);
467					}
468				});
469			}
470		});
471	}
472
473	
474	// Section Pan init
475	if (container.find('.sc_pan:not(.inited_pan)').length > 0) {
476		container.find('.sc_pan:not(.inited_pan)')
477			.each(function () {
478				"use strict";
479				if (jQuery(this).parents('div:hidden,article:hidden').length > 0) return;
480				var pan = jQuery(this).addClass('inited_pan');
481				var cont = pan.parent();
482				cont.mousemove(function(e) {
483					"use strict";
484					var anim = {};
485					var tm = 0;
486					var pw = pan.width(), ph = pan.height();
487					var cw = cont.width(), ch = cont.height();
488					var coff = cont.offset();
489					if (pan.hasClass('sc_pan_vertical'))
490						pan.css('top', -Math.floor((e.pageY - coff.top) / ch * (ph-ch)));
491					if (pan.hasClass('sc_pan_horizontal'))
492						pan.css('left', -Math.floor((e.pageX - coff.left) / cw * (pw-cw)));
493				});
494				cont.mouseout(function(e) {
495					"use strict";
496					pan.css({'left': 0, 'top': 0});
497				});
498			});
499	}
500
501	// Scroll
502	if (container.find('.sc_scroll:not(.inited)').length > 0) {
503		container.find('.sc_scroll:not(.inited)')
504			.each(function () {
505				"use strict";
506				if (jQuery(this).parents('div:hidden,article:hidden').length > 0) return;
507				RUNCREW_STORAGE['scroll_init_counter'] = 0;
508				runcrew_sc_init_scroll_area(jQuery(this));
509			});
510	}
511
512
513	// Swiper Slider
514	if (container.find('.sc_slider_swiper:not(.inited)').length > 0) {
515		container.find('.sc_slider_swiper:not(.inited)')
516			.each(function () {
517				"use strict";
518				if (jQuery(this).parents('div:hidden,article:hidden').length > 0) return;
519				//if (jQuery(this).parents('.isotope_wrap:not(.inited)').length > 0) return;
520				jQuery(this).addClass('inited');
521				runcrew_sc_slider_autoheight(jQuery(this));
522				if (jQuery(this).parents('.sc_slider_pagination_area').length > 0) {
523					jQuery(this).parents('.sc_slider_pagination_area').find('.sc_slider_pagination .post_item').eq(0).addClass('active');
524				}
525				var id = jQuery(this).attr('id');
526				if (id == undefined) {
527					id = 'swiper_'+Math.random();
528					id = id.replace('.', '');
529					jQuery(this).attr('id', id);
530				}
531				jQuery(this).addClass(id);
532				jQuery(this).find('.slides .swiper-slide').css('position', 'relative');
533				var width = jQuery(this).width();
534				if (width == 0) width = jQuery(this).parent().width();
535				var spv = jQuery(this).data('slides-per-view');
536				if (spv == undefined) spv = 1;
537				var min_width = jQuery(this).data('slides-min-width');
538				if (min_width == undefined) min_width = 50;
539				if (width / spv < min_width) spv = Math.max(1, Math.floor(width / min_width));
540				var space = jQuery(this).data('slides-space');
541				if (space == undefined) space = 0;
542				if (RUNCREW_STORAGE['swipers'] === undefined) RUNCREW_STORAGE['swipers'] = {};
543				RUNCREW_STORAGE['swipers'][id] = new Swiper('.'+id, {
544					calculateHeight: !jQuery(this).hasClass('sc_slider_height_fixed'),
545					resizeReInit: true,
546					autoResize: true,
547					loop: true,
548					grabCursor: true,
549			        nextButton: jQuery(this).hasClass('sc_slider_controls') ? '#'+id+' .sc_slider_next' : false,
550			        prevButton: jQuery(this).hasClass('sc_slider_controls') ? '#'+id+' .sc_slider_prev' : false,
551					pagination: jQuery(this).hasClass('sc_slider_pagination') ? '#'+id+' .sc_slider_pagination_wrap' : false,
552				    paginationClickable: true,
553					autoplay: jQuery(this).hasClass('sc_slider_noautoplay') ? false : (isNaN(jQuery(this).data('interval')) ? 7000 : jQuery(this).data('interval')),
554					autoplayDisableOnInteraction: false,
555					initialSlide: 0,
556					slidesPerView: spv,
557					loopedSlides: spv,
558					spaceBetween: space,
559					speed: 600,
560					// Autoheight on start
561					onFirstInit: function (slider){
562						"use strict";
563						var cont = jQuery(slider.container);
564						if (!cont.hasClass('sc_slider_height_auto')) return;
565						var li = cont.find('.swiper-slide').eq(1);
566						var h = li.data('height_auto');
567						if (h > 0) {
568							var pt = parseInt(li.css('paddingTop')), pb = parseInt(li.css('paddingBottom'));
569							li.height(h);
570							cont.height(h + (isNaN(pt) ? 0 : pt) + (isNaN(pb) ? 0 : pb));
571							cont.find('.swiper-wrapper').height(h + (isNaN(pt) ? 0 : pt) + (isNaN(pb) ? 0 : pb));
572						}
573					},
574					// Autoheight on slide change
575					onSlideChangeStart: function (slider){
576						"use strict";
577						var cont = jQuery(slider.container);
578						if (!cont.hasClass('sc_slider_height_auto')) return;
579						var idx = slider.activeIndex;
580						var li = cont.find('.swiper-slide').eq(idx);
581						var h = li.data('height_auto');
582						if (h > 0) {
583							var pt = parseInt(li.css('paddingTop')), pb = parseInt(li.css('paddingBottom'));
584							li.height(h);
585							cont.height(h + (isNaN(pt) ? 0 : pt) + (isNaN(pb) ? 0 : pb));
586							cont.find('.swiper-wrapper').height(h + (isNaN(pt) ? 0 : pt) + (isNaN(pb) ? 0 : pb));
587						}
588					},
589					// Change current item in 'full' or 'over' pagination wrap
590					onSlideChangeEnd: function (slider, dir) {
591						"use strict";
592						var cont = jQuery(slider.container);
593						if (cont.parents('.sc_slider_pagination_area').length > 0) {
594							var li = cont.parents('.sc_slider_pagination_area').find('.sc_slider_pagination .post_item');
595							var idx = slider.activeIndex > li.length ? 0 : slider.activeIndex-1;
596							runcrew_sc_change_active_pagination_in_slider(cont, idx);
597						}
598					}
599				});
600				
601				jQuery(this).data('settings', {mode: 'horizontal'});		// VC hook
602				
603				var curSlide = jQuery(this).find('.slides').data('current-slide');
604				if (curSlide > 0)
605					RUNCREW_STORAGE['swipers'][id].slideTo(curSlide-1);
606
607				runcrew_sc_prepare_slider_navi(jQuery(this));
608
609			});
610			
611		// Check slides per view
612		runcrew_sc_sliders_resize();
613	}
614
615	//Skills init
616	if (container.find('.sc_skills_item:not(.inited)').length > 0) {
617		runcrew_sc_init_skills(container);
618		jQuery(window).scroll(function () { runcrew_sc_init_skills(container); });
619	}
620	//Skills type='arc' init
621	if (container.find('.sc_skills_arc:not(.inited)').length > 0) {
622		runcrew_sc_init_skills_arc(container);
623		jQuery(window).scroll(function () { runcrew_sc_init_skills_arc(container); });
624	}
625
626	// Tabs
627	if (container.find('.sc_tabs:not(.inited):not(.no_jquery_ui),.tabs_area:not(.inited)').length > 0) {
628		container.find('.sc_tabs:not(.inited):not(.no_jquery_ui),.tabs_area:not(.inited)').each(function () {
629			"use strict";
630			var init = jQuery(this).data('active');
631			if (isNaN(init)) init = 0;
632			else init = Math.max(0, init);
633			jQuery(this)
634				.addClass('inited')
635				.tabs({
636					active: init,
637					show: {
638						effect: 'fadeIn',
639						duration: 300
640					},
641					hide: {
642						effect: 'fadeOut',
643						duration: 300
644					},
645					create: function (event, ui) {
646						"use strict";
647						runcrew_sc_init(ui.panel);
648						if (window.runcrew_init_hidden_elements) runcrew_init_hidden_elements(ui.panel);
649					},
650					activate: function (event, ui) {
651						"use strict";
652						runcrew_sc_init(ui.newPanel);
653						if (window.runcrew_init_hidden_elements) runcrew_init_hidden_elements(ui.newPanel);
654					}
655				});
656		});
657	}
658	if (container.find('.sc_tabs.no_jquery_ui:not(.inited)').length > 0) {
659		container.find('.sc_tabs.no_jquery_ui:not(.inited)').each(function () {
660			"use strict";
661			jQuery(this)
662				.addClass('inited')
663				.on('click', '.sc_tabs_titles li a', function(e) {
664					"use strict";
665					if (!jQuery(this).parent().hasClass('sc_tabs_active')) {
666						var id_act = jQuery(this).parent().siblings('.sc_tabs_active').find('a').attr('href');
667						var id = jQuery(this).attr('href');
668						jQuery(this).parent().addClass('sc_tabs_active').siblings().removeClass('sc_tabs_active');
669						jQuery(id_act).fadeOut(function() {
670							"use strict";
671							jQuery(id).fadeIn(function() {
672								"use strict";
673								runcrew_sc_init(jQuery(this));
674								if (window.runcrew_init_hidden_elements) runcrew_init_hidden_elements(jQuery(this));
675							});
676						});
677					}
678					e.preventDefault();
679					return false;
680				});
681			jQuery(this).find('.sc_tabs_titles li').eq(0).addClass('sc_tabs_active');
682			jQuery(this).find('.sc_tabs_content').eq(0).fadeIn(function() {
683				"use strict";
684				runcrew_sc_init(jQuery(this));
685				if (window.runcrew_init_hidden_elements) runcrew_init_hidden_elements(jQuery(this));
686			});
687		});
688	}
689
690	// Toggles
691	if (container.find('.sc_toggles .sc_toggles_title:not(.inited)').length > 0) {
692		container.find('.sc_toggles .sc_toggles_title:not(.inited)')
693			.addClass('inited')
694			.on('click', function () {
695				"use strict";
696				jQuery(this).toggleClass('ui-state-active').parent().toggleClass('sc_active');
697				jQuery(this).parent().find('.sc_toggles_content').slideToggle(300, function () { 
698					"use strict";
699					runcrew_sc_init(jQuery(this).parent().find('.sc_toggles_content')); 
700					if (window.runcrew_init_hidden_elements) runcrew_init_hidden_elements(jQuery(this).parent().find('.sc_toggles_content'));
701				});
702			});
703	}
704
705	//Zoom
706	if (container.find('.sc_zoom:not(.inited)').length > 0) {
707		container.find('.sc_zoom:not(.inited)')
708			.each(function () {
709				"use strict";
710				if (jQuery(this).parents('div:hidden,article:hidden').length > 0) return;
711				jQuery(this).addClass('inited');
712				jQuery(this).find('img').elevateZoom({
713					zoomType: "lens",
714					lensShape: "round",
715					lensSize: 200,
716					lensBorderSize: 4,
717					lensBorderColour: '#ccc'
718				});
719			});
720	}
721
722}
723
724
725
726// Scrolled areas
727function runcrew_sc_init_scroll_area(obj) {
728	"use strict";
729
730	// Wait for images loading
731	if (!runcrew_check_images_complete(obj) && RUNCREW_STORAGE['scroll_init_counter']++ < 30) {
732		setTimeout(function() { runcrew_sc_init_scroll_area(obj); }, 200);
733		return;
734	}
735
736	// Start init scroll area
737	obj.addClass('inited');
738
739	var id = obj.attr('id');
740	if (id == undefined) {
741		id = 'scroll_'+Math.random();
742		id = id.replace('.', '');
743		obj.attr('id', id);
744	}
745	obj.addClass(id);
746
747	var parent_obj = obj.parent();
748	var parent_id  = parent_obj.attr('id');
749	if (parent_id == undefined) {
750		parent_id = 'scroll_wrap_'+Math.random();
751		parent_id = parent_id.replace('.', '');
752		parent_obj.attr('id', parent_id);
753	}
754	parent_obj.addClass(parent_id);
755
756	var bar = obj.find('#'+id+'_bar');
757	if (bar.length > 0 && !bar.hasClass(id+'_bar')) {
758		bar.addClass(id+'_bar');
759	}
760	
761	// Correct wrapper width (if scroll dir = horizontal)
762	if (obj.hasClass('sc_scroll_horizontal')) {
763		obj.find('.sc_scroll_wrapper >
763 .sc_scroll_slide').css('width', 'auto');
764		obj.find('.sc_scroll_wrapper').css('width', obj.find('.sc_scroll_wrapper > .sc_scroll_slide').width()+10);
765		obj.find('.sc_scroll_wrapper > .sc_scroll_slide').css('width', '100%')
766	}
767
768	// Init Swiper with scroll plugin
769	if (RUNCREW_STORAGE['swipers'] === undefined) RUNCREW_STORAGE['swipers'] = {};
770	RUNCREW_STORAGE['swipers'][id] = new Swiper('.'+id, {
771		calculateHeight: false,
772		resizeReInit: true,
773		autoResize: true,
774		freeMode: true,
775		freeModeFluid: true,
776		grabCursor: true,
777		mode: obj.hasClass('sc_scroll_vertical') ? 'vertical' : 'horizontal',
778		direction: obj.hasClass('sc_scroll_vertical') ? 'vertical' : 'horizontal',
779		slidesPerView: obj.hasClass('sc_scroll') ? 'auto' : 1,
780        nextButton: parent_obj.hasClass('sc_scroll_controls') ? '#'+parent_id+' .sc_scroll_next' : false,
781        prevButton: parent_obj.hasClass('sc_scroll_controls') ? '#'+parent_id+' .sc_scroll_prev' : false,
782        scrollbar: '.'+id+'_bar',
783        scrollbarHide: true,
784	})
785	
786	// VC hook
787	obj.data('settings', {mode: 'horizontal'});
788}
789
790
791// Slider navigation
792function runcrew_sc_prepare_slider_navi(slider) {
793	"use strict";
794	var navi = null;
795	
796/*
797	// Prev / Next
798	navi = slider.find('> .sc_slider_controls_wrap, > .sc_scroll_controls_wrap');
799	if (navi.length == 0) navi = slider.siblings('.sc_slider_controls_wrap,.sc_scroll_controls_wrap');
800	if (navi.length > 0) {
801		navi.on('click', '.sc_slider_prev,.sc_scroll_prev', function(e) {
802			var swiper = jQuery(this).parents('.swiper-slider-container');
803			if (swiper.length == 0) swiper = jQuery(this).parents('.sc_slider_controls_wrap,.sc_scroll_controls_wrap').siblings('.swiper-slider-container');
804			var id = swiper.attr('id');
805			RUNCREW_STORAGE['swipers'][id].slidePrev();
806			e.preventDefault();
807			return false;
808		})
809        .on('click', '.sc_slider_next,.sc_scroll_next', function(e){
810			var swiper = jQuery(this).parents('.swiper-slider-container');
811			if (swiper.length == 0) swiper = jQuery(this).parents('.sc_slider_controls_wrap,.sc_scroll_controls_wrap').siblings('.swiper-slider-container');
812			var id = swiper.attr('id');
813			RUNCREW_STORAGE['swipers'][id].slideNext();
814			e.preventDefault();
815			return false;
816		});
817	}
818*/
819	// Pagination with slide's title
820	navi = slider.siblings('.sc_slider_pagination');
821	if (navi.length > 0) {
822		navi.on('click', '.post_item', function(e){
823			var swiper = jQuery(this).parents('.sc_slider_pagination_area').find('.swiper-slider-container');
824			var id = swiper.attr('id');
825			RUNCREW_STORAGE['swipers'][id].slideTo(jQuery(this).index()+1);
826			e.preventDefault();
827			return false;
828		});
829	}
830}
831
832// Sliders: Pagination
833function runcrew_sc_change_active_pagination_in_slider(slider, idx) {
834	"use strict";
835	var pg = slider.parents('.sc_slider_pagination_area').find('.sc_slider_pagination');
836	if (pg.length==0) return;
837	pg.find('.post_item').removeClass('active').eq(idx).addClass('active');
838	var h = pg.height();
839	var off = pg.find('.active').offset().top - pg.offset().top;
840	var off2 = pg.find('.sc_scroll_wrapper').offset().top - pg.offset().top;
841	var h2  = pg.find('.active').height();
842	if (off < 0) {
843		pg.find('.sc_scroll_wrapper').css({'transform': 'translate3d(0px, 0px, 0px)', 'transition-duration': '0.3s'});
844	} else if (h <= off+h2) {
845		pg.find('.sc_scroll_wrapper').css({'transform': 'translate3d(0px, -'+(Math.abs(off2)+off-h/4)+'px, 0px)', 'transition-duration': '0.3s'});
846	}
847}
848
849// Sliders: Autoheight
850function runcrew_sc_slider_autoheight(slider) {
851	"use strict";
852	if (slider.hasClass('.sc_slider_height_auto')) {
853		slider.find('.swiper-slide').each(function() {
854			"use strict";
855			if (jQuery(this).data('height_auto') == undefined) {
856				jQuery(this).attr('data-height_auto', jQuery(this).height());
857			}
858		});
859	}
860}
861
862// Sliders: Resize
863function runcrew_sc_sliders_resize() {
864	"use strict";
865	var slider = arguments[0]!==undefined ? arguments[0] : '.sc_slider_swiper.inited';
866	var resize = arguments[1]!==undefined ? arguments[1] : true;
867
868	jQuery(slider).each(function() {
869		"use strict";
870		var id = jQuery(this).attr('id');
871		var width = jQuery(this).width();
872		var last_width = jQuery(this).data('last-width');
873		if (isNaN(last_width)) last_width = 0;
874		
875		// Change slides_per_view
876		if (last_width==0 || last_width!=width) {
877			var spv = jQuery(this).data('slides-per-view');
878			if (spv == undefined) spv = 1;
879			var min_width = jQuery(this).data('slides-min-width');
880			if (min_width == undefined) min_width = 50;
881			if (width / spv < min_width) spv = Math.max(1, Math.floor(width / min_width));
882			jQuery(this).data('last-width', width);
883			if (RUNCREW_STORAGE['swipers'][id].params.slidesPerView != spv) {
884				RUNCREW_STORAGE['swipers'][id].params.slidesPerView = spv;
885				RUNCREW_STORAGE['swipers'][id].params.loopedSlides = spv;
886				//RUNCREW_STORAGE['swipers'][id].reInit();
887			}
888		}
889		
890		// Resize slider
891		if ( resize && !jQuery(this).hasClass('sc_slider_height_fixed') ) {
892			var h = 0;
893			if ( jQuery(this).find('.swiper-slide > img').length > 0 ) {
894				jQuery(this).find('.swiper-slide > img').each(function() {
895					"use strict";
896					if (jQuery(this).height() > h) h = jQuery(this).height();
897				});
898				jQuery(this).height(h);
899			} else if ( jQuery(this).find('.swiper-slide').css('backgroundImage')!='none' ) {
900				h = Math.floor(width/16*9);
901				jQuery(this).height(h).find('.swiper-slide').height(h);
902			}
903		}
904	});
905	
906	// Resize slider pagination area
907	jQuery('.sc_slider_pagination_area').each(function() {
908		"use strict";
909		var h = jQuery(this).find('.sc_slider').height();
910		if (h) {
911			jQuery(this).height(h);
912			jQuery(this).find('.sc_slider_pagination').height(h);
913			jQuery(this).find('.sc_slider_pagination .sc_scroll_vertical').height(h);
914		}
915	});
916}
917
918
919// Skills init
920function runcrew_sc_init_skills(container) {
921	"use strict";
922	if (arguments.length==0) var container = jQuery('body');
923	var scrollPosition = jQuery(window).scrollTop() + jQuery(window).height();
924
925	container.find('.sc_skills_item:not(.inited)').each(function () {
926		"use strict";
927		var skillsItem = jQuery(this);
928		var scrollSkills = skillsItem.offset().top;
929		if (scrollPosition > scrollSkills) {
930			skillsItem.addClass('inited');
931			var skills = skillsItem.parents('.sc_skills').eq(0);
932			var type = skills.data('type');
933			var total = (type=='pie' && skills.hasClass('sc_skills_compact_on')) ? skillsItem.find('.sc_skills_data .pie') : skillsItem.find('.sc_skills_total').eq(0);
934			var start = parseInt(total.data('start'));
935			var stop = parseInt(total.data('stop'));
936			var maximum = parseInt(total.data('max'));
937			var startPercent = Math.round(start/maximum*100);
938			var stopPercent = Math.round(stop/maximum*100);
939			var ed = total.data('ed');
940			var duration = parseInt(total.data('duration'));
941			var speed = parseInt(total.data('speed'));
942			var step = parseInt(total.data('step'));
943			if (type == 'bar') {
944				var dir = skills.data('dir');
945				var count = skillsItem.find('.sc_skills_count').eq(0);
946				if (dir=='horizontal')
947					count.css('width', startPercent + '%').animate({ width: stopPercent + '%' }, duration);
948				else if (dir=='vertical')
949					count.css('height', startPercent + '%').animate({ height: stopPercent + '%' }, duration);
950				runcrew_sc_animate_skills_counter(start, stop, speed-(dir!='unknown' ? 5 : 0), step, ed, total);
951			} else if (type == 'counter') {
952				runcrew_sc_animate_skills_counter(start, stop, speed - 5, step, ed, total);
953			} else if (type == 'pie') {
954				var steps = parseInt(total.data('steps'));
955				var bg_color = '#fff';/*total.data('alter_bg_color');*/
956				var border_color = total.data('border_color');
957				var cutout = parseInt(total.data('cutout'));
958				var easing = total.data('easing');
959				var options = {
960					segmentShowStroke: false,
961					segmentStrokeColor: border_color,
962					segmentStrokeWidth: 1,
963					percentageInnerCutout : cutout,
964					animationSteps: steps,
965					animationEasing: easing,
966					animateRotate: true,
967					animateScale: false,
968				};
969				var pieData = [];
970				total.each(function() {
971					"use strict";
972					var color = jQuery(this).data('color');
973					var stop = parseInt(jQuery(this).data('stop'));
974					var stopPercent = Math.round(stop/maximum*100);
975					pieData.push({
976						value: stopPercent,
977						color: color
978					});
979				});
980				if (total.length == 1) {
981					runcrew_sc_animate_skills_counter(start, stop, Math.round(1500/steps), step, ed, total);
982					pieData.push({
983						value: 100-stopPercent,
984						color: bg_color
985					});
986				}
987				var canvas = skillsItem.find('canvas');
988				canvas.attr({width: skillsItem.width(), height: skillsItem.width()}).css({width: skillsItem.width(), height: skillsItem.height()});
989				new Chart(canvas.get(0).getContext("2d")).Doughnut(pieData, options);
990			}
991		}
992	});
993}
994
995// Skills counter animation
996function runcrew_sc_animate_skills_counter(start, stop, speed, step, ed, total) {
997	"use strict";
998	start = Math.min(stop, start + step);
999	total.text(start+ed);
1000	if (start < stop) {
1001		setTimeout(function () {
1002			runcrew_sc_animate_skills_counter(start, stop, speed, step, ed, total);
1003		}, speed);
1004	}
1005}
1006
1007// Skills arc init
1008function runcrew_sc_init_skills_arc(container) {
1009	"use strict";
1010	if (arguments.length==0) var container = jQuery('body');
1011	container.find('.sc_skills_arc:not(.inited)').each(function () {
1012		var arc = jQuery(this);
1013		arc.addClass('inited');
1014		var items = arc.find('.sc_skills_data .arc');
1015		var canvas = arc.find('.sc_skills_arc_canvas').eq(0);
1016		var legend = arc.find('.sc_skills_legend').eq(0);
1017		var w = Math.round(arc.width() - legend.width());
1018		var c = Math.floor(w/2);
1019		var o = {
1020			random: function(l, u){
1021				"use strict";
1022				return Math.floor((Math.random()*(u-l+1))+l);
1023			},
1024			diagram: function(){
1025				"use strict";
1026				var r = Raphael(canvas.attr('id'), w, w),
1027					hover = Math.round(w/2/items.length),
1028					rad = hover,
1029					step = Math.round(((w-20)/2-rad)/items.length),
1030					stroke = Math.round(w/9/items.length),
1031					speed = 400;
1032				
1033				
1034				r.circle(c, c, Math.round(w/2)).attr({ stroke: 'none', fill: RUNCREW_STORAGE['theme_skin_bg_color'] ? RUNCREW_STORAGE['theme_skin_bg_color'] : '#ffffff' });
1035
1036				var title = r.text(c, c, arc.data('caption')).attr({
1037					font: Math.round(rad*0.75)+'px "'+RUNCREW_STORAGE['theme_font']+'"',
1038					fill: RUNCREW_STORAGE['theme_skin_color'] ? RUNCREW_STORAGE['theme_skin_color'] : '#909090'
1039				}).toFront();
1040				
1041				rad -= Math.round(step/2);
1042
1043				r.customAttributes.arc = function(value, color, rad){
1044					"use strict";
1045					var v = 3.6 * value,
1046						alpha = v == 360 ? 359.99 : v,
1047						rand = o.random(91, 240),
1048						a = (rand-alpha) * Math.PI/180,
1049						b = rand * Math.PI/180,
1050						sx = c + rad * Math.cos(b),
1051						sy = c - rad * Math.sin(b),
1052						x = c + rad * Math.cos(a),
1053						y = c - rad * Math.sin(a),
1054						path = [['M', sx, sy], ['A', rad, rad, 0, +(alpha > 180), 1, x, y]];
1055					return { path: path, stroke: color }
1056				}
1057				
1058				items.each(function(i){
1059					"use strict";
1060					var t = jQuery(this), 
1061						color = t.find('.color').val(),
1062						value = t.find('.percent').val(),
1063						text = t.find('.text').text();
1064					
1065					rad += step;
1066					var z = r.path().attr({ arc: [value, color, rad], 'stroke-width': stroke });
1067					
1068					z.mouseover(function(){
1069						"use strict";
1070						this.animate({ 'stroke-width': hover, opacity: .75 }, 1000, 'elastic');
1071						if (Raphael.type != 'VML') //solves IE problem
1072							this.toFront();
1073						title.stop().animate({ opacity: 0 }, speed, '>', function(){
1074							this.attr({ text: (text ? text + '\n' : '') + value + '%' }).animate({ opacity: 1 }, speed, '<');
1075						});
1076					}).mouseout(function(){
1077						"use strict";
1078						this.stop().animate({ 'stroke-width': stroke, opacity: 1 }, speed*4, 'elastic');
1079						title.stop().animate({ opacity: 0 }, speed, '>', function(){
1080							title.attr({ text: arc.data('caption') }).animate({ opacity: 1 }, speed, '<');
1081						});	
1082					});
1083					
1084				});
1085				
1086			}
1087		}
1088		o.diagram();
1089	});
1090}
1091
1092
1093// Countdown update
1094function runcrew_countdown(dt) {
1095	"use strict";
1096	var counter = jQuery(this).parent();
1097	for (var i=3; i<dt.length; i++) {
1098		var v = (dt[i]<10 ? '0' : '') + dt[i];
1099		counter.find('.sc_countdown_item').eq(i-3).find('.sc_countdown_digits span').addClass('hide');
1100		for (var ch=v.length-1; ch>=0; ch--) {
1101			counter.find('.sc_countdown_item').eq(i-3).find('.sc_countdown_digits span').eq(ch+(i==3 && v.length<3 ? 1 : 0)).removeClass('hide').text(v.substr(ch, 1));
1102		}
1103	}
1104}
1105
1106
1107// Contact form handlers
1108function runcrew_sc_form_validate(form){
1109	"use strict";
1110	var url = form.attr('action');
1111	if (url == '') return false;
1112	form.find('input').removeClass('error_fields_class');
1113	var error = false;
1114	var form_custom = form.data('formtype')=='form_custom';
1115	if (!form_custom) {
1116		error = runcrew_form_validate(form, {
1117			error_message_show: true,
1118			error_message_time: 4000,
1119			error_message_class: "sc_infobox sc_infobox_style_error",
1120			error_fields_class: "error_fields_class",
1121			exit_after_first_error: false,
1122			rules: [
1123				{
1124					field: "username",
1125					min_length: { value: 1,	 message: RUNCREW_STORAGE['strings']['name_empty'] },
1126					max_length: { value: 60, message: RUNCREW_STORAGE['strings']['name_long'] }
1127				},
1128				{
1129					field: "email",
1130					min_length: { value: 7,	 message: RUNCREW_STORAGE['strings']['email_empty'] },
1131					max_length: { value: 60, message: RUNCREW_STORAGE['strings']['email_long'] },
1132					mask: { value: RUNCREW_STORAGE['email_mask'], message: RUNCREW_STORAGE['strings']['email_not_val
1132id'] }
1133				},
1134				{
1135					field: "message",
1136					min_length: { value: 1,  message: RUNCREW_STORAGE['strings']['text_empty'] },
1137					max_length: { value: RUNCREW_STORAGE['contacts_maxlength'], message: RUNCREW_STORAGE['strings']['text_long'] }
1138				}
1139			]
1140		});
1141	}
1142	if (!error && url!='#') {
1143		jQuery.post(url, {
1144			action: "send_form",
1145			nonce: RUNCREW_STORAGE['ajax_nonce'],
1146			type: form.data('formtype'),
1147			data: form.serialize()
1148		}).done(function(response) {
1149			"use strict";
1150			var rez = {};
1151			try {
1152				rez = JSON.parse(response);
1153			} catch (e) {
1154				rez = { error: RUNCREW_STORAGE['ajax_error'] };
1155				console.log(response);
1156			}
1157			var result = form.find(".result").toggleClass("sc_infobox_style_error", false).toggleClass("sc_infobox_style_success", false);
1158			if (rez.error === '') {
1159				form.get(0).reset();
1160				result.addClass("sc_infobox_style_success").html(RUNCREW_STORAGE['strings']['send_complete']);
1161				var return_url = form.find('input[name="return_url"]');
1162				if (return_url.length > 0 && return_url.val()!='') {
1163					setTimeout(function() {
1164						"use strict";
1165						window.location.href = return_url.val();
1166					}, 3300);
1167				}
1168			} else {
1169				result.addClass("sc_infobox_style_error").html(RUNCREW_STORAGE['strings']['send_error'] + ' ' + rez.error);
1170			}
1171			result.fadeIn().delay(3000).fadeOut();
1172		});
1173	}
1174	return !error;
1175}
1176
1177
1178
1179// Get players by category
1180function runcrew_select_players_category(sel) {
1181	var value = sel.find(':selected').data('cat');
1182	var table = sel.parents('.sc_players_table');
1183	if (value == 'all') 
1184		jQuery(table).find('.sc_table tr:nth-child(n+2)').show();
1185	else {
1186		jQuery(table).find('.sc_table tr:nth-child(n+2)').hide();
1187		jQuery(table).find('.sc_table tr').each(function() { 
1188			var cat = jQuery(this).data('cat'); 
1189			if (cat != null && cat.indexOf(value)!=-1)
1190			   jQuery(this).show();
1191		});
1192	}
1193}
1194
1195
1196
1197// Display menuitem in the popup
1198function runcrew_menuitems_show_popup(obj) {
1199	"use strict";
1200	
1201	// First init vars
1202	if (typeof RUNCREW_STORAGE['menuitem_load'] == 'undefined') {
1203		RUNCREW_STORAGE['menuitem_load'] = false;
1204		RUNCREW_STORAGE['menuitems_list'] = [];
1205
1206	// If busy - return
1207	} else if ( RUNCREW_STORAGE['menuitem_load'] ) {
1208		return;
1209	}
1210	
1211	// Show preloader
1212	jQuery('#page_preloader').data('bg-color', jQuery('#page_preloader').css('background-color')).css({display: 'block', opacity: 0, backgroundColor: 'transparent'}).animate({opacity:0.8}, 300);
1213
1214	// Get items list on first click
1215	if (RUNCREW_STORAGE['menuitems_list'].length == 0) {
1216		var menuitems_list_id = obj.parents('.sc_menuitems').attr("id");
1217		RUNCREW_STORAGE['menuitems_list'] = RUNCREW_STORAGE['menuitems'][menuitems_list_id].split(",");
1218	}
1219	
1220	var menuitem_id = obj.attr('rel');
1221	
1222	RUNCREW_STORAGE['menuitem_load'] = true;
1223	
1224	jQuery.post(RUNCREW_STORAGE['ajax_url'], {
1225		action: 'ajax_menuitem',
1226		nonce: RUNCREW_STORAGE['ajax_nonce'],
1227		text: menuitem_id
1228	}).done(function(response) {
1229		"use strict";
1230		RUNCREW_STORAGE['menuitem_load'] = false;
1231		var rez = {};
1232		try {
1233			rez = JSON.parse(response);
1234		} catch (e) {
1235			rez = { error: RUNCREW_STORAGE['ajax_error'] + '<br>' + response };
1236		}
1237		jQuery('#page_preloader').animate({opacity:0}
1237, 500, function() { jQuery(this).css({display: 'none', backgroundColor: jQuery(this).data('bg-color')}); });
1238		if (rez.error === '') {
1239			var delay = 0;
1240			// Create popup
1241			if (jQuery('.popup_menuitem').length == 0) {
1242				jQuery('body').append('<div id="overlay"></div><div class="popup_menuitem"></div>');
1243				jQuery('#overlay').fadeIn(500);
1244			} else {
1245				delay = 500;
1246				jQuery('.popup_menuitem').fadeOut(delay);
1247			}
1248			// Add new content in the popup
1249			setTimeout(function() {
1250				jQuery('.popup_menuitem').html(rez.data);
1251				jQuery('.popup_menuitem .sc_menuitems_wrap').append("<a class='close_menuitem' href='#'><span class='icon-cancel'></span></a>");
1252				if ( RUNCREW_STORAGE['menuitems_list'].length > 1 ) {
1253					var idx = 0;
1254					for (var i=0; i<RUNCREW_STORAGE['menuitems_list'].length; i++ ) {
1255						if ( RUNCREW_STORAGE['menuitems_list'][i] === menuitem_id ) {
1256							idx = i;
1257							break;
1258						}
1259					}
1260					var prev = (idx - 1 + RUNCREW_STORAGE['menuitems_list'].length) % RUNCREW_STORAGE['menuitems_list'].length;
1261					var next = (idx + 1) % RUNCREW_STORAGE['menuitems_list'].length;
1262					jQuery('.popup_menuitem .sc_menuitems_wrap .sc_menuitem_content').append(
1263						  "<a class='prev_menuitem prevnext_menuitem show_popup_menuitem' rel='"+RUNCREW_STORAGE['menuitems_list'][prev]+"'  href='#'><span class='icon-left'></span></a>"
1264						+ "<a class='next_menuitem prevnext_menuitem show_popup_menuitem' rel='"+RUNCREW_STORAGE['menuitems_list'][next]+"'  href='#'><span class='icon-right'></span></a>"
1265					);
1266				}
1267				jQuery('.popup_menuitem').fadeIn(500);
1268			}, delay);
1269		} else {
1270			runcrew_message_warning(RUNCREW_STORAGE['strings']['search_error']);
1271		}
1272	});	
1273}
1274
1275// Hide popup with menuitem
1276function runcrew_menuitems_hide_popup() {
1277	"use strict";
1278	jQuery('#overlay').fadeOut();
1279	jQuery('.popup_menuitem').fadeOut(function() {
1280		RUNCREW_STORAGE['menuitem_load'] = false;
1281		RUNCREW_STORAGE['menuitems_list'] = [];
1282		jQuery('#overlay').remove();
1283		jQuery(this).remove();
1284	});
1285}

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.