PageSourceSearch

https://www.sifytechnologies.com/us/wp-content/themes/metamax/js/scripts.js?ver=1.0

js sifytechnologies.com collected 2026-09-24 09:17:07 UTC 111,622 bytes, 3,618 lines download raw bytes

1"use strict";
2
3function cws_uniq_id ( prefix ){
4	var prefix = prefix != undefined && typeof prefix === 'string' ? prefix : "";
5	var d = new Date();
6	var t = d.getTime();
7	var unique = Math.random() * t;
8	var unique_id = prefix + unique;
9	return unique_id;
10}
11function cws_has_class ( el, cls_name ){
12	var re = new RegExp( "(^|\\s)" + cls_name + "(\\s|$)", 'g' );
13	return re.test( el.className );
14}
15function cws_add_class ( el, cls_name ){
16	if(!el){
17		return false;
18	}
19	el.className =  el.className.length ? el.className + " " + cls_name : cls_name;		
20}
21function cws_remove_class ( el, cls_name ){
22	var re = new RegExp( "\\s?" + cls_name, "g" );
23	el.className = el.className.replace( re, '' );
24}
25
26/*--------- CWS_RESPONSIVE_SCRIPTS ----------*/
27function is_mobile_device(){
28	if ( navigator.userAgent.match( /(Android|iPhone|iPod|iPad|Phone|DROID|webOS|BlackBerry|Windows Phone|ZuneWP7|IEMobile|Tablet|Kindle|Playbook|Nexus|Xoom|SM-N900T|GT-N7100|SAMSUNG-SGH-I717|SM-T330NU)/ ) ) {
29		return true;
30	} else {
31		return false;
32	}
33}
34function cws_is_tablet_viewport () {
35	if ( window.innerWidth > 767 && window.innerWidth < 1367 && is_mobile_device() ){
36		return true;
37	} else {
38		return false;
39	}		
40}
41function is_mobile () {
42	if ( window.innerWidth < 768 ){
43		return true;
44	} else {
45		return false;
46	}		
47}
48function not_desktop(){
49	if( (window.innerWidth < 1367 && is_mobile_device()) || window.innerWidth < 1200 ){
50		return true;
51	} else {
52		return false;
53	}
54}
55function cws_resize_controller() {
56	var cwsBody = jQuery('body');
57	if( is_mobile_device() && cws_is_tablet_viewport()){
58		cwsBody.removeClass('cws_mobile');
59		cwsBody.addClass('cws_tablet');
60	} else if ( is_mobile_device() && is_mobile() ){
61		cwsBody.removeClass('cws_tablet');
62		cwsBody.addClass('cws_mobile');
63	} else {
64		cwsBody.removeClass('cws_tablet');
65		cwsBody.removeClass('cws_mobile');
66	}
67}
68function cws_resize() {
69	cws_resize_controller();
70	window.addEventListener( "resize", function (){
71		cws_resize_controller();
72	}, false );
73}
74function cws_is_mobile () {
75	var device = is_mobile_device();
76	var viewport = not_desktop();
77	return device || viewport;
78}
79/*\--------- CWS_RESPONSIVE_SCRIPTS ----------\*/
80
81function cws_merge_trees ( arr1, arr2 ){
82	if ( typeof arr1 != 'object' || typeof arr2 != 'object' ){
83		return false;
84	}
85	return cws_merge_trees_walker ( arr1, arr2 );
86}
87function cws_merge_trees_walker ( arr1, arr2 ){
88	if ( typeof arr1 != 'object' || typeof arr2 != 'object' ){
89		return false;
90	}
91	var keys1 = Object.keys( arr1 ); /* ! not working with null value */
92	var keys2 = Object.keys( arr2 );
93	var r = {};
94	var i;
95	for ( i = 0; i < keys2.length; i++ ){
96		if ( typeof arr2[keys2[i]] == 'object' ){
97			if ( Array.isArray( arr2[keys2[i]] ) ){
98				if ( keys1.indexOf( keys2[i] ) === -1 ){
99					r[keys2[i]] = arr2[keys2[i]];
100				}
101				else{
102					r[keys2[i]] = arr1[keys2[i]];
103				}				
104			}
105			else{
106				if ( typeof arr1[keys2[i]] == 'object' ){
107					r[keys2[i]] = cws_merge_trees_walker( arr1[keys2[i]], arr2[keys2[i]] );
108				}
109				else{
110					r[keys2[i]] = cws_merge_trees_walker( {}, arr2[keys2[i]] );
111				}
112			}
113		}
114		else{
115			if ( keys1.indexOf( keys2[i] ) === -1 ){
116				r[keys2[i]] = arr2[keys2[i]];
117			}
118			else{
119				r[keys2[i]] = arr1[keys2[i]];
120			}
121		}
122	}
123	return r;
124}
125
126function cws_get_flowed_previous ( el ){
127	var prev = el.previousSibling;
128	var is_prev_flowed;
129	if ( !prev ) return false;
130	is_prev_flowed = cws_is_element_flowed( prev );
131	if ( !is_prev_flowed ){
132		return cws_get_flowed_previous( prev );
133	}
134	else{
135		return prev;
136	}
137}
138function cws_is_element_flowed ( el ){
139	var el_styles;
140	if ( el.nodeName === "#text" ){
141		return false;
142	}
143	el_styles = getComputedStyle( el );
144	if ( el_styles.display === "none" || ["fixed","absolute"].indexOf( el_styles.position ) != -1 ){
145		return false;
146	}else{
147		return true;
148	}
149}
150
151function cws_empty_p_filter_callback (){
152	var el = this;
153	if ( el.tagName === "P" && !el.innerHTML.length ){
154		return false;
155	}
156	else{
157		return true;
158	}	
159}
160function cws_br_filter_callback (){
161	var el = this;
162	if ( el.tagName === "BR" ){
163		return false;
164	}
165	else{
166		return true;
167	}	
168}
169
170function cws_getRandomInt ( min, max ){
171	var min = min !== undefined ? min : 0;
172	var max = max !== undefined ? max : 1000000;
173	return Math.floor( Math.random() * (max - min + 1) ) + min;
174}
175
176// Converts from degrees to radians.
177function cws_math_radians (degrees){
178	return degrees * Math.PI / 180;
179};
180
181// Converts from radians to degrees.
182function cws_math_degrees (radians){
183	return radians * 180 / Math.PI;
184};
185
186
187/**********************************
188************ CWS HOOKS ************
189**********************************/
190function cws_hooks_init (){
191	window.cws_hooks = {}
192}
193function cws_add_action ( tag, callback ){
194	if ( typeof tag !== "string" || !tag.length ){
195		return false;
196	}
197	if ( typeof callback !== "function" ){
198		return false;
199	}
200	var hooks 	= window.cws_hooks;
201	var hook;
202	if ( hooks[tag] === 'object' ){
203		hook = hooks[tag];
204	}
205	else{
206		hooks[tag] = hook = new cws_hook ( tag );
207	}
208	hook.addAction( callback );
209}
210function cws_do_action ( tag, args ){
211	var args 		= Array.isArray( args ) ? args : new Array ();
212	var hooks 		= window.cws_hooks;
213	var hook 		= hooks[tag]; 
214	var hook_exists = typeof hook === 'object';
215	if ( hook_exists ){
216		hook.run( args );
217	}
218	return false;
219}
220function cws_hook ( tag ){
221	this.tag = tag;
222	this.actions = {};
223	this.genActionID 	= function (){
224		return cws_uniq_id( "cws_action_" );
225	}
226	this.addAction 		= function ( callback ){
227		var actionID 			= this.genActionID();
228		var action 				= new cws_action( this, actionID, callback )
229		this.actions[actionID] 	= action;
230	}
231	this.run 			= function ( args ){
232		var actionID, action;
233		for ( actionID in this.actions ){
234			action = this.actions[actionID];
235			action.do( args );
236		}
237	}
238}
239function cws_action ( hook, actionID, callback ){
240	this.hook 		= hook;
241	this.id 		= actionID;
242	this.callback 	= callback;
243	this.do 		= function ( args ){
244		this.callback.apply( this, args );
245	}
246}
247/**********************************
248************ \CWS HOOKS ***********
249**********************************/
250
251
252/**********************************
253*********** CWS LOADER ************
254**********************************/
255(function ($){
256
257	var loader;
258	$.fn.start_cws_loader = start_cws_loader;
259	$.fn.stop_cws_loader = stop_cws_loader;
260
261	jQuery(document).ready(function (){
262		cws_page_loader_controller ();
263	});
264
265	function cws_page_loader_controller (){
266		var cws_page_loader, interval, timeLaps ;
267		cws_page_loader = $( "#cws-page-loader" );
268		timeLaps = 0;
269		interval = setInterval( function (){
270			var page_loaded = cws_check_if_page_loaded ();	
271			timeLaps ++;
272			if ( page_loaded || timeLaps == 12) {
273				clearInterval ( interval );
274				cws_page_loader.stop_cws_loader ();
275			}
276		}, 10);
277	}
278	function cws_check_if_page_loaded (){
279		var keys, key, i, r;
280		if ( window.cws_modules_state == undefined ) return false;
281		r = true;
282		keys = Object.keys( window.cws_modules_state );
283		for ( i = 0; i < keys.length; i++ ){
284			key = keys[i];
285			if ( !window.cws_modules_state[key] ){
286				r = false;
287				break;
288			}
289		}
290		return r;
291	}
292	function start_cws_loader (){
293		var loader_obj, loader_container, indicators;
294		loader = jQuery( this );
295		if ( !loader.length ) return;
296		loader_container = loader[0].parentNode;
297		if ( loader_container != null ){
298			loader_container.style.opacity = 1;
299			setTimeout( function (){
300				loader_container.style.display = "block";
301			}, 10);
302		}
303	}
304	function stop_cws_loader (){
305		var loader_obj, loader_container, indicators;
306		loader = jQuery( this );
307		if ( !loader.length ) return;
308		loader_container = loader[0].parentNode;
309		if ( loader_container != null ){
310			loader_container.style.opacity = 0;
311			setTimeout( function (){
312				loader_container.style.display = "none";
313				jQuery( ".cws-textmodule-icon-wrapper.add-animation-icon" ).cws_services_icon();
314			}, 200);
315		}
316	}
317	function updateCirclePos(){
318		var circle=$obj.data("circle");
319		TweenMax.set($obj,{
320			x:Math.cos(circle.angle)*circle.radius,
321			y:Math.sin(circle.angle)*circle.radius,
322		})
323		requestAnimationFrame(updateCirclePos);
324	}
325	function setupCircle($obj){
326		if(typeof($obj.data("circle"))=="undefined"){
327			$obj.data("circle",{radius:0,angle:0});
328
329			updateCirclePos();
330		}
331	}
332	function startCircleAnim($obj,radius,delay,startDuration,loopDuration){
333		setupCircle($obj);
334		$obj.data("circle").radius=0;
335		$obj.data("circle").angle=0;
336		TweenMax.to($obj.data("circle"),startDuration,{
337			delay:delay,
338			radius:radius,
339			ease:Quad.easeInOut
340		});
341		TweenMax.to($obj.data("circle"),loopDuration,{
342			delay:delay,
343			angle:Math.PI*2,
344			ease:Linear.easeNone,
345			repeat:-1
346		});
347	}
348	function stopCircleAnim($obj,duration){
349		TweenMax.to($obj.data("circle"),duration,{
350			radius:0,
351			ease:Quad.easeInOut,
352			onComplete:function(){
353				TweenMax.killTweensOf($obj.data("circle"));
354			}
355		});
356	}
357
358}(jQuery));
359
360/**********************************
361*********** \CWS LOADER ***********
362**********************************/
363
364
365/**********************************
366********** CWS PARALLAX ***********
367**********************************/
368
369(function ( $ ){
370  
371	$.fn.cws_prlx = cws_prlx;
372
373	window.addEventListener( 'scroll', function (){
374		if ( window.cws_prlx != undefined && !window.cws_prlx.disabled ){
375			window.cws_prlx.translate_layers();
376		}
377	}, false );
378
379	window.addEventListener( 'resize', function (){
380		var i, section_id, section_params, layer_id;
381		if ( window.cws_prlx != undefined ){
382			if ( window.cws_prlx.servant.is_mobile() ){
383				if ( !window.cws_prlx.disabled ){
384					for ( layer_id in window.cws_prlx.layers ){
385						window.cws_prlx.layers[layer_id].el.removeAttribute( 'style' );
386					}
387					window.cws_prlx.disabled = true;          
388				}
389			}
390			else{
391				if ( window.cws_prlx.disabled ){
392					window.cws_prlx.disabled = false;
393				}
394				for ( section_id in window.cws_prlx.sections ){
395					section_params = window.cws_prlx.sections[section_id];
396					if ( section_params.height != section_params.el.offsetHeight ){
397						window.cws_prlx.prepare_section_data( section_id );
398					}
399				}
400			}
401		}
402	}, false );
403
404	function cws_prlx ( args ){
405		var factory, sects;
406		sects = $( this );
407		if ( !sects.length ) return;
408		factory = new cws_prlx_factory( args );
409		window.cws_prlx = window.cws_prlx != undefined ? window.cws_prlx : new cws_prlx_builder ();
410		sects.each( function (){
411			var sect = $( this );
412			var sect_id = factory.add_section( sect );
413			if ( sect_id ) window.cws_prlx.prepare_section_data( sect_id );
414		});
415	}
416
417	function cws_prlx_factory ( args ){
418		var args = args != undefined ? args : {};
419		args.def_speed = args.def_speed != undefined && !isNaN( parseInt( args.def_speed ) ) && parseInt( args.def_speed > 0 ) && parseInt( args.def_speed <= 100 ) ? args.def_speed : 50;
420		args.layer_sel = args.layer_sel != undefined && typeof args.layer_sel == "string" && args.layer_sel.length ? args.layer_sel : ".cws_prlx_layer";  
421		this.args = args;
422		this.add_section = cws_prlx_add_section;
423		this.add_layer = cws_prlx_add_layer; 
424		this.remove_layer = cws_prlx_remove_layer;   
425	}
426
427	function cws_prlx_builder (){
428		this.servant = new cws_servant ();
429		this.sections = {};
430		this.layers = {}; 
431		this.calc_layer_speed = cws_prlx_calc_layer_speed;
432		this.prepare_section_data = cws_prlx_prepare_section_data;
433		this.prepare_layer_data = cws_prlx_prepare_layer_data;
434		this.translate_layers = cws_prlx_translate_layers;
435		this.translate_layer = cws_prlx_translate_layer;
436		this.conditions = {};
437		this.conditions.layer_loaded = cws_prlx_layer_loaded_condition;
438		this.disabled = false;
439	}
440
441	function cws_prlx_add_section ( section_obj ){
442		var factory, section, section_id, layers, layer, i;
443		factory = this;
444		section = section_obj[0];
445		layers = $( factory.args.layer_sel, section_obj );
446		if ( !layers.length ) return false;
447		section_id = window.cws_prlx.servant.uniq_id( 'cws_prlx_section_' );
448		section.id = section_id;
449
450		window.cws_prlx.sections[section_id] = {
451			'el' : section,
452			'height' : null,
453			'layer_sel' : factory.args.layer_sel
454		}
455
456		if ( /cws_Yt_video_bg/.test( section.className ) ){  /* for youtube video background */ 
457			section.addEventListener( "DOMNodeRemoved", function ( e ){
458				var el = e.srcElement ? e.srcElement : e.target;
459				if ( $( el ).is( factory.args.layer_sel ) ){
460					factory.remove_layer( el.id );
461				}
462			}, false );
463			section.addEventListener( "DOMNodeInserted", function ( e ){
464				var el = e.srcElement ? e.srcElement : e.target;
465				if ( $( el ).is( factory.args.layer_sel ) ){
466					factory.add_layer( el, section_id );
467				}
468			}, false );
469		}
470
471		section.addEventListener( "DOMNodeRemoved", function ( e ){ /* for dynamically removed content */
472			window.cws_prlx.prepare_section_data( section_id );
473		},false );
474		section.addEventListener( "DOMNodeInserted", function ( e ){ /* for dynamically added content */
475			window.cws_prlx.prepare_section_data( section_id );
476		},false );
477
478		for ( i = 0; i < layers.length; i++ ){
479			layer = layers[i];
480			factory.add_layer( layer, section_id )
481		}
482
483		return section_id;
484
485	}
486
487	function cws_prlx_add_layer ( layer, section_id ){
488		var factory, layer_rel_speed, layer_params;
489		factory = this;
490		layer.id = !layer.id.length ? window.cws_prlx.servant.uniq_id( 'cws_prlx_layer_' ) : layer.id;
491		layer_rel_speed = $( layer ).data( 'scroll-speed' );
492		layer_rel_speed = layer_rel_speed != undefined ? layer_rel_speed : factory.args.def_speed;
493		layer_params = {
494			'el' : layer,
495			'section_id' : section_id,
496			'height' : null,
497			'loaded' : false,
498			'rel_speed' : layer_rel_speed,
499			'speed' : null
500		}
501		window.cws_prlx.layers[layer.id] = layer_params;
502		return layer.id;
503	}
504
505	function cws_prlx_remove_layer ( layer_id ){
506		var layers;
507		layers = window.cws_prlx.layers;
508		if ( layers[layer_id] != undefined ){
509			delete layers[layer_id];
510		}
511	}
512
513	function cws_prlx_prepare_section_data ( section_id ){
514		var section, section_params, layer_sel, layers, layer, layer_id, i, section_obj;
515		if ( !Object.keys( window.cws_prlx.sections ).length || window.cws_prlx.sections[section_id] == undefined ) return false;
516		section_params = window.cws_prlx.sections[section_id];
517		section = section_params.el;
518		section_params.height = section.offsetHeight;
519		section_obj = $( section );
520		layers = $( section_params.layer_sel, section_obj );
521		for ( i=0; i<layers.length; i++ ){
522			layer = layers[i];
523			layer_id = layer.id;
524			if ( layer_id ) window.cws_prlx.prepare_layer_data( layer_id, section_id );
525		}
526	}
527
528	function cws_prlx_prepare_layer_data ( layer_id, section_id ){
529		window.cws_prlx.servant.wait_for( 'layer_loaded', [ layer_id ], function ( layer_id ){
530			var layer_params, layer;
531			layer_params = window.cws_prlx.layers[layer_id];
532			layer = layer_params.el;
533			layer_params.height = layer.offsetHeight;
534			window.cws_prlx.calc_layer_speed( layer_id );
535			window.cws_prlx.translate_layer( layer_id );
536			layer_params.loaded = true;
537		}, [ layer_id ]);    
538	}
539
540	function cws_prlx_translate_layers (){
541		var layers, layer_ids, layer_id, i;
542		if ( window.cws_prlx == undefined ) return;
543		layers = window.cws_prlx.layers;
544		layer_ids = Object.keys( layers );
545		for ( i = 0; i < layer_ids.length; i++ ){
546			layer_id = layer_ids[i];
547			window.cws_prlx.translate_layer( layer_id );
548		}
549	}
550
551	function cws_prlx_translate_layer ( layer_id ){
552		var layer_params, section, layer, layer_translation, style_adjs;
553		if ( window.cws_prlx == undefined || window.cws_prlx.layers[layer_id] == undefined ) return false;
554		layer_params = window.cws_prlx.layers[layer_id];
555		if ( layer_params.speed == null ) return false;
556		if ( layer_params.section_id == undefined || window.cws_prlx.sections[layer_params.section_id] == undefined ) return false;
557		section = window.cws_prlx.sections[layer_params.section_id].el;
558		if ( window.cws_prlx.servant.is_visible( section ) ) {
559			layer = layer_params.el;
560
561			layer_translation = ( section.getBoundingClientRect().top - window.innerHeight ) * layer_params.rel_speed;
562			style_adjs = {
563				"WebkitTransform" : "translate(0%," + layer_translation + "px)",
564				"MozTransform" : "translate(0%," + layer_translation + "px)",
565				"msTransform" : "translate(0%," + layer_translation + "px)",
566				"OTransform" : "translate(0%," + layer_translation + "px)",
567				"transform" : "translate(0%," + layer_translation + "px)"
568			}
569
570			for (var key in style_adjs ){
571				layer.style[key] = style_adjs[key];
572			}
573		}
574	}
575
576	function cws_servant (){
577		this.uniq_id = cws_uniq_id;
578		this.wait_for = cws_wait_for;
579		this.is_visible = cws_is_visible;
580		this.is_mobile = cws_is_mobile;
581	}
582
583	function cws_uniq_id ( prefix ){
584		var d, t, n, id;
585		var prefix = prefix != undefined ? prefix : "";
586		d = new Date();
587		t = d.getTime();
588		n = parseInt( Math.random() * t );
589		id = prefix + n;
590		return id;
591	}
592
593	function cws_wait_for ( condition, condition_args, callback, callback_args ){
594		var match = false;
595		var condition_args = condition_args != undefined && typeof condition_args == 'object' ? condition_args : new Array();
596		var callback_args = callback_args != undefined && typeof callback_args == 'object' ? callback_args : new Array();
597		if ( condition == undefined || typeof condition != 'string' || callback == undefined || typeof callback != 'function' ) return match;
598		match = window.cws_prlx.conditions[condition].apply( window, condition_args );
599		if ( match == true ){
600			callback.apply( window, callback_args );
601			return true;
602		}
603		else if ( match == false ){
604			setTimeout( function (){
605				cws_wait_for ( condition, condition_args, callback, callback_args );
606			}, 10);
607		}
608		else{
609			return false;
610		}
611	}
612
613	function cws_is_visible ( el ){
614		var window_top, window_height, window_bottom, el_top, el_height, el_bottom, r;
615		window_top = window.pageYOffset;
616		window_height = window.innerHeight;
617		window_bottom = window_top + window_height;
618		el_top = $( el ).offset().top;
619		el_height = el.offsetHeight;
620		el_bottom = el_top + el_height;
621		r = ( el_top > window_top && el_top < window_bottom ) || ( el_top < window_top && el_bottom > window_bottom ) || ( el_bottom > window_top && el_bottom < window_bottom ) ? true : false;
622		return r;
623	}
624
625	function cws_prlx_layer_loaded_condition ( layer_id ){
626		var layer, r;
627		r = false;
628		if ( layer_id == undefined || typeof layer_id != 'string' ) return r;
629		if ( window.cws_prlx.layers[layer_id] == undefined ) return r;
630		layer = window.cws_prlx.layers[layer_id].el;
631		switch ( layer.tagName ){
632			case "IMG":
633			if ( layer.complete == undefined ){
634			}
635			else{
636				if ( !layer.complete ){
637					return r;
638				}
639			}
640			break;  
641			case "DIV":  /* for youtube video background */
642			if ( /^video-/.test( layer.id ) ){
643				return r;
644			}
645			break;      
646		}
647		return true;
648	}
649
650	function cws_prlx_calc_layer_speed ( layer_id ){
651		var layer_params, layer, section_id, section_params, window_height;
652		layer_params = window.cws_prlx.layers[layer_id];
653		layer = layer_params.el;
654		section_id = layer_params.section_id;
655		section_params = window.cws_prlx.sections[section_id];
656		window_height = window.innerHeight;
657		layer_params.speed = ( ( layer_params.height - section_params.height ) / ( window_height + section_params.height ) ) * ( layer_params.rel_speed / 100 );
658	}
659
660}(jQuery));
661
662/**********************************
663********** \CWS PARALLAX **********
664**********************************/
665
666/* cws rtl */
667var directRTL;
668var wait_load_portfolio = false;
669if (jQuery("html").attr('dir') == 'rtl') {
670	directRTL = 'rtl';
671} else {
672	directRTL = '';
673};
674
675/* cws megamenu */
676if ( window.cws_megamenu != undefined ){
677
678	var menu = document.querySelectorAll( ".main-nav-container .main-menu" );
679	for (var i = 0; i <= menu.length; i++) {
680		window.cws_megamenu_main = new cws_megamenu( menu[i], {
681			'fw_sel'							: '.container',
682			'bottom_level_sub_menu_width_adj'	: 2
683		});
684	}
685	
686	window.cws_megamenu_sticky = new cws_megamenu( document.querySelector( "#sticky_menu" ), {
687		'fw_sel'							: '.wide-container',
688		'bottom_level_sub_menu_width_adj'	: 2
689	});	
690
691}
692
693/**********************************
694********** SCRIPTS INIT ***********
695**********************************/
696cws_modules_state_init();
697is_visible_init();
698cws_milestone_init();
699cws_progress_bar_init();
700cws_widget_divider_init();
701setTimeout(cws_widget_services_init,0);
702
703jQuery(document).ready(function (){	
704
705	window.cws_modules_state.sync = true;
706	wp_standard_processing();
707
708	/***** Header scripts init *****/
709	cws_center_menu_init();
710	cws_top_panel_search();
711	cws_adaptive_top_bar_init();
712	cws_top_social_init();
713	cws_page_header_video_init();
714	cws_sidebar_bottom_info();
715	cws_revslider_class_add();
716	cws_blog_full_width_layout();
717	cws_fullwidth_background_row();
718	cws_header_bg_init();
719	cws_header_imgs_cover_init();
720	cws_header_parallax_init();
721	cws_scroll_parallax_init();
722    /****\ Header scripts init \****/
723	
724	/***** Other libraries init  *****/
725	vimeo_init();
726	cws_self_hosted_video();
727	wow_init();
728	cws_fancybox_init();
729	isotope_init();
730	onYouTubePlayerAPIReady();
731	/****\ Other libraries init \****/
732
733	/***** Pages filter/pagination/carousel init  *****/
734	if( jQuery('body').hasClass('customize-support') ){
735		setTimeout(function() {
736			cws_carousel(".cws-carousel-wrapper:not(.inner_slick)");
737			cws_carousel(".cws-carousel-wrapper.inner_slick");
738		}, 1);
739	} else {
740		cws_carousel(".cws-carousel-wrapper:not(.inner_slick)");
741		cws_carousel(".cws-carousel-wrapper.inner_slick");
742	}
743	cws_portfolio_pagination_init();
744	cws_portfolio_filter_init();
745	cws_ourteam_pagination_init();
746	cws_ourteam_filter_init();
747	widget_archives_hierarchy_init();
748	/****\ Pages filter/pagination/carousel init  \****/
749
750	/***** CWS Features init  *****/
751	cws_resize();
752	cws_fs_video_bg_init();
753	boxed_var_init();
754	load_more_init();
755	cws_parallax_init();
756	cws_prlx_init_waiter();
757	cws_message_box_init();
758	jQuery( ".cws-milestone-module" ).cws_milestone();
759	jQuery( ".cws-progress-bar-module" ).cws_progress_bar();
760	cws_sticky_sidebars_init();
761	single_sticky_content();
762	smooth_comment_link();
763	cws_widgets_on_tablet();
764	cws_footer_on_bottom();
765	scroll_to_top();
766	navigation_hold_post();
767	cws_roadmap_before_end_point();
768	cws_roadmap_animation();
769	cws_benefits_init();
770	cws_countdown();
771    cws_vc_pie_chart_layout();
772    cws_advanced_form_focus();
773    cws_service_card_activation();
774    cws_service_gallery_activation();
775    cws_testimonials_card_activation();
776    cws_submenu_location();
777	/****\ CWS Features init  \****/
778
779	/***** CWS Fixes init  *****/
780	cws_first_place_col();
781	staff_advanced_hover();
782	cws_custom_inputs();
783	cws_fix_styles_init();
784	metamax_services_hover();
785	metamax_portfolio_tablet_hover();
786    metamax_product_tablet_hover();
787	Video_resizer();
788	vc_accordion_fix();
789	embed_videos_height();
790	cws_megamenu_active();
791	/****\ CWS Fixes init \****/
792
793});
794
795window.addEventListener( "load", function() {
796
797	/***** CWS Fixes init  *****/
798	cws_revslider_pause_init();
799	/****\ CWS Fixes init  \****/
800
801	/***** Header scripts init *****/
802	cws_simple_sticky_menu();
803	cws_smart_sticky_menu();
804	mainSearchForm();
805	cws_toggle_topbar();
806	cws_toggle_menu();
807	cws_close_menu();
808	cws_click_menu_item();
809	cws_side_panel_init();
810	pmc_plugin_styling();
811	/****\ Header scripts init \****/
812
813	setTimeout(function() {
814        cws_particles_init();
815		cws_blank_preloader();
816	}, 500);
817	cws_infinite_autoplay();
818}, false);
819
820jQuery(window).resize( function (){
821	cws_full_width_row();
822	cws_fullwidth_background_row();
823	cws_slider_video_height (jQuery( ".fs-video-slider" ));
824	cws_slider_video_height (jQuery( ".fs-img-header" ));
825
826	vimeo_init();
827	cws_self_hosted_video ();
828	Video_resizer ();
829
830	cws_go_to_page_init();
831	cws_toggle_menu();
832	cws_click_menu_item();
833	cws_widgets_on_tablet();
834	cws_footer_on_bottom();
835    cws_vc_pie_chart_layout();
836    cws_submenu_location();
837} );
838/**********************************
839********** /SCRIPTS INIT **********
840**********************************/
841
842/**********************************
843******* SCRIPTS DECLARATION *******
844**********************************/
845function cws_modules_state_init (){
846	window.cws_modules_state = {
847		"sync" : false,		
848	}
849}
850
851function cws_unique_id ( prefix ){
852	var prefix = prefix != undefined && typeof prefix == 'string' ? prefix : "";
853	var d = new Date();
854	var t = d.getTime();
855	var unique = Math.random() * t;	
856	var unique_id = prefix + unique;
857	return unique_id;	
858}
859
860function wp_standard_processing (){
861	var galls;
862	jQuery( "img[class*='wp-image-']" ).each( function (){
863		var canvas_id;
864		var el = jQuery( this );
865		var parent = el.parent( "a" );
866		var align_class_matches = /align\w+/.exec( el.attr( "class" ) );
867		var align_class = align_class_matches != null && align_class_matches[0] != undefined ? align_class_matches[0] : "";
868		var added_class = "cws_img_frame";
869		if ( align_class.length ){
870			if ( parent.length ){
871				el.removeClass( align_class );
872			}
873			added_class += " " + align_class;
874		}
875		if ( parent.length ){
876			parent.addClass( added_class );
877			parent.children().wrapAll( "<div class='cws_blur_wrapper' />" );
878		}
879	});
880	galls = jQuery( ".gallery[class*='galleryid-']" );
881	if ( galls.length ){
882		galls.each( function (){
883			var gall = jQuery( this );
884			var gall_id = cws_unique_id ( "wp_gallery_" );
885			jQuery( "a", gall ).attr( "data-fancybox-group", gall_id );
886		});
887	}
888
889	//Check if function exist
890	if (typeof fancybox === 'function') {
891		jQuery( ".gallery-icon a[href*='.jpg'], .gallery-icon a[href*='.jpeg'], .gallery-icon a[href*='.png'], .gallery-icon a[href*='.gif'], .cws_img_frame[href*='.jpg'], .cws_img_frame[href*='.jpeg'], .cws_img_frame[href*='.png'], .cws_img_frame[href*='.gif']" ).fancybox();
892	}
893}
894
895/***** Header scripts declaration *****/
896function cws_center_menu_init(){
897	if (!is_mobile() && !is_mobile_device() && jQuery('header').hasClass('menu-center') ){
898		var icons_block_width = [];
899		var max_block_width;
900
901		var headerLogoWidth = jQuery('header').find('.header-logo-part').width(),
902			menuIconLeft = jQuery('.menu-left-icons .menu-icons-wrapper'),
903			menuIconRight = jQuery('.menu-right-icons .menu-icons-wrapper');
904
905		jQuery.each([menuIconLeft,menuIconRight], function(i, el) {
906			icons_block_width.push(jQuery(el).width());
907		});
908
909		max_block_width = Math.max.apply(null, icons_block_width);
910
911		if( jQuery('header').hasClass('logo-left') ){
912			menuIconLeft.css('min-width', max_block_width);
913			menuIconRight.css('min-width', max_block_width+headerLogoWidth);
914		}
915
916		if( jQuery('header').hasClass('logo-center') ){
917			menuIconLeft.css('min-width', max_block_width);
918			menuIconRight.css('min-width', max_block_width);
919		}	
920
921		if( jQuery('header').hasClass('logo-right') ){
922			menuIconLeft.css('min-width', max_block_width+headerLogoWidth);
923			menuIconRight.css('min-width', max_block_width);
924		}		
925
926	}
927}
928
929function cws_top_panel_search (){
930	//Top bar search
931	jQuery(".top-bar-search .search-icon").on('click', function(){
932		var el = jQuery(this);
933		el.closest('.top-bar-search').find('.row-text-search .search-field').val('');
934		if(!not_desktop()){
935			el.closest('.top-bar-search').find('.row-text-search .search-field').focus();
936		}
937		el.closest('.top-bar-search').toggleClass( "show-search" );
938	});
939
940	//Clear text (ESC)
941	jQuery(".top-bar-search .row-text-search .search-field").keydown(function(event) {
942		if (event.keyCode == 27){
943			jQuery(this).val('');
944		}
945	});
946}
947
948function cws_adaptive_top_bar(first_init, top_bar_window_resolution, top_bar_left_items, top_bar_right_items){
949	if( jQuery(window).width() < 768 && (localStorage.getItem('top_bar_check') != 'mobile' || first_init)){
950		//Set mobile top-bar
951		jQuery('.top-bar-wrapper .container').append(top_bar_left_items);
952		jQuery('.top-bar-wrapper .container').append(top_bar_right_items);
953
954		//Сheck if the script was started
955		localStorage.setItem('top_bar_check', 'mobile');
956	} else if( jQuery(window).width() > 767 && localStorage.getItem('top_bar_check') != 'desktop' ) {
957		//Remove mobile top-bar
958		jQuery(top_bar_left_items).remove();
959		jQuery(top_bar_right_items).remove();
960
961		//Set desktop top-bar
962		jQuery('.top-bar-wrapper .top-bar-icons.left-icons').append(top_bar_left_items);
963		jQuery('.top-bar-wrapper .top-bar-icons.right-icons').append(top_bar_right_items);
964
965		//Сheck if the script was started
966		localStorage.setItem('top_bar_check', 'desktop');
967
968		//Reinit JS
969		cws_top_panel_search();
970		cws_top_social_init();
971		cws_side_panel_toggle();
972	}
973}
974
975function cws_adaptive_top_bar_init(){
976	//Definite variables
977	var top_bar_left_items = jQuery('.top-bar-wrapper .top-bar-icons.left-icons > *');
978	var top_bar_right_items = jQuery('.top-bar-wrapper .top-bar-icons.right-icons > *');
979	var first_init = false;
980
981	if( jQuery(window).width() < 768 ){
982		var top_bar_window_resolution = localStorage.setItem('top_bar_check', 'mobile');
983		first_init = true;
984	} else {
985		var top_bar_window_resolution = localStorage.setItem('top_bar_check', 'desktop');
986	}
987
988	cws_adaptive_top_bar(first_init, top_bar_window_resolution, top_bar_left_items, top_bar_right_items);
989
990	jQuery(window).resize( function (){
991		cws_adaptive_top_bar(false, top_bar_window_resolution, top_bar_left_items, top_bar_right_items);
992	});
993}
994
995function cws_top_social_init (){
996	jQuery('.social-links-wrapper.toogle-of').on('click', function() {
997		jQuery(this).find('.cws-social-links').toggleClass('active');
998		jQuery(this).find('.social-btn-open-icon').toggleClass('active');
999		jQuery(this).find('.social-btn-open').toggleClass('active');
1000	});
1001}
1002
1003function cws_set_header_video_wrapper_height (){
1004	var containers = document.getElementsByClassName( 'page-header-video-wrapper' );
1005	for ( var i=0; i<containers.length; i++ ){
1006		cws_set_window_height( containers[i] );
1007	}			
1008}
1009
1010function cws_page_header_video_init (){
1011	cws_set_header_video_wrapper_height();
1012	window.addEventListener( 'resize', cws_set_header_video_wrapper_height, false )
1013}
1014
1015function cws_side_panel_toggle(){
1016	jQuery(".side-panel-trigger").on( 'click', function(){
1017		jQuery("body").toggleClass("side-panel-show");
1018		return false;
1019	});
1020}
1021
1022function cws_side_panel_init () {
1023	if( jQuery('.side-panel-container').hasClass('appear-pull') ){
1024		jQuery('body').addClass('side-panel-pull');
1025	}
1026
1027	cws_side_panel_toggle();
1028
1029	jQuery(".side-panel-overlay, .close-side-panel").on( 'click', function(){
1030		jQuery("body").removeClass("side-panel-show");
1031		jQuery("body").removeClass('oveflow-hidden');
1032		jQuery(".page-content aside").removeClass('active');
1033	});
1034}
1035
1036function pmc_plugin_styling(){
1037	jQuery('.tradingview-widget-copyright').remove();
1038}
1039
1040function cws_sidebar_bottom_info(){
1041    var sideBarBottomHeight = jQuery('.side-panel-bottom').height();
1042    jQuery('.side-panel').css('padding-bottom', sideBarBottomHeight + 80);
1043}
1044
1045function cws_blank_preloader(){
1046	jQuery('.cws-blank-preloader').removeClass('active');
1047}
1048
1049function cws_particles_init(){
1050    var particlesID = '';
1051    var particlesColor = '#fff';
1052    var particlesSpeed = 2;
1053    var particlesSaturation = 200;
1054    var particlesSize = 10;
1055    var particlesCount = 8;
1056    var particlesHide = 767;
1057
1058    var particlesImage1 = '';
1059    var particlesImage2 = '';
1060    var particlesImage3 = '';
1061    var particlesImage4 = '';
1062
1063    jQuery('.particles-js').each(function(i, el) {
1064
1065        particlesID = jQuery(el).attr('id');
1066
1067        if( jQuery(el).data('hide') != undefined ){
1068            particlesHide = jQuery(el).data('hide');
1069        }
1070
1071        if( jQuery(window).width() > particlesHide ){
1072
1073            /* -----> Grab data attributes <----- */
1074            if( jQuery(el).data('color') != undefined ){
1075                particlesColor = jQuery(el).data('color');
1076            }
1077            if( jQuery(el).data('saturation') != undefined ){
1078                particlesSaturation = jQuery(el).data('saturation');
1079            }
1080            if( jQuery(el).data('speed') != undefined ){
1081                particlesSpeed = jQuery(el).data('speed');
1082            }
1083            if( jQuery(el).data('size') != undefined ){
1084                particlesSize = jQuery(el).data('size');
1085            }
1086            if( jQuery(el).data('count') != undefined ){
1087                particlesCount = jQuery(el).data('count');
1088            }
1089            if( jQuery(el).data('image') != undefined ){
1090                particlesImage1 = jQuery(el).data('image') + "/img/particles/particle-1.svg";
1091                particlesImage2 = jQuery(el).data('image') + "/img/particles/particle-2.svg";
1092                particlesImage3 = jQuery(el).data('image') + "/img/particles/particle-3.svg";
1093                particlesImage4 = jQuery(el).data('image') + "/img/particles/particle-4.svg";
1094                // particlesImage5 = jQuery(el).data('image') + "/img/particles/particle-yellow-2.svg";
1095            }
1096
1097            /* -----> Particles Init <----- */
1098            var test = particlesJS(particlesID,
1099                {
1100                    "particles": {
1101                        "number": {
1102                            "value": particlesCount,
1103                            "density": {
1104                                "enable": false,
1105                                "value_area": particlesSaturation
1106                            }
1107                        },
1108                        "color": {
1109                            "value": particlesColor
1110                        },
1111                        "shape": {
1112                            "type": ["image", "image2", "image3", "image4"],
1113                            "stroke": {
1114                                "width": 0,
1115                                "color": "#000000"
1116                            },
1117                            "polygon": {
1118                                "nb_sides": 5
1119                            },
1120							"image": {
1121                                "src": particlesImage1,
1122                                "width": 83,
1123                                "height": 83
1124                            },
1125							"image2": {
1126                                "src": particlesImage2,
1127                                "width": 83,
1128                                "height": 83
1129                            },
1130                            "image3": {
1131                                "src": particlesImage3,
1132                                "width": 83,
1133                                "height": 83
1134                            },
1135							"image4": {
1136                                "src": particlesImage4,
1137                                "width": 83,
1138                                "height": 83
1139                            }
1140                        },
1141                        "opacity": {
1142                            "value": 1,
1143                            "random": false,
1144                            "anim": {
1145                                "enable": false,
1146                                "speed": 0.2,
1147                                "opacity_min": 0.5,
1148                                "sync": false
1149                            }
1150                        },
1151                        "size": {
1152                            "value": particlesSize,
1153                            "random": false,
1154                            "anim": {
1155                                "enable": false,
1156                                "speed": 1,
1157                                "size_min": particlesSize * 0.7,
1158                                "sync": false
1159                            }
1160                        },
1161                        "line_linked": {
1162                            "enable": false,
1163                            "distance": 150,
1164                            "color": "#000000",
1165                            "opacity": 1,
1166                            "width": 1
1167                        },
1168                        "move": {
1169                            "enable": true,
1170                            "speed": particlesSpeed,
1171                            "direction": "none",
1172                            "random": false,
1173                            "straight": false,
1174                            "out_mode": "bounce",
1175                            "attract": {
1176                                "enable": false,
1177                                "rotateX": 0,
1178                                "rotateY": 0
1179                            }
1180                        }
1181                    },
1182                    "interactivity": {
1183                        "detect_on": "canvas",
1184                        "events": {
1185                            "onhover": {
1186                                "enable": false,
1187                                "mode": "repulse"
1188                            },
1189                            "onclick": {
1190                                "enable": false,
1191                                "mode": "push"
1192                            },
1193                            "resize": true
1194                        },
1195                        "modes": {
1196                            "grab": {
1197                                "distance": 100,
1198                                "line_linked": {
1199                                    "opacity": .7
1200                                }
1201                            },
1202                            "bubble": {
1203                                "distance": 250,
1204                                "size": particlesSize*1.5,
1205                                "duration": 2,
1206                                "opacity": 1,
1207                                "speed": 1.5
1208                            },
1209                            "repulse": {
1210                                "distance": 100
1211                            },
1212                            "push": {
1213                                "particles_nb": 1
1214                            },
1215                            "remove": {
1216                                "particles_nb": 2
1217                            }
1218                        }
1219                    },
1220                    "retina_detect": true,
1221                }
1222            );
1223
1224        }
1225
1226    });
1227}
1228
1229function cws_revslider_class_add (){
1230	if (jQuery('.rev_slider_wrapper.fullwidthbanner-container').length) {
1231		jQuery('.rev_slider_wrapper.fullwidthbanner-container').next().addClass('benefits-after-slider');
1232		if (jQuery('.rev_slider_wrapper.fullwidthbanner-container').length && jQuery('.site-main main .benefits_cont:first-child').length) {
1233			if (jQuery('.site-main main .benefits_cont:first-child').css("margin-top").replace("px", "") < -90) {
1234				jQuery('.site-main main .benefits_cont:first-child').addClass('responsive-minus-margin');
1235			}
1236		}
1237	};
1238}
1239
1240function cws_blog_full_width_layout() {
1241	function cws_blog_full_width_controller(){
1242		var div = jQuery('.posts-grid.posts_grid_fw_img');
1243		jQuery(div).each(function(){
1244			div = jQuery(this);
1245			if (!div.hasClass('posts_grid_carousel')) {
1246				var doc_w = jQuery(window).width();
1247				var div_w = jQuery('.page-content main .grid-row').width();
1248				var marg = ( doc_w - div_w ) / 2;
1249
1250				div.each(function() {
1251					jQuery(this).css({
1252						'margin-left' : '-'+(marg-15)+'px',
1253						'margin-right' : '-'+(marg-15)+'px'
1254					})
1255				});
1256				div.find('article.posts_grid_post').each(function() {
1257					jQuery(this).css({
1258						'padding-left' : marg+'px',
1259						'padding-right' : marg+'px'
1260					})
1261				})
1262			}
1263		});
1264	}
1265	cws_blog_full_width_controller();
1266
1267	jQuery(window).resize( function(){
1268		cws_blog_full_width_controller();
1269	});
1270}
1271
1272function cws_fix_vc_full_width_row(){
1273    if( jQuery('html').attr('dir') == 'rtl' ){        
1274        var $elements = jQuery('.cws-stretch-row[data-vc-full-width="true"]');
1275        jQuery($elements).each(function( i, el ){
1276        	jQuery(el).css('right', '-'+jQuery(el).css('left')).css('left', '');	
1277        });
1278    }
1279}
1280
1281// Fixes rows in RTL
1282jQuery(document).on('vc-full-width-row', function () {
1283    cws_fix_vc_full_width_row();
1284});
1285
1286// Run one time because it was not firing in Mac/Firefox and Windows/Edge some times
1287cws_fix_vc_full_width_row();
1288
1289var IE_fix_section = '.cws-vc-shortcode-grid.layout-2';
1290
1291function cws_full_width_row(IE_fix_section){
1292	var section = jQuery(section);
1293    var $elements = jQuery(section).find('[data-cws-full-width="true"]');
1294    $elements.after('<div class="cws_row-full-width"></div>');
1295    jQuery.each($elements, function(key, item) {
1296        var $el = jQuery(this);
1297        var test = $el.attr("data-cws-full-width-init");
1298        $el.addClass("vc_hidden");
1299        var $el_full = $el.next(".cws_row-full-width");
1300        if ($el_full.length || ($el_full = $el.parent().next(".cws_row-full-width")),
1301        $el_full.length) {
1302            var el_margin_left = parseInt($el.css("margin-left"), 10), 
1303        		el_margin_right = parseInt($el.css("margin-right"), 10), 
1304        		offset = 0 - $el_full.offset().left - el_margin_left, 
1305        		width = jQuery(window).width(), 
1306        		cws_styles = '', 
1307        		top = $el.css('top');
1308
1309            cws_styles += "position: absolute;";
1310            cws_styles += "left: "+offset+"px !important;";
1311            cws_styles += "box-sizing: border-box;";
1312            cws_styles += "width: "+width+ "px;";
1313            cws_styles += "top: "+top+ ";";
1314
1315            if (!$el.data("vcStretchContent")) {
1316                var padding = -1 * offset;
1317                0 > padding && (padding = 0);
1318                var paddingRight = width - padding - $el_full.width() + el_margin_left + el_margin_right;
1319                0 > paddingRight && (paddingRight = 0);
1320                cws_styles += "padding-left:"+ padding + "px;";
1321                cws_styles += "padding-right:"+ paddingRight + "px;";
1322            }
1323
1324            $el.css("cssText", cws_styles);
1325
1326            $el.attr("data-cws-full-width-init", "true"),
1327            $el.removeClass("vc_hidden");
1328        }
1329    });
1330}
1331
1332function cws_fullwidth_background_row(){
1333	var main_width = jQuery('main').width();
1334	var row_bg_ofs, column_first_ofs, column_last_ofs;
1335	jQuery('.row_bg.fullwidth_background_bg').each(function(){
1336
1337		row_bg_ofs = jQuery(this).offset();
1338
1339		column_first_ofs = jQuery(this).find('.grid-col:first-child .cols-wrapper').offset();
1340		column_last_ofs = jQuery(this).find('.grid-col:last-child .cols-wrapper').offset();
1341
1342		jQuery(this).find('.grid-col:first-child > .cols-wrapper > .row_bg_layer').css({'left':''+( row_bg_ofs.left - column_first_ofs.left )+'px','width':'auto','right':'0'});
1343		jQuery(this).find('.grid-col:first-child > .cols-wrapper > .row_bg_img_wrapper').css({'left':''+( row_bg_ofs.left - column_first_ofs.left )+'px','width':'auto','right':'0'});
1344
1345		jQuery(this).find('.grid-col:last-child > .cols-wrapper > .row_bg_layer').css({'left':'0px','width':'auto','right':'-'+(jQuery(this).outerWidth() + row_bg_ofs.left - column_last_ofs.left - jQuery(this).find('.grid-col:last-child .cols-wrapper').outerWidth())+'px'});
1346		jQuery(this).find('.grid-col:last-child > .cols-wrapper > .row_bg_img_wrapper').css({'left':'0px','width':'auto','right':'-'+(jQuery(this).outerWidth() + row_bg_ofs.left - column_last_ofs.left - jQuery(this).find('.grid-col:last-child .cols-wrapper').outerWidth())+'px'});
1347		
1348	});
1349}
1350
1351function cws_header_bg_controller ( bg_section ){
1352	var benefits_area = jQuery( ".benefits_area" ).eq( 0 );
1353	var page_content_section = jQuery( ".page-content" ).eq( 0 );
1354	var top_curtain_hidden_class = "hidden";
1355	var top_panel = jQuery( "#site_top_panel" );
1356	var top_curtain = jQuery( "#top_panel_curtain" );
1357	var consider_top_panel = top_panel.length && top_curtain.length && top_curtain.hasClass( top_curtain_hidden_class );
1358		if ( benefits_area.length ){
1359			if ( consider_top_panel ){
1360				bg_section.css( {
1361					'height' : bg_section.parent().outerHeight() + 200 + bg_section.parent().offset().top + top_panel.outerHeight() + "px",
1362					'margin-top' : "-" + ( bg_section.parent().offset().top + top_panel.outerHeight() ) + "px"
1363				});
1364			}
1365			else{
1366				bg_section.css( {
1367					'height' : bg_section.parent().outerHeight() + 200 + bg_section.parent().offset().top + "px",
1368					'margin-top' : "-" + bg_section.parent().offset().top + "px"
1369				});
1370			}
1371			bg_section.addClass( 'height_assigned' );
1372		}
1373		else if ( page_content_section.length ){
1374			if ( page_content_section.hasClass( "single-sidebar" ) || page_content_section.hasClass( "double-sidebar" ) ){
1375				if ( consider_top_panel ){
1376					bg_section.css({
1377						'height' : bg_section.parent().outerHeight() + bg_section.parent().offset().top + top_panel.outerHeight() + "px",
1378						'margin-top' : "-" + ( bg_section.parent().offset().top + top_panel.outerHeight() ) + "px"
1379					});
1380				}
1381				else{
1382					bg_section.css({
1383						'height' : bg_section.parent().outerHeight() + bg_section.parent().offset().top + "px",
1384						'margin-top' : "-" + bg_section.parent().offset().top + "px"
1385					});
1386				}
1387				bg_section.addClass( 'height_assigned' );				
1388			}
1389			else{
1390				if ( consider_top_panel ){
1391					bg_section.css({
1392						'height' : bg_section.parent().outerHeight() + 200 + bg_section.parent().offset().top + top_panel.outerHeight() + "px",
1393						'margin-top' : "-" + ( bg_section.parent().offset().top + top_panel.outerHeight() ) + "px"
1394					});
1395				}
1396				else{
1397					bg_section.css({
1398						'height' : bg_section.parent().outerHeight() + 200 + bg_section.parent().offset().top + "px",
1399						'margin-top' : "-" + bg_section.parent().offset().top + "px"
1400					});
1401				}
1402				bg_section.addClass( 'height_assigned' );				
1403			}
1404		}
1405}
1406
1407function cws_header_bg_init(){
1408	var bg_sections = jQuery('.header-bg-img, .cws-parallax-scene-container');
1409	bg_sections.each( function (){
1410		var bg_section = jQuery( this );
1411		cws_header_bg_controller( bg_section );
1412	});
1413	window.addEventListener( 'resize', function (){
1414		var bg_sections = jQuery('.header-bg-img, .cws-parallax-scene-container');
1415		bg_sections.each( function (){
1416			var bg_section = jQuery( this );
1417			cws_header_bg_controller( bg_section );
1418		});
1419	}, false );
1420}
1421
1422function cws_header_imgs_cover_controller (){
1423	var prlx_sections, prlx_section, section_imgs, section_img, i, j;
1424	var prlx_sections = jQuery( '.cws-parallax-scene-container > .cws-parallax-scene, .header-bg-img >' +
1425		' .cws-parallax-section');
1426	for ( i = 0; i < prlx_sections.length; i++ ){
1427		prlx_section = prlx_sections[i];
1428		section_imgs = jQuery( "img", jQuery( prlx_section ) );
1429		for ( j = 0; j < section_imgs.length; j++ ){
1430			section_img = section_imgs[j];
1431			cws_cover_image( section_img, prlx_section );
1432		}
1433	}
1434}
1435
1436function cws_cover_image ( img, section ){
1437	var section_w, section_h, img_nat_w, img_nat_h, img_ar, img_w, img_h, canvas;
1438	if ( img == undefined || section == undefined ) return;
1439	section_w = section.offsetWidth;
1440	section_h = section.offsetHeight;	
1441	img_nat_w = img.naturalWidth;
1442	img_nat_h = img.naturalHeight;
1443	img_ar = img_nat_w / img_nat_h;
1444	if ( img_ar > 1 ){
1445		img_h = section_h;
1446		img_w = section_h * img_ar;
1447	}
1448	else{
1449		img_w = section_w;
1450		img_h = section_w / img_ar;
1451	}
1452	img.width = img_w;
1453	img.height = img_h;
1454}
1455
1456function cws_header_imgs_cover_init (){
1457	cws_header_imgs_cover_controller ();
1458	window.addEventListener( "resize", cws_header_imgs_cover_controller, false );
1459}
1460
1461function cws_wait_for_header_bg_height_assigned ( callback ){
1462	var header_bg_sections = jQuery( '.header-bg-img, .cws-parallax-scene-container' );
1463	if ( callback == undefined || typeof callback != 'function' ) return;
1464	cws_header_bg_height_assigned_waiter ( header_bg_sections, callback );
1465}
1466
1467function cws_header_bg_height_assigned_waiter ( els, callback ){
1468	var i;
1469	for ( i = 0; i < els.length; i++ ){
1470		if ( jQuery( els[i] ).hasClass( 'height_assigned' ) ){
1471			els.splice( i, 1 );
1472		}
1473	}
1474	if ( els.length ){
1475		setTimeout( function (){
1476			cws_header_bg_height_assigned_waiter ( els, callback );
1477		}, 10 );
1478	}
1479	else{
1480		callback ();
1481		return true;
1482	}
1483}
1484
1485function cws_header_parallax_init (){
1486	var scenes = jQuery( ".cws-parallax-section, .cws-parallax-scene" );
1487	if (typeof Parallax === 'function') {
1488		scenes.each( function (){
1489			var scene = this;
1490			var prlx_scene = new Parallax ( scene );
1491		});
1492	}
1493}
1494
1495function cws_scroll_parallax_init (){
1496	var scroll = 0;
1497	var window_width = jQuery(window).width();
1498	var background_size_width;
1499
1500	jQuery(window).scroll(function() {
1501		scroll = jQuery(window).scrollTop();
1502		window_width = jQuery(window).width();
1503	});
1504
1505
1506	if(jQuery('.title.has_fixed_background').length){
1507
1508		var background_size_width = parseInt(jQuery('.title.has_fixed_background').css('background-size').match(/\d+/));
1509		var title_holder_height = jQuery('.title.has_fixed_background').height();
1510
1511		if (jQuery('.bg-page-header').hasClass('hide_header')){
1512			var top = jQuery('.bg-page-header').data('top');
1513			var bottom = jQuery('.bg-page-header').data('bottom');
1514			title_holder_height = top+bottom+88;
1515		}
1516
1517		var title_rate = (title_holder_height / 10000) * 7;
1518		var title_distance = scroll - jQuery('.title.has_fixed_background').offset().top;
1519		var title_bpos = -(title_distance * title_rate);
1520		jQuery('.title.has_fixed_background').css({'background-position': 'center 0px' });
1521		if(jQuery('.title.has_fixed_background').hasClass('zoom_out')){
1522			jQuery('.title.has_fixed_background').css({'background-size': background_size_width-scroll + 'px auto'});
1523		}
1524	}
1525
1526	jQuery(window).on('scroll', function() {
1527
1528		if(jQuery('.title.has_fixed_background').length){
1529			var title_distance = scroll - jQuery('.title.has_fixed_background').offset().top;
1530			var title_bpos = -(title_distance * title_rate);
1531			jQuery('.title.has_fixed_background').css({'background-position': 'center ' + title_bpos + 'px' });
1532			if(jQuery('.title.has_fixed_background').hasClass('zoom_out') && (background_size_width-scroll > window_width)){
1533				jQuery('.title.has_fixed_background').css({'background-size': background_size_width-scroll + 'px auto'});
1534			}
1535		}
1536	});
1537}
1538
1539function cws_toggle_topbar(){
1540	jQuery('.topbar-trigger').off();
1541	jQuery('.topbar-trigger').on('click', function() {
1542		jQuery('.top-bar-wrapper').toggleClass('active');
1543		jQuery('.top-bar-wrapper .top-bar-inner-wrapper').slideToggle();
1544
1545		setTimeout(function() {
1546			cws_infinite_autoplay();
1547		}, 401);
1548	});
1549}
1550
1551function cws_toggle_menu(){
1552
1553	// -----> Different mneu hamburger animation
1554	if ( cws_detect_browser() == 'Safari' ) {
1555		jQuery('.mobile-menu-hamburger').addClass('iOS-anim');
1556	} else {
1557		jQuery('.mobile-menu-hamburger').addClass('custom-anim');
1558	}
1559
1560	// -----> Toggle menu
1561	if( jQuery('.site-header').hasClass('active-sandwich-menu') && !not_desktop() ){
1562		jQuery('.mobile-menu-hamburger').on('click', function() {
1563			jQuery('.mobile-menu-hamburger').toggleClass('active');
1564			jQuery('.main-nav-container').toggleClass('active');
1565		});
1566	} else if( not_desktop() ){
1567		jQuery('.mobile-menu-hamburger').on('click', function() {
1568
1569			// -----> Close top-bar if is open
1570			if( is_mobile() && jQuery('.top-bar-wrapper').hasClass('active') ){
1571				jQuery('.top-bar-wrapper .top-bar-inner-wrapper').hide();
1572				jQuery('.top-bar-wrapper').removeClass('active');
1573			}
1574
1575			jQuery(this).addClass('active');
1576			jQuery('body').addClass('menu-visible');
1577			jQuery('.top-bar-wrapper .topbar-trigger').addClass('hidden');
1578			jQuery('.menu-overlay').addClass('active');
1579			jQuery('.menu-box-wrapper').addClass('active');
1580		});
1581	}
1582}
1583
1584function cws_close_menu(){
1585	jQuery('.menu-overlay').on('click', function() {
1586		jQuery(this).removeClass('active');
1587		jQuery('.menu-box-wrapper').removeClass('active');
1588		jQuery('.top-bar-wrapper .topbar-trigger').removeClass('hidden');
1589		jQuery('.mobile-menu-hamburger').removeClass('active');
1590		jQuery('body').removeClass('menu-visible');
1591	});
1592}
1593
1594function cws_click_menu_item(){
1595	var initCounter = 0;
1596
1597	if( not_desktop() ){
1598		if( initCounter == 0 ){
1599			var menuItem = jQuery('.menu-box-wrapper .main-menu .menu-item > a');
1600			var menuItemTrigger = jQuery('.menu-box-wrapper .main-menu .menu-item > .button-open');
1601			var currentParents;
1602
1603			//Disable 'cws_go_to_page_init' script & multi init on resize
1604			menuItem.off();
1605			menuItemTrigger.off();
1606
1607			menuItem.on('click', function(e) {
1608
1609				if( jQuery(this).parent().hasClass('menu-item-has-children') || jQuery(this).parent().hasClass('menu-item-object-megamenu_item') ){
1610
1611					if( !jQuery(this).parent().hasClass('active') ){
1612						//Close all anouther sub-menu`s
1613						currentParents = jQuery(this).parents('.menu-item');
1614						menuItem.parent().not(currentParents).removeClass('active');
1615						menuItem.parent().not(currentParents).find('.sub-menu').slideUp(300);
1616
1617						jQuery(this).parent().addClass('active');
1618						jQuery(this).parent().children('.sub-menu').slideDown(300);
1619
1620						e.preventDefault();
1621						return false;
1622					}
1623				}
1624
1625			});
1626
1627			menuItemTrigger.on('click', function() {
1628
1629				if( jQuery(this).parent().hasClass('active') ){
1630
1631					jQuery(this).next().slideUp(300);
1632					jQuery(this).parent().removeClass('active');
1633
1634				} else {
1635					//Close all anouther sub-menu`s
1636					currentParents = jQuery(this).parents('.menu-item');
1637					menuItemTrigger.parent().not(currentParents).removeClass('active');
1638					menuItemTrigger.parent().not(currentParents).find('.sub-menu').slideUp(300);
1639
1640					jQuery(this).next().slideDown(300);
1641					jQuery(this).parent().addClass('active');
1642
1643				}
1644
1645			});
1646		}
1647		initCounter ++;
1648	} else {
1649		initCounter = 0;
1650	}
1651}
1652
1653function cws_simple_sticky_menu(){
1654	if( jQuery('.site-header').hasClass('sticky_simple') && !not_desktop() ){
1655
1656		//Definition variables
1657		var menuBox = jQuery('.menu-box');
1658		var stickyMenu = menuBox.clone();
1659		var adminBar = jQuery('#wpadminbar').height();
1660		var menuOffset = parseInt(menuBox.offset().top);
1661		var currentScroll = jQuery(window).scrollTop();
1662		var menuBoxHeight = menuBox.outerHeight();
1663		var displaySticky = 0;
1664		var startPosition = 0;
1665
1666		//Show menu on page load
1667		stickyMenu.addClass('sticky-menu-box');
1668		stickyMenu.appendTo('.header-zone');
1669
1670		//Get Sticky menu height
1671		var stickyBoxHeight = stickyMenu.outerHeight();
1672
1673		//Sticky menu declaration after getting height
1674		stickyMenu.css('transform', 'translateY(-'+ (stickyBoxHeight - adminBar) + 'px)');
1675
1676		//Get condition for start position
1677		if( stickyBoxHeight <= menuBoxHeight ){
1678			startPosition = menuBoxHeight - stickyBoxHeight;
1679		}
1680
1681		jQuery(window).on('scroll', function() {
1682			var currentScroll = jQuery(this).scrollTop();
1683			
1684			//Main script
1685			if( jQuery(this).scrollTop() > menuOffset + startPosition ){
1686				jQuery('.sticky-enable').addClass('sticky-active');
1687				jQuery('.sticky-enable .menu-box').css('transform', 'translateY(0px)');
1688				stickyMenu.show();
1689			}
1690			//Stop on the original position
1691			else if( currentScroll <= menuOffset ){
1692				jQuery('.sticky-enable').removeClass('sticky-active');
1693				stickyMenu.hide();
1694				displaySticky = 0;
1695			}
1696			
1697		});
1698
1699		if(currentScroll > menuOffset){
1700			jQuery('.sticky-enable .menu-box').css('transform', 'translateY(0px)');
1701			jQuery('.sticky-enable').addClass('sticky-active');
1702		} else if(currentScroll <= menuOffset && currentScroll != 0){
1703			jQuery('.sticky-enable .menu-box').css('transform', 'translateY('+ (menuOffset - currentScroll - 1) +'px)');
1704		}
1705	}
1706}
1707
1708function cws_smart_sticky_menu(){
1709	if( jQuery('.site-header').hasClass('sticky_smart') && !not_desktop() && jQuery('.menu-box').length != 0 ){
1710		//Definition variables
1711		var menuBox = jQuery('.menu-box');
1712		var stickyMenu = menuBox.clone();
1713		var adminBar = jQuery('#wpadminbar').height();
1714		var menuOffset = parseInt(menuBox.offset().top);
1715		var menuBoxHeight = menuBox.outerHeight();
1716		var currentScroll = jQuery(window).scrollTop();
1717		var tempScroll = jQuery(window).scrollTop();
1718		var minOffset = menuOffset + (menuBoxHeight * 3); //Min top offset, when should show the menu.
1719		var defaultSlideUp = true;
1720		var smoothSlideUp = false;
1721		var smoothSlideDown = false;
1722		var scrollMarkerUp = 0;
1723		var scrollMarkerDown = 0;
1724		var menuCurrentTransform = 0;
1725		var translateY_down = 0;
1726		var displaySticky = 0;
1727		var defaultCondition = false;
1728
1729		//Sticky menu declaration 
1730		stickyMenu.addClass('sticky-menu-box');
1731		stickyMenu.appendTo('.header-zone');
1732
1733		//Get Sticky menu height
1734		var stickyBoxHeight = stickyMenu.outerHeight();
1735
1736		//Sticky menu declaration after getting height
1737		stickyMenu.css('transform', 'translateY(-'+ (stickyBoxHeight - adminBar) + 'px)');
1738
1739
1740		//Get condition for default position
1741		if( stickyBoxHeight <= menuBoxHeight ){
1742			defaultCondition = false;
1743		} else if( stickyBoxHeight > menuBoxHeight ) {
1744			defaultCondition = true;
1745		}
1746
1747		//Main script
1748		jQuery(window).on('scroll', function() {
1749			currentScroll = jQuery(this).scrollTop();
1750
1751			//Sticky trigger
1752			if( currentScroll > minOffset ){
1753
1754				jQuery('.sticky-enable').addClass('sticky-active');
1755
1756				//When scrolling down ----> HIDE MENU SCRIPTS
1757				if( tempScroll < currentScroll ){
1758					//Hide menu
1759					if( currentScroll > (menuOffset + menuBoxHeight) ){
1760						//Taking the scroll position
1761						if(smoothSlideUp == false){
1762							scrollMarkerDown = currentScroll;
1763							menuCurrentTransform = parseInt(stickyMenu.css('transform').split(',')[5]);
1764							smoothSlideUp = true;
1765						}
1766						var translateY_up = menuCurrentTransform - (currentScroll - scrollMarkerDown);
1767						stickyMenu.css('transform', 'translateY('+ parseInt(translateY_up) +'px)');
1768					}
1769					smoothSlideDown = false;
1770				}
1771
1772				//When scrolling top ----> SHOW MENU SCRIPTS
1773				else if( tempScroll > currentScroll ){
1774					//Taking the scroll position
1775					if(smoothSlideDown == false){
1776						scrollMarkerUp = currentScroll;
1777						menuCurrentTransform = parseInt(stickyMenu.css('transform').split(',')[5]);
1778						smoothSlideDown = true;
1779					}
1780					//Smooth slide down if menu-box is visible now
1781					if( Math.abs(menuCurrentTransform) < stickyBoxHeight ){
1782						//Smooth slide down
1783						if( (scrollMarkerUp - currentScroll) <= (stickyBoxHeight - (stickyBoxHeight - Math.abs(menuCurrentTransform)) ) ){
1784
1785							translateY_down = Math.abs(menuCurrentTransform) - (scrollMarkerUp - currentScroll);
1786							stickyMenu.css('transform', 'translateY(-'+parseInt(translateY_down)+'px)');
1787						}
1788					}
1789					//Smooth slide down if menu-box is not visible now
1790					else {
1791						if( displaySticky == 0 ){
1792							stickyMenu.show();
1793							displaySticky = 1;
1794						}
1795						//Smooth slide down
1796						if( (scrollMarkerUp - currentScroll) < stickyBoxHeight ){
1797							translateY_down = stickyBoxHeight - (scrollMarkerUp - currentScroll);
1798							stickyMenu.css('transform', 'translateY(-'+ parseInt(translateY_down) +'px)');
1799						}
1800						//Show menu box (Sharp movement of the mouse wheel)
1801						else {
1802							stickyMenu.css('transform', 'translateY(0px)');
1803						}
1804					}
1805
1806					smoothSlideUp = false;
1807				}
1808			}
1809			//Stop on the original position ( Sticky < Menu Box )
1810			else if( !defaultCondition && currentScroll <= menuOffset + (menuBoxHeight - stickyBoxHeight) ){
1811				jQuery('.sticky-enable').removeClass('sticky-active');
1812				//Hide sticky right in center of default menu box
1813				if( currentScroll <= menuOffset + ((menuBoxHeight - stickyBoxHeight) / 2) ){
1814					stickyMenu.hide();
1815					displaySticky = 0;
1816				}
1817			}
1818			//Stop on the original position ( Sticky > Menu Box )
1819			else if( defaultCondition && currentScroll <= menuOffset ){
1820				jQuery('.sticky-enable').removeClass('sticky-active');
1821				stickyMenu.hide();
1822				displaySticky = 0;
1823			}
1824
1825			tempScroll = currentScroll;
1826		});
1827
1828	}
1829}
1830
1831function cws_vc_responsive(){
1832	if( !not_desktop() ){
1833		jQuery('div[class*="desktop_vc_custom"]');
1834	}
1835}
1836
1837function mainSearchForm(){
1838	jQuery('.menu-box .search-icon').on('click', function() {
1839		jQuery('.site-search-wrapper').addClass('active');
1840		jQuery('.site-search-wrapper').find('.search-field').focus();
1841	});
1842
1843	jQuery('.site-search-wrapper .close-search').on('click', function(){
1844		jQuery('.site-search-wrapper').removeClass('active');
1845	});
1846}
1847/****\ Header scripts declaration \****/
1848
1849
1850/***** Other libraries declaration  *****/
1851function vimeo_init() {
1852	var element;
1853	var vimeoId;
1854	var chek;
1855	jQuery(".cws_Vimeo_video_bg").each(function(){
1856		element = jQuery(this);
1857		var el_width;
1858		var el_height;
1859		vimeoId = jQuery(".cws_Vimeo_video_bg").attr('data-video-id');
1860
1861		jQuery("#"+vimeoId).vimeo("play");
1862			jQuery("#"+vimeoId).vimeo("setVolume", 0);
1863			jQuery("#"+vimeoId).vimeo("setLoop", true);
1864			el_width = element[0].offsetWidth;
1865
1866		if (element[0].offsetHeight<((el_width/16)*9)) {
1867			el_height = (element[0].offsetWidth/16)*9;
1868		}else{
1869			el_height = element[0].offsetHeight;
1870			el_width = (el_height/9)*16;
1871		}
1872		jQuery("#"+vimeoId)[0].style.width = el_width+'px';
1873		jQuery("#"+vimeoId)[0].style.height = el_height+'px';
1874		setInterval(check_on_page, 1000);
1875	})
1876
1877	function check_on_page (){
1878		if (document.getElementsByTagName('html')[0].hasAttribute('data-focus-chek')) {		
1879			if (chek < 1) {
1880				chek++
1881				jQuery("#"+vimeoId).vimeo("play");
1882			}else{
1883				chek = 1
1884			}									
1885		}else{
1886			jQuery("#"+vimeoId).vimeo("pause");
1887			chek = 0;
1888		}
1889	}	
1890}
1891
1892function cws_self_hosted_video (){
1893	var element,el_width,video
1894	jQuery('.cws_self_hosted_video').each(function(){
1895		element = jQuery(this)
1896		video = element.find('video')
1897		el_width = element[0].offsetWidth;
1898
1899		if (element[0].offsetHeight<((el_width/16)*9)) {
1900			el_height = (element[0].offsetWidth/16)*9;
1901		}else{
1902			el_height = element[0].offsetHeight;
1903			el_width = (el_height/9)*16;
1904		}
1905		video[0].style.width = el_width+'px';
1906		video[0].style.height = el_height+'px';
1907	})	
1908}
1909
1910function wow_init (){
1911	if( typeof WOW === 'function' ){
1912		new WOW().init();	
1913	}
1914}
1915
1916function cws_fancybox_init(){
1917	//Check if function exist
1918	if( typeof fancybox === 'function' ){
1919		jQuery(".fancy").fancybox();
1920	}
1921}
1922
1923function isotope_init (){		
1924	jQuery(".news.news-pinterest .isotope").each(function(item, value){	
1925		jQuery(this).isotope({
1926			itemSelector: ".item"
1927		});					
1928	});	
1929	jQuery(".blog_gallery_grid.isotope").each(function(item, value){	
1930		jQuery(this).isotope({
1931			// percentPosition: true,
1932			itemSelector: ".pic"
1933		});					
1934	});
1935}
1936
1937/* -----> Youtube Video <----- */
1938var i,
1939	currTime,
1940	duration,
1941	video_source,
1942	video_id,
1943	el_height,
1944	element,
1945	el_width,
1946	el_quality,
1947	player;
1948
1949	element = document.getElementsByClassName("cws_Yt_video_bg"); 
1950	
1951function onYouTubePlayerAPIReady() {
1952	if(typeof element === 'undefined') 
1953		return; 
1954	for (var i = element.length - 1; i >= 0; i--) {
1955		video_source = element[i].getAttribute("data-video-source");
1956		video_id = element[i].getAttribute("data-video-id");
1957		el_width = element[i].offsetWidth;
1958
1959		
1960
1961		if (element[i].offsetHeight<((el_width/16)*9)) {
1962			el_height = (element[i].offsetWidth/16)*9;
1963		}else{
1964			el_height = element[i].offsetHeight;
1965			el_width = (el_height/9)*16;
1966		}
1967		if (el_width > 1920){
1968			el_quality = 'highres'; 
1969		}
1970		if (el_width < 1920){
1971			el_quality = 'hd1080'; 
1972		}
1973		if (el_width < 1280) {
1974			el_quality = 'hd720'; 
1975		}
1976		if (el_width < 853) {
1977			el_quality = 'large';
1978		}
1979		if (el_width < 640) {
1980			el_quality = 'medium';
1981		};
1982		rev (video_id,video_source,el_width,el_height);
1983		
1984	};
1985}
1986function rev (video_id,video_source,el_width,el_height){
1987	window.setTimeout(function() {
1988		if (!YT.loaded) {
1989			console.log('not loaded yet');
1990			window.setTimeout(arguments.callee, 50)
1991		} else {
1992			var curplayer = video_control(video_id,video_source,el_width,el_height);		
1993		}
1994	}, 50);
1995}
1996
1997var chek = 0;
1998var YouTube;
1999
2000function video_control (uniqid,video_source,el_width,el_height) {
2001	var interval;
2002
2003	player = new YT.Player(uniqid, {
2004			height: el_height,
2005			width: el_width,
2006			videoId: video_source,
2007			playerVars: {
2008				'autoplay' : 1,
2009				'rel' : 0,
2010				'showinfo' : 0,
2011				'showsearch' : 0,
2012				'controls' : 0,
2013				'loop' : 1,
2014				'enablejsapi' : 1,
2015				'theme' : 'dark',
2016				'modestbranding' : 0,
2017				'wmode' : 'transparent',
2018			},
2019			events: {
2020				'onReady': onPlayerReady,
2021				'onStateChange': onPlayerStateChange
2022			}
2023		}
2024	);
2025}
2026
2027window.addEventListener('focus', function() {
2028	checkPlayer();
2029	return true;
2030});
2031function onPlayerReady(event){
2032	YouTube = event.target;
2033	YouTube.mute();
2034	YouTube.setPlaybackQuality(el_quality);	    
2035}
2036function onPlayerStateChange(event) {	
2037	YouTube.playVideo();
2038}
2039function seekTo(event) {
2040	player.seekTo(0);									
2041}
2042function checkPlayer() {	
2043	if (undefined !== player && undefined !== player.getCurrentTime) {
2044		currTime = player.getCurrentTime(); //get video position	
2045		duration = player.getDuration(); //get video duration
2046		(currTime > (duration - 0.8)) ? seekTo(event) : '';		
2047	};		
2048					
2049}
2050function chek_on_page (){
2051	if (document.getElementsByTagName('html')[0].hasAttribute('data-focus-chek')) {		
2052		if (chek < 1 && undefined !== player.playVideo) {
2053			chek++
2054			player.playVideo();
2055		}else{
2056			chek = 1
2057		}									
2058	}else if (undefined !== player.pauseVideo) {
2059		player.pauseVideo();
2060		chek = 0;
2061	}
2062}
2063/*\ ----> Youtube Video <---- \*/
2064/****\ Other libraries declaration  \****/
2065
2066
2067/***** Pages filter/pagination/carousel declaration  *****/
2068function cws_carousel($class, area){
2069	jQuery( $class, area ).each( function() {
2070
2071		var this_is = jQuery(this);
2072
2073		/* -----> Getting carousel attributes <-----*/	
2074		var slidesToShow = this_is.data('columns');
2075		var slidesToScroll = this_is.data('slides-to-scroll');
2076		var infinite = this_is.data('infinite') == 'on';
2077		var pagination = this_is.data('pagination') == 'on';
2078		var navigation = this_is.data('navigation') == 'on';
2079		var autoHeight = this_is.data('auto-height') == 'on';
2080		var draggable = this_is.data('draggable') == 'on';
2081		var autoplay = this_is.data('autoplay') == 'on';
2082		var autoplaySpeed = this_is.data('autoplay-speed');
2083		var pauseOnHover = this_is.data('pause-on-hover') == 'on';
2084		var vertical = this_is.data('vertical') == 'on';
2085		var verticalSwipe = this_is.data('vertical-swipe') == 'on';
2086		var tabletPortrait = this_is.data('tablet-portrait');
2087		var landscapeMobile = this_is.data('mobile-landscape');
2088		var centerMode = this_is.data('center-mode') == 'on';
2089		var carousel = this_is.children('.cws-carousel');
2090		if( carousel.length == 0 ){
2091			carousel = this_is.find('.products.cws-carousel'); //Need for woocommerce shortcodes
2092		}
2093		var responsive = 'centerMode';
2094		var rtl = jQuery('body').hasClass('rtl');
2095		console.log();
2096
2097		/* -----> Collect attributes in aruments object <-----*/	
2098		var args = {
2099			slidesToShow: slidesToShow,
2100			slidesToScroll: slidesToScroll,
2101			infinite: infinite,
2102			dots: pagination,
2103			arrows: navigation,
2104			adaptiveHeight: autoHeight,
2105			draggable: draggable,
2106			autoplay: autoplay,	
2107			autoplaySpeed: autoplaySpeed,
2108			pauseOnHover: pauseOnHover, 
2109			vertical: vertical,
2110			verticalSwiping: verticalSwipe,
2111			margin: 20,
2112            centerMode: centerMode,
2113			centerPadding: '0px',
2114			rtl: rtl
2115		};
2116
2117
2118		/* -----> Responsive rules <----- */
2119		if( typeof tabletPortrait !== 'undefined' && typeof landscapeMobile !== "undefined" ){
2120			responsive = {
2121				responsive: [
2122					{
2123						breakpoint: 992,
2124						settings: {
2125							slidesToShow: tabletPortrait,
2126                            arrows: navigation,
2127						}
2128					},
2129					{
2130						breakpoint: 768,
2131						settings: {
2132							slidesToShow: landscapeMobile,
2133                            arrows: false,
2134                            vertical: vertical,
2135                            verticalSwiping: verticalSwipe
2136						}
2137					},
2138					{
2139						breakpoint: 480,
2140						settings: {
2141							slidesToShow: 1,
2142							slidesToScroll: 1,
2143							dots: true,
2144							arrows: false,
2145                            vertical: false,
2146                            verticalSwiping: false
2147						}
2148					},
2149				]
2150			}
2151		} else if( typeof tabletPortrait !== 'undefined' ){
2152			responsive = {
2153				responsive: [
2154					{
2155						breakpoint: 992,
2156						settings: {
2157							slidesToShow: tabletPortrait,
2158                            arrows: navigation,
2159                            vertical: vertical,
2160                            verticalSwiping: verticalSwipe
2161						}
2162					},
2163					{
2164						breakpoint: 768,
2165						settings: {
2166							slidesToShow: 1,
2167							slidesToScroll: 1,
2168                            arrows: false,
2169                            vertical: vertical,
2170                            verticalSwiping: verticalSwipe
2171						}
2172					},
2173					{
2174						breakpoint: 480,
2175						settings: {
2176                            arrows: false,
2177                            vertical: false,
2178                            verticalSwiping: false,
2179                            dots: true,
2180						}
2181					}
2182				]
2183			}
2184		} else if( landscapeMobile !== "undefined" ){
2185			responsive = {
2186				responsive: [
2187                    {
2188                        breakpoint: 992,
2189                        settings: {
2190                            arrows: navigation,
2191                            vertical: vertical,
2192                            verticalSwiping: verticalSwipe
2193                        }
2194                    },
2195					{
2196						breakpoint: 768,
2197						settings: {
2198							slidesToShow: landscapeMobile,
2199                            arrows: false,
2200                            vertical: vertical,
2201                            verticalSwiping: verticalSwipe
2202						}
2203					},
2204					{
2205						breakpoint: 480,
2206						settings: {
2207							slidesToShow: 1,
2208							slidesToScroll: 1,
2209                            arrows: false,
2210                            vertical: false,
2211                            verticalSwiping: false,
2212                            dots: true,
2213						}
2214					}
2215				]
2216			}
2217		} else {
2218			responsive = {
2219				responsive: [
2220                    {
2221                        breakpoint: 992,
2222                        settings: {
2223                            arrows: navigation,
2224                        }
2225                    },
2226					{
2227						breakpoint: 768,
2228						settings: {
2229							slidesToShow: 1,
2230							slidesToScroll: 1,
2231							dots: true,
2232							arrows: false,
2233						}
2234					}
2235				]
2236			}
2237		}
2238		
2239		args = jQuery.extend({}, args, responsive);
2240
2241		/* -----> Carousel init <-----*/	
2242		carousel.slick(args);
2243		
2244	});
2245}
2246
2247function cws_portfolio_pagination_init (){
2248	jQuery( ".cws-portfolio .pagination" ).each( function (){
2249		var pagination = jQuery( this );
2250		cws_portfolio_pagination ( pagination );
2251	});
2252
2253	jQuery('.cws-portfolio-fw .pagination').each( function (){
2254		var pagination = jQuery( this );
2255		cws_portfolio_pagination ( pagination , true );
2256	});
2257}
2258
2259function cws_portfolio_pagination ( pagination , is_fw ){
2260	if ( pagination == undefined ) return;
2261	if (is_fw != undefined){ 
2262		is_fw == is_fw ;
2263	}else{
2264		is_fw == false ;
2265	}
2266	var old_page_links = pagination.find( ".page-links" );
2267	var items = old_page_links.find( ".page-numbers:not(.dots)" ).not( ".current" ); 
2268	if (is_fw) {
2269		var parent = pagination.closest( ".cws-portfolio-fw" );
2270	}else{
2271		var parent = pagination.closest( ".cws-portfolio" );
2272	}
2273	
2274	if (is_fw) {
2275		var grid = parent.find( ".grid_fw" );
2276	}else{
2277		var grid = parent.find( ".cws-portfolio-items" );
2278	}
2279
2280	if (is_fw) {
2281		var ajax_data_input = parent.find( "input.cws-portfolio-fw-ajax-data" );
2282	}else{
2283		var ajax_data_input = parent.find( "input.cws-portfolio-ajax-data" );
2284	}
2285
2286	items.each( function (){
2287		var item = jQuery( this );
2288		var url = item.attr( "href" );
2289		var ajax_data = JSON.parse( ajax_data_input.val() );
2290		var action_func;
2291		ajax_data['url'] = url;		
2292		if (is_fw) {
2293			action_func = 'cws_portfolio_fw_pagination';
2294		}else{
2295			action_func = 'cws_portfolio_pagination';
2296		}
2297
2298		item.on( "click", function ( e ){
2299			e.preventDefault();
2300			if ( wait_load_portfolio ) return;
2301			wait_load_portfolio = true;
2302			if (is_fw) {
2303				pagination.closest('.cws-portfolio-fw').find('.portfolio-loader-wraper').show();
2304			}else{
2305				pagination.closest('.cws-portfolio').find('.portfolio-loader-wraper').show();
2306			}
2307			jQuery.post( ajaxurl, {
2308				"action" : action_func,
2309				"data" : ajax_data
2310			}, function ( data, status ){
2311				var img_loader;
2312				var parent_offset = parent.offset().top;
2313				var old_items = jQuery( ".item", grid );
2314				var new_items = jQuery( ".item", jQuery( data ) );
2315				var new_page_links = jQuery( ".pagination .page-links", jQuery( data ) );
2316				var new_page_links_exists = Boolean( new_page_links.children().length );
2317				new_items.css( "display", "none" );
2318				if (ajax_data['pagination_style'] != 'load_more') {
2319					grid.isotope( 'remove', old_items );
2320					if ( window.scrollY > parent_offset ){
2321						jQuery( 'html, body' ).stop().animate({
2322							scrollTop : parent_offset
2323						}, 300);
2324					}					
2325				}
2326				grid.append( new_items );
2327				img_loader = imagesLoaded( grid );
2328				img_loader.on( "always", function (){
2329					grid.isotope( 'appended', new_items );
2330					if (is_fw) {
2331						pagination.closest('.cws-portfolio-fw').find('.portfolio-loader-wraper').hide();
2332					}else{
2333						pagination.closest('.cws-portfolio').find('.portfolio-loader-wraper').hide();
2334					}
2335					grid.isotope( 'layout' );
2336					old_page_links.fadeOut( function (){
2337						old_page_links.remove();
2338						wait_load_portfolio = false;
2339						if ( new_page_links_exists ){
2340							new_page_links.css( "display", "none" );
2341							pagination.append( new_page_links );
2342							new_page_links.fadeIn();
2343							if (is_fw){
2344								cws_portfolio_pagination ( pagination , true );
2345							}else{
2346								cws_portfolio_pagination ( pagination );
2347							}
2348						}
2349						else{
2350							pagination.remove();
2351						}
2352					    if (Retina.isRetina()) {
2353				        	jQuery(window.retina.root).trigger( "load" );
2354					    }
2355						cws_fancybox_init ();
2356					});
2357				});
2358			});
2359		});
2360	});
2361}
2362
2363function cws_portfolio_filter_init (){
2364	var els = jQuery( ".cws-portfolio .cws-portfolio-filter" );
2365	els.each( function (){
2366		var el = jQuery( this );
2367		var parent = el.closest( ".cws-portfolio" );
2368		var grid = parent.find( ".cws-portfolio-items" );
2369		var ajax_data_input = parent.find( "input.cws-portfolio-ajax-data" );
2370		var filter_el = el.children("a");
2371		filter_el.on( "click", function (e){
2372
2373			e.preventDefault();
2374			jQuery( this ).addClass('active').siblings().removeClass('active');
2375			var val = jQuery( this ).attr('data-filter');
2376			var ajax_data = JSON.parse( ajax_data_input.val() );
2377			ajax_data["filter"] = val;
2378			var old_pagination = parent.find( ".pagination" );
2379			var old_page_links = jQuery( ".page-links", old_pagination );
2380
2381			el.closest('.cws-portfolio-header').siblings( '.cws-wrapper' ).find('.portfolio-loader-wraper').show();
2382			jQuery.post( ajaxurl, {
2383				"action" : "cws_portfolio_filter",
2384				"data" : ajax_data
2385			}, function ( data, status ){
2386				var img_loader;
2387				var old_items = jQuery( ".item", grid );
2388				var new_items = jQuery( ".item", jQuery( data ) );
2389				var new_pagination = jQuery( ".pagination", jQuery( data ) );
2390				var new_page_links = jQuery( ".page-links", new_pagination );
2391				var new_page_links_exists = Boolean( new_page_links.children().length );
2392				new_items.css( "display", "none" );
2393				grid.isotope( 'remove', old_items );
2394				grid.append( new_items );
2395				el.closest('.cws-portfolio-header').siblings( '.cws-wrapper' ).find('.portfolio-loader-wraper').hide();
2396				img_loader = imagesLoaded( grid );
2397				img_loader.on( "always", function (){
2398					grid.isotope( 'appended', new_items );
2399					grid.isotope( 'layout' );
2400					ajax_data_input.attr( "value", JSON.stringify( ajax_data ) );
2401					if ( old_pagination.length ){
2402						if ( new_page_links_exists ){
2403							new_page_links.css( "display", "none" );
2404							old_page_links.fadeOut( function (){
2405								old_page_links.remove();
2406								old_pagination.append( new_page_links );
2407								new_page_links.fadeIn();
2408								cws_portfolio_pagination ( old_pagination );
2409							});
2410						}
2411						else{
2412							old_pagination.fadeOut( function (){
2413								old_pagination.remove();
2414							});
2415						}
2416					}
2417					else{
2418						if ( new_page_links_exists ){
2419							new_pagination.css( "display", "none" );
2420							parent.append( new_pagination );
2421							new_pagination.fadeIn();
2422							cws_portfolio_pagination ( new_pagination );
2423						}
2424					}
2425				    if (Retina.isRetina()) {
2426			        	jQuery(window.retina.root).trigger( "load" );
2427				    }
2428					cws_fancybox_init ();
2429				});
2430			});
2431		});
2432	});
2433}
2434
2435function cws_ourteam_pagination_init (){
2436	var els = jQuery( ".cws_ourteam .pagination" );
2437	els.each( function (){
2438		var pagination = jQuery( this );
2439		cws_ourteam_pagination( pagination );
2440	});	
2441}
2442
2443function cws_ourteam_pagination ( pagination ){
2444	if ( pagination == undefined ) return;
2445	var old_page_links = pagination.find( ".page-links" );
2446	var items = old_page_links.find( ".page-numbers" ).not( ".current" );
2447	var parent = pagination.closest( ".cws_ourteam" );
2448	var grid = parent.find( ".cws_ourteam_items" );
2449	var ajax_data_input = parent.find( "input.cws-ourteam-ajax-data" );
2450	items.each( function (){
2451		var item = jQuery( this );
2452		var url = item.attr( "href" );
2453		var ajax_data = JSON.parse( ajax_data_input.val() );
2454		ajax_data['url'] = url;
2455		item.on( "click", function ( e ){
2456			e.preventDefault();
2457			jQuery.post( ajaxurl, {
2458				"action" : "cws_ourteam_pagination",
2459				"data" : ajax_data
2460			}, function ( data, status ){
2461				var img_loader;
2462				var parent_offset = parent.offset().top;
2463				var old_items = jQuery( ".item", grid );
2464				var new_items = jQuery( ".item", jQuery( data ) );
2465				var new_page_links = jQuery( ".pagination .page-links", jQuery( data ) );
2466				var new_page_links_exists = Boolean( new_page_links.children().length );
2467				new_items.css( "display", "none" );
2468				grid.isotope( 'remove', old_items );
2469				if ( window.scrollY > parent_offset ){
2470					jQuery( 'html, body' ).stop().animate({
2471						scrollTop : parent_offset
2472					}, 300);
2473				}
2474				grid.append( new_items );
2475				img_loader = imagesLoaded( grid );
2476				img_loader.on( "always", function (){
2477					grid.isotope( 'appended', new_items );
2478					grid.isotope( 'layout' );
2479					old_page_links.fadeOut( function (){
2480						old_page_links.remove();
2481						if ( new_page_links_exists ){
2482							new_page_links.css( "display", "none" );
2483							pagination.append( new_page_links );
2484							new_page_links.fadeIn();
2485							cws_ourteam_pagination ( pagination );
2486						}
2487						else{
2488							pagination.remove();
2489						}
2490					    if (Retina.isRetina()) {
2491				        	jQuery(window.retina.root).trigger( "load" );
2492					    }
2493						cws_fancybox_init ();
2494					});
2495				});
2496
2497			});
2498		});
2499	});
2500}
2501
2502function cws_ourteam_filter_init (){
2503	var els = jQuery( ".cws_ourteam select.cws_ourteam_filter" );
2504	els.each( function (){
2505		var el = jQuery( this );
2506		var parent = el.closest( ".cws_ourteam" );
2507		var grid = parent.find( ".cws_ourteam_items" );
2508		var ajax_data_input = parent.find( "input.cws-ourteam-ajax-data" );
2509		el.on( "change", function (){
2510			var val = el.val();
2511			var ajax_data = JSON.parse( ajax_data_input.val() );
2512			ajax_data["filter"] = val;
2513			var old_pagination = parent.find( ".pagination" );
2514			var old_page_links = jQuery( ".page-links", old_pagination );
2515			jQuery.post( ajaxurl, {
2516				"action" : "cws_ourteam_filter",
2517				"data" : ajax_data
2518			}, function ( data, status ){
2519				console.log(data);
2520				var img_loader;
2521				var old_items = jQuery( ".item", grid );
2522				var new_items = jQuery( ".item", jQuery( data ) );
2523				var new_pagination = jQuery( ".pagination", jQuery( data ) );
2524				var new_page_links = jQuery( ".page-links", new_pagination );
2525				var new_page_links_exists = Boolean( new_page_links.children().length );
2526				new_items.css( "display", "none" );
2527				grid.isotope( 'remove', old_items );
2528				grid.append( new_items );
2529				img_loader = imagesLoaded( grid );
2530				img_loader.on( "always", function (){
2531					grid.isotope( 'appended', new_items );
2532					grid.isotope( 'layout' );
2533					ajax_data_input.attr( "value", JSON.stringify( ajax_data ) );
2534					if ( old_pagination.length ){
2535						if ( new_page_links_exists ){
2536							new_page_links.css( "display", "none" );
2537							old_page_links.fadeOut( function (){
2538								old_page_links.remove();
2539								old_pagination.append( new_page_links );
2540								new_page_links.fadeIn();
2541								cws_ourteam_pagination ( old_pagination );
2542							});
2543						}
2544						else{
2545							old_pagination.fadeOut( function (){
2546								old_pagination.remove();
2547							});
2548						}
2549					}
2550					else{
2551						if ( new_page_links_exists ){
2552							new_pagination.css( "display", "none" );
2553							parent.append( new_pagination );
2554							new_pagination.fadeIn();
2555							cws_ourteam_pagination ( new_pagination );
2556						}
2557					}
2558				    if (Retina.isRetina()) {
2559			        	jQuery(window.retina.root).trigger( "load" );
2560				    }
2561					cws_fancybox_init ();
2562				});
2563			});
2564		});
2565	});
2566}
2567
2568function widget_archives_hierarchy_init (){
2569	//widget_archives_hierarchy_controller ( ".cws-widget>ul li", "ul.children", "parent_archive", "widget_archive_opener" );
2570	widget_archives_hierarchy_controller ( ".cws-widget .menu li", "ul.sub-menu", "menu-item-has-children", "opener" );
2571}
2572
2573function widget_archives_hierarchy_controller ( list_item_selector, sublist_item_selector, parent_class, opener_class ){
2574	jQuery( list_item_selector ).has( sublist_item_selector ).each( function (){
2575		jQuery( this ).addClass( parent_class );
2576		var sublist = jQuery( this ).children( sublist_item_selector ).first();
2577		var level_height = jQuery( this ).outerHeight() - sublist.outerHeight();
2578		jQuery(this).append( "<span class='flaticon flaticon-arrow-point-to-right " + opener_class + "'></span>" );
2579	});
2580	jQuery( list_item_selector + ">" + sublist_item_selector ).css( "display", "none" );
2581
2582	jQuery( document ).on( "click", "." + opener_class, function (){
2583		var el = jQuery(this);
2584		var sublist = el.siblings( sublist_item_selector );
2585
2586		if ( !sublist.length ) return;
2587		sublist = sublist.first();
2588
2589		el.parent().toggleClass( "active" );
2590		sublist.slideToggle( 300 );
2591	});
2592}
2593/****\ Pages filter/pagination/carousel declaration  \****/
2594
2595
2596/***** CWS Features declaration  *****/
2597
2598function cws_fs_video_bg_init (){
2599	var slider_wrappers, header_height_is_set;
2600	header_height_is_set = document.getElementsByClassName( 'header-video-fs-view' );
2601
2602
2603	if ( !header_height_is_set.length) return;
2604		cws_fs_video_slider_controller( header_height_is_set[0] );
2605	window.addEventListener( 'resize', function (){
2606		cws_fs_video_slider_controller( header_height_is_set[0] );
2607	});
2608}
2609function cws_fs_video_slider_controller ( el ){
2610	cws_set_window_width( el );
2611	cws_set_window_height( el );
2612}
2613
2614function cws_slider_video_height (element){
2615	var height_coef = element.attr('data-wrapper-height')
2616	if (height_coef) {
2617		if (window.innerWidth<960) {
2618			element.height(window.innerWidth/height_coef)
2619		}else{
2620			element.height(960/height_coef)
2621		}
2622	}	
2623}
2624
2625function boxed_var_init (){
2626	var body_el = document.body;
2627	var children = body_el.childNodes;
2628	var child_class = "";
2629	var match;
2630	window.boxed_layout = false;
2631	for ( var i=0; i<children.length; i++ ){
2632		child_class = children[i].className;
2633		if ( child_class != undefined ){
2634			match = /page_boxed/.test( child_class );
2635			if ( match ){
2636				window.boxed_layout = true;
2637				break;
2638			}
2639		}
2640	}
2641}
2642
2643var wait_load_posts = false;
2644
2645function reload_scripts(){
2646	wp_standard_processing();
2647	cws_fancybox_init();
2648}
2649
2650function load_more_init (){
2651	jQuery( document ).on( "click", ".cws-load-more", function (e){
2652		e.preventDefault();
2653		if ( wait_load_posts ) return;
2654		var el = jQuery(this);
2655		var url = el.attr( "href" );
2656		var paged = parseInt( el.data( "paged" ) );
2657		var max_paged = parseInt( el.data( "max-paged" ) );
2658		var template = el.data( "template" );
2659		var item_cont = el.parent().siblings( ".grid" );
2660		var isotope = false;
2661		var args = { ajax : "true", paged : paged, template: template };
2662
2663		if ( !item_cont.length ) return;
2664		el.closest('.cws-wrapper').find('.portfolio_loader_wraper').show();
2665		wait_load_posts = true;
2666		jQuery.post( url, args, function ( data ){
2667			var new_items = jQuery(data).filter( '.item' );
2668			if ( !new_items.length ) return;
2669			new_items.css( 'display' , 'none' );
2670			jQuery(item_cont).append( new_items );
2671			el.closest('.cws-wrapper').find('.portfolio_loader_wraper').hide();
2672			wait_load_posts = false;
2673			var img_loader = imagesLoaded( jQuery(item_cont) );
2674			img_loader.on ('always', function (){
2675				reload_scripts();
2676				new_items.css( 'display', 'block' );
2677				if ( jQuery(item_cont).isotope ){
2678					jQuery(item_cont).isotope( 'appended', new_items);
2679					jQuery(item_cont).isotope( 'layout' );
2680				}
2681			    if (Retina.isRetina()) {
2682		        	jQuery(window.retina.root).trigger( "load" );
2683			    }
2684			    if ( paged == max_paged ){
2685			    	el.fadeOut( { duration : 300, complete : function (){
2686			    		el.remove();
2687			    	}})
2688			    }
2689			    else{
2690			    	el.data( "paged", String( paged + 1 ) );
2691			    }
2692			});
2693		});
2694	});
2695}
2696
2697function cws_go_to_page_init(){
2698	if(!not_desktop()){
2699		var hashTagActive = false;
2700
2701		jQuery('.menu-item a').on('click', function(event) {
2702			if(!jQuery(this).hasClass("fancy") && jQuery(this).attr("href") != "#" && jQuery(this).attr("target") != "_blank"){
2703				event.stopPropagation();
2704			    var anchor = jQuery(this).attr("href");
2705			    var link = anchor.replace('/#','#')
2706				var re = new RegExp( "^#.*$" );
2707				var matches = re.exec( link );
2708
2709				if ((matches == null && jQuery(this).attr("href").indexOf("#") != -1) || (!!navigator.userAgent.match(/Version\/[\d\.]+.*Safari/))){
2710					return true;
2711				} else {
2712					event.preventDefault();
2713				}
2714
2715			    if (hashTagActive) return;
2716			    hashTagActive = true;      
2717			    
2718			    if (jQuery(this).attr("href").indexOf("#") != -1 && matches !== null){
2719
2720			        if (jQuery(link).length){
2721			                jQuery('html, body').animate({
2722			                scrollTop: jQuery(link).offset().top
2723			            }, animation_curve_speed, animation_curve_menu, function () {
2724			                hashTagActive = false;
2725			            });              
2726			        }
2727
2728			    } else {
2729			        jQuery('body').fadeOut(1000, newpage(anchor)); 
2730			    }
2731			       
2732			}
2733		});
2734
2735	   function newpage(e) {
2736	     window.location = e;
2737	   }
2738	}
2739}
2740
2741function cws_parallax_init(){
2742	if (jQuery( ".cws_prlx_section" ).length) {
2743		jQuery( ".cws_prlx_section" ).cws_prlx();
2744	};
2745}
2746
2747function cws_clone_obj ( src_obj ){
2748	var new_obj, keys, i, key, val;
2749	if ( src_obj == undefined || typeof src_obj != 'object' ) return false;
2750	new_obj = {};
2751	keys = Object.keys( src_obj );
2752	for ( i = 0; i < keys.length; i++ ){
2753		key = keys[i];
2754		val = src_obj[key];
2755		new_obj[key] = val;
2756	}
2757	return new_obj;
2758}
2759
2760function cws_prlx_init_waiter (){
2761	var interval, layers, layer_ids, i, layer_id, layer_obj, layer_loaded;
2762	if ( window.cws_prlx == undefined ){
2763		return;
2764	}
2765	layers = cws_clone_obj( window.cws_prlx.layers );
2766	interval = setInterval( function (){
2767		layer_ids = Object.keys( layers );
2768		for ( i = 0; i < layer_ids.length; i++ ){
2769			layer_id = layer_ids[i];
2770			layer_obj = window.cws_prlx.layers[layer_id];
2771			layer_loaded = layer_obj.loaded;
2772			if ( layer_loaded ){
2773				delete layers[layer_id];
2774			}
2775		}
2776		if ( !Object.keys( layers ).length ){
2777			clearInterval ( interval );
2778		}
2779	}, 100);
2780}
2781
2782function cws_message_box_init (){
2783	jQuery( document ).on( 'click', '.cws-msg-box-module .close-btn', function (){
2784		var cls_btn = jQuery(this);
2785		var el = cls_btn.closest( ".cws-msg-box-module" );
2786		el.fadeOut( function (){
2787			el.remove();
2788		});
2789	});
2790}
2791
2792function cws_milestone_init (){
2793	jQuery.fn.cws_milestone = function (){
2794		jQuery(this).each( function (){		
2795			var el = jQuery(this);
2796			var number_container = el.find(".cws-milestone-number");
2797			var done = false;
2798			if (number_container.length){
2799				if ( !done ) done = milestone_controller (el, number_container);
2800				jQuery(window).scroll(function (){
2801					if ( !done ) done = milestone_controller (el, number_container);
2802				});
2803			}
2804		});
2805	}
2806}
2807
2808function milestone_controller (el, number_container){
2809	var od, args;
2810	var speed = number_container.data( 'speed' );
2811	var number = number_container.text();
2812	if (el.is_visible()){
2813		args= {
2814			el: number_container[0],
2815			format: 'd',
2816		};
2817		if ( speed ) args['duration'] = speed;
2818		od = new Odometer( args );
2819		od.update( number );
2820		return true;
2821	}
2822	return false;
2823}
2824
2825function get_digit (number, digit){
2826	var exp = Math.pow(10, digit);
2827	return Math.round(number/exp%1*10);
2828}
2829
2830function cws_progress_bar_init (){
2831	jQuery.fn.cws_progress_bar = function (){
2832		jQuery(this).each( function (){
2833			var el = jQuery(this);
2834			var done = false;
2835			if (!done) done = progress_bar_controller(el);
2836			jQuery(window).scroll(function (){
2837				if (!done) done = progress_bar_controller(el);
2838			});
2839		});
2840	}
2841}
2842
2843function progress_bar_controller (el){
2844	if (el.is_visible()){
2845		var progress = el.find(".progress-bar");
2846		var value = parseInt( progress.attr("data-value") );
2847		var width = parseInt(progress.css('width').replace(/%|(px)|(pt)/,""));
2848		var ind = el.find(".indicator");
2849		if ( width < value ){
2850			var progress_interval = setInterval( function(){
2851				width ++;
2852				progress.css("width", width+"%");
2853				ind.text(width+'%');
2854				if (width == value){
2855					clearInterval(progress_interval);
2856				}
2857			}, 5);
2858		}
2859		return true;
2860	}
2861	return false;
2862}
2863
2864function cws_sticky_sidebars_init(){
2865	//Check if function exist
2866	if (typeof jQuery.fn.theiaStickySidebar === 'function') {
2867		if (sticky_sidebars == 1 && !is_mobile() ){
2868			jQuery('aside.sb-left, aside.sb-right').theiaStickySidebar({
2869			      additionalMarginTop: 60,
2870			      additionalMarginBottom: 60
2871			}); 		
2872		}
2873	}
2874}
2875
2876function cws_set_window_width ( el ){
2877	var window_w;
2878	if ( el != undefined ){
2879		window_w = document.body.clientWidth;
2880		el.style.width = window_w + 'px';
2881	}
2882}
2883function cws_set_window_height ( el ){
2884	var window_h;
2885	if ( el != undefined ){
2886		window_h = window.innerHeight;
2887		el.style.height = window_h + 'px';
2888	}
2889}
2890
2891function single_sticky_content() {
2892	var item = jQuery(".cws-portfolio-single-content.sticky-cont");
2893	var item_p = item.parent();
2894	if(typeof item_p.theiaStickySidebar != 'undefined'){
2895		item_p.theiaStickySidebar({
2896			additionalMarginTop: 80,
2897			additionalMarginBottom: 30
2898		}); 		
2899	}
2900}
2901
2902function smooth_comment_link(){
2903	if( jQuery('body').hasClass('single-post') || jQuery('body').hasClass('attachment') ){
2904		jQuery('.post-comments a').on('click', function(e) {
2905			e.preventDefault();
2906
2907			var href = jQuery(this).attr('href');
2908			var anchor = href.split('#')[1];
2909
2910			jQuery('html, body').animate({
2911				scrollTop: jQuery('#'+anchor).offset().top
2912			}, 500)			
2913		});
2914	}
2915}
2916
2917function cws_widgets_on_tablet(){
2918	if( cws_is_tablet_viewport() ){
2919		var body = jQuery('body');
2920		var widgetsTrigger = jQuery('.sidebar-tablet-trigger');
2921		var aside = jQuery('.page-content aside');
2922		var windowHeight = jQuery(window).height();
2923
2924		var showTrigger = body.height() * 0.4;
2925		var widgetsPos = aside.attr('class');
2926				
2927		widgetsPos = 'trigger_'+widgetsPos;
2928		widgetsTrigger.addClass(widgetsPos);
2929
2930		jQuery(window).on('scroll', function() {
2931			if( jQuery(this).scrollTop() > showTrigger ) {
2932				widgetsTrigger.addClass('active');
2933			} else {
2934				widgetsTrigger.removeClass('active');
2935			}
2936		});
2937
2938		widgetsTrigger.on('click', function() {
2939			aside.addClass('active');
2940			body.addClass('oveflow-hidden');
2941			jQuery('.aside-widgets-overlay').addClass('active');
2942		});
2943
2944		jQuery('.aside-widgets-overlay').on('click', function() {
2945			jQuery(this).removeClass('active');
2946			aside.removeClass('active');
2947			body.removeClass('oveflow-hidden');
2948		});
2949	}
2950}
2951
2952function cws_footer_on_bottom(){
2953	if( jQuery(window).height() > jQuery('body').height() ){
2954		jQuery('.copyrights-area').addClass('bottom_fixed');
2955	} else {
2956		jQuery('.copyrights-area').removeClass('bottom_fixed');
2957	}
2958}
2959
2960function scroll_to_top(){
2961
2962	jQuery('.footer-icon').on('click', function() {
2963		jQuery('html, body').animate({
2964			scrollTop: 0
2965		}, 1000)
2966	});
2967}
2968
2969function navigation_hold_post(){
2970	jQuery('.nav-post-links .nav-post').on('click', function() {
2971		jQuery(this).addClass('active');
2972	});
2973}
2974
2975function cws_roadmap_before_end_point(){
2976	if( jQuery('body').hasClass('rtl') ){
2977		jQuery('.roadmap-row.breakpoint').find('.end-point').nextAll().addClass('before_end');
2978	} else {
2979		jQuery('.roadmap-row.breakpoint').find('.end-point').prevAll().addClass('before_end');
2980	}
2981}
2982
2983function cws_roadmap_animation(){
2984	jQuery('.roadmap-row').each(function(i, el){
2985		//Animate icons when module is visible
2986		var module_offset = jQuery(el).offset().top;
2987
2988		if( jQuery(window).scrollTop() + (jQuery(window).height() * 0.7) >= module_offset ){
2989			jQuery(el).addClass('active');
2990		} else {
2991			jQuery(window).on('scroll', function() {
2992				if( jQuery(window).scrollTop() + (jQuery(window).height() * 0.7) >= module_offset ){
2993					jQuery(el).addClass('active');
2994				}
2995			});
2996		}
2997	});
2998}
2999
3000function cws_benefits_init(){
3001	if( !not_desktop() ){
3002		cws_benefits_animation('hover');
3003	} else {
3004		cws_benefits_animation('click');
3005	}
3006
3007	cws_benefits_equal_height();
3008}
3009function cws_benefits_animation(trigger){
3010	jQuery('.cws-benefits-module').on(trigger, function() {
3011		jQuery(this).closest('.vc_row').find('.cws-benefits-module').addClass('hidden');
3012		jQuery(this).removeClass('hidden');
3013	});
3014}
3015function cws_benefits_equal_height(){
3016	jQuery('.cws-benefits-module').each(function(i, el){
3017		if( jQuery(el).closest('.vc_row').hasClass('vc_row-o-equal-height') ){
3018			jQuery(el).parent('.wpb_wrapper').css('height', '100%');
3019			jQuery(el).css('height', '100%');
3020		}
3021	});
3022}
3023
3024function cws_infinite_autoplay(){
3025	if( jQuery('.top-bar-ticker').length != 0 ){
3026		jQuery('.top-bar-ticker').simplemarquee();
3027	}
3028}
3029
3030function cws_countdown(){
3031	if( jQuery('.countdown_clock').length != 0 ){
3032
3033		var clock;
3034		var futureDate;
3035		var diff;
3036		var currentDate = new Date();
3037
3038		jQuery('.countdown_clock').each(function(i, el){
3039			futureDate = new Date(jQuery(el).data('time'));
3040			diff = futureDate.getTime() / 1000 - currentDate.getTime() / 1000;
3041
3042			clock = jQuery(el).FlipClock(diff, {
3043				clockFace: 'DailyCounter',
3044				countdown: true
3045			});
3046		});
3047	}
3048}
3049
3050function cws_vc_pie_chart_layout(){
3051    jQuery('.vc_pie_chart').each( function() {
3052		var width = jQuery('.vc_pie_wrapper', this).width();
3053        var width_block = jQuery(this).width();
3054		var fsize_title = Math.round(width_block*0.1);
3055		var fsize_value = Math.round(width*0.152);
3056		var title_padding = Math.round(width*0.1826);
3057		if (fsize_title < 20) {
3058			fsize_title = 20;
3059		}
3060		if (title_padding > 100) {
3061            title_padding = 100;
3062		}
3063        jQuery('.wpb_pie_chart_heading', this).css({'font-size': fsize_title + 'px', 'padding-top': title_padding + 'px'});
3064        jQuery('.vc_pie_chart_value', this).css({'font-size': fsize_value + 'px'});
3065    });
3066}
3067
3068function cws_advanced_form_focus() {
3069	jQuery('.form-advanced').each(function() {
3070		jQuery('.wpcf7-text', this).on('focus', function() {
3071			jQuery(this).parents('.form-field-wrapper').addClass('focused');
3072		});
3073        jQuery('.wpcf7-text', this).on('blur', function() {
3074            jQuery(this).parents('.form-field-wrapper').removeClass('focused');
3075        });
3076	});
3077}
3078
3079function cws_service_card_activation() {
3080	jQuery('.service-type-card').each(function() {
3081		var row = jQuery(this).parents('.cws-content');
3082		jQuery('.service-type-card:first', row).addClass('hovered');
3083        jQuery('.service-type-card', row).on('mouseover', function() {
3084        	if (jQuery(this).hasClass('hovered')) {
3085        		return false;
3086			} else {
3087                jQuery('.service-type-card', row).removeClass('hovered');
3088                jQuery(this).addClass('hovered');
3089			}
3090		});
3091	});
3092}
3093
3094function cws_service_gallery_activation() {
3095    jQuery('.service-type-gallery').each(function() {
3096        var row = jQuery(this).closest('.cws-content');
3097        jQuery('.service-type-gallery', row).eq(1).addClass('hovered');
3098        jQuery('.service-type-gallery', row).on('mouseover', function() {
3099            if (jQuery(this).hasClass('hovered')) {
3100                return false;
3101            } else {
3102                jQuery('.service-type-gallery', row).removeClass('hovered');
3103                jQuery(this).addClass('hovered');
3104            }
3105        });
3106    });
3107}
3108
3109function cws_testimonials_card_activation() {
3110	jQuery('.cws-testimonial-module.style-1.cws-carousel-wrapper').each(function() {
3111        jQuery('.cws-testimonial-item').on('mouseover', function() {
3112        	if (jQuery(this).hasClass('slick-center')) {
3113        		return false;
3114			} else {
3115                jQuery(this).addClass('active').siblings('.slick-center').removeClass('slick-center').addClass('temp');
3116			}
3117		});
3118        jQuery('.cws-testimonial-item').on('mouseleave', function() {
3119            jQuery(this).removeClass('active').siblings('.temp').removeClass('temp').addClass('slick-center');
3120        });
3121	});
3122}
3123
3124function cws_submenu_location() {
3125    jQuery(".header-nav-part .sub-menu .sub-menu").each(function() {
3126        if ( jQuery(window).width() >= 1200 ) {
3127            var menu_width = Math.trunc(parseInt(jQuery(this).outerWidth()));
3128
3129            var parent_offset_left = Math.trunc(parseInt(jQuery(this).parent('li').offset().left));
3130            var parent_width = Math.trunc(parseInt(jQuery(this).parent('li').outerWidth()));
3131
3132            var menu_offset_left = Math.trunc(parent_offset_left + parent_width);
3133            var menu_offset_right = Math.trunc(parseInt(jQuery(window).width() - menu_offset_left - menu_width));
3134
3135            if (menu_offset_right < 15) {
3136                jQuery(this).css({
3137                    'left': 'auto',
3138                    'right': '100%'
3139                });
3140            } else {
3141                jQuery(this).css({
3142                    'left': '100%',
3143                    'right': 'auto'
3144                });
3145            }
3146        } else {
3147            jQuery(this).removeAttr('style');
3148        }
3149    });
3150}
3151/****\ CWS Features declaration  \****/
3152
3153/***** CWS Fixes declaration  *****/
3154
3155function cws_revslider_pause_init (){
3156	var slider_els, slider_el, slider_id, id_parts, revapi_ind, revapi_id, i;
3157	var slider_els = document.getElementsByClassName( "rev_slider" );
3158	window.cws_revsliders = {};
3159	if ( !slider_els.length ) return;
3160	for ( i = 0; i < slider_els.length; i++ ){
3161		slider_el = slider_els[i];
3162		slider_id = slider_el.id;
3163		id_parts = /rev_slider_(\d+)(_\d+)?/.exec( slider_id );
3164		if ( id_parts == null ) continue;
3165		if ( id_parts[1] == undefined ) continue;
3166		revapi_ind = id_parts[1];
3167		revapi_id = "revapi" + revapi_ind;
3168		window.cws_revsliders[slider_id] = {
3169			'el' : slider_el,
3170			'api_id' : revapi_id,
3171			'stopped' : false
3172		}
3173		window[revapi_id].on( 'bind', 'revolution.slide.onloaded', function (){
3174			cws_revslider_scroll_controller ( slider_id );
3175		});
3176		window.addEventListener( 'scroll', function (){
3177			cws_revslider_scroll_controller ( slider_id );
3178		});	
3179	}	
3180}
3181function cws_revslider_scroll_controller ( slider_id ){
3182	var slider_obj, is_visible;
3183	if ( slider_id == undefined ) return;
3184	slider_obj = window.cws_revsliders[slider_id];
3185	is_visible = jQuery( slider_obj.el ).is_visible();
3186	if ( is_visible && slider_obj.stopped ){
3187		window[slider_obj.api_id].revresume();
3188		slider_obj.stopped = false;
3189	}
3190	else if ( !is_visible && !slider_obj.stopped ){
3191		window[slider_obj.api_id].revpause();	
3192		slider_obj.stopped = true;		
3193	}
3194}
3195
3196function cws_first_place_col(){
3197	jQuery('.first_col_trigger').each(function(i, el) {
3198		jQuery(el).next().addClass('vc_inner_col-first-place');
3199	});
3200
3201	jQuery('.vc_col-first-place').closest('.vc_row').addClass('custom_flex_row');
3202	jQuery('.vc_inner_col-first-place').closest('.vc_row').addClass('custom_inner_flex_row');
3203}
3204
3205function staff_advanced_hover() {
3206	if( not_desktop() ){
3207		jQuery('.staff-module-wrapper.style_advanced .staff-item-inner').on('click', function(e) {
3208			jQuery(this).closest('.cws-vc-shortcode-grid').find('.staff-item-inner').removeClass('active');
3209			jQuery(this).addClass('active');
3210
3211			e.preventDefault();
3212			return false;
3213		});
3214	}
3215}
3216
3217function cws_custom_inputs() {
3218	jQuery('.cws-input-mail').closest('p').addClass('cws-input-mail');
3219	jQuery('.cws-submit-mail').closest('p').addClass('cws-submit-mail');
3220
3221	jQuery('.big-input').closest('p').addClass('big-input');
3222	jQuery('.submit-inside').closest('p').addClass('submit-inside');
3223	jQuery('.second-color').closest('p').addClass('second-color');
3224	jQuery('.full-width').closest('p').addClass('full-width');
3225	jQuery('.width-50').closest('p').addClass('width-50');
3226	jQuery('.float-right').closest('p').addClass('float-right');
3227
3228	jQuery('.cws-standart-form').closest('form').addClass('cws-standart-form');
3229
3230	jQuery('.wpcf7-form-control-wrap').children().each(function(i, el) {
3231		if( el.tagName == 'SELECT' ){
3232			jQuery(el).parent().addClass('cws-custom-select');
3233		}
3234	});
3235}
3236
3237function cws_fix_styles_init(){
3238	//Full width map fix
3239	jQuery('#wpgmza_map').closest('.cws-column').addClass('full_width_map');
3240
3241	var browser = cws_detect_browser();
3242	jQuery('body').addClass('browser_'+browser);
3243}
3244
3245function metamax_services_hover(){
3246	if( !not_desktop() ){
3247		jQuery('.cws-service-module.scale_on_hover').hover( function() {
3248			jQuery(this).closest('.vc_row').find('.cws-column-wrapper').css('z-index', '1');
3249			jQuery(this).closest('.cws-column-wrapper').css('z-index', '2');
3250		});
3251	}
3252}
3253
3254function metamax_portfolio_tablet_hover(){
3255	if( not_desktop() ){
3256		jQuery('.portfolio-module-wrapper.cws-carousel-wrapper .item .item-content, .cws-vc-shortcode-grid .item .item-content').on('click', function(e) {
3257			if( !jQuery(this).hasClass('active') ){
3258				jQuery('.item .item-content').removeClass('active');
3259				jQuery(this).addClass('active');
3260				e.preventDefault();
3261				return false;
3262			}
3263		});
3264	}
3265}
3266function metamax_product_tablet_hover(){
3267    if( not_desktop() ){
3268        jQuery('.products .product .metamax-shop-loop-item-content-wrapper').on('click', function(e) {
3269            if( !jQuery(this).hasClass('active') ){
3270                jQuery('.products .product .metamax-shop-loop-item-content-wrapper').removeClass('active');
3271                jQuery(this).addClass('active');
3272                e.preventDefault();
3273                return false;
3274            }
3275        });
3276    }
3277}
3278
3279function Video_resizer (){
3280	if (element.length) {
3281		for (var i = element.length - 1; i >= 0; i--) {
3282			video_source = element[i].getAttribute("data-video-source");
3283			video_id = element[i].getAttribute("data-video-id");
3284			el_width = element[i].offsetWidth;
3285		
3286
3287			if (element[i].offsetHeight<((el_width/16)*9)) {
3288				el_height = (element[i].offsetWidth/16)*9;
3289			}else{
3290				el_height = element[i].offsetHeight;
3291				el_width = (el_height/9)*16;
3292			}
3293			var el_iframe = document.getElementById(element[i].getAttribute("data-video-id"));
3294			el_iframe.style.width = el_width+'px';
3295			el_iframe.style.height = el_height+'px';
3296		};
3297	};
3298}
3299
3300function vc_accordion_fix(){
3301	jQuery('.vc_tta-panel-title').each(function(i, el){
3302		if( jQuery(el).hasClass('vc_tta-controls-icon-position-right') ){
3303			jQuery(el).closest('.vc_tta-panel').find('.vc_tta-panel-body').addClass('vc_tta-content-position-right');
3304		}
3305	});
3306}
3307
3308function embed_videos_height(){
3309	jQuery('.cws-oembed-wrapper').each(function(i, el) {
3310		if( typeof jQuery(el).children('iframe').attr('src') !== 'undefined' && jQuery(el).children('iframe').attr('src') != '' ){
3311			jQuery(el).addClass('video-inside');
3312		}
3313	});
3314}
3315
3316function cws_megamenu_active(){
3317	jQuery('.menu-item-object-megamenu_item').each(function(i, el) {
3318		if( jQuery(el).find('.current_page_item').length != 0 ){
3319			jQuery(el).addClass('current_page_ancestor');
3320		}
3321	});
3322}
3323
3324/****\ CWS Fixes declaration  \****/
3325
3326/**********************************
3327****** /SCRIPTS DECLARATION *******
3328**********************************/
3329
3330
3331/*******************************************
3332******** OTHER SCRIPTS DECLARATION *********
3333*******************************************/
3334
3335function is_visible_init (){
3336	jQuery.fn.is_visible = function (){
3337		return ( jQuery(this).offset().top >= jQuery(window).scrollTop() ) && ( jQuery(this).offset().top <= jQuery(window).scrollTop() + jQuery(window).height() );
3338	}
3339}
3340
3341function cws_is_rtl(){
3342	return jQuery("body").hasClass("rtl");
3343}
3344
3345function cws_widget_divider_init (){
3346	jQuery.fn.cws_widget_divider = function (){
3347		jQuery(this).each( function (){
3348			var el = jQuery(this);
3349			var done = false;
3350			if (!done) done = cws_widget_divider_controller(el);
3351			jQuery(window).scroll(function (){
3352				if (!done) done = cws_widget_divider_controller(el);
3353			});
3354		});
3355	}
3356}
3357
3358function cws_widget_divider_controller (el){
3359	if (el.is_visible()){
3360		jQuery(el).addClass('divider_init');
3361		return true;
3362	}
3363	return false;
3364}
3365
3366function cws_widget_services_init (){
3367	jQuery.fn.cws_services_icon = function (){
3368		jQuery(this).each( function (){
3369			var el = jQuery(this);
3370			var done = false;
3371			if (!done) done = cws_icon_animation_controller(el);
3372			jQuery(window).scroll(function (){
3373				if (!done) done = cws_icon_animation_controller(el);
3374			});
3375		});
3376	}
3377}
3378
3379function cws_icon_animation_controller (el){
3380	if (el.is_visible() && jQuery(el).hasClass('add_animation_icon') ){
3381		jQuery(el).addClass('icon_init');
3382		return true;
3383	}
3384	return false;
3385}
3386
3387function hexdec(hex_string) {
3388	hex_string = (hex_string + '')
3389	.replace(/[^a-f0-9]/gi, '');
3390	return parseInt(hex_string, 16);
3391}
3392
3393function cws_Hex2RGB(hex) {
3394	var hex = hex.replace("#", "");
3395	var color = '';
3396	if (hex.length == 3) {
3397		color = hexdec(hex.substr(0,1))+',';
3398		color = color + hexdec(hex.substr(1,1))+',';
3399		color = color + hexdec(hex.substr(2,1));
3400	}else if(hex.length == 6){
3401		color = hexdec(hex.substr(0,2))+',';
3402		color = color + hexdec(hex.substr(2,2))+',';
3403		color = color + hexdec(hex.substr(4,2));
3404	}
3405	return color;
3406}
3407
3408function cws_detect_browser() { 
3409    if((navigator.userAgent.indexOf("Opera") || navigator.userAgent.indexOf('OPR')) != -1 ) 
3410    {
3411        return 'Opera';
3412    }
3413    else if(navigator.userAgent.indexOf("Chrome") != -1 )
3414    {
3415        return 'Chrome';
3416    }
3417    else if(navigator.userAgent.indexOf("Safari") != -1)
3418    {
3419        return 'Safari';
3420    }
3421    else if(navigator.userAgent.indexOf("Firefox") != -1 ) 
3422    {
3423        return 'Firefox';
3424    }
3425    else if((navigator.userAgent.indexOf("MSIE") != -1 ) || (!!document.documentMode == true )) //IF IE > 10
3426    {
3427    	return 'IE';
3428    }  
3429    else 
3430    {
3431       return 'unknown';
3432    }
3433}
3434
3435/*******************************************
3436******* /OTHER SCRIPTS DECLARATION *********
3437*******************************************/
3438
3439
3440/*************************************
3441************** RETINA ****************
3442*************************************/
3443
3444var retina = {};
3445retina.root = (typeof exports === 'undefined' ? window : exports);
3446retina.config = {
3447        // An option to choose a suffix for 2x images
3448        retinaImageSuffix : '@2x',
3449
3450        // Ensure Content-Type is an image before trying to load @2x image
3451        // https://github.com/imulus/retinajs/pull/45)
3452        check_mime_type: true,
3453
3454        // Resize high-resolution images to original image's pixel dimensions
3455        // https://github.com/imulus/retinajs/issues/8
3456        force_original_dimensions: true
3457    };
3458retina.config.retinaImagePattern = new RegExp( retina.config.retinaImageSuffix + "." );
3459
3460(function() {
3461    function Retina() {}
3462
3463    window.retina.root.Retina = Retina;
3464
3465    Retina.configure = function(options) {
3466        if (options === null) {
3467            options = {};
3468        }
3469
3470        for (var prop in options) {
3471            if (options.hasOwnProperty(prop)) {
3472                window.retina.config[prop] = options[prop];
3473            }
3474        }
3475    };
3476
3477    Retina.init = function(context) {
3478        if (context === null) {
3479            context = window.retina.root;
3480        }
3481
3482        var existing_onload = context.onload || function(){};
3483
3484        context.onload = function() {
3485            var images = document.getElementsByTagName('img'), retinaImages = [], i, image;
3486            for (i = 0; i < images.length; i += 1) {
3487                image = images[i];
3488                if ( !retina.config.retinaImagePattern.test(image.getAttribute("src")) ){
3489                    if (!!!image.getAttributeNode('data-no-retina')) {
3490                        retinaImages.push(new RetinaImage(image));
3491                    }
3492                }
3493            }
3494            existing_onload();
3495        };
3496    };
3497
3498    Retina.isRetina = function(){
3499        var mediaQuery = '(-webkit-min-device-pixel-ratio: 1.5), (min--moz-device-pixel-ratio: 1.5), (-o-min-device-pixel-ratio: 3/2), (min-resolution: 1.5dppx)';
3500
3501        if (window.retina.root.devicePixelRatio > 1) {
3502            return true;
3503        }
3504
3505        if (window.retina.root.matchMedia && window.retina.root.matchMedia(mediaQuery).matches) {
3506            return true;
3507        }
3508
3509        return false;
3510    };
3511
3512
3513    var regexMatch = /\.\w+$/;
3514    function suffixReplace (match) {
3515        return window.retina.config.retinaImageSuffix + match;
3516    }
3517
3518    function RetinaImagePath(path, at_2x_path) {
3519        this.path = path || '';
3520        if (typeof at_2x_path !== 'undefined' && at_2x_path !== null) {
3521            this.at_2x_path = at_2x_path;
3522            this.perform_check = false;
3523        } else {
3524            if (undefined !== document.createElement) {
3525                var locationObject = document.createElement('a');
3526                locationObject.href = this.path;
3527                locationObject.pathname = locationObject.pathname.replace(regexMatch, suffixReplace);
3528                this.at_2x_path = locationObject.href;
3529            } else {
3530                var parts = this.path.split('?');
3531                parts[0] = parts[0].replace(regexMatch, suffixReplace);
3532                this.at_2x_path = parts.join('?');
3533            }
3534            this.perform_check = true;
3535        }
3536    }
3537
3538    window.retina.root.RetinaImagePath = RetinaImagePath;
3539
3540    RetinaImagePath.confirmed_paths = [];
3541
3542    RetinaImagePath.prototype.is_external = function() {
3543        return !!(this.path.match(/^https?\:/i) && !this.path.match('//' + document.domain) );
3544    };
3545
3546    RetinaImagePath.prototype.check_2x_variant = function(callback) {
3547        var http, that = this;
3548        if (this.is_external()) {
3549            return callback(false);
3550        } else if (!this.perform_check && typeof this.at_2x_path !== 'undefined' && this.at_2x_path !== null) {
3551            return callback(true);
3552        } else if (this.at_2x_path in RetinaImagePath.confirmed_paths) {
3553            return callback(true);
3554        } else {
3555            return callback(false);
3556        }
3557    };
3558
3559
3560    function RetinaImage(el) {
3561        this.el = el;
3562        this.path = new RetinaImagePath(this.el.getAttribute('src'), this.el.getAttribute('data-at2x'));
3563        var that = this;
3564        this.path.check_2x_variant(function(hasVariant) {
3565            if (hasVariant) {
3566                that.swap();
3567            }
3568        });
3569    }
3570
3571    window.retina.root.RetinaImage = RetinaImage;
3572
3573    RetinaImage.prototype.swap = function(path) {
3574        if (typeof path === 'undefined') {
3575            path = this.path.at_2x_path;
3576        }
3577
3578        var that = this;
3579        function load() {
3580            var width = that.el.offsetWidth;
3581            var height = that.el.offsetHeight;
3582            if ( !that.el.complete || !width || !height ) {
3583                setTimeout(load, 5);
3584            } else {
3585                if (window.retina.config.force_original_dimensions) {
3586                    that.el.setAttribute('width', width);
3587                    that.el.setAttribute('height', height);
3588                }
3589
3590                that.el.setAttribute('src', path);
3591            }
3592        }
3593        load();
3594    };
3595
3596
3597    if (Retina.isRetina()) {
3598        Retina.init(window.retina.root);
3599    }
3600})();
3601
3602/**************************************
3603************** \RETINA ****************
3604**************************************/
3605
3606
3607/*******************************************************
3608************** TIPR ****************
3609*******************************************************/
3610(function($){$.fn.tipr=function(options){var set=$.extend({'speed':200,'mode':'bottom'},options);return this.each(function(){var tipr_cont='.tipr_container_'+set.mode;$(this).hover( function()
3611{var d_m=set.mode;if($(this).attr('data-mode'))
3612{d_m=$(this).attr('data-mode')
3613tipr_cont='.tipr_container_'+d_m;}
3614var out='<div class="tipr_container_'+d_m+'"><div class="tipr_point_'+d_m+'"><div class="tipr_content">'+$(this).attr('data-tip')+'</div></div></div>';$(this).append(out);var w_t=$(tipr_cont).outerWidth();var w_e=$(this).width();var m_l=(w_e / 2)-(w_t / 2);$(tipr_cont).css('margin-left',m_l+'px');$(this).removeAttr('title alt');$(tipr_cont).fadeIn(set.speed);},function()
3615{$(tipr_cont).remove();});});};})(jQuery);
3616/*******************************************************
3617************** \TIPR ****************
3618*******************************************************/

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.