PageSourceSearch

https://sportdivers.com/js/dive-custom.js

js sportdivers.com collected 2026-09-26 21:33:56 UTC 122,032 bytes, 3,762 lines download raw bytes

1let Utility = (function () {
2	let sort = 'name_asc',
3		view = 'grid',
4		allViews = ['list', 'grid'],
5		allSorts = ['price_desc', 'price_asc', 'created_desc', 'created_asc', 'name_desc', 'name_asc'];
6
7	function Utility() { }
8	let _toParam = function (ary) {
9		if (!(ary instanceof Array)) {
10			console.warn('Exception: Not an array');
11			return false;
12		}
13		var str = '';
14		for (var len = ary.length, i = 0; i < len; i++) {
15			str += (i === 0) ? '?' : '';
16			str += ary[i].join('=');
17			str += (i === len - 1) ? '' : '&';
18		}
19		return str;
20	}
21	let _getParams = function (sort, view) {
22		var ary = [
23			['sort_type', sort],
24			['view', view]
25		];
26		return _toParam(ary);
27	}
28	Utility.prototype.setSort = function (srt) {
29		localStorage.dssf_sort = srt;
30		return _getParams(this.getSort(), this.getView());
31	}
32	Utility.prototype.getSort = function () {
33		return localStorage.dssf_sort || sort;
34	}
35	Utility.prototype.setView = function (vw) {
36		localStorage.dssf_view = vw;
37		return _getParams(this.getSort(), this.getView());
38	}
39	Utility.prototype.getView = function () {
40		return localStorage.dssf_view || view;
41	}
42	Utility.prototype.initFilterButtons = function () {
43		$('.btn-filter').removeClass('text-primary').addClass('text-muted');
44		if (this.getView() === 'grid') {
45			$('.btn-filter.fa-th-large').addClass('text-primary');
46		} else {
47			$('.btn-filter.fa-th-list').addClass('text-primary');
48		}
49	}
50	return Utility;
51})();
52
53let util = new Utility();
54var filter_products = {};
55
56var urlParams = new URLSearchParams(window.location.search);
57var entries = urlParams.entries();
58var price = {};
59for(var pair of entries) {
60	
61  if (pair[0]=="category") {
62	var category = {};
63	category.id = pair[1];
64	filter_products.category = category;
65  }
66  else if (pair[0]=="manufacture") {
67	var mf = pair[1].split(",");
68	filter_products.manufacture = mf;
69	
70  }
71  else if (pair[0]=="min") {
72	price.min = pair[1];
73	filter_products.price = price;
74	
75  }
76  else if (pair[0]=="max") {	
77	price.max = pair[1];
78	filter_products.price = price;
79	
80  }
81  else if (pair[0]=="firearmType") {	
82	filter_products.firearmType = pair[1];	
83  }
84  else if (pair[0]=="firearmCaliber") {	
85	filter_products.firearmCaliber = pair[1];	
86  }
87}
88
89
90function splstr(str)
91{
92	return str.replace(/[&\/\\#,+()$~%.'":*?<>{}@ ]/g, "");
93}
94
95document.addEventListener("DOMContentLoaded", function (e) {
96	$(document).on('click', '.btn-buy-cart', function () {
97		location.href = BASE_PATH + '/cart';
98	});
99	$('.search-mobile-icon').click(function () {
100		$('.search-ico').slideToggle();
101	});
102	var slide_count = 0;
103	$(".bxslider li").map(function (i, n) {
104		slide_count++;
105	});
106	var auto_enable_slide = true;
107	if (slide_count == 1) {
108		auto_enable_slide = false;
109	}
110	if ($('.bxslider').length == true) {
111		$('.bxslider').bxSlider({
112			auto: auto_enable_slide,
113			adaptiveHeight: true,
114			touchEnabled: !1,
115			pager: auto_enable_slide
116		});
117	}
118	if ($("#enable_expanded_sidebar").val() == 1) {
119	}
120	var imgMain = document.getElementById("imgMain");
121	if (imgMain) {
122		var x1 = 0,
123			y1 = 0;
124		var box = document.getElementById("magnifierBox");
125		imgMain.addEventListener("mousemove", function (e) {
126			$(".thumbnail.zoom").show();
127			x1 = -(e.offsetX - 150);
128			y1 = -(e.offsetY - 150);
129			setTimeout(function () {
130					$("#imgMainZoom").css({
131						"transform": "scale(1.3) translate3d(" + x1 + "px, " + y1 + "px, 0)"
132					});
133			}, 10);
134		});
135		imgMain.addEventListener("mouseleave", function (e) {
136			$(".thumbnail.zoom").hide();
137		});
138	}
139	var imgMain = $(".imgMain");
140	if (imgMain) {
141		var x1 = 0,
142			y1 = 0;
143		var box = $("#magnifierBox");
144		imgMain.mousemove(function( e ) {
145			$(".thumbnail.zoom").show();
146			x1 = -(e.offsetX - 150);
147			y1 = -(e.offsetY - 150);
148			setTimeout(function () {
149					$("#imgMainZoom").css({
150						"transform": "scale(1.3) translate3d(" + x1 + "px, " + y1 + "px, 0)"
151					});
152			}, 10);
153		});
154		imgMain.mouseleave(function( e ) {
155			$(".thumbnail.zoom").hide();
156		});
157	}
158	
159	util.initFilterButtons();
160	var cur_handle = '';
161	var match_vgp = '';
162	$(".variant-images .variant_pro").on('mouseenter', function (e) {
163		var varaint_name = '';
164		var vur_variant_pos = $(this).parent().find(".loop_value").val();
165		console.log("vur_variant_pos==="+vur_variant_pos+"-------$(this)[0].id=="+$(this)[0].id);
166		if (vur_variant_pos == 1) {
167			var first_variant = $(this)[0].id;
168			varaint_name += "/" +  first_variant;
169			if ($("#hightlight_value_2").val() != undefined) {
170				var second_variant = $("#hightlight_value_2").val();
171				varaint_name += "/" + second_variant;
172			}
173			if ($("#hightlight_value_3").val() != undefined) {
174				var third_variant = $("#hightlight_value_3").val();
175				varaint_name += "/" + third_variant;
176			}
177			
178		} else if (vur_variant_pos == 2) {
179			if ($("#hightlight_value_1").val() != undefined) {
180				var first_variant = $("#hightlight_value_1").val();
181				varaint_name += "/" + first_variant;
182			}
183			var second_variant = $(this)[0].id;
184			varaint_name += "/" + second_variant;
185			if ($("#hightlight_value_3").val() != undefined) {
186				var third_variant = $("#hightlight_value_3").val();
187				varaint_name += "/" + third_variant;
188			}
189
190		} else if (vur_variant_pos == 3) {
191			if ($("#hightlight_value_1").val() != undefined) {
192				var first_variant = $("#hightlight_value_1").val();
193				varaint_name += "/" + first_variant;
194			}
195			if ($("#hightlight_value_2").val() != undefined) {
196				var second_variant = $("#hightlight_value_2").val();
197				varaint_name += "/" + second_variant;
198			}
199			var third_variant = $(this)[0].id;
200			varaint_name += "/" + third_variant;
201		}
202		var variant_comp = varaint_name.replace(/\$##\$/g, "/").replace('N/A', "Unavailable").replace(/"/g,"").toLowerCase().split("/");
203		if(variant_comp[0]==''){variant_comp.shift();}
204		if(variant_comp.length>=3){
205			if(variant_comp[0]==0 || variant_comp[0]==1){
206		    	variant_comp.shift();
207		    }	
208		}
209		// varaint_name = varaint_name.replace(" ","");
210		// varaint_name = varaint_name.replace("'","");
211		// varaint_name = varaint_name.replace('"','');
212		// varaint_name = varaint_name.replace('#','');
213		varaint_name = splstr(varaint_name);
214
215
216		variant_comp1 = "_"+variant_comp.join("_");
217		// variant_comp1 = variant_comp1.replace(" ","");
218		// variant_comp1 = variant_comp1.replace("'","");
219		// variant_comp1 = variant_comp1.replace('"','');
220		// variant_comp1 = variant_comp1.replace('#','');
221		variant_comp1 = splstr(variant_comp1);
222		
223		variant_comp = "/"+variant_comp.join("/");
224		// variant_comp = variant_comp.replace(" ","");
225		// variant_comp = variant_comp.replace("'","");
226		// variant_comp = variant_comp.replace('"','');
227		// variant_comp = variant_comp.replace('#','');
228		variant_comp = splstr(variant_comp);
229		console.log("variant_comp======>"+variant_comp);
230		var part_ex = 0;
231		maincontent.forEach(function (item, index) {
232			var vfxs = item['variant_code'];
233			// vfxs = vfxs.replace(" ","");
234			// vfxs = vfxs.replace("'","");
235			// vfxs = vfxs.replace('"','');
236			// vfxs = vfxs.replace('#','');
237			vfxs = splstr(vfxs);
238			console.log("LOG1:  "+vfxs);
239			vfxs = vfxs.replace(/\$##\$/g, "/").replace('N/A', "Unavailable").replace(/"/g,"").toLowerCase();
240			vfxs  = vfxs.split("/");
241			console.log(vfxs)
242			if(vfxs.length>=3){
243				if(vfxs[0]==0 || vfxs[0]==1){
244			    	vfxs.shift();
245			    }	
246			}
247			vfxs = "/"+vfxs.join("/");
248			console.log(vfxs+" =----= "+varaint_name.toLowerCase())
249			if ( vfxs == varaint_name.toLowerCase() ) {
250				$(".unavailable_msg").hide();
251				var mainImg = document.getElementById('imgMain');
252				if (!mainImg) {mainImg = $(".imgMain");}
253				mainImg.src = item['product_image'];
254				cur_handle = item['handle'];
255				console.log(item);
256				if ($("#" + cur_handle).val() == 0) {
257					//part_ex = 1;
258					cur_handle = '';
259				}
260			}
261		});
262		console.log("part_ex==="+part_ex);
263		var t_cur_handle = new Array();
264		var u_cur_handle = new Array();
265		if (cur_handle == "" ) { //&& part_ex==0
266			match_vgp = $(this).find("a").html().trim().toLowerCase();
267			
268				match_vgp = splstr(match_vgp);
269			
270			var ti = 0;
271			maincontent.forEach(function (item, index) {
272				item['variant_code'] = item['variant_code'].replace('N/A', "Unavailable").toLowerCase();
273				
274					var vc = item['variant_code'].split("$##$").map(v => splstr(v));
275				
276				console.log(match_vgp+"---------TS--------"+vc);
277				if(vc.find(matching_vc))
278				{					
279					console.log("cur_handle===> "+item['handle']+"=======>"+$("#" + item['handle']).val());
280					//if(vc.length>=3){
281						if(vc[0]==0 || vc[0]==1){
282					    	vc.shift();
283					    }	
284					//}
285					vc = "/"+vc.join("/");
286					// vc = vc.replace(" ","");
287					// vc = vc.replace("'","");
288					// vc = vc.replace('"','');
289					// vc = vc.replace('#','');
290					vc = splstr(vc);
291					console.log(variant_comp+"----##SS1###----"+vc+"--->>>>"+item['handle']+"@@@@@@@@@@===>"+$("#" + item['handle']).val());
292					if(parseInt($("#" + item['handle']).val()) > 0)
293					{
294						console.log("------------SET T CUR HANDLE -----------");
295						if($("#insufficient_stock_showing_unavailable_3").length>0 && $("#insufficient_stock_showing_unavailable_3").val()==1){
296							// Clean a variant string safely (normal function)
297							function clean(v) {
298							    if (!v) return "";
299							    return v.replace(/[^a-zA-Z0-9-]/g, "").toLowerCase();
300							}
301							// Cleaned variants
302							var first  = clean(first_variant);
303							var second = clean(second_variant);
304							var third  = clean(third_variant);
305							// Selected variant values in fixed positions
306							var selectedVariants = [null, first, second, third];
307							// Build comphandle array
308							var splitArr = item.variant_code.split("$##$");
309							var comphandle = [];
310							for (var i = 0; i < splitArr.length; i++) {
311							    comphandle.push(clean(splstr(splitArr[i])));
312							}
313							if (comphandle.length > 0) {
314							    // Check index 1,2,3 automatically
315							    for (var j = 1; j <= 3; j++) {
316							        if (selectedVariants[j] && comphandle[j] === selectedVariants[j]) {
317							            t_cur_handle[ti] = item.handle;
318							            break;
319							        }
320							    }
321							} else {
322							    t_cur_handle[ti] = item.handle;
323							}
324							console.log("t_cur_handle:", t_cur_handle);
325						}else{	
326								var comphandle=item['variant_code'].split("$##$").map(v => splstr(v));
327								if(first_variant){
328									first_variant = first_variant.replace(/[^a-zA-Z0-9]/g, "");
329								}
330								if(second_variant){
331									second_variant = second_variant.replace(/[^a-zA-Z0-9]/g, "");
332								}
333								if(third_variant){
334									third_variant = third_variant.replace(/[^a-zA-Z0-9]/g, "");
335								}
336						
337							if (comphandle.length>0) {
338								if ((comphandle[1]).toLowerCase()==first_variant.toLowerCase()) {
339									t_cur_handle[ti]=item['handle'];
340								}	
341							} else {
342								t_cur_handle[ti]=item['handle'];
343							}
344						}
345		
346						if(variant_comp!=vc){
347							u_cur_handle[ti] = t_cur_handle[ti];
348							t_cur_handle[ti] = "" ;
349						}
350						ti++;
351					}else if(parseInt($("#" + item['handle']).val()) == 0){
352						variant_comp1 = item['handle'];
353					}
354				}
355				var vc = item['variant_code'].split("$##$");
356				if(vc.length>=3){
357					if(vc[0]==0 || vc[0]==1){
358				    	vc.shift();
359				    }	
360				}
361				vc = "/"+vc.join("/");
362				// vc = vc.replace(" ","");
363				// vc = vc.replace("'","");
364				// vc = vc.replace('"','');
365				// vc = vc.replace('#','');
366				vc = splstr(vc);
367				console.log(variant_comp+"---T---"+vc+"---T---"+$("#"+variant_comp1).length);
368				if(variant_comp==vc)
369				{
370					part_ex++;
371				}	
372				console.log("Part_ex-------4-----"+part_ex); 
373			});
374		}
375		console.log("------------t_cur_handle-----------1");
376		console.log(t_cur_handle);
377		console.log("------------u_cur_handle-----------1");
378		console.log(u_cur_handle);
379		t_cur_handle = clearn_array(t_cur_handle); //t_cur_handle.clean("");
380		u_cur_handle = clearn_array(u_cur_handle); //u_cur_handle.clean("");
381		console.log("------------t_cur_handle-----------2");
382		console.log(t_cur_handle);
383		console.log("------------u_cur_handle-----------2");
384		console.log(u_cur_handle);
385		console.log(variant_comp1+"====Part_ex-------5-----"+part_ex+"---");
386		
387		if($("#"+t_cur_handle).val()>0 && $(".li_hightlight").length==1)
388		{
389			cur_handle = t_cur_handle;
390		}
391		console.log("Log Handle: "+cur_handle+"====="+t_cur_handle)
392		if(t_cur_handle.length>0)
393		{
394			t_cur_handle.sort();
395			cur_handle = t_cur_handle[0];
396		}
397		console.log("Final Handle: "+cur_handle)
398		if (cur_handle == "") {
399			if($("#"+variant_comp1).length==1)
400			{
401				$(this).find("a").parent("li").attr("data-original-title", "Out of Stock");
402				$(this).find("a").parent("li").attr("title", "Out of Stock");
403			}
404			else{
405				$(this).find("a").parent("li").attr("data-original-title", "Unavailable");
406				$(this).find("a").parent("li").attr("title", "Unavailable");				
407			}
408		}
409		if(cur_handle=='' && u_cur_handle.length>0)
410		{
411			u_cur_handle.sort();
412			cur_handle = u_cur_handle[0];
413		}
414		console.log("Very Final Handle: "+cur_handle)
415		
416	});
417	/* User Remove empty values - Start */ 
418	function clearn_array(actual)
419	{
420		var newArray = new Array();
421		for (var i = 0; i < actual.length; i++) {
422			if (actual[i]) {
423			  newArray.push(actual[i]);
424			}
425		}
426		return newArray;
427	}
428	/*
429	Array.prototype.clean = function(deleteValue) {
430	  for (var i = 0; i < this.length; i++) {
431	    if (this[i] == deleteValue) {         
432	      this.splice(i, 1);
433	      i--;
434	    }
435	  }
436	  return this;
437	};
438	*/
439	/* User Remove empty values - End */
440	function matching_vc(arg){
441		return (match_vgp==arg)?true:false;
442	}
443	$(".variant-images .variant_pro").click(function (e) {
444		if (cur_handle != "") {
445			window.location.href = BASE_PATH + "/products/" + cur_handle;
446		}
447	});
448	$(".variant-images .variant_pro").mouseleave(function () {
449		$(".unavailable_msg").hide();
450		var main_img = document.getElementById('main_img_lg').value;
451		var mainImg = document.getElementById('imgMain');
452		if (!mainImg) {mainImg = $(".imgMain");}
453		cur_handle = '';
454		mainImg.src = main_img;
455	});
456	$("#contact_us_btn").on("click", function () {
457		$("#contact_us_model").show();
458	});
459	$(".contact_us_btn").on("click", function () {
460		$("#contact_us_model").show();
461		$("#contact_part_number").val($(this).attr("data-part"));
462	});
463	$("#close_popup").on('click', function () {
464		$("#contact_us_model").hide();
465	});
466	if (CONTROLL == "products" && (ACTION == "index" || ACTION == "collection" || ACTION == "mywishlist")) {
467		var option = '';
468		let min_price_filter = min_price;
469		let max_price_filter = max_price;
470		var count = manufacturer_keys.length;
471		manufacturer_values.sort();
472		for (var g = 0; g < count; g++) {
473			var str = manufacturer_values[g].split("#@#");
474			if ($.inArray(str[1], filter_products.manufacture) >= 0) option += '<option selected="selected" value="' + str[1] + '">' + str[0] + '</option>';
475			else option += '<option value="' + str[1] + '">' + str[0] + '</option>';
476		}
477		var counts = [products_per_row, "25", "50", "75", "100", "125"];
478		var counts_options = '';
479		for (var k = 0; k < counts.length; k++) {
480			counts_options += '<option value="' + counts[k] + '">' + counts[k] + '</option>';
481		}
482		$('#productlimiter').append(counts_options);
483		$('#productlimiter_sample').append(counts_options);
484		$('#selectManufacture').append(option);
485		if (industry_type == "Orchidshop") 
486		{
487			var brand_name = MANUFACTURER_TEXT;
488		}else{
489			var brand_name = BRANDS_TEXT;
490		}
491		$('#selectManufacture').multiselect({
492			columns: 1,
493			placeholder: brand_name,
494			search: true
495		});
496		var instance = $('#selectManufacture');
497		var placeholder = $(instance).next('.ms-options-wrap').find('> button:first-child');
498		var optionsWrap = $(instance).next('.ms-options-wrap').find('> .ms-options');
499		var select = optionsWrap.parent().prev();
500		optionsWrap.on('click', 'input[type="checkbox"]', function () {
501			optionsWrap.find('input[type="checkbox"]').prop("disabled", true);
502			$(this).closest('li').toggleClass('selected');
503			var select = optionsWrap.parent().prev();
504			let selOpts = [];
505			select.find('option[value="' + $(this).val() + '"]').prop('selected', $(this).is(':checked')).closest('select').trigger('change');
506			select.find('option:selected').each(function () {
507				if ($(this).val() == "") {
508					selOpts.push('null');
509				} else {
510					if ($(this).val() == "Unknown") {
511						selOpts.push(0);
512					} else {
513						selOpts.push($(this).val());
514					}
515				}
516			});
517			filter_products.manufacture = selOpts;
518			load_products();
519		});
520		$("#slider-range").slider({
521			range: true,
522			min: min_price,
523			max: max_price,
524			values: [min_price, max_price],
525			slide: function (event, ui) {
526				$("#amount").val( formatMoney(ui.values[0]) + " - "+formatMoney(ui.values[1]));
527				min_price_filter = Number(ui.values[0]);
528				max_price_filter = Number(ui.values[1]);
529				var select = optionsWrap.parent().prev();
530				let selOpts = [];
531				select.find('option[value="' + $(this).val() + '"]').prop('selected', $(this).is(':checked')).closest('select').trigger('change');
532				select.find('option:selected').each(function () {
533					if ($(this).val() == "") {
534						selOpts.push('null');
535					} else {
536						selOpts.push($(this).val());
537					}
538				});
539			}
540		});
541		if ($("#slider-range").length == true) {
542			setTimeout(function () {
543				$("#amount").val( formatMoney($("#slider-range").slider("values", 0)) + " - "+formatMoney($("#slider-range").slider("values", 1)));
544			}, 1500);
545		}
546		if (view === 'grid') {
547			$('.btn-filter.fa-th-large').addClass('text-primary');
548			$('.btn-filter.fa-th-list').removeClass('text-primary');
549		} else {
550			$('.btn-filter.fa-th-list').addClass('text-primary');
551			$('.btn-filter.fa-th-large').removeClass('text-primary');
552		}
553		setTimeout(function () {
554			if ($('#filtered_products > div').length > 0) {
555				setHeight($('#filtered_products > div'));
556			} else if ($('#filtered_products > li').length > 0) {
557				setHeight($('#filtered_products > li'));
558			}
559		}, 1000);
560		if ($("#productlimiter_sample").length > 0) {
561			$("#productlimiter_sample").on('change', function () {
562				var show_count = this.value;
563				products_per_row = show_count;
564				var select = optionsWrap.parent().prev();
565				let selOpts = [];
566				select.find('option[value="' + $(this).val() + '"]').prop('selected', $(this).is(':checked')).closest('select').trigger('change');
567				select.find('option:selected').each(function () {
568					if ($(this).val() == "") {
569						selOpts.push('null');
570					} else {
571						selOpts.push($(this).val());
572					}
573				});
574				applyFilters(selOpts, min_price_filter, max_price_filter, '');
575			});
576		}
577		if ($("#productlimiter").length > 0) {
578			$("#productlimiter").val(item_per_page);
579			$("#productlimiter").selectbox({
580				onChange: function (val, inst) {
581					var show_count = val;
582					products_per_row = show_count;
583					var select = optionsWrap.parent().prev();
584					let selOpts = [];
585					select.find('option[value="' + $(this).val() + '"]').prop('selected', $(this).is(':checked')).closest('select').trigger('change');
586					select.find('option:selected').each(function () {
587						if ($(this).val() == "") {
588							selOpts.push('null');
589						} else {
590							selOpts.push($(this).val());
591						}
592					});
593					item_per_page = $(this).val();
594					load_products();
595				}
596			});
597		}
598		if ($("#selectFirearmType").length > 0) {
599			$("#selectFirearmType").selectbox();
600		}
601		if ($("#selectFirearmCaliber").length > 0) {
602			$("#selectFirearmCaliber").selectbox();
603		}
604	}
605	if ($("#store_theme").length == 1 && ($("#store_theme").val() == "SAMPLE" || $("#store_theme") == "DEFAULT")) {
606		$(".sub-menu li").hover(function () {
607			if ($(this).height() > 30) {
608				$(this).children("ul").css("margin-top", "-45px");
609			}
610		});
611	}
612	$('img').each(function () {
613		var a = $(this).attr('data-filename');
614		if (a != undefined && a != "") {
615			if ($(this).width() >= $(window).width()) {
616				$(this).css("width", "100%", "!important");
617			}
618		}
619	});
620	$(".product-description *").each(function () {
621		if ($(this).width() >= $(this).closest(".panel-body").width()) {
622			$(this).css("width", "100%", "!important");
623		}
624	});
625	if ($('#reviewlist > li').length > 0) {
626	}
627	if ($('#filtered_products > li').length > 0) {
628		$("#filtered_products_section").val("li");
629	} else if ($('#filtered_products > div').length > 0) {
630		$("#filtered_products_section").val("div");
631	}
632	if ($('#filter_slider').length) {
633		$('#filter_slider').slideReveal({
634			push: false,
635			position: "left",
636			trigger: $(".handle"),
637			shown: function (obj) {
638				obj.find(".handle").html('<i class="fa fa-arrow-left">Filters</i>');
639				obj.addClass("left-shadow-overlay");
640			},
641			hidden: function (obj) {
642				obj.find(".handle").html('<i class="fa fa-arrow-right">Filters</i>');
643				obj.removeClass("left-shadow-overlay");
644			}
645		});
646	}
647});
648
649function setHeight(col) {
650	var $col = $(col);
651	var $maxHeight = 0;
652	$col.each(function () {
653		var $thisHeight = $(this).outerHeight() - 20;
654		if ($thisHeight > $maxHeight) {
655			$maxHeight = $thisHeight;
656		}
657	});
658	$("#spinner").css("display", "none");
659}
660
661function apply_text_length() {
662	$(".webpt").each(function () {
663		if (isUpperCase($(this).text())) {
664			var st = $(this).text();
665			$(this).text(st.substring(0, 20) + "..");
666		}
667	});
668}
669
670function isUpperCase(str) {
671	return str === str.toUpperCase();
672}
673
674function changeMainImage(e, evt) {
675	evt.preventDefault();
676	var mainImg = document.getElementById('imgMain');
677	var mainImgZoom = document.getElementById('imgMainZoom');
678	if (mainImg) {
679		mainImg.src = e.dataset.large;
680	}
681	mainImgZoom.src = e.dataset.xlarge;	
682}
683
684function getProductImg($url, $size) {
685	let $image = '../img/no-product.png';
686	if ($url) {
687		let $imgName = $url.split('part_images/');
688		$image = $imgName[0] + 'thumb/' + $size + '_' + $imgName[1];
689	}
690	return $image;
691}
692var recaptchaUserCreateCallback = function recaptchaUserCreateCallback(response) {
693	$("#hiddenRecaptcha").val(response);
694};
695var recaptchaUserForgetCallback = function recaptchaUserForgetCallback(response) {
696	$("#hiddenRecaptchaForget").val(response);
697};
698var recaptchaCallback = function recaptchaCallback(response) {
699	$("#hiddenRecaptchaContactus").val(response).css('color','#f00');
700};
701var recaptchaCallbackReview = function recaptchaCallbackReview(response) {
702	$("#hiddenRecaptchaReview").val(response);
703};
704
705function applyFilters(selOpts, min_price_filter, max_price_filter, catOpts) {
706	var filtered_products = [];
707	var products = all_products;
708	if (catOpts) {
709		filtered_products = [];
710		var k = 0;
711		for (var j = 0; j < products.length; j++) {
712			if ((
713				(products[j]['Category']['id'] == catOpts.id && catOpts.type == 'c') || (products[j]['Category']['parent_category_id'] == catOpts.id && catOpts.type == 'p') || (products[j]['Category']['parent_category_id'] == null && products[j]['Category']['id'] == catOpts.id && catOpts.type == 'p'))) {
714				filtered_products[k] = products[j];
715				k++;
716			}
717		}
718		displayFilteredProducts(filtered_products);
719	} else if (selOpts.length > 0) {
720		filtered_products = [];
721		var k = 0;
722		for (var i = 0; i < selOpts.length; i++) {
723			for (var j = 0; j < products.length; j++) {
724				if (products[j]['Manufacturer']['manufacture_name'] == null) {
725					products[j]['Manufacturer']['manufacture_name'] = "Unknown";
726				}
727				var man_name = products[j]['Manufacturer']['manufacture_name'].charAt(0).toUpperCase() + products[j]['Manufacturer']['manufacture_name'].slice(1).toLowerCase();
728				if (man_name == selOpts[i] && (products[j]['PartPriceLevel']['price'] >= min_price_filter && products[j]['PartPriceLevel']['price'] <= max_price_filter)) {
729					filtered_products[k] = products[j];
730					k++;
731				}
732			}
733		}
734		displayFilteredProducts(filtered_products);
735	} else {
736		filtered_products = [];
737		var k = 0;
738		for (var j = 0; j < products.length; j++) {
739			if (products[j]['PartPriceLevel']['price'] >= min_price_filter && products[j]['PartPriceLevel']['price'] <= max_price_filter) {
740				filtered_products[k] = products[j];
741				k++;
742			}
743		}
744		displayFilteredProducts(filtered_products);
745	}
746}
747
748function displayFilteredProducts(filtered_products) {
749	var minimized = ((tileCount == 2) ? true : false);
750	var size = 'md';
751	var strLen = 60;
752	if (minimized) {
753		var strLen = 15;
754		var size = 'sm';
755	}
756	var data_pro = "";
757	if (filtered_products.length > 0) {
758		for (var m = 0; m < filtered_products.length; m++) {
759			var url = filtered_products[m]['Part']['part_image_url'];
760			var image = getProductImg(url, size);
761			var height = '';
762			if (image == "../img/no-product.png" && size == 'sm' && view === 'grid') {
763				height = "height:150px !important";
764			} else {
765				if (view === 'grid') {
766					height = "width:auto !important";
767				} else {
768					height = "margin-left:5px;";
769				}
770			}
771			if (view === 'list') {
772				if ($("#filtered_products_section").val() == "div" || $('#filtered_products > div').length > 0) {
773					data_pro += '<div class="col-md-12 m10-0 product_grids">';
774				} else if ($("#filtered_products_section").val() == "li" || $('#filtered_products > li').length > 0) {
775					data_pro += '<li class="col-md-12 m10-0">';
776				}
777			} else {
778				if ($("#filtered_products_section").val() == "div" || $('#filtered_products > div').length > 0) {
779					data_pro += '<div class="col-lg-' + tileCount + ' col-md-4 col-sm-4 col-xs-6 product_grids" >';
780				} else if ($("#filtered_products_section").val() == "li" || $('#filtered_products > li').length > 0) {
781					data_pro += '<li class="col-lg-' + tileCount + ' col-md-4 col-sm-4 col-xs-6">';
782				}
783			}
784			if ($("#filtered_products_section").val() == "li" || $('#filtered_products > li').length > 0) {
785				data_pro += '<a class="wrapper" href="/products/' + filtered_products[m]['Part']['handle'] + '">';
786			}
787			if (view === 'list') {
788				if ($("#filtered_products_section").val() == "div" || $('#filtered_products > div').length > 0) {
789					data_pro += '<div data-product-id="' + filtered_products[m]['Part']['id'] + '" class="productListView chkProductID">';
790					data_pro += '<div class="media">';
791					var cls = "list_img";
792					data_pro += '<div class="media-left productThumb">';
793					data_pro += "<div style='width:231px;background-color: transpatant;position: relative;'>";
794					data_pro += '<img src="' + image + '" class="' + cls + '" alt="" style="width:231px;position:relative;top:0;right:0;bottom:0;left:0;margin:auto;" >';
795					data_pro += "</div>";
796					data_pro += '</div>';
797					data_pro += '<div class="media-body productInfo">';
798					data_pro += '<div class="productTitle"><h3><a href="/products/' + filtered_products[m]['Part']['handle'] + '">';
799					if (filtered_products[m]['Part']['website_part_title'].length > 60) {
800						data_pro += filtered_products[m]['Part']['website_part_title'].substring(0, 60) + '..';
801					} else {
802						data_pro += filtered_products[m]['Part']['website_part_title'].substring(0, 60);
803					}
804					data_pro += '</a></h3>';
805					if (filtered_products[m]['Manufacturer']["manufacture_name"] != '' && filtered_products[m]['Manufacturer']["manufacture_name"] != null) {
806						data_pro += '<h5 class="manuf">' + filtered_products[m]['Manufacturer']["manufacture_name"] + '</h5>';
807					}
808					data_pro += '<span class="price">' + filtered_products[m]['PartPriceLevel']['price_label'] + '</span></div>';
809					data_pro += '<div class="sortDesc"><p>Part# <small>' + filtered_products[m]['Part']['part_number'] + '</small></p>';
810					if (filtered_products[m]['Part']["website_part_description"] != '' && filtered_products[m]['Part']["website_part_description"] != null) {
811						data_pro += '<p>' + filtered_products[m]['Part']["website_part_description"] + '</p>';
812					}
813					data_pro += '</div>';
814					var checkInventory = true;
815					var inStock = false;
816					var stock = '<span class="text-danger">Out of Stock!</span>';
817					if (filtered_products[m]['Part']['check_inventory'] || filtered_products[m]['Part']['stock'] == 1) {
818						stock = '<span class="text-success">In Stock</span>';
819						checkInventory = false;
820						inStock = true;
821					}
822					if (filtered_products[m]['Part']['stock'] > 0) {
823						stock = '<span class="text-success">In Stock</span>';
824						inStock = true;
825					}
826					var str = '';
827					str += '<div class="pdMetas"><ul class="clear"><input type="hidden" id="numProductQty" value="1" />';
828					if (pl_value == 2) {
829						if (inStock) {
830							var st = true;
831							if (st == true) {
832								str += '<li><a href="#" onclick="var count = 1; if(!' + checkInventory + ') { count = 1;  } addToCart(\'' + filtered_products[m]['Part']['handle'] + '\', count, ' + checkInventory + ');$(this).removeAttr(\'onclick\');$(this).attr(\'href\',\'' + DSSF_PAGE_HOME + '/cart\');$(this).html(\'<i class=\'fa fa-fw fa-shopping-cart\'></i> GO TO CART\');return false;"><i class="fa fa-fw fa-shopping-cart"></i> ADD TO CART</a></li>';
833							} else {
834								str += '<li><a href="' + DSSF_PAGE_HOME + '/cart"><i class="fa fa-fw fa-shopping-cart"></i> GO TO CART</a></li>';
835							}
836						} else {
837							str += '<li><a href="javascript:void(0);"><span class="text-danger"><i class="fa fa-cart-arrow-down"></i> Out of stock</span></a></li>';
838						}
839					} else {}
840					str += '<li><a  href="javascript:;"  data-id="' + filtered_products[m]['Part']['category_id'] + '" data-type="' + category_type[filtered_products[m]['Part']['category_id']] + '" onclick="category_filter(' + filtered_products[m]['Part']['category_id'] + ',\'' + category_type[filtered_products[m]['Part']['category_id']] + '\')" ><i class="fa fa-tags"></i>' + categoriesid[filtered_products[m]['Part']['category_id']] + '</a></li>';
841					str += '<li>';
842					str += '<center><div class="rating product-rating bottom_rating" style=\'display: inline-block!important;\' >';
843					var min = 1;
844					var max = 9999;
845					var random = Math.floor(Math.random() * (+max - +min)) + +min;
846					var rid = "rateYo_" + filtered_products[m]['Part']['id'] + "_" + random;
847					var wid = "110px";
848					if (filtered_products[m]['Part']['avg_rating'].length < 2) {
849						wid = "100px";
850					} else if (filtered_products[m]['Part']['avg_rating'].length > 2) {
851						wid = "117px";
852					}
853					str += '<div id="' + rid + '"></div>';
854					str += '<div class="counter" style="float: left;font-family:serif;margin-left: ' + wid + ';margin-top: -12px;">(' + filtered_products[m]['Part']['avg_rating'] + ')</div>';
855					str += '<input class="rating_value" value="' + filtered_products[m]['Part']['avg_rating'] + '" type="hidden"/>';
856					str += '<script>'
857					str += '$(function () {';
858					str += '$("#' + rid + '").rateYo({';
859					str += 'starWidth: "12px",';
860					str += 'normalFill: "transparent",';
861					str += 'ratedFill: "#FDB634",';
862					str += 'spacing: \'2px\','
863					str += 'rating: ' + filtered_products[m]['Part']['avg_rating'] + ',';
864					str += 'readOnly: true';
865					str += '});';
866					str += '$("polygon").css("stroke","#999");';
867					str += '});</script>';
868					str += '</div></center>';
869					str += '</li>';
870					str += '</ul></div>';
871					data_pro += str;
872					data_pro += '</div>';
873					data_pro += '</div>';
874					data_pro += '</div>';
875				} else if ($("#filtered_products_section").val() == "li" || $('#filtered_products > li').length > 0) {
876					data_pro += '<div class="flex-wrap border light">';
877					data_pro += '<div class="flex"><div class="thumb md">';
878					data_pro += '<img src="' + image + '" alt="" style="' + height + '">';
879					data_pro += '</div></div><div class="flex flex-auto"><div class="col-md-9"><h4 class="pb10">';
880					if (filtered_products[m]['Part']['website_part_title'].length > 60) {
881						data_pro += '<strong>' + filtered_products[m]['Part']['website_part_title'].substring(0, 60) + '..</strong>';
882					} else {
883						data_pro += '<strong>' + filtered_products[m]['Part']['website_part_title'].substring(0, 60) + '</strong>';
884					}
885					if (filtered_products[m]['Manufacturer']['manufacture_name'] != null) {
886						data_pro += '<br><small>by ' + filtered_products[m]['Manufacturer']['manufacture_name'] + '</small>';
887					}
888					data_pro += '</h4>';
889					data_pro += '<p>Part# <small>' + filtered_products[m]['Part']['part_number'] + '</small></p>';
890					if (filtered_products[m]['Part']['model'] != "") {
891						data_pro += '<p>Model <small>' + filtered_products[m]["Part"]["model"] + '</small></p>';
892					}
893					data_pro += '</div><div class="col-md-3">';
894					data_pro += '<h4><strong>' + filtered_products[m]['PartPriceLevel']['price_label'] + '</strong><br><small>Free Shipping**</small></h4>';
895					data_pro += '</div>';
896					data_pro += '</div>';
897					data_pro += '</div>';
898				}
899			} else {
900				if ($("#filtered_products_section").val() == "div" || $('#filtered_products > div').length > 0) {
901					data_pro += '<div data-product-id="' + filtered_products[m]['Part']['id'] + '" class="productBorder chkProductID">';
902					var cls = "home_img";
903					data_pro += "<div style='width:100%;height:190px;background-color: transpatant;position: relative;'>";
904					data_pro += '<img src="' + image + '" alt="" class="img-responsive ' + cls + '" style="max-width:100%;max-height: 190px;position:absolute;top:0;right:0;bottom:0;left:0;margin:auto;">';
905					data_pro += "</div>";
906					data_pro += '<div class="productBorderHover verticalMiddle">';
907					data_pro += '<a href="/products/' + filtered_products[m]['Part']['handle'] + '">';
908					data_pro += '<div class="verticalInner">';
909					data_pro += '<h4>';
910					if (filtered_products[m]['Part']['website_part_title'].length > 60) {
911						data_pro += filtered_products[m]['Part']['website_part_title'].substring(0, 60) + '..';
912					} else {
913						data_pro += filtered_products[m]['Part']['website_part_title'].substring(0, 60);
914					}
915					data_pro += '</h4>';
916					data_pro += '<!--p class="rating">';
917					data_pro += '</p-->';
918					data_pro += '<div class="price">';
919					data_pro += '<span class="amount">' + filtered_products[m]['PartPriceLevel']['price_label'] + '</span>';
920					data_pro += '</div>';
921					data_pro += '</a>';
922					data_pro += '</div>';
923					data_pro += '</div>';
924					data_pro += '<div class="frontinfo">';
925					data_pro += '<h4 class="mainshopthumb">';
926					data_pro += '<a href="/products/' + filtered_products[m]['Part']['handle'] + '">';
927					var limt = 60;
928					if (tileCount == 2) {
929						limt = 30;
930					} else if (tileCount == '5ths') {
931						limt = 40;
932					} else if (tileCount == 3) {
933						limt = 50;
934					}
935					if (filtered_products[m]['Part']['website_part_title'].length > limt) {
936						data_pro += filtered_products[m]['Part']['website_part_title'].substring(0, limt) + '..';
937					} else {
938						data_pro += filtered_products[m]['Part']['website_part_title'].substring(0, limt);
939					}
940					data_pro += '</a>';
941					data_pro += '</h4>';
942					if (filtered_products[m]['Manufacturer']["manufacture_name"] != '' && filtered_products[m]['Manufacturer']["manufacture_name"] != null) {
943						data_pro += '<h5 class="manuf">' + filtered_products[m]['Manufacturer']["manufacture_name"] + '</h5>';
944					}
945					data_pro += '<center><div class="rating product-rating bottom_rating" style=\'display: inline-block!important;\' >';
946					var min = 1;
947					var max = 9999;
948					var random = Math.floor(Math.random() * (+max - +min)) + +min;
949					var rid = "rateYo_" + filtered_products[m]['Part']['id'] + "_" + random;
950					var wid = "110px";
951					if (filtered_products[m]['Part']['avg_rating'].length < 2) {
952						wid = "100px";
953					} else if (filtered_products[m]['Part']['avg_rating'].length > 2) {
954						wid = "117px";
955					}
956					data_pro += '<div id="' + rid + '"></div>';
957					data_pro += '<div class="counter" style="float: left;font-family:serif;margin-left: ' + wid + ';margin-top: -10px;">(' + filtered_products[m]['Part']['avg_rating'] + ')</div>';
958					data_pro += '<input class="rating_value" value="' + filtered_products[m]['Part']['avg_rating'] + '" type="hidden"/>';
959					data_pro += '<script>'
960					data_pro += '$(function () {';
961					data_pro += '$("#' + rid + '").rateYo({';
962					data_pro += 'starWidth: "12px",';
963					data_pro += 'normalFill: "transparent",';
964					data_pro += 'ratedFill: "#FDB634",';
965					data_pro += 'spacing: \'2px\','
966					data_pro += 'rating: ' + filtered_products[m]['Part']['avg_rating'] + ',';
967					data_pro += 'readOnly: true';
968					data_pro += '});';
969					data_pro += '$("polygon").css("stroke","#999");';
970					data_pro += '});</script>';
971					data_pro += '</div></center>';
972					data_pro += '<div class="amount">' + filtered_products[m]['PartPriceLevel']['price_label'] + '</div>';
973					data_pro += '</div>';
974					data_pro += '<ul class="productMetas">';
975					data_pro += '<li><a href="/products/product_quick/' + filtered_products[m]['Part']['handle'] + '" class="ajax-view"><span><i class="fa fa-eye"></i></span> Quick View</a></li>';
976					data_pro += '<li><a href="#"><span><i class="fa fa-shopping-cart"></i></span> Add to Cart</a></li>';
977					data_pro += '<li><a href="#"><span><i class="fa fa-heart-o"></i></span> Wishlist</a></li>';
978					data_pro += '</ul>';
979					data_pro += '<span class="linetop"></span>';
980					data_pro += '<span class="lineright"></span>';
981					data_pro += '<span class="linebottom"></span>';
982					data_pro += '<span class="lineleft"></span>';
983					data_pro += '</div>';
984				} else if ($("#filtered_products_section").val() == "li" || $('#filtered_products > li').length > 0) {
985					data_pro += '<div class="thumbnail con-product inner_div"><div class="img-wrapper thumb">';
986					data_pro += '<img src="' + image + '" alt="" style="' + height + '">';
987					data_pro += '</div>';
988					data_pro += '<div class="text-caption">';
989					data_pro += '<p class="webpt">';
990					var limt = strLen;
991					if (filtered_products[m]['Part']['website_part_title'].length > limt) {
992						filtered_products[m]['Part']['website_part_title'] = filtered_products[m]['Part']['website_part_title'].substring(0, limt) + "...";
993					}
994					data_pro += filtered_products[m]['Part']['website_part_title'];
995					data_pro += '</p>';
996					data_pro += '<p class="text-danger">' + filtered_products[m]['PartPriceLevel']['price_label'] + '</p>';
997					data_pro += '</div></div>';
998				}
999			}
1000			if ($("#filtered_products_section").val() == "div" || $('#filtered_products > div').length > 0) {
1001				data_pro += '</div>';
1002			} else if ($("#filtered_products_section").val() == "li" || $('#filtered_products > li').length > 0) {
1003				data_pro += '</li>';
1004			}
1005		}
1006	} else {
1007		data_pro += '<br><br><br><h3 class="text-center">OOPS! No Products Found!</h3><br><br><br>';
1008	}
1009	$("#filtered_products").html("");
1010	$("#filtered_products").html(data_pro);
1011	$(".webpt").each(function (index) {
1012		var p_tag_height = $(this).height();
1013		var limt = 20;
1014		if (p_tag_height > limt) {
1015			$(this).html($(this).html().substr(0, 25) + "...");
1016		}
1017	});
1018}
1019
1020function download_receipt() {
1021	$("#download_receipt").html("<img src='"+BASE_PATH+"/img/loading1.gif'>"+LOADING_TEXT+"...").attr("onclick","javascript:void(0);");
1022	$.ajax({
1023		url: BASE_PATH + '/checkout/download_receipt/' + $("#generated_id").val(),
1024		type: "post",
1025		data: {
1026			generated_id: $("#generated_id").val()
1027		},
1028		success: function (data) {
1029			$("#download_receipt").html(DOWNLOAD_RECEIPT_TEXT).attr("onclick","download_receipt();");
1030			window.location.href = BASE_PATH + "/checkout/save_pdf/" + data;
1031		}
1032	});
1033}
1034
1035function OpenForgotPass() {
1036	$("#forgot_password").modal();
1037}
1038$(document).ready(function () {
1039	var wishlist_part = (getCookie('WISHLISTPART'))?JSON.parse(getCookie('WISHLISTPART')):null;
1040	setTimeout(function () {
1041		var con_obj = $("#contact_user_id");
1042		if (wishlist_part != null && con_obj.length > 0 && con_obj.val() != '') {
1043			msg = ADDED_TO_WISHLIST_TEXT;
1044			icon = 'fa-heart';
1045			setCookie('WISHLISTPART', '', 0);
1046			$.notify({
1047				title: "",
1048				icon: 'fa ' + icon,
1049				message: msg
1050			}, {
1051				timer: 1000,
1052				type: 'success',
1053				animate: {
1054					enter: 'animated lightSpeedIn',
1055					exit: 'animated lightSpeedOut'
1056				}
1057			});
1058
1059		}
1060	}, 2500);
1061});
1062$(document).on('click', '.add_wishlists', function () {
1063	var part_id = $(this).attr("data-part");
1064	setCookie('WISHLISTPART', part_id, 0);
1065	$("#signin_signup").show();
1066	$(".guest_acc").hide();
1067});
1068$(document).on('click', '.add_my_wishlists', function () {
1069	var part_id = $(this).attr("data-part");
1070	var obj = $(this);
1071	var list_view = $("#part_" + part_id).length;
1072	if (list_view) {
1073		$("#part_" + part_id).remove();
1074		if ($(".product_grids").length == 0) {
1075			$("#filtered_products1").html("<br><br><br><h3 class='text-center'>"+OOPS_NO_PRODUCTS_FOUND_TEXT+"</h3><br><br><br>");
1076		}
1077	}
1078	var search_val = parseInt(obj.html().search("fa-heart-o"));
1079	var msg = REMOVED_FROM_WISHLIST_TEXT;
1080	var icon = 'fa-heart-o';
1081	if (search_val >= 0) {
1082		msg = ADDED_TO_WISHLIST_TEXT;
1083		icon = 'fa-heart';
1084	}
1085	if (!list_view) {
1086		obj.html("<span><i class='fa fa-spinner fa-spin'></i></span> "+LOADING_TEXT+"....");
1087	}
1088	$.ajax({
1089		url: BASE_PATH + '/products/add_wishlist/',
1090		type: "post",
1091		data: {
1092			'id': part_id,
1093			'msg': msg
1094		},
1095		success: function (data) {
1096			if (!list_view) {
1097				if (obj.attr('data-btn')) {
1098					data = "<button class='btn btn-warning btn-add-cart '>" + data + "</button>";
1099				}
1100				obj.html(data);
1101			}
1102			
1103			$.notify({
1104				title: "",
1105				icon: 'fa ' + icon,
1106				message: msg
1107			}, {
1108				timer: 1000,
1109				type: 'success',
1110				animate: {
1111					enter: 'animated lightSpeedIn',
1112					exit: 'animated lightSpeedOut'
1113				}
1114			});
1115			
1116		}
1117	});
1118	if ($(this).attr("data-load") == 1) {
1119		window.location.reload();
1120	}
1121});
1122
1123function email_validation(arg) {
1124	var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
1125	if (!emailReg.test(arg)) {
1126		return false;
1127	} else {
1128		return true;
1129	}
1130}
1131$(document).on('click', '.newsletter_submit', function (e) {
1132	var tim = $(this).attr('data_news');
1133	var obj = $("#" + this.id);
1134	obj.val(LOADING_TEXT+"...").attr("disabled", true);
1135	var name = $("#newsletter_name_" + tim).val();
1136	var email = $("#newsletter_email_" + tim).val();
1137	var sh = 0;
1138	if (name == '' && $("#newsletter_name_" + tim).length>0) {
1139		
1140		$.notify({
1141			title: "<strong>"+NAME_TEXT+"</strong> ",
1142			icon: 'glyphicon glyphicon-user',
1143			message: MUST_NOT_BE_EMPTY_TEXT
1144		}, {
1145			offset: {
1146				x: 50,
1147				y: 200
1148			},
1149			timer: 1000,
1150			type: 'danger',
1151			animate: {
1152				enter: 'animated lightSpeedIn',
1153				exit: 'animated lightSpeedOut'
1154			}
1155		});
1156		
1157		$("#newsletter_name_" + tim).focus();
1158		obj.val("Submit").attr("disabled", false);
1159		sh++;
1160	}
1161	if (email == '' || !email_validation(email)) {
1162		
1163		$.notify({
1164			title: "<strong>"+EMAIL_TEXT+"</strong> ",
1165			icon: 'glyphicon glyphicon-envelope',
1166			message: (email != '') ? INVALID_TEXT : MUST_NOT_BE_EMPTY_TEXT
1167		}, {
1168			offset: {
1169				x: 50,
1170				y: 200
1171			},
1172			timer: 1000,
1173			type: 'danger',
1174			animate: {
1175				enter: 'animated lightSpeedIn',
1176				exit: 'animated lightSpeedOut'
1177			}
1178		});
1179		
1180		$("#newsletter_email_" + tim).focus();
1181		obj.val(SUBMIT_TEXT).attr("disabled", false);
1182		sh++;
1183	}
1184	if (sh > 0) {
1185		return false;
1186	}
1187	$.ajax({
1188		type: "POST",
1189		url: BASE_PATH + "/ajax/signup_newsletter",
1190		cache: false,
1191		data: {
1192			'name': name,
1193			'email': email
1194		},
1195		success: function (data) {
1196			var json = $.parseJSON(data);
1197			if (json.status == true) {
1198				$("#newsletter_name_" + tim).val('');
1199				$("#newsletter_email_" + tim).val('');
1200				
1201				$.notify({
1202					title: "<strong>"+NEWSLETTER_TEXT+"</strong> ",
1203					icon: 'glyphicon glyphicon-envelope',
1204					message: THANKS_FOR_SIGNING_UP_TEXT
1205				}, {
1206					offset: {
1207						x: 50,
1208						y: 200
1209					},
1210					timer: 1000,
1211					type: 'success',
1212					animate: {
1213						enter: 'animated lightSpeedIn',
1214						exit: 'animated lightSpeedOut'
1215					}
1216				});
1217				
1218			} else {
1219				
1220				$.notify({
1221					title: "<strong>"+ERROR_TEXT+":</strong> ",
1222					icon: 'glyphicon glyphicon-envelope',
1223					message: json.response
1224				}, {
1225					offset: {
1226						x: 50,
1227						y: 200
1228					},
1229					timer: 1000,
1230					type: 'danger',
1231					animate: {
1232						enter: 'animated lightSpeedIn',
1233						exit: 'animated lightSpeedOut'
1234					}
1235				});
1236				
1237			}
1238			obj.val("Submit").attr("disabled", false);
1239		}
1240	});
1241});
1242function setCookie(name, value, days) {
1243	// var expires = "";
1244	// if (days) {
1245	// 	var date = new Date();
1246	// 	date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
1247	// 	expires = "; expires=" + date.toUTCString();
1248	// }
1249	//document.cookie = name + "=" + (value || "") + expires + "; path="+DOMAIN_NAME+";secure = "+true;
1250	$.ajax({
1251        url: BASE_PATH + '/site/cart_cookie',
1252        type: "post",
1253        data: {
1254            'name': name,
1255            'arg': value,
1256            'cookie_act' : ''
1257        },
1258        success: function (data) {
1259        }
1260    });
1261}
1262
1263function getCookie(name) {
1264	return wishlist_cookie;
1265	// var nameEQ = name + "=";
1266	// var ca = document.cookie.split(';');
1267	// for (var i = 0; i < ca.length; i++) {
1268	// 	var c = ca[i];
1269	// 	while (c.charAt(0) == ' ') c = c.substring(1, c.length);
1270	// 	if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length);
1271	// }
1272	return false;
1273}
1274
1275function eraseCookie(name) {
1276	document.cookie = name + '=;expires=Thu, 01 Jan 1970 00:00:01 GMT;';
1277}
1278function gotomenu(arg, url, obj) {
1279	var name = "CURRENT_MENU";
1280	setCookie(name, arg, 0);
1281	if ($(obj).attr('target') == '_blank') {
1282		window.open(url, $(obj).attr('target'));
1283	} else {
1284		window.location.href = url;
1285	}
1286}
1287
1288function gotoCart(arg) {
1289	$.confirm({
1290		title: '',
1291		type: 'orange',
1292		typeAnimated: true,
1293		content: THIS_PRODUCT_IS_ALREADY_IN_THE_CART_DO_YOU_WANT_TO_PROCEED_TO_CART,
1294		buttons: {
1295			cancel: {
1296				text: NO_TEXT,
1297				btnClass: 'btn-default',
1298				keys: ['esc', 'n'],
1299				action: function () {
1300				}
1301			},
1302			confirm: {
1303				text: YES_TEXT,
1304				btnClass: 'btn-warning',
1305				keys: ['enter', 'y'],
1306				action: function () {
1307					window.location.href = arg;
1308				},
1309			}
1310		}
1311	});
1312}
1313setTimeout(function () {
1314	if ($(".pix_sc_slider1").length > 0) {
1315		$('.pix_sc_slider1').flexslider({
1316			animation: "slide",
1317			pauseOnHover: true,
1318			directionNav: false,
1319			smoothHeight: true,
1320			slideshow: true,
1321			easing: "easeOutQuad",
1322			useCSS: false,
1323			touch: true,
1324			slideshow: false,
1325			controlNav: true,
1326			slideshowSpeed: 7000,
1327			animationSpeed: 600,
1328			initDelay: 0,
1329			start: function (slider) { 
1330				var slide_count = slider.count - 1;
1331				$(slider).find('img.lazy:eq(0)').each(function () {
1332					var src = $(this).attr('data-src');
1333					$(this).attr('src', src).removeAttr('data-src');
1334				});
1335			},
1336			before: function (slider) {
1337				var slides = slider.slides,
1338					index = slider.animatingTo,
1339					$slide = $(slides[index]),
1340					$img = $slide.find('img[data-src]'),
1341					current = index,
1342					nxt_slide = current + 1,
1343					prev_slide = current - 1;
1344				$slide.parent().find('img.lazy:eq(' + current + '), img.lazy:eq(' + prev_slide + '), img.lazy:eq(' + nxt_slide + ')').each(function () {
1345					var src = $(this).attr('data-src');
1346					$(this).attr('src', src).removeAttr('data-src');
1347				});
1348			}
1349		});
1350	}
1351}, 1000);
1352
1353function page_slider() {
1354	$('.pix_sc_slider1').flexslider({
1355		animation: "slide",
1356		pauseOnHover: true,
1357		directionNav: false,
1358		smoothHeight: true,
1359		slideshow: true,
1360		easing: "easeOutQuad",
1361		useCSS: false,
1362		slideshowSpeed: 3000,
1363		start: function (slider) { 
1364			var slide_count = slider.count - 1;
1365			$(slider).find('img.lazy:eq(0)').each(function () {
1366				var src = $(this).attr('data-src');
1367				$(this).attr('src', src).removeAttr('data-src');
1368			});
1369		},
1370		before: function (slider) {
1371			var slides = slider.slides,
1372				index = slider.animatingTo,
1373				$slide = $(slides[index]),
1374				$img = $slide.find('img[data-src]'),
1375				current = index,
1376				nxt_slide = current + 1,
1377				prev_slide = current - 1;
1378			$slide.parent().find('img.lazy:eq(' + current + '), img.lazy:eq(' + prev_slide + '), img.lazy:eq(' + nxt_slide + ')').each(function () {
1379				var src = $(this).attr('data-src');
1380				$(this).attr('src', src).removeAttr('data-src');
1381			});
1382		}
1383	});
1384}
1385var asidebar = false;
1386$(document).ready(function() {
1387    setTimeout(function() {
1388        slider();
1389    }, 1000);
1390});
1391
1392function slider(){
1393	if($('.lazy-slider').length){
1394		$('.lazy-slider').slick({		
1395			lazyLoad: 'ondemand',
1396			infinite: true,
1397			slidesToShow: 1,
1398			slidesToScroll: 1,
1399			arrows:true,
1400			dots: true,
1401			autoplay: true,
1402			autoplaySpeed: 3000,
1403			nextArrow: '<i class="fa fa-arrow-right"></i>',
1404			prevArrow: '<i class="fa fa-arrow-left"></i>',
1405		});
1406	}
1407}
1408$(document).ready(function () {
1409	$('content').each(function (i) {
1410		var ObjParent = $(this).parent();
1411		var content_id = $(this).attr('data-id');
1412		$.ajax({
1413			type: "POST",
1414			url: BASE_PATH + "/ajax/getcontent",
1415			cache: false,
1416			data: {
1417				'content_id': content_id
1418			},
1419			success: function (res) {
1420				ObjParent.html(res);
1421			}
1422		});
1423	});
1424	function call_wid(){
1425		$('fb_timeline').each(function (i) {
1426			var ObjParent = $(this).parent();
1427			ObjParent.html("<center><img src='"+BASE_PATH+"/img/loading1.gif'>Loading feeds...</center>");
1428			var title = $(this).attr("data-title");
1429			var tl_url = $(this).attr("data-url");
1430			if(tl_url!='')
1431			{
1432				var html = '';
1433				html += "<div id='fb-root'></div>";
1434				html += "<script async defer crossorigin='anonymous' src='https://connect.facebook.net/en_GB/sdk.js#xfbml=1&version=v13.0&appId=2171287246459575&autoLogAppEvents=1' nonce='5XBaPzl1'></script>";
1435				html += "<div class='fb-page' data-href='"+tl_url+"' data-tabs='timeline' data-width='' data-height='' data-small-header='false' data-adapt-container-width='true' data-hide-cover='false' data-show-facepile='true'>";
1436				if(title!='')
1437				{
1438					html += "<blockquote cite='"+tl_url+"' class='fb-xfbml-parse-ignore'><a href='"+tl_url+"'>"+title+"</a></blockquote>";
1439				}
1440				html += "</div>";
1441				ObjParent.html(html);
1442			}else{
1443				ObjParent.html('');
1444			}
1445		});
1446		$('twitter_timeline').each(function (i) {
1447			var ObjParent = $(this).parent();
1448			ObjParent.html("<center><img src='"+BASE_PATH+"/img/loading1.gif'>Loading feeds...</center>");
1449			var title = $(this).attr("data-title");
1450			var tl_url = $(this).attr("data-url");
1451			if(tl_url!='')
1452			{
1453				var html = '';
1454				html += "<a class='twitter-timeline' href='"+tl_url+"' data-width='360' data-height='405' data-dnt='true'>"+title+"</a>";
1455				html += "<script async src='https://platform.twitter.com/widgets.js' charset='utf-8'></script>";
1456				ObjParent.html(html);
1457			}
1458		});
1459		$('upcoming').each(function (i) {
1460			var ObjParent = $(this).parent();
1461			ObjParent.html("<center><img src='"+BASE_PATH+"/img/loading1.gif'>Loading upcoming...</center>");
1462			$.ajax({
1463				type: "POST",
1464				url: BASE_PATH + "/ajax/upcoming_events",
1465				data: {
1466					'title': $(this).attr("data-title")
1467				},
1468				cache: false,
1469				success: function (res) {
1470					ObjParent.html(res);
1471				}
1472			});
1473		});
1474		$('latest_blogs').each(function (i) {
1475			//alert("latest_blog");
1476			var ObjParent = $(this).parent();
1477			ObjParent.html("<center><img src='"+BASE_PATH+"/img/loading1.gif'>Loading latest blog...</center>");
1478			$.ajax({
1479				type: "POST",
1480				url: BASE_PATH + "/ajax/latest_blogs",
1481				data: {
1482					'title': $(this).attr("data-title"),
1483					'blog_id': ($(this).attr("data-id"))?$(this).attr("data-id"):''
1484				},
1485				cache: false,
1486				success: function (res) {
1487					//console.log(res);
1488					ObjParent.html(res);
1489				}
1490			});
1491		});
1492		if($("#create_a_widget_to_display_all_the_dates_for_a_specific_course_group").length>0 && $("#create_a_widget_to_display_all_the_dates_for_a_specific_course_group").val()==1){
1493			loadGroupCalendar('course');
1494			loadGroupCalendar('travel');
1495			loadGroupCalendar('charter');
1496		}
1497		$('upcoming_events').each(function (i) {
1498			var ObjParent = $(this).parent();
1499			ObjParent.html("<center><img src='"+BASE_PATH+"/img/loading1.gif'>Loading upcoming events...</center>");
1500			$.ajax({
1501				type: "POST",
1502				url: BASE_PATH + "/ajax/upcoming_events/misc",
1503				data: {
1504					'title': $(this).attr("data-title")
1505				},
1506				cache: false,
1507				success: function (res) {
1508					ObjParent.html(res);
1509				}
1510			});
1511		});
1512		$('upcoming_courses').each(function (i) {
1513			var ObjParent = $(this).parent();
1514			ObjParent.html("<center><img src='"+BASE_PATH+"/img/loading1.gif'>Loading upcoming courses...</center>");
1515			$.ajax({
1516				type: "POST",
1517				url: BASE_PATH + "/ajax/upcoming_events/course",
1518				data: {
1519					'title': $(this).attr("data-title")
1520				},
1521				cache: false,
1522				success: function (res) {
1523					ObjParent.html(res);
1524				}
1525			});
1526		});
1527		$('upcoming_trips').each(function (i) {
1528			var ObjParent = $(this).parent();
1529			ObjParent.html("<center><img src='"+BASE_PATH+"/img/loading1.gif'>Loading upcoming trips...</center>");
1530			$.ajax({
1531				type: "POST",
1532				url: BASE_PATH + "/ajax/upcoming_events/travel&charter",
1533				data: {
1534					'title': $(this).attr("data-title")
1535				},
1536				cache: false,
1537				success: function (res) {
1538					ObjParent.html(res);
1539				}
1540			});
1541		});
1542		$('gallery').each(function (i) {
1543			var ObjParent = $(this).parent();
1544			ObjParent.html("<center><img src='"+BASE_PATH+"/img/loading1.gif'>Loading gallery...</center>");
1545			var album_id = $(this).attr('data-id');
1546			var album_type = $(this).attr('data-type');
1547			$.ajax({
1548				type: "POST",
1549				url: BASE_PATH + "/ajax/getalbum",
1550				cache: false,
1551				data: {
1552					'album_id': album_id
1553				},
1554				success: function (res) {
1555					var response = $.parseJSON(res);
1556					if (response.status == true) {
1557						var html = '';
1558						if (album_type == 1) {
1559							html += '<div class="lazy-slider">';
1560						} else if (album_type == 2) {
1561							html += '<div class="row gallery-filterable fullwidth">';
1562						}
1563						$.each(response.data, function (i, item) {
1564							var img_count = response.data.length;
1565							if (album_type == 1) {
1566								if( img_count == 1 ){
1567									html += '<div class="slick-item"><img class="lazy-image single-image" src="' + item.link + '"  alt="' + item.link + '" title="' + item.link + '" /></div>';
1568								}
1569								else{
1570								html += '<div class="slick-item"><img class="lazy-image" data-lazy="' + item.link + '" /></div>';
1571								}
1572							} else if (album_type == 2) {
1573								html += '<div class="col-xs-12 col-sm-6 col-md-4 col-lg-4">';
1574								html += '<div class="portfolio-item">';
1575								html += '<div class="portfolio-hover">';
1576								html += '<a href="' + item.link + '" data-lightbox="product">';
1577								html += '<img src="' + item.link + '" alt="' + item.link + '" title="' + item.link + '" class="img-responsive">';
1578								html += '</a>';
1579								html += '</div>';
1580								html += '<div class="portfolio_details"></div>';
1581								html += '</div>';
1582								html += '</div>';
1583							}
1584						});
1585						if (album_type == 1) {
1586							html += '</div>';
1587						} else if (album_type == 2) {
1588							html += '</div>';
1589						}
1590						ObjParent.html(html);
1591						if (album_type == 1) {
1592							page_slider();
1593						} else if (album_type == 2) {}
1594					} else {
1595					}
1596					
1597				}
1598			});
1599		});
1600		$('customform').each(function (i) {
1601			var ObjParent = $(this).parent();
1602			ObjParent.html("<center><img src='"+BASE_PATH+"/img/loading1.gif' alt='"+LOADING_TEXT+"...' title='"+LOADING_TEXT+"...'>"+LOADING_FORM_TEXT+"...</center>");
1603			var form_id = $.trim($(this).attr('data-id'));
1604			//alert(form_id)
1605			$.ajax({
1606				type: "POST",
1607				url: BASE_PATH + "/ajax/render_form",
1608				cache: false,
1609				data: {
1610					'form_id': form_id
1611				},
1612				success: function (html) {
1613					ObjParent.html(html);
1614					setTimeout(function(){
1615						$.ajax({
1616							url: BASE_PATH + "/ajax/simple_captcha", 
1617							success: function(result){
1618								var form_uuid = $("#custom_form_id_"+form_id).val();
1619								//alert("------------------"+form_uuid);
1620						    	$("#ss_captcha_"+form_uuid).html(result).hide();
1621						    		$("#ss_captcha_"+form_uuid).find("#UserCaptchaCustomForm").attr("id","UserCaptchaCustomForm_"+form_uuid);
1622						    	if( !$('#custom_data_form_'+form_uuid+' #g-recaptcha-response').length )
1623						    	{
1624			    					$('#custom_data_form_'+form_uuid+' #action_'+form_uuid).after("<input type='hidden' id='g-recaptcha-response_"+form_uuid+"' name='g-recaptcha-response' value=''  >");
1625						    	}
1626			    				reset_captcha(form_uuid);
1627						 	}
1628						});
1629					},1000);
1630			    	
1631				}
1632			});
1633		});
1634		$('popular_courses').each(function (i) {
1635			var ObjParent = $(this).parent();
1636			ObjParent.html("<center><img src='"+BASE_PATH+"/img/loading1.gif'>"+LOADING_POPULAR_COURSES_TEXT+"....</center>");
1637			$.ajax({
1638				type: "POST",
1639				url: BASE_PATH + "/ajax/popular_courses",
1640				data: {
1641					'title': $(this).attr("data-title")
1642				},
1643				cache: false,
1644				success: function (res) {
1645					if($(ObjParent).parent().attr("class")=="sidebar")
1646					{
1647						asidebar = true;
1648					}
1649					ObjParent.html(res);
1650					call_Carousel();
1651				}
1652			});
1653		});
1654		$('popular_trips').each(function (i) {
1655			var ObjParent = $(this).parent();
1656			ObjParent.html("<center><img src='"+BASE_PATH+"/img/loading1.gif'>"+LOADING_POPULAR_TRIPS_TEXT+"....</center>");
1657			$.ajax({
1658				type: "POST",
1659				url: BASE_PATH + "/ajax/popular_trips",
1660				data: {
1661					'title': $(this).attr("data-title")
1662				},
1663				cache: false,
1664				success: function (res) {
1665					if($(ObjParent).parent().attr("class")=="sidebar")
1666					{
1667						asidebar = true;
1668					}
1669					ObjParent.html(res);
1670					call_Carousel();
1671				}
1672			});
1673		});
1674	}
1675	$('widget').each(function (i) {
1676		var ObjParent = $(this).parent();
1677		var sw_id = $(this).attr('data-id');
1678		$.ajax({
1679			type: "POST",
1680			url: BASE_PATH + "/ajax/getwidget",
1681			cache: false,
1682			data: {
1683				'sw_id': sw_id
1684			},
1685			success: function (res) {
1686				ObjParent.html(res);
1687				autocomplete_search();
1688				call_wid();
1689						AftercallSlickSlider();
1690
1691				
1692			}
1693		});
1694	});
1695	call_wid();
1696});
1697
1698function loadGroupCalendar(type) {
1699	$(type+"_group_calendar").each(function (i) {
1700	    var $this = $(this);
1701	    var $parent = $this.parent();
1702	    var parent_id = $this.parent().attr("id");
1703	    if(type=="course"){
1704	    	var cal_msg_load = LOADING_COURSE_GROUP_CALENDAR;
1705	    }else if(type=="travel"){
1706	    	var cal_msg_load = LOADING_TRAVEL_GROUP_CALENDAR;
1707	    }else if(type=="charter"){
1708	    	var cal_msg_load = LOADING_CHARTER_GROUP_CALENDAR;
1709	    }
1710
1711		var payload_data = {
1712			'title': $this.attr("data-title"),
1713			'parent_id' : parent_id,
1714			'group_id': $this.attr("data-id") || '',
1715			'offset': $this.attr("data-offset") || 5
1716		}
1717
1718	    $("#"+parent_id).html("<center><img src='" + BASE_PATH + "/img/loading1.gif'>"+cal_msg_load+"...</center>");
1719	    $.ajax({
1720	      	type: "POST",
1721	      	url: BASE_PATH+'/ajax/'+type+'_group_calendar',
1722	      	data: payload_data,
1723	      	cache: false,
1724	      	success: function (res) {
1725	        	$("#"+parent_id).html(res);
1726	      	}
1727	    });
1728	});
1729}
1730
1731$(document).ready(function () {
1732	if (flash_success_msg)
1733	{
1734		setTimeout(function(){
1735			flash_success_msg = flash_success_msg.split("#@#");
1736				flash_success_msg.forEach(function(msg) {
1737					$.notify({
1738						title: "",
1739						message: msg
1740					}, {
1741						offset: {
1742							x: 50,
1743							y: 200
1744						},
1745						timer: 2000,
1746						type: 'success',
1747						animate: {
1748							enter: 'animated lightSpeedIn',
1749							exit: 'animated lightSpeedOut'
1750						}
1751					});
1752				});				
1753		},1500);
1754	}
1755	if($("#avalara_tax_api").length>0 && $("#avalara_tax_api").val()==1)  //FeatureTag
1756	{
1757		if (flash_error_msg)
1758		{
1759			setTimeout(function(){
1760				flash_error_msg = flash_error_msg.split("#@#");
1761					// Loop through each message in the flash_error_msg array
1762					flash_error_msg.forEach(function(msg) {
1763					    $.notify({
1764					        title: "",
1765					        icon: 'glyphicon glyphicon-user',
1766					        message: msg
1767					    }, {
1768					        offset: {
1769					            x: 50,
1770					            y: 200
1771					        },
1772					        timer: 1000,
1773					        type: 'danger',
1774					        animate: {
1775					            enter: 'animated lightSpeedIn',
1776					            exit: 'animated lightSpeedOut'
1777					        }
1778					    });
1779					});
1780				
1781			},500);
1782		}
1783	}
1784		if (flash_error_msg)
1785		{
1786			setTimeout(function(){
1787				flash_error_msg = flash_error_msg.split("#@#");
1788					// Loop through each message in the flash_error_msg array
1789					flash_error_msg.forEach(function(msg) {
1790					    $.notify({
1791					        title: "",
1792					        icon: 'glyphicon glyphicon-user',
1793					        message: msg
1794					    }, {
1795					        offset: {
1796					            x: 50,
1797					            y: 200
1798					        },
1799					        timer: 1000,
1800					        type: 'danger',
1801					        animate: {
1802					            enter: 'animated lightSpeedIn',
1803					            exit: 'animated lightSpeedOut'
1804					        }
1805					    });
1806					});
1807				
1808			},500);
1809		}
1810	
1811	var sm = 0;
1812	$(".sitemessage").each(function () {
1813		sm++;
1814		if (sm > 1) {
1815			this.remove();
1816		}
1817	});
1818	if (CONTROLL == "products" && (ACTION == "index" || ACTION == "collection" || ACTION == "mywishlist")) {
1819	}
1820});
1821function price_filter() {
1822	var price = {};
1823	if ($("#slider-range").length == true) {
1824		price.min = $("#slider-range").slider("values", 0);
1825		price.max = $("#slider-range").slider("values", 1);
1826	} else {
1827		price.min = $(".priceRange").slider("values", 0);
1828		price.max = $(".priceRange").slider("values", 1);
1829	}
1830	filter_products.price = price;
1831	load_products();
1832}
1833
1834function reset_filter() {
1835	filter_products.category = '';
1836	filter_products.manufacture = '';
1837	filter_products.price = '';
1838	if (industry_type == "Orchidshop") {
1839		filter_products.firearmType = '';
1840		filter_products.firearmCaliber = '';
1841	}
1842	load_products();
1843}
1844
1845function category_filter(id, type) {
1846	var category = {};
1847	category.id = id;
1848	category.type = type;
1849	filter_products.category = category;
1850	load_products();
1851}
1852
1853function changeSortType(value, url) {
1854	sort_type = value;
1855	load_products();
1856}
1857
1858function changeView(view, url, e) {
1859	url = BASE_PATH + url;
1860	location.href = url + util.setView(view);
1861}
1862$(document).on('click', '#show_more', function () {
1863	offset = parseInt(offset) + parseInt(products_per_row);
1864	load_products();
1865});
1866$(document).on('click', '#part_search_button', function () {
1867	load_products();
1868});
1869$(document).ready(function () {
1870	$('#part_search_form').on('submit', function (e) {
1871		e.preventDefault();
1872		load_products();
1873	});
1874});
1875$(document).on('change', '#selectFirearmType', function () {
1876	if($(this).val()!=''){
1877		filter_products.firearmType = $(this).val();
1878		load_products();	
1879	}
1880});
1881$(document).on('change', '#selectFirearmCaliber', function () {
1882	if($(this).val()!=''){
1883		filter_products.firearmCaliber = $(this).val();
1884		load_products();	
1885	}
1886});
1887function load_products() {
1888	var dataobj = {};
1889	dataobj.limit = item_per_page;
1890	
1891	var search_part_val = '';
1892	if ($("#search_part").length) {
1893		search_part_val = $("#search_part").val();
1894	}
1895	
1896	if (search_part_val != '') {
1897		dataobj.search_part = search_part_val;
1898	}
1899	if (sort_type != '') {
1900		dataobj.sort_type = sort_type;
1901	} else {
1902		dataobj.sort_type = $("#selectSortType").children("option:selected").val();
1903	}
1904	if (filter_products.category && filter_products.category != '') {
1905		dataobj.category = filter_products.category.id;
1906	}
1907	if (filter_products.manufacture && filter_products.manufacture!='') {
1908		dataobj.manufacture = filter_products.manufacture;
1909	}
1910	if (filter_products.price && filter_products.price != '') {
1911		if(filter_products.price.min)
1912			dataobj.min = filter_products.price.min;
1913		else 
1914			dataobj.min = '0';
1915		if(filter_products.price.max)
1916			dataobj.max = filter_products.price.max;
1917	}
1918	if (collection_handle != "") {
1919		dataobj.collection_handle = collection_handle;
1920	}
1921	if (mywishlist != '') {
1922		dataobj.mywishlist = mywishlist;
1923	}
1924	if (industry_type == "Petshop") {
1925		dataobj.animal_type_id = animal_type_id;
1926		dataobj.cat_id = cat_id;
1927	}
1928	if (industry_type == "Orchidshop") {
1929		if (filter_products.firearmType && filter_products.firearmType!='') {
1930			dataobj.firearmType = filter_products.firearmType;
1931		}
1932		if (filter_products.firearmCaliber && filter_products.firearmCaliber!='') {
1933			dataobj.firearmCaliber = filter_products.firearmCaliber;
1934		}
1935	}
1936	
1937	var text = [];
1938	var x;
1939	for (x in dataobj) {
1940		if (dataobj[x]!='') {
1941			text.push(x + "=" + dataobj[x]);
1942		}
1943	}
1944	var p_url = part_url + "?" + text.join('&');
1945	window.location.href = p_url;
1946}
1947
1948function update_showing_part(no, cnt) {
1949}
1950
1951function manufacture_filter(id) {
1952	var selOpts = []
1953	selOpts.push(id);
1954	filter_products.manufacture = selOpts;
1955	
1956	$('#go-top').trigger("click");
1957	load_products();
1958}
1959
1960function custom_data_filter(val) {
1961	filter_products.custom_data = val;
1962	$('#go-top').trigger("click");
1963	load_products();
1964}
1965$('body').on("click", ".slide-top .hide-top", function () {
1966	$(".header-top").slideToggle();
1967	$("i", this).toggleClass("fa-angle-up fa-angle-down");
1968});
1969setTimeout(function () {
1970	if (CONTROLL == "products" && (ACTION == "index" || ACTION == "collection" || ACTION == "mywishlist")) {
1971		$(".priceRange").slider({
1972			range: true,
1973			min: min_price,
1974			max: max_price,
1975			values: [min_price, max_price],
1976			slide: function (event, ui) {
1977				$("#amount").val(formatMoney(ui.values[0]) + " - "+ formatMoney(ui.values[1]));
1978				var selOpts = [];
1979				$("#selectManufacture :selected").map(function (i, el) {
1980					selOpts.push($(el).val());
1981				});
1982			}
1983		});
1984		$("#amount").val(formatMoney($(".priceRange").slider("values", 0)) + " - "+ formatMoney($(".priceRange").slider("values", 1)));
1985	}
1986}, 1500);
1987
1988
1989$(document).ready(function () {
1990		setTimeout(function(){
1991	        if (($('.fb_timeline').length==true && $.trim($('.fb_timeline').html()=='')) || ($('.tw_timeline').length==true && $.trim($('.tw_timeline').html()))) {
1992	            $.ajax({
1993	                type        : "POST",
1994	                url     : BASE_PATH+"/ajax/timeline",
1995	                cache       : false,
1996	                data        : {
1997	                                'fb_tl':$('.fb_timeline').attr("data-url"), 'fb_title':$('.fb_timeline').attr("data-title"),
1998	                                'tw_tl':$('.tw_timeline').attr("data-url"), 'tw_title':$('.tw_timeline').attr("data-title")
1999	                            },
2000	                success : function(res){
2001	                    res = $.parseJSON(res);
2002	                    $('.fb_timeline').html(res[0]);
2003	                    $('.tw_timeline').html(res[1]);
2004	                }
2005	            });
2006	        }
2007	    },1500);
2008	
2009
2010	$("body").scroll(function () {
2011		if ($(this).scrollTop() >= 400) {
2012			$('#go-top').fadeIn();
2013		} else {
2014			$('#go-top').fadeOut();
2015		}
2016	});
2017	$("#go-top").on('click', function () {
2018		$("html, body").stop().animate({
2019			scrollTop: 0
2020		}, 1500, "easeInOutExpo")
2021	});
2022	if ($(".ajax-view").length > 0) {
2023		$(".ajax-view").magnificPopup({
2024			type: "ajax",
2025			alignTop: false,
2026			overflowY: 'scroll',
2027			preloader: true,
2028			midClick: true,
2029			closeOnContentClick: false,
2030			enableEscapeKey: true,
2031			showCloseBtn: false,
2032			closeOnBgClick: false,
2033			mainClass: 'mfp-fade',
2034		});
2035	}
2036	if ($(".selectbox").length == true) {
2037		$(".selectbox").selectbox();
2038	}
2039	if ($(".image-popup-zoomin").length) {
2040		$(".image-popup-zoomin").magnificPopup({
2041			type: "image",
2042			removalDelay: 500, 
2043			gallery: {
2044				enabled: true, 
2045				arrowMarkup: '<button title="%title%" type="button" class="fa fa-angle-%dir%"></button>',
2046			},
2047			callbacks: {
2048				beforeOpen: function () {
2049					$(".mfp-bg").addClass("mfp-bg-white");
2050					this.st.image.markup = this.st.image.markup.replace("mfp-figure", "mfp-figure mfp-with-anim");
2051					this.st.mainClass = this.st.el.attr("data-effect");
2052				}
2053			},
2054			closeOnContentClick: true,
2055			midClick: true 
2056		});
2057	}
2058});
2059if ($(".service-carousel").length) {
2060	$(".service-carousel").owlCarousel({
2061		loop: true,
2062		items: 3,
2063		autoplay: true,
2064		dots: false,
2065		margin: 30,
2066		nav: true,
2067		smartSpeed: 800,
2068		autoplayHoverPause: true,
2069		navText: ['<i class="fa fa-angle-left"></i>', '<i class="fa fa-angle-right"></i>'],
2070		responsive: {
2071			0: {
2072				items: 1
2073			},
2074			480: {
2075				items: 1
2076			},
2077			768: {
2078				items: 2
2079			},
2080			1050: {
2081				items: 3
2082			}
2083		}
2084	});
2085}
2086if ($(".Slider4-carousel").length) {
2087	$(".Slider4-carousel").owlCarousel({
2088		loop: true,
2089		items: 24,
2090		dots: false,
2091		margin: 30,
2092		nav: true,
2093		navText: ['<i class="fa fa-angle-left"></i>', '<i class="fa fa-angle-right"></i>'],
2094		responsive: {
2095			0: {
2096				items: 1
2097			},
2098			480: {
2099				items: 1
2100			},
2101			768: {
2102				items: 4
2103			},
2104			1050: {
2105				items: 4
2106			}
2107		}
2108	});
2109}
2110if ($(".testimonialsSlider").length) { // DS-9111
2111	$(".testimonialsSlider").owlCarousel({
2112		nav    : true,
2113		loop    : true,
2114		items     : 12,
2115		margin  : 15,
2116		dots    : false,
2117		navText  : ["<i class='fa fa-angle-left' aria-hidden='true'></i>","<i class='fa fa-angle-right' aria-hidden='true'></i>"],
2118		responsive : {
2119			// breakpoint from 0 up
2120			0 : {
2121				items     : 1
2122			},
2123			// breakpoint from 768 up
2124			992 : {
2125				items     : 2
2126			}
2127		}
2128	});
2129}  // DS-9111 ends
2130if ($(".SliderL2M5").length) { // DS-12806
2131	$(".SliderL2M5").owlCarousel({
2132		nav    : true,
2133           loop    : true,
2134           items     : 24,
2135           margin  : 5,
2136           dots    : false,
2137           navText  : ["<i class='fa fa-angle-left' aria-hidden='true'></i>","<i class='fa fa-angle-right' aria-hidden='true'></i>"],
2138           responsive : {
2139               // breakpoint from 0 up
2140               0 : {
2141                   items     : 1
2142               },
2143               // breakpoint from 480 up
2144               480 : {
2145                   items     : 1
2146               },
2147               // breakpoint from 768 up
2148               768 : {
2149                   items     : 2
2150               },
2151               // breakpoint from 1050 up
2152               1050 : {
2153                   items     : 2
2154               }
2155           }
2156	});
2157}  // DS-12806 ends
2158if ($(".SliderL3M15").length) {
2159	$(".SliderL3M15").owlCarousel({
2160		nav    : true,
2161           loop    : true,
2162           items     : 12,
2163           margin  : 15,
2164           dots    : false,
2165           navText  : ["<i class='fa fa-angle-left' aria-hidden='true'></i>","<i class='fa fa-angle-right' aria-hidden='true'></i>"],
2166           responsive : {
2167               // breakpoint from 0 up
2168               0 : {
2169                   items     : 1
2170               },
2171               // breakpoint from 480 up
2172               480 : {
2173                   items     : 1
2174               },
2175               // breakpoint from 768 up
2176               768 : {
2177                   items     : 3
2178               },
2179               // breakpoint from 1050 up
2180               1050 : {
2181                   items     : 3
2182               }
2183           }
2184	});
2185}
2186if ($("#testcaro").length) { // DS-13072
2187	$("#testcaro").owlCarousel({
2188		nav    : true,
2189		loop    : true,
2190		items     : 24,
2191		margin  : 30,
2192		dots    : false,
2193		navText  : ["<i class='fa fa-angle-left' aria-hidden='true'></i>","<i class='fa fa-angle-right' aria-hidden='true'></i>"],
2194		responsive : {
2195			// breakpoint from 0 up
2196			0 : {
2197				items     : 1
2198			},
2199			// breakpoint from 480 up
2200			480 : {
2201				items     : 1
2202			},
2203			// breakpoint from 768 up
2204			768 : {
2205				items     : 1
2206			},
2207			// breakpoint from 1050 up
2208			1050 : {
2209				items     : 1
2210			}
2211	  
2212		}
2213	}); 
2214}
2215// OP-402
2216let owlMNone = $(".NoMarginSlider");
2217//  OP-478
2218if (owlMNone.length > 0) { 
2219	owlMNone.owlCarousel({
2220		nav: owlMNone.children().length > 1,
2221		loop: owlMNone.children().length > 1,
2222		items: 12,
2223		margin: 0,
2224		dots: false,
2225		navText  : ["<i class='fa fa-angle-left' aria-hidden='true'></i>","<i class='fa fa-angle-right' aria-hidden='true'></i>"],
2226		responsive : {
2227			// breakpoint from 0 up
2228			0 : {
2229				items     : 1
2230			},
2231			// breakpoint from 480 up
2232			480 : {
2233				items     : 1
2234			},
2235			// breakpoint from 768 up
2236			768 : {
2237				items     : 2
2238			},
2239			// breakpoint from 1050 up
2240			1050 : {
2241				items     : 3
2242			}
2243	
2244	
2245		}
2246	}); 
2247}
2248function addPartDetails(handle,part_title)
2249{
2250
2251	$("#ContactName").val('').removeClass('error').next().remove();
2252	$("#ContactEmail").val('').removeClass('error').next().remove();
2253	$("#ContactMessage").val('');
2254	$("#hiddenRecaptchaContactus").val('').removeClass('error').next().find('label').remove();	
2255	$("#enq_reset_captch").click();
2256	$('#contact_part_number').val('');
2257	$('#contact_size').val('');
2258	$('#contact_color').val('');
2259	$('#contact_description').val('');
2260	$("#part_title").html(part_title);
2261	$('#ContactContactUsForm #action').next().remove();
2262	$(".simple_security").hide();
2263	$.ajax({
2264		url:BASE_PATH+"/site/getContactUsdata",
2265		type:"POST",
2266		data: {
2267			handle:handle,			
2268		},
2269		success:function(msg){
2270			$('.contact_us_form_btn').attr('disabled',false);
2271			var data=msg.split('$@$');
2272			if(data[0]!=''){
2273				$('#contact_part_number').val(data[0]);
2274				$('#contact_size').val(data[2]);
2275				$('#contact_color').val(data[1]);
2276				$('#contact_description').val(data[3]);
2277				$('#ContactContactUsForm #action').after("<input type='hidden' id='g-recaptcha-response' name='g-recaptcha-response' value=''  >"); 
2278					reset_captcha('',ENQUIRY_ACTION);				
2279			}else{
2280				window.history.back();
2281			}
2282		}
2283    });
2284}
2285
2286function addCollectionDetails(handle,part_title)
2287{
2288
2289	$("#ContactName").val('').removeClass('error').next().remove();
2290	$("#ContactEmail").val('').removeClass('error').next().remove();
2291	$("#ContactMessage").val('');
2292	$("#hiddenRecaptchaContactus").val('').removeClass('error').next().find('label').remove();	
2293	$("#enq_reset_captch").click();
2294	$('#contact_part_number').val('');
2295	$('#contact_size').val('');
2296	$('#contact_color').val('');
2297	$('#contact_description').val('');
2298	$("#part_title").html(part_title);
2299	$('#ContactContactUsForm #action').next().remove();
2300	$(".simple_security").hide();
2301	setTimeout(function(){
2302		$('#contact_part_number').val(part_title);
2303	},500);	
2304	$('#contact_description').val(part_title);
2305	$('#ContactContactUsForm #action').after("<input type='hidden' id='g-recaptcha-response' name='g-recaptcha-response' value=''  >"); 
2306		reset_captcha('',ENQUIRY_ACTION);	
2307}
2308
2309var enq_cap_error = false;
2310$(document).on('click', '.contact_us_form_btn', function(){
2311	var ContactContactUsForm_validate = $("#ContactContactUsForm").valid();
2312	if(  ContactContactUsForm_validate == true )
2313	{
2314		var btnObj = this;
2315		$(btnObj).attr('disabled',true);
2316			var userEnquiryData = {
2317				captcha:$("#ContactContactUsForm #g-recaptcha-response").val(),
2318				action: "user/contact_us",
2319				UserCaptcha : ($("#ContactContactUsForm #UserCaptchaContactUs").length)?$("#ContactContactUsForm #UserCaptchaContactUs").val():'',
2320				scode : ($("#ContactContactUsForm #UserCaptchaContactUs").length)?$("#ContactContactUsForm #UserCaptchaContactUs").attr('data-val'):''
2321			};
2322		
2323		$.ajax({
2324			url:BASE_PATH+"/site/verify_captcha",
2325			type:"POST",
2326			data: userEnquiryData,
2327			success:function(res){
2328					reset_captcha('',ENQUIRY_ACTION);
2329				var obj = JSON.parse(res);
2330				if( 	(Object.keys(obj).length>1 && obj.success==true && obj.action && obj.score==captcha_threshold) ||  
2331						(Object.keys(obj).length==1 && obj.success==true)
2332					) 
2333				{
2334					$("#ContactContactUsForm #g-recaptcha-response").val('');	
2335					$("#ContactContactUsForm").submit();
2336				}
2337				else
2338				{
2339					$(btnObj).attr('disabled',false);
2340					$('.creload:visible').trigger('click');
2341					$(".simple_security").fadeIn();
2342					$(btnObj).attr('disabled',false);
2343					if(enq_cap_error==true){
2344							if(obj.message){
2345								$("#ContactContactUsForm #CaptchaContactUs").after('<label id="usercaptcha-error" class="error" for="CaptchaContactUs">'+obj.message+'</label>');
2346							}else{
2347								$("#ContactContactUsForm #CaptchaContactUs").after('<label id="usercaptcha-error" class="error" for="CaptchaContactUs">'+PLEASE_ENTER_THE_SECURITY_CODE_TEXT+'</label>');	
2348							}
2349					}else{
2350						enq_cap_error = true;
2351					}
2352					
2353				}
2354			}
2355		});
2356	}
2357});
2358
2359	$(document).on('keypress', '.clabel:visible', function(){
2360		if($("label#usercaptcha-error:visible").length>0){
2361			$("label#usercaptcha-error:visible").remove();	
2362		}
2363	});
2364
2365var pwd_cap_error = false;
2366$(document).on('click', '.login_form_btn', function(){
2367	if($("#LoginInfoCreateAccountForm:visible").length)
2368	{
2369		var LoginInfoCreateAccountForm_validate = $("#LoginInfoCreateAccountForm:visible").valid();
2370		if(  LoginInfoCreateAccountForm_validate == true )
2371		{
2372			var btnObj = this;
2373			$(btnObj).attr('disabled',true);
2374
2375				var userRegData = {
2376					captcha:$("#LoginInfoCreateAccountForm #g-recaptcha-response").val(),
2377					action : "user/create_account",
2378					UserCaptcha : ($("#LoginInfoCreateAccountForm #UserCaptchaRegister").length)?$("#LoginInfoCreateAccountForm #UserCaptchaRegister").val():'',
2379					scode : ($("#LoginInfoCreateAccountForm #UserCaptchaRegister").length)?$("#LoginInfoCreateAccountForm #UserCaptchaRegister").attr('data-val'):''
2380				};
2381			
2382			$.ajax({
2383				url:BASE_PATH+"/site/verify_captcha",
2384				type:"POST",
2385				data: userRegData,
2386				success:function(res){
2387						reset_captcha('',REGISTER_ACTION);
2388					var obj = JSON.parse(res);
2389					if( 	(Object.keys(obj).length>1 && obj.success==true && obj.action && obj.score==captcha_threshold) ||  
2390							(Object.keys(obj).length==1 && obj.success==true)
2391						) 
2392					{
2393						$("#LoginInfoCreateAccountForm #g-recaptcha-response").val('');	
2394						$("#LoginInfoCreateAccountForm").submit();
2395					}
2396					else
2397					{
2398						$(btnObj).attr('disabled',false);
2399						$('.creload:visible').trigger('click');
2400						$(".simple_security").fadeIn();
2401						$(btnObj).attr('disabled',false);
2402						if(pwd_cap_error==true){
2403								if(obj.message){
2404									$("#LoginInfoCreateAccountForm #UserCaptchaRegister").after('<label id="usercaptcha-error" class="error" for="UserCaptchaRegister">'+obj.message+'</label>');
2405								}else{
2406									$("#LoginInfoCreateAccountForm #UserCaptchaRegister").after('<label id="usercaptcha-error" class="error" for="UserCaptchaRegister">'+PLEASE_ENTER_THE_SECURITY_CODE_TEXT+'</label>');	
2407								}								
2408							
2409						}else{
2410							pwd_cap_error = true;
2411						}
2412						
2413					}
2414				}
2415			});
2416		}
2417	}
2418	else if($("#ContactForgetPasswordForm:visible").length)
2419	{
2420		var ContactForgetPasswordForm_validate = $("#ContactForgetPasswordForm:visible").valid();
2421		if(  ContactForgetPasswordForm_validate == true )
2422		{
2423			var btnObj = this;
2424			$(btnObj).attr('disabled',true);
2425				var userForgetPasswordData = {
2426					captcha:$("#ContactForgetPasswordForm #g-recaptcha-response").val(),
2427					action : "user/forget_password",
2428					UserCaptcha : ($("#ContactForgetPasswordForm #UserCaptchaForgetPassword").length)?$("#ContactForgetPasswordForm #UserCaptchaForgetPassword").val():'',
2429					scode : ($("#ContactForgetPasswordForm #UserCaptchaForgetPassword").length)?$("#ContactForgetPasswordForm #UserCaptchaForgetPassword").attr('data-val'):''					
2430				};
2431			$.ajax({
2432				url:BASE_PATH+"/site/verify_captcha",
2433				type:"POST",
2434				data: userForgetPasswordData,
2435				success:function(res){
2436						reset_captcha('',FORGET_PASSWORD_ACTION);
2437					var obj = JSON.parse(res);
2438					if( 	(Object.keys(obj).length>1 && obj.success==true && obj.action && obj.score==captcha_threshold) ||  
2439							(Object.keys(obj).length==1 && obj.success==true)
2440						) 
2441					{
2442						$("#ContactForgetPasswordForm #g-recaptcha-response").val('');	
2443						$("#ContactForgetPasswordForm").submit();
2444					}
2445					else
2446					{
2447						$(btnObj).attr('disabled',false);
2448						$('#ContactForgetPasswordForm:visible .creload').trigger('click');
2449						$(".simple_security").fadeIn();
2450						$(btnObj).attr('disabled',false);
2451						if(pwd_cap_error==true){
2452								if(obj.message){
2453									$("#ContactForgetPasswordForm #UserCaptchaForgetPassword").after('<label id="usercaptcha-error" class="error" for="UserCaptchaForgetPassword">'+obj.message+'</label>');
2454								}else{
2455									$("#ContactForgetPasswordForm #UserCaptchaForgetPassword").after('<label id="usercaptcha-error" class="error" for="UserCaptchaForgetPassword">'+PLEASE_ENTER_THE_SECURITY_CODE_TEXT+'</label>');	
2456								}
2457						}else{
2458							pwd_cap_error = true;
2459						}
2460					}
2461				}
2462			});
2463		}
2464	}
2465});
2466
2467		
2468$(document).on('click', '.creload', function(){
2469    var mySrc = $(this).prev().attr('src');
2470    var glue = '?';
2471    if(mySrc.indexOf('?')!=-1)  {
2472        glue = '&';
2473    }
2474    $(this).prev().attr('src', mySrc + glue + new Date().getTime());
2475    setTimeout(function(){
2476    	$.post(BASE_PATH+"/ajax/getSecurityCode", function(data, status){
2477	    	if($("#cc_security #UserCaptcha").is(":visible")){
2478				 $("#cc_security #UserCaptcha").attr("data-val", $.trim(data));
2479		}else{
2480	    	$("#UserCaptcha").attr("data-val",$.trim(data));
2481		}
2482			
2483	  	});
2484    },750);
2485    return false;
2486});
2487
2488var rew_cap_error = false;		
2489$(document).on('click', '#submit_preview', function(){
2490	var ReviewProductForm_validate = $("#ReviewProductForm").valid();
2491	if(  ReviewProductForm_validate == true )
2492	{
2493		var btnObj = this;
2494		$(btnObj).attr('disabled',true);
2495			var userProductReviewData = {
2496				captcha:$("#ReviewProductForm #g-recaptcha-response").val(),
2497				action : "user/product_review",
2498				UserCaptcha : ($("#ReviewProductForm #UserCaptchaProductReview").length)?$("#ReviewProductForm #UserCaptchaProductReview").val():'',
2499				scode : ($("#ReviewProductForm #UserCaptchaProductReview").length)?$("#ReviewProductForm #UserCaptchaProductReview").attr('data-val'):''					
2500			};
2501		$.ajax({
2502			url:BASE_PATH+"/site/verify_captcha",
2503			type:"POST",
2504			data: userProductReviewData,
2505			success:function(res){
2506					reset_captcha('',REVIEW_ACTION);
2507				var obj = JSON.parse(res);
2508				if( 	(Object.keys(obj).length>1 && obj.success==true && obj.action && obj.score==captcha_threshold) ||  
2509						(Object.keys(obj).length==1 && obj.success==true)
2510					) 
2511				{
2512					$("#ReviewProductForm #g-recaptcha-response").val('');	
2513					$("#ReviewProductForm").submit();
2514				}
2515				else
2516				{
2517					$(btnObj).attr('disabled',false);
2518					$('#ReviewProductForm:visible .creload').trigger('click');
2519					$("#ReviewProductForm:visible .simple_security").fadeIn();
2520					$(btnObj).attr('disabled',false);
2521					if(rew_cap_error==true)
2522					{
2523							if(obj.message){
2524								$("#ReviewProductForm:visible #UserCaptchaProductReview").after('<label id="usercaptcha-error" class="error" for="UserCaptchaProductReview">'+obj.message+'</label>');
2525							}else{
2526								$("#ReviewProductForm:visible #UserCaptchaProductReview").after('<label id="usercaptcha-error" class="error" for="UserCaptchaProductReview">'+PLEASE_ENTER_THE_SECURITY_CODE_TEXT+'</label>');	
2527							}
2528						
2529					}else{
2530						rew_cap_error = true;
2531					}
2532				}
2533			}
2534		});
2535	}
2536});
2537
2538$( document ).ready(function() {
2539	$(".clabel").val('');
2540    if($("#LoginInfoCreateAccountForm:visible").length)
2541    {
2542    	$("#LoginInfoCreateAccountForm .simple_security").hide();
2543    	if( !$('#LoginInfoCreateAccountForm #g-recaptcha-response').length )
2544    		$('#LoginInfoCreateAccountForm #action').after("<input type='hidden' id='g-recaptcha-response' name='g-recaptcha-response' value=''  >");
2545    	reset_captcha('',REGISTER_ACTION);
2546    }
2547    else if($("#ContactForgetPasswordForm:visible").length)
2548	{
2549		$("#ContactForgetPasswordForm .simple_security").hide();
2550    	if( !$('#ContactForgetPasswordForm #g-recaptcha-response').length )
2551    		$('#ContactForgetPasswordForm #action').after("<input type='hidden' id='g-recaptcha-response' name='g-recaptcha-response' value=''  >");
2552    	reset_captcha('',FORGET_PASSWORD_ACTION);    	
2553	}
2554	else if($("#ReviewProductForm").length)
2555	{
2556		$("#ReviewProductForm .simple_security").hide();
2557    	if( !$('#ReviewProductForm #g-recaptcha-response').length )
2558    		$('#ReviewProductForm #action').after("<input type='hidden' id='g-recaptcha-response' name='g-recaptcha-response' value=''  >");
2559    	reset_captcha('',REVIEW_ACTION);
2560	}
2561	else if($("#custom_data_form").length)
2562	{
2563	 	$("#custom_data_form .simple_security").hide();
2564     	if( !$('#custom_data_form #g-recaptcha-response').length )
2565     		$('#custom_data_form #action').after("<input type='hidden' id='g-recaptcha-response' name='g-recaptcha-response' value=''  >");
2566     	reset_captcha('',CUSTOM_FORM_ACTION);
2567	}
2568	else if( ($("#avalara_tax_api").length>0 && $("#avalara_tax_api").val()==1) || ($("#remove_duplicitous_shipping_address_step").length>0 && $("#remove_duplicitous_shipping_address_step").val()==1) )//FeatureTag 
2569	{
2570		if($("#CustomerInfoShippingForm:visible").length && $("#CustomerInfoShippingForm .simple_security").length)
2571    	{
2572	    	//$("#CustomerInfoShippingForm .simple_security").hide();
2573	    	if( !$('#CustomerInfoShippingForm #g-recaptcha-response').length )
2574	    		$('#CustomerInfoShippingForm #action').after("<input type='hidden' id='g-recaptcha-response' name='g-recaptcha-response' value=''  >");
2575	    	reset_captcha('',REGISTER_ACTION);
2576    	}
2577    }
2578    
2579	    if($("#CardConnectCreditCardAuthForm:visible").length)
2580		{
2581			//$("#CardConnectCreditCardAuthForm .simple_security").hide();
2582	    	if( !$('#CardConnectCreditCardAuthForm #g-recaptcha-response').length )
2583	    		$('#CardConnectCreditCardAuthForm #hiddenRecaptcha').attr("name","data[hiddenRecaptcha]").after("<input type='hidden' id='g-recaptcha-response' name='data[g-recaptcha-response]' value=''  >");
2584	    	reset_captcha('',CHECKOUT_ACTION);
2585		}
2586		if($("#CreditCardAuthForm:visible").length)
2587		{
2588			//$("#CreditCardAuthForm .simple_security").hide();
2589	    	if( !$('#CreditCardAuthForm #g-recaptcha-response').length )
2590	    		$('#CreditCardAuthForm #hiddenRecaptcha').attr("name","data[hiddenRecaptcha]").after("<input type='hidden' id='g-recaptcha-response' name='data[g-recaptcha-response]' value=''  >");
2591	    	reset_captcha('',CHECKOUT_ACTION);
2592		}
2593	        if($("#AdyenCreditCardAuthForm:visible").length)
2594	        {
2595	        	if( !$('#AdyenCreditCardAuthForm #g-recaptcha-response').length )
2596		    		$('#AdyenCreditCardAuthForm #hiddenRecaptcha').attr("name","data[hiddenRecaptcha]").after("<input type='hidden' id='g-recaptcha-response' name='data[g-recaptcha-response]' value=''  >");
2597		    	reset_captcha('',CHECKOUT_ACTION);
2598	        }
2599		/* House Account Pay Later: the checkout form is #paylaterAuthForm, so it needs a token too. */
2600		if($("#add_paylater_for_stores_with_no_integrated_payments").length>0 && $("#add_paylater_for_stores_with_no_integrated_payments").val()==1 && $("#paylaterAuthForm:visible").length) //FeatureTag
2601		{
2602	    	if( !$('#paylaterAuthForm #g-recaptcha-response').length )
2603	    		$('#paylaterAuthForm #hiddenRecaptcha').attr("name","data[hiddenRecaptcha]").after("<input type='hidden' id='g-recaptcha-response' name='data[g-recaptcha-response]' value=''  >");
2604	    	reset_captcha('',CHECKOUT_ACTION);
2605		}
2606		if($("#payment-form:visible").length)
2607		{
2608			//$("#CreditCardAuthForm .simple_security").hide();
2609	    	if( !$('#payment-form #g-recaptcha-response').length )
2610	    		$('#payment-form #hiddenRecaptcha').attr("name","data[hiddenRecaptcha]").after("<input type='hidden' id='g-recaptcha-response' name='data[g-recaptcha-response]' value=''  >");
2611	    	reset_captcha('',CHECKOUT_ACTION);
2612		}
2613		
2614	
2615});
2616
2617function reset_captcha(uuid='',action='')
2618{
2619	if(action!='') //FeatureTag
2620    { 
2621    	grecaptcha.ready(function() {
2622	        grecaptcha.execute( GOOGLE_RECAPTCHA_SITE_KEY , {action:action})
2623	                  .then(function(token) {
2624
2625	            if($("#avalara_tax_api").length>0 && $("#avalara_tax_api").val()==1) //FeatureTag
2626	            {      	
2627		            if($("#CustomerInfoShippingForm:visible").length)
2628		            {
2629		            	$('#CustomerInfoShippingForm:visible #hiddenRecaptchashipping').val(token);
2630			    		$("#CustomerInfoShippingForm:visible #g-recaptcha-response").val(token);	
2631		            }      	
2632		        }
2633	            if($("#LoginInfoCreateAccountForm:visible").length)
2634	            {
2635	            	$('#LoginInfoCreateAccountForm:visible #hiddenRecaptcha').val(token);
2636		    		$("#LoginInfoCreateAccountForm:visible #g-recaptcha-response").val(token);	
2637	            }
2638	            if($("#ContactForgetPasswordForm:visible").length)
2639	            {
2640	            	$('#ContactForgetPasswordForm:visible #hiddenRecaptchaForget').val(token);
2641		    		$("#ContactForgetPasswordForm:visible #g-recaptcha-response").val(token);	
2642	            }
2643	            if($("#ReviewProductForm").length)
2644	            {
2645	            	$('#ReviewProductForm #hiddenRecaptchaReview').val(token);
2646		    		$("#ReviewProductForm #g-recaptcha-response").val(token);	
2647	            }
2648	            if($("#ContactSigninOtpForm").length)
2649	            {
2650	            	$("#ContactSigninOtpForm #g-recaptcha-response").val(token);	
2651	            }
2652	            if($("#custom_data_form_"+uuid).length)
2653	            {
2654	            	$("#hiddenRecaptchaReview_"+uuid).val(token);
2655		    		$("#g-recaptcha-response_"+uuid).val(token);	
2656	            }
2657	            if(  $("#CardConnectCreditCardAuthForm:visible").length)
2658		        {
2659	            	$('#CardConnectCreditCardAuthForm:visible #hiddenRecaptcha').val(token);
2660		    		$("#CardConnectCreditCardAuthForm:visible #g-recaptcha-response").val(token);	
2661		        }
2662		        if( $("#CreditCardAuthForm:visible").length)
2663		        {
2664	            	$('#CreditCardAuthForm:visible #hiddenRecaptcha').val(token);
2665		    		$("#CreditCardAuthForm:visible #g-recaptcha-response").val(token);	
2666		        }
2667			        if($("#AdyenCreditCardAuthForm:visible").length)
2668			        {
2669		            	$('#AdyenCreditCardAuthForm:visible #hiddenRecaptcha').val(token);
2670			    		$("#AdyenCreditCardAuthForm:visible #g-recaptcha-response").val(token);	
2671			        }
2672		        /* House Account Pay Later posts #paylaterAuthForm, which none of the forms above cover. */
2673		        if($("#add_paylater_for_stores_with_no_integrated_payments").length>0 && $("#add_paylater_for_stores_with_no_integrated_payments").val()==1 && $("#paylaterAuthForm:visible").length) //FeatureTag
2674		        {
2675	            	$('#paylaterAuthForm:visible #hiddenRecaptcha').attr("name","data[hiddenRecaptcha]").val(token); /* data[] so a later plain hiddenRecaptcha (guest Create Account form) can't overwrite it */
2676		    		$("#paylaterAuthForm:visible #g-recaptcha-response").val(token);
2677		        }
2678		        if($("#payment-form:visible").length)
2679		        {
2680	            	$('#payment-form:visible #hiddenRecaptcha').val(token);
2681		    		$("#payment-form:visible #g-recaptcha-response").val(token);	
2682		        }
2683	            else
2684	            {
2685	            	
2686	            	$("#ContactContactUsForm:visible #hiddenRecaptchaContactus").val(token);
2687		    		$("#ContactContactUsForm:visible #g-recaptcha-response").val(token);
2688		    	}
2689	        });
2690	    });
2691	}else{
2692		grecaptcha.ready(function() {
2693	        grecaptcha.execute( GOOGLE_RECAPTCHA_SITE_KEY , {action:'validate_captcha'})
2694	                  .then(function(token) {
2695	            if($("#avalara_tax_api").length>0 && $("#avalara_tax_api").val()==1) //FeatureTag
2696	            {      	
2697		            if($("#CustomerInfoShippingForm:visible").length)
2698		            {
2699		            	$('#CustomerInfoShippingForm:visible #hiddenRecaptchashipping').val(token);
2700			    		$("#CustomerInfoShippingForm:visible #g-recaptcha-response").val(token);	
2701		            }      	
2702		        }
2703	            if($("#LoginInfoCreateAccountForm:visible").length)
2704	            {
2705	            	$('#LoginInfoCreateAccountForm:visible #hiddenRecaptcha').val(token);
2706		    		$("#LoginInfoCreateAccountForm:visible #g-recaptcha-response").val(token);	
2707	            }
2708	            if($("#ContactForgetPasswordForm:visible").length)
2709	            {
2710	            	$('#ContactForgetPasswordForm:visible #hiddenRecaptchaForget').val(token);
2711		    		$("#ContactForgetPasswordForm:visible #g-recaptcha-response").val(token);	
2712	            }
2713	            if($("#ReviewProductForm").length)
2714	            {
2715	            	$('#ReviewProductForm #hiddenRecaptchaReview').val(token);
2716		    		$("#ReviewProductForm #g-recaptcha-response").val(token);	
2717	            }
2718	            if($("#ContactSigninOtpForm").length)
2719	            {
2720	            	$("#ContactSigninOtpForm #g-recaptcha-response").val(token);	
2721	            }
2722	            if($("#custom_data_form_"+uuid).length)
2723	            {
2724	            	$("#hiddenRecaptchaReview_"+uuid).val(token);
2725		    		$("#g-recaptcha-response_"+uuid).val(token);	
2726	            }
2727	            if(  $("#CardConnectCreditCardAuthForm:visible").length)
2728		        {
2729	            	$('#CardConnectCreditCardAuthForm:visible #hiddenRecaptcha').val(token);
2730		    		$("#CardConnectCreditCardAuthForm:visible #g-recaptcha-response").val(token);	
2731		        }
2732		        if( $("#CreditCardAuthForm:visible").length)
2733		        {
2734	            	$('#CreditCardAuthForm:visible #hiddenRecaptcha').val(token);
2735		    		$("#CreditCardAuthForm:visible #g-recaptcha-response").val(token);	
2736		        }
2737			        if($("#AdyenCreditCardAuthForm:visible").length)
2738			        {
2739		            	$('#AdyenCreditCardAuthForm:visible #hiddenRecaptcha').val(token);
2740			    		$("#AdyenCreditCardAuthForm:visible #g-recaptcha-response").val(token);	
2741			        }
2742		        /* House Account Pay Later posts #paylaterAuthForm, which none of the forms above cover. */
2743		        if($("#add_paylater_for_stores_with_no_integrated_payments").length>0 && $("#add_paylater_for_stores_with_no_integrated_payments").val()==1 && $("#paylaterAuthForm:visible").length) //FeatureTag
2744		        {
2745	            	$('#paylaterAuthForm:visible #hiddenRecaptcha').attr("name","data[hiddenRecaptcha]").val(token); /* data[] so a later plain hiddenRecaptcha (guest Create Account form) can't overwrite it */
2746		    		$("#paylaterAuthForm:visible #g-recaptcha-response").val(token);
2747		        }
2748		        if($("#payment-form:visible").length)
2749		        {
2750	            	$('#payment-form:visible #hiddenRecaptcha').val(token);
2751		    		$("#payment-form:visible #g-recaptcha-response").val(token);	
2752		        }
2753	            else
2754	            {
2755	            	
2756	            	$("#ContactContactUsForm:visible #hiddenRecaptchaContactus").val(token);
2757		    		$("#ContactContactUsForm:visible #g-recaptcha-response").val(token);
2758		    	}
2759	        });
2760	    });
2761	}
2762}
2763
2764
2765$(document).ready(function () {
2766	if($('.gallery-2column').length>0)
2767	{
2768		$('.gallery-2column').removeClass('hide');
2769		$(".gallery-2column").css({"width":"100%!important"});
2770		var itemSelector = '.filter';
2771		var $container = $('.gallery-2column').isotope({
2772			itemSelector: itemSelector,
2773		});
2774		var responsiveIsotope = [	[480, 4],	[720, 6]	];
2775		var itemsPerPageDefault = (fitemsPerPage)?fitemsPerPage:10;
2776		var itemsPerPage = defineItemsPerPage();
2777		var currentNumberPages = 1;
2778		var currentPage = 1;
2779		var currentFilter = '*';
2780		var filterAtribute = 'data-filter';
2781		var pageAtribute = 'data-page';
2782		var pagerClass = 'isotope-pager';
2783	}
2784
2785	function changeFilter(selector) {
2786		$container.isotope({
2787			filter: selector
2788		});
2789	}
2790
2791	function goToPage(n) {
2792		if(itemSelector)
2793		{
2794			currentPage = n;
2795			var selector = itemSelector;
2796			selector += (currentFilter != '*') ?  currentFilter  : '';
2797			selector += '[' + pageAtribute + '="' + currentPage + '"]';
2798			
2799			changeFilter(selector);
2800		}
2801	}
2802
2803	function defineItemsPerPage() {
2804		if(responsiveIsotope){
2805			var pages = itemsPerPageDefault;
2806			for (var i = 0; i < responsiveIsotope.length; i++) {
2807				if ($(window).width() <= responsiveIsotope[i][0]) {
2808					pages = responsiveIsotope[i][1];
2809					break;
2810				}
2811			}
2812			return pages;
2813		}
2814	}
2815
2816	function setPagination() {
2817        if (itemSelector) {
2818            var SettingsPagesOnItems = function() {
2819                var itemsLength = $container.children(itemSelector).length;
2820                var pages = Math.ceil(itemsLength / itemsPerPage);
2821                var item = 1;
2822                var page = 1;
2823                var selector = itemSelector;
2824                selector += (currentFilter != '*') ? currentFilter : '';
2825                $container.children(selector).each(function() {
2826                    if (item > itemsPerPage) {
2827                        page++;
2828                        item = 1;
2829                    }
2830                    $(this).attr(pageAtribute, page);
2831                    item++;
2832                });
2833                currentNumberPages = page;
2834            }();
2835            var CreatePagers = function() {
2836                var $isotopePager = ($('.' + pagerClass).length == 0) ? $('<div class="' + pagerClass + '"></div>') : $('.' + pagerClass);
2837                $isotopePager.html('');
2838                for (var i = 0; i < currentNumberPages; i++) {
2839                    var $pager = $('<a href="javascript:void(0);" class="pager page' + (i + 1) + '" ' + pageAtribute + '="' + (i + 1) + '"></a>');
2840                    $pager.html(i + 1);
2841                    $pager.click(function() {
2842                        $(".pager").css({
2843                            'color': '#FFF',
2844                            'font-weight': 'normal',
2845                            'background-color': '#052542 !important'
2846                        });
2847                        $(".page" + $(this).html()).css({
2848                            'color': '#fff',
2849                            'font-weight': 'bold',
2850                            'background-color': '#7c7c7c !important'
2851                        });
2852                        var page = $(this).eq(0).attr(pageAtribute);
2853                        goToPage(page);
2854                    });
2855                    $pager.appendTo($isotopePager);
2856                }
2857                $container.after($isotopePager);
2858            }();
2859            homepart_isotope();
2860            $(".pager:first-child").css({
2861                'color': '#fff',
2862                'font-weight': 'bold',
2863                'background-color': '#7c7c7c !important'
2864            });
2865        }
2866    }
2867	if($('.gallery-2column').length>0)
2868	{
2869		setPagination();
2870		goToPage(1);
2871		$('.gallery-filter a').click(function () {
2872			$('.gallery-filter .active').removeClass('active');
2873			$(this).addClass('active');
2874			var filter = $(this).attr(filterAtribute);
2875			currentFilter = filter;
2876			setPagination();
2877			goToPage(1);
2878		});
2879	}
2880	$(window).resize(function () {
2881		itemsPerPage = defineItemsPerPage();
2882		setPagination();
2883		goToPage(1);
2884	});
2885});
2886
2887
2888function homepart_isotope()
2889{
2890	if($(".isotope-pager").length>0)
2891	{
2892		$(".isotope-pager").css({
2893			'text-align'	: 'right'
2894		});
2895	}
2896	if($(".isotope-pager .pager").length>0)
2897	{
2898		$(".isotope-pager .pager").css({
2899			'display'	: 'inline-block',
2900			'padding'   : '5px 10px',
2901			'background-color' : '#052542',
2902			'margin-right':'17px',
2903			'color': 'aliceblue',
2904			'border-radius': '5px'
2905		});
2906	}
2907}
2908if($(window).width() <= 1024){
2909    $(document).on('click touchstart', '.btn_place_order', function () {
2910      $("#signin_signup").show();      
2911    });
2912    $(document).on('click touchstart', '.close_icon_popup', function () {
2913        $("#signin_signup").hide();
2914    });
2915    
2916}
2917$(document).on('click touchstart', '.resend_otp', function () {
2918	reset_captcha('',SIGNIN_OTP_ACTION);
2919	$("#ContactOtpLoginEmail-error").remove();
2920	$("#ContactLoginEmailOtp-error").remove();
2921	$("#ContactLoginEmailOtp").val('').hide();
2922	$("#ContactLoginEmailOtp").prev().hide();
2923	$(".resend_otp").hide();
2924	$(".otp_mail").html("<img src='"+BASE_PATH+"/img/loading1.gif'>").removeClass("error");
2925	$.ajax({
2926			url:BASE_PATH+"/api/sent_otp_login_email",
2927			type:"POST",
2928			data: {
2929				'email' : $("#ContactOtpLoginEmail").val(),
2930				'captcha' : $("#ContactSigninOtpForm").find("#g-recaptcha-response").val()
2931			},
2932			success:function(response){
2933				var json = $.parseJSON(response);
2934				if(json.status==true)
2935				{
2936					otp_counter();
2937					if(json.sms_to){
2938						var res_msg = "Please enter the OTP sent to '"+json.sms_to+"'";
2939					}
2940					if(json.mail_to){
2941						var res_msg = "Please enter the OTP sent to '"+json.mail_to+"'";
2942					}
2943					$(".otp_mail").html(res_msg);
2944					$("#ContactOtpLoginNumber").focus();
2945					$("#ContactLoginEmailOtp").val('').show();
2946					$("#ContactLoginEmailOtp").prev().show();
2947				}
2948				else
2949				{
2950					$(".otp_mail").html(json.message).addClass("error")
2951					$("#ContactOtpLoginEmail").focus();
2952					$(".resend_otp").hide();	
2953					$("#ContactLoginEmailOtp").val('').hide();
2954					$("#ContactLoginEmailOtp").prev().hide();	
2955				}
2956			}
2957		});
2958	$(".login_otp_form_btn").show();
2959});
2960$(document).on('click touchstart', '.signin_otp', function () {
2961	$("#signin_otp_modal").show();
2962	$(".otp_mail").html("").removeClass("error");
2963	$("#ContactLoginEmailOtp").val('').hide();
2964	$("#ContactLoginEmailOtp").prev().hide();
2965	$(".resend_otp").hide();
2966	$('#otp_counter').text('');
2967	$("#ContactOtpLoginEmail-error").remove();
2968	$("#ContactLoginEmailOtp-error").remove();
2969	$("#ContactOtpLoginEmail").val("");
2970	$(".login_otp_form_btn").show().attr("disabled",false);
2971
2972	$("#ContactSigninOtpForm .simple_security").hide();
2973 	if( !$('#ContactSigninOtpForm #g-recaptcha-response').length )
2974 		$('#ContactSigninOtpForm .simple_security').after("<input type='hidden' id='g-recaptcha-response' name='g-recaptcha-response' value=''  >");
2975 	reset_captcha('',SIGNIN_OTP_ACTION);
2976});
2977$(document).on('click touchstart', '.login_otp_form_btn', function () {
2978	var ContactSigninOtpForm =  $("#ContactSigninOtpForm").valid();
2979	if(ContactSigninOtpForm)
2980	{
2981		//alert($("#ContactSigninOtpForm .simple_security").is(":visible")+"---"+$("#ContactLoginEmailOtp").is(":visible"))
2982		if($("#ContactSigninOtpForm .simple_security").is(":visible")==0 && $("#ContactLoginEmailOtp").is(":visible")==0){
2983			$("#ContactSigninOtpForm .simple_security").show();
2984			$("#ContactSigninOtpForm").find(".creload").trigger('click');
2985			$(".login_otp_form_btn").show();
2986			return false;
2987		}
2988		if($("#ContactOtpLoginEmail").val()!='' && $("#ContactLoginEmailOtp").val()!='')
2989		{
2990			$("#ContactSigninOtpForm").submit();
2991		}
2992		else if($("#ContactOtpLoginEmail").val()!='' && $("#ContactLoginEmailOtp").val()=='')
2993		{
2994			$(".login_otp_form_btn").hide();
2995			$(".otp_mail").html("<img src='"+BASE_PATH+"/img/loading1.gif'>").removeClass("error");
2996			
2997				var UserOtpData = {
2998					UserCaptcha : ($("#ContactSigninOtpForm #UserCaptchaSigninOtp").length)?$("#ContactSigninOtpForm #UserCaptchaSigninOtp").val():'',
2999					action: "user/signin_otp",
3000				};
3001			
3002
3003			$.ajax({
3004				url:BASE_PATH+"/site/verify_captcha",
3005				type:"POST",
3006				data: UserOtpData,
3007				success:function(res){
3008					reset_captcha('',SIGNIN_OTP_ACTION);
3009					var obj = JSON.parse(res);
3010					if( Object.keys(obj).length==1 && obj.success==true ) 
3011					{
3012						$.ajax({
3013							url:BASE_PATH+"/api/sent_otp_login_email",
3014							type:"POST",
3015							data: {
3016								'email' : $("#ContactOtpLoginEmail").val(),
3017								'captcha' : $("#ContactSigninOtpForm").find("#g-recaptcha-response").val()
3018							},
3019							success:function(response){
3020								var json = $.parseJSON(response);
3021								if(json.status==true)
3022								{
3023									otp_counter();
3024									if(json.sms_to){
3025										var res_msg = "Please enter the OTP sent to '"+json.sms_to+"'";
3026									}
3027									if(json.mail_to){
3028										var res_msg = "Please enter the OTP sent to '"+json.mail_to+"'";
3029									}
3030									$(".otp_mail").html(res_msg);
3031									$("#ContactOtpLoginNumber").focus();
3032									$("#ContactLoginEmailOtp").val('').show();
3033									$("#ContactLoginEmailOtp").prev().show();
3034									$("#ContactSigninOtpForm .simple_security").hide();
3035								}
3036								else
3037								{
3038									$(".otp_mail").html(json.message).addClass("error");
3039									$("#ContactOtpLoginEmail").focus();
3040									$(".resend_otp").hide();	
3041									$("#ContactLoginEmailOtp").val('').hide();
3042									$("#ContactLoginEmailOtp").prev().hide();	
3043									$("#ContactSigninOtpForm .simple_security").show();
3044									$("#ContactSigninOtpForm").find(".creload").trigger('click');
3045								}
3046								$(".login_otp_form_btn").show().attr("disabled",false);
3047							}
3048						});
3049					}
3050					else
3051					{
3052						$(".otp_mail").html(obj.message);
3053						$("#ContactSigninOtpForm").find(".creload").trigger('click');
3054						$(".login_otp_form_btn").show();
3055					}
3056				}
3057			});
3058		}
3059	}
3060});
3061
3062function otp_counter()
3063{
3064	$(".login_otp_form_btn").attr('disabled',false);
3065	var counter = 120;
3066	var interval = setInterval(function() {
3067		if($("#ContactLoginEmailOtp").is(":visible")==1)
3068		{
3069		    counter--;
3070		    if (counter <= 0) {
3071		     	clearInterval(interval);
3072		      	$('#otp_counter').text('');
3073				$(".login_otp_form_btn").attr('disabled',true);
3074		      	$(".resend_otp").show();
3075		        return;
3076		    }else{
3077		    	var minutes = "00";
3078		    	if( parseInt(counter/60) >=1 )
3079		    	{
3080		    		var minutes = "01";
3081		    	}
3082		    	var counter_html = minutes+":"+(counter%60)+" Seconds";
3083		    	$('#otp_counter').html(counter_html);
3084		    }
3085		}
3086	}, 1000);
3087}
3088
3089$(document).ready(function () {
3090	var owl = $('.one-slide-anim');
3091	if (owl.length > 0) {
3092		owl.owlCarousel({
3093			items: 1,
3094			nav: owl.children().length > 1,
3095			loop: owl.children().length > 1,
3096			dots: false,
3097			autoplay: true,
3098			smartSpeed: 900,
3099			autoplayHoverPause: true,
3100			navText: ['<i class="fa fa-angle-left"></i>', '<i class="fa fa-angle-right"></i>']
3101		});
3102	}
3103	var testimonial = $('.home-testimonials');
3104	if (testimonial.length > 0) {
3105		testimonial.owlCarousel({
3106		loop: true,
3107		items: 24,
3108		autoplay: true,
3109		dots: false,
3110		nav: true,
3111		margin: 30,
3112		autoplayHoverPause: true,
3113		navText: ["<span class='fa fa-chevron-left'></span>","<span class='fa fa-chevron-right'></span>"],
3114		responsive: {
3115			0: {
3116				items: 1
3117			},
3118			480: {
3119				items: 1
3120			},
3121			768: {
3122				items: 2
3123			},
3124			1050: {
3125				items: 3
3126			}
3127		}
3128		});
3129	}
3130	var testimonial = $('.home-testimonial');
3131	if (testimonial.length > 0) {
3132			console.log('call HT Slider');
3133			$(testimonial).each(function(i) {
3134				let ifMultiple = false;
3135				$TripsSlider = $(this);
3136				if($TripsSlider.children('.item').length > 1) {
3137				ifMultiple = true;
3138				}
3139				$TripsSlider.owlCarousel({
3140				loop   : ifMultiple,
3141				nav    : true,
3142				autoplay: true,
3143				dots: false,
3144				margin: 30,
3145				autoplayHoverPause: true,
3146				navText: ["<span class='fa fa-chevron-left'></span>","<span class='fa fa-chevron-right'></span>"],
3147				responsive: {
3148					0: {
3149						items: 1
3150					},
3151					480: {
3152						items: 1
3153					},
3154					768: {
3155						items: 2
3156					},
3157					1050: {
3158						items: 2
3159					}
3160				}
3161				})
3162			});
3163		
3164	}
3165 });
3166 var SLen = $('.logoticker').children().length;
3167$(document).ready(function() {
3168	call_Carousel();
3169	autocomplete_search();
3170
3171		AftercallSlickSlider();
3172
3173});
3174$(document).on('keyup', '.productSearch', function(event){
3175	if($(this).val().length>=3)
3176	{
3177	   $(this).addClass("loading");
3178	}else{
3179		$(this).removeClass("loading");
3180	}
3181});
3182$(document).on('keypress', '.productSearch', function(event){
3183	if (event.keyCode === 10 || event.keyCode === 13) {
3184		$(this).addClass("loading");
3185		$(this).next(".productSearch_btn").trigger("click");
3186		event.preventDefault();
3187	}
3188});
3189
3190$(document).on('click', '.productSearch_btn', function(){
3191	$(this).prev().addClass("loading");
3192	if ($(this).prev().val().length < 3) {
3193		
3194		$.notify({
3195			title: "<strong>Search</strong> ",
3196			icon: 'fa fa-search',
3197			message: " please make sure the input is above 3 characters long"
3198		}, {
3199			timer: 1000,
3200			type: 'warning',
3201			animate: {
3202				enter: 'animated lightSpeedIn',
3203				exit: 'animated lightSpeedOut'
3204			}
3205		});
3206		
3207		$(this).removeClass("loading");
3208	} else {
3209		$(this).prev("#productSearch,.productSearch").focus();
3210		$(this).prev("#productSearch,.productSearch").trigger("keydown");
3211	}
3212});
3213function autocomplete_search()
3214{
3215	if($("#productSearch").length>0 || $(".productSearch").length>0)
3216    {
3217    	$("#productSearch,.productSearch").autocomplete({
3218			source: BASE_PATH + '/api/search/',
3219			minLength: 3,
3220			autoFocus: true,
3221			delay: 1000,
3222			open: function( event, ui ) {
3223				$("#productSearch,.productSearch").removeClass("loading");
3224			},
3225			create: function () {
3226				var i = 0;
3227				$(this).data('ui-autocomplete')._renderItem = function (ul, item) {
3228					let path = BASE_PATH + '/products/' + item.handle;
3229					let price = Number(item.price);
3230					var html = '';
3231					if (item.handle) html += '<a href="' + path + '">';
3232					html += '<div class="row">';
3233					html += '<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">';
3234					html += '<div class="col-xs-2 col-sm-2 col-md-2 col-lg-2">';
3235					if (item.image) html += '<img src="' + item.image + '" width="40px" alt="product">';
3236					html += '</div>';
3237					html += '<div class="col-xs-10 col-sm-10 col-md-10 col-lg-10">';
3238					html += '<p class="autocomplete-product-para"><span class="autocomplete-product-title">' + item.title + '</span>';
3239					if (item.price) html += ' - $' + price.toFixed(2);
3240					html += '</p>';
3241					html += '</div>';
3242					html += '</div>';
3243					html += '</div>';
3244					if (item.handle) html += '</a>';
3245					return  $('<li>').append(html).appendTo(ul);
3246					i++;
3247				}
3248				// console.log('Create', res, ui);
3249				$('.productSearch').removeClass('loading');
3250			},
3251			response: function(res, ui) {
3252				$('.productSearch').removeClass('loading');
3253				// console.log('response', res, ui);
3254			},
3255			appendTo: "#Resultcontainer"
3256		});		
3257	}
3258}
3259function call_Carousel() {	
3260	if ($(".owl-carousel.owl-theme").length > 0) {
3261        carousel_plugin(".owl-carousel.owl-theme",1);
3262    }	
3263    if ($("#spn_sc_slider_1").length > 0) 
3264    {
3265        carousel_plugin("#spn_sc_slider_1",2);
3266    }
3267    if ($("#spn_sc_slider_2").length > 0) 
3268    {
3269        carousel_plugin("#spn_sc_slider_2",2);
3270    }
3271    if ($("#spn_sc_slider_5").length > 0) 
3272    {
3273        carousel_plugin("#spn_sc_slider_5",2);
3274    }
3275    
3276    if($(".pics-carousel").length>0)
3277    {
3278    	carousel_plugin(".pics-carousel",3);	
3279    }
3280    if($(".quotes-carousel").length>0)
3281    {
3282    	carousel_plugin(".quotes-carousel",3);	
3283    }
3284    if($(".clients-carousel").length>0)
3285    {
3286    	carousel_plugin(".clients-carousel",3);	
3287    }
3288    
3289    if($(".team-carousel").length>0)
3290    {
3291    	carousel_plugin(".team-carousel",4);		
3292    }
3293    if($(".services-carousel").length>0)
3294    {
3295    	carousel_plugin(".services-carousel",4);		
3296    }
3297    if($(".testimonials-carousel").length>0)
3298    {
3299    	carousel_plugin(".testimonials-carousel",4);		
3300    }
3301    
3302    if($('#owl').length>0)
3303    {
3304    	carousel_plugin("#owl2",5);	
3305    }
3306    if($('#owl2').length>0)
3307    {
3308    	carousel_plugin("#owl2",5);	
3309    }
3310    
3311    if ($(".service-carousel").length>0) {
3312    	carousel_plugin(".service-carousel",6);	
3313    }
3314	
3315}
3316function carousel_plugin(obj,arg){
3317	var currentli = $('.home-carousel').parent().attr('id');	
3318	var carousel = $('#head').children().attr('id');
3319	var carousel_five1 = $('#head').children().attr('id');
3320	var carousel_five = $('#home_courses').children().attr('id');
3321	var carousel_three = $('#head').children().attr('id');
3322	var carousel_travel_three = $('#home_trip_three').children().attr('id');
3323	var margin = $('#head').children().attr('id');
3324	var margin5px = $('#head').children().attr('id');
3325	console.log(margin);
3326	if(arg==1){
3327		if(asidebar==true){
3328			asidebar = false;
3329			var resp = { 0	: {	items: 1	},480	: {	items: 1	},768	: {	items: 1	},1050: {	items: 1	} };
3330		}else if(currentli == "carousel_header_top")
3331		{
3332			var resp = { 0	: {	items: 1	},480	: {	items: 1	},768	: {	items: 3	},1050: {	items: 3	} };
3333		}else if(carousel_three == "home_carousel_three")
3334		{
3335			var resp = { 0	: {	items: 1	},480	: {	items: 1	},768	: {	items: 2	},1050: {	items: 3	} };
3336		}else if(carousel_travel_three == "home_carousel_trip")
3337		{
3338			var resp = { 0	: {	items: 1	},480	: {	items: 1	},768	: {	items: 2	},1050: {	items: 3	} };
3339		}else if(carousel == "home_carousel_five")
3340		{
3341			var resp = { 0	: {	items: 1	},480	: {	items: 1	},768	: {	items: 3	},1050: {	items: 5	} };
3342		}else if(carousel_five == "home_carousel_five")
3343		{
3344			var resp = { 0	: {	items: 1	},480	: {	items: 1	},768	: {	items: 3	},1050: {	items: 5	} };
3345		}else if(carousel_five1 == "westshorescuba")
3346		{
3347			var resp = { 0	: {	items: 1	},480	: {	items: 1	},768	: {	items: 3	},1050: {	items: 5	} };
3348		} else if(margin5px == "margin5pxtahoe")	
3349		{	
3350			var resp1 = { 0	: {	items: 1	},480	: {	items: 1	},768	: {	items: 3	},1050: {	items: 4	} };	
3351		} else{
3352			if($(obj).width()<1050){
3353				var resp = { 0	: {	items: 1	},480	: {	items: 1	},768	: {	items: 2	},1050: {	items: 3	} };	
3354			}else{
3355				var resp = { 0	: {	items: 1	},480	: {	items: 1	},768	: {	items: 2	},1050: {	items: 4	} };
3356			}
3357		}
3358		if(margin == "divephoto"){
3359		$(obj).owlCarousel({
3360	        nav 		: $(obj).children().length > 1,
3361        	loop 		: $(obj).children().length > 1,
3362	        items 		: 24,	
3363	        margin 		: 10,	
3364	        dots 		: false,
3365	        navText 	: ["<span class='fa fa-chevron-left'></span>", "<span class='fa fa-chevron-right'></span>"],
3366	        responsive 	: resp
3367	    });
3368		}
3369		else if(carousel_five1 == "westshorescuba"){
3370				$(obj).each(function(i) {
3371					let ifMultiple = false;
3372					$coursesSlider = $(this);
3373					if($coursesSlider.children('.item').length > 1) {
3374					ifMultiple = true;
3375					}
3376					$coursesSlider.owlCarousel({
3377					loop   : ifMultiple,
3378					nav    : ifMultiple,
3379					items  : 24,	
3380					margin : 5,	
3381					dots 	 : false,
3382					navText: ["<span class='fa fa-angle-left'></span>", "<span class='fa fa-angle-right'></span>"],
3383					responsive : resp
3384					})
3385				})
3386		}
3387		else if(margin5px == "margin5px"){
3388		$(obj).owlCarousel({
3389	        nav 		: $(obj).children().length > 1,
3390        	loop 		: $(obj).children().length > 1,
3391	        items 		: 24,	
3392	        margin 		: 5,	
3393	        dots 		: false,
3394	        navText 	: ["<span class='fa fa-angle-left'></span>", "<span class='fa fa-angle-right'></span>"],
3395	        responsive 	: resp
3396	    });
3397		} else if(margin5px == "margin5pxtahoe"){
3398		$(obj).owlCarousel({
3399	        nav 		: $(obj).children().length > 1,
3400        	loop 		: $(obj).children().length > 1,
3401	        items 		: 24,	
3402	        margin 		: 5,	
3403	        dots 		: false,
3404	        navText 	: ['<i class="fa fa-angle-left" aria-hidden="true"></i>', '<i class="fa fa-angle-right" aria-hidden="true"></i>'],
3405	        responsive 	: resp1
3406	    });
3407		}
3408		else{
3409			console.log('Calll Trip')
3410				$(obj).each(function(i) {
3411					let ifMultiple = false;
3412					$coursesSlider = $(this);
3413					if($coursesSlider.children('.item').length > 1) {
3414					  ifMultiple = true;
3415					}
3416					$coursesSlider.owlCarousel({
3417					  loop   : ifMultiple,
3418					  nav    :true,
3419					  items  : 24,	
3420					  margin : 30,	
3421					  dots 	 : false,
3422					  navText: ["<span class='fa fa-chevron-left'></span>", "<span class='fa fa-chevron-right'></span>"],
3423					  responsive : resp
3424					})
3425				})	
3426				$('.lozad').css('display', 'block');
3427		}
3428	}
3429	else if(arg==2)
3430	{
3431		$(obj).owlCarousel({
3432            nav 		: $(obj).children().length > 1,
3433        	loop 		: $(obj).children().length > 1,
3434            items   	: 24,	
3435            dots    	: false,	
3436            margin  	: 30,
3437            navText  	: ["<span class='fa fa-chevron-left'></span>","<span class='fa fa-chevron-right'></span>"],
3438            responsive 	: {
3439                0	: {	items: 1	},480	: {	items: 2	},768	: {	items: 3	},1050: {	items: 3	}
3440            }
3441        });
3442	}
3443	else if(arg==3)
3444	{
3445		$(obj).owlCarousel({
3446	        autoPlay: 5000,
3447	        slideSpeed: 500,
3448	        items: 1,
3449	        itemsDesktop: [1199, 1],
3450	        itemsDesktopSmall: [979, 1],
3451	        itemsTablet: [768, 1],
3452	        itemsMobile: [479, 1],
3453	        autoHeight: false,
3454	        pagination: false,
3455	        navigation: true,
3456	        transitionStyle: "fade",        
3457	        navigationText: [
3458	            "<i class='fa fa-angle-left'></i>",
3459	            "<i class='fa fa-angle-right'></i>"
3460	        ],
3461	    });
3462	}
3463	else if (arg==4)
3464	{
3465		$(obj).owlCarousel({
3466	        autoPlay: false,
3467	        slideSpeed: 500,
3468	        items: 4,
3469	        itemsDesktop: [1199, 4],
3470	        itemsDesktopSmall: [979, 3],
3471	        itemsTablet: [768, 2],
3472	        itemsMobile: [479, 1],
3473	        autoHeight: false,
3474	        pagination: true,
3475	        navigation: false,
3476	        transitionStyle: "fade",        
3477	        navigationText: [
3478	            "<i class='fa fa-angle-left'></i>",
3479	            "<i class='fa fa-angle-right'></i>"
3480	        ],
3481    	});
3482	}
3483	else if (arg==5)
3484	{
3485		$(obj).owlCarousel({
3486	        nav    : true,
3487	        loop    : true,
3488	        items     : 24,
3489	        margin  : 30,
3490	        dots    : false,
3491	        autoplay:true,
3492	        autoplayTimeout:3000,
3493	        autoplayHoverPause:true,
3494	        navText  : ["<span class='icon-arrow-left10'></span>","<span class='icon-uniE936'></span>"],
3495	        responsiveClass: true,
3496	        responsive 	: {
3497	        	0	: {	items: 1	},480	: {	items: 2	},768	: {	items: 4	},1050: {	items: 4	}
3498	        }
3499	    });
3500	}
3501	else if(arg==6)
3502	{
3503		$(".service-carousel").owlCarousel({
3504			loop: true,
3505			items: 24,
3506			autoplay: true,
3507			dots: false,
3508			margin: 30,
3509			nav: true,
3510			smartSpeed: 800,
3511			autoplayHoverPause: true,
3512			navText: ['<i class="fa fa-angle-left"></i>', '<i class="fa fa-angle-right"></i>'],
3513			responsive: {
3514				0: {
3515					items: 1
3516				},
3517				480: {
3518					items: 1
3519				},
3520				768: {
3521					items: 2
3522				},
3523				1050: {
3524					items: 3
3525				}
3526			}
3527		});
3528	}
3529	
3530	
3531}
3532
3533$(document).on('change', '.dive_states ', function() {
3534	$(".dive_states1").val($(".dive_states").val());	
3535});
3536$(document).on('change', '.dive_country ', function() {
3537	var proceed = true;
3538	var country = $(this).val();
3539		if(country!="US" && country!="CA" && country!="AU")
3540		{
3541			$(".dive_states").val("");
3542			$(".dive_states").parent().hide();$(".dive_states").hide();
3543			if($("#remove_duplicitous_shipping_address_step").length>0 && $("#remove_duplicitous_shipping_address_step").val()==1)
3544			{
3545				$(".dive_states1").removeClass("hide");
3546			}
3547			proceed = false;
3548		}else{
3549			$(".dive_states").parent().show();$(".dive_states").show();
3550			if($("#remove_duplicitous_shipping_address_step").length>0 && $("#remove_duplicitous_shipping_address_step").val()==1)
3551			{
3552				$(".dive_states1").addClass("hide");
3553			}
3554			proceed = true;
3555		}
3556	
3557	if(proceed==true)
3558	{
3559	    $.ajax({
3560	        url: BASE_PATH + '/ajax/getStates/',
3561	        type: "post",
3562	        data: {
3563	            'country': country
3564	        },
3565	        success: function(result) {
3566	            if(result!=''){
3567	                $(".dive_states").children("option").remove();
3568	                $(".dive_states").append(result);
3569		        }
3570	        }
3571	    });
3572	}
3573	
3574});
3575$(document).ready(function(){
3576    $(".featured_products ul li a").each(function(){
3577        $(this).attr("href", "javascript:void(0);");
3578    });
3579	
3580});	
3581$(window).on('load', function(){
3582	if($('.pix_sc_slider3').length){
3583		$('.pix_sc_slider3').flexslider({
3584			animation: "slide",
3585			pauseOnHover: true,
3586			smoothHeight: true,
3587			directionNav: false
3588		});
3589	}
3590});
3591$(document).ready(function(){    
3592        $("span.description-para .with-description").prev().addClass("with-description-display");
3593        $("span.short-description .with-description").prev().addClass("with-description-display");
3594});
3595$(document).ready(function(){
3596	if($("#popup_model").length>=1 && !inIframe()){
3597		//document.cookie = "POPUP=true; expires=Fri, 04 June 2021 12:00:00 UTC";
3598		var POPUP = false;//getCookie('POPUP');
3599		if(POPUP==false && SF_POPUP!=0){
3600			setTimeout(function(){
3601				$(window).scroll(function() { return false; });
3602				$("#popup_model").show();
3603			},10000);
3604		}
3605	}
3606
3607	if($("#course_location_model").length>=1 && !inIframe()){
3608		$(window).scroll(function() { return false; });
3609		$("#course_location_model").show();
3610	}
3611
3612});
3613function close_course_location_popup(link='')
3614{
3615  	$("#course_location_model").hide();
3616}
3617function close_sf_popup(link='')
3618{
3619  	$.ajax({
3620      url: BASE_PATH + '/ajax/setSessionPopup',
3621      type: "post",
3622      success: function(result) {
3623      		if(link!='')
3624      		{
3625    			$("#popup_model").hide();
3626    			window.location.href= link;  			
3627      		}
3628      }
3629  	});  
3630  	$("#popup_model").hide();
3631}
3632function inIframe()
3633{
3634    try {
3635        return window.self !== window.top;
3636    } catch (e) {
3637        return true;
3638    }
3639}
3640// DS-9340
3641function calSlickSlider() {
3642	
3643		if($('#customerLogoSlider').length>0){
3644			$('#customerLogoSlider').slick({
3645				infinite: true,
3646				autoplay: true,
3647				autoplaySpeed: 800,
3648				speed: 1400,
3649				slidesToShow:  12,
3650				slidesToScroll:  12,
3651				slidesToScroll: true,
3652				swipeToSlide: true,
3653				responsive: [
3654					{
3655					  breakpoint: 640,
3656					  settings: {
3657						slidesToShow: 1,
3658						slidesToScroll: 1
3659					  }
3660					}
3661				  ]
3662		  	}).on('wheel', function (e) {
3663				e.preventDefault();
3664				if (e.originalEvent.deltaY < 0) {
3665				$(this).slick('slickPrev');
3666				} else {
3667				$(this).slick('slickNext');
3668				}
3669		  	});			
3670		}
3671		else{
3672			return false;
3673		}
3674	
3675	
3676
3677	  $('#customerLogoSlider').addClass('slickRowCss')
3678   
3679}
3680function AftercallSlickSlider() {
3681	console.log('logoticker Lenth::', SLen, SLen >= 4 ? true : false);
3682	
3683		if($('#customerLogoSlider').length>0){
3684			$('#customerLogoSlider').slick({
3685				infinite: true,
3686				autoplay: true,
3687				autoplaySpeed: 800,
3688				speed: 1400,
3689				slidesToShow: SLen - 1,
3690				slidesToScroll: true,
3691				swipeToSlide: true,
3692				responsive: [
3693					{
3694					  breakpoint: 640,
3695					  settings: {
3696						slidesToShow: 1
3697					  }
3698					}
3699				  ]
3700		  	}).on('wheel', function (e) {
3701				e.preventDefault();
3702				if (e.originalEvent.deltaY < 0) {
3703				$(this).slick('slickPrev');
3704				} else {
3705				$(this).slick('slickNext');
3706				}
3707		  	});			
3708		}
3709		else{
3710			return false;
3711		}
3712	
3713	
3714
3715	  $('#customerLogoSlider').addClass('slickRowCss')
3716   
3717}
3718
3719function price_filter_new() {
3720	var price = {};
3721	price.min = $("#amount-min").val();
3722	price.max = $("#amount-max").val();
3723	console.log("priceee",price);
3724	filter_products.price = price;
3725	load_products();
3726}
3727$(document).on('keypress', '.allowdec', function () {
3728	if($("#speedup_product_list").length>0 && $("#speedup_product_list").val()==1)  //FeatureTag
3729	{
3730	if ((event.which != 46 || $(this).val().indexOf('.') != -1)&& (event.which < 48 || event.which > 57))
3731	{
3732		if((event.which != 46 || $(this).val().indexOf('.') != -1))
3733		{
3734		  //alert('Multiple Decimals are not allowed');
3735		}
3736		event.preventDefault();
3737	}
3738	if(this.value.indexOf(".")>-1 && (this.value.split('.')[1].length > 1))
3739	{
3740		//alert('Two numbers only allowed after decimal point');
3741		//event.preventDefault();
3742	}
3743	}
3744});
3745if($("#create_a_widget_to_display_all_the_dates_for_a_specific_course_group").length>0 && $("#create_a_widget_to_display_all_the_dates_for_a_specific_course_group").val()==1)  //FeatureTag
3746{
3747	$(document).on('click', '.expander-icon', function () {
3748	    const $icon = $(this);
3749	    const $row = $icon.closest('tr');
3750	    const $expandRow = $row.next('.expand-row');
3751
3752	    // Collapse all other expanded rows smoothly
3753	    $('.expand-row').not($expandRow).slideUp(300);
3754	    $('.expander-icon').not($icon).removeClass('fa-minus-square').addClass('fa-plus-square');
3755
3756	    // Toggle the clicked row smoothly
3757	    $expandRow.slideToggle(300);
3758
3759	    // Toggle icon
3760	    $icon.toggleClass('fa-plus-square fa-minus-square');
3761	});
3762}

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.