<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">var page_count=1;
var pg_style=0;
var price=[0,1000000];
var operation=0;
var nocategory=0;
		$("li.cz-filter-item").click(function() {
		var input = $(this).find("input:checkbox");
		var input1 = $(input).parent().closest('.cz-filter-item');
		if (operation==2)
		{
			operation=0;
		}
		
		if($(input).is(":checked") == true &amp;&amp; operation==0)
		{ 	
			//$(this).parent().append($(this)); 
			// const el = new SimpleBar(document.getElementById('cat_list'));
			//el.scrollTop = 0;
		//insertAfter(document.getElementById('myId'), '&lt;p&gt;after&lt;/p&gt;');
		//$( this ).insertAfter( $( input1 ) );
		}
		if($(input).is(":checked") == false &amp;&amp; operation==0)
		{ 
			$(this).parent().prepend($(this)); 
			
		}
		operation++;
  });
		function show_record(id,style){
			page_count=id;
			ss(page_count,'sort');
		}
		function sort(){
			ss(1,'sort');
		}
		function sshow_record(id,style){
			page_count=id;
			ssearch(page_count,'sort');
		}
		function ssort(){
		ssearch(1,'sort');
		}
		function change_view(style){
			var modal = document.getElementById("myModal");
			modal.style.display = "block";
			pg_style=style;
				if (style==1){
					$("#grid_list").addClass("d-none");
					$("#prod_list").removeClass("d-none");
					$("#button_grid").removeClass("bg-light text-orange disabled opacity-100").addClass("nav-link-light");
					$("#button_list").addClass("bg-light text-orange disabled opacity-100 mr-2");
				}
				else{
					$("#prod_list").addClass("d-none");
					$("#grid_list").removeClass("d-none");
					$("#button_list").removeClass("bg-light text-orange disabled opacity-100").addClass("nav-link-light");
					$("#button_grid").addClass("bg-light text-orange disabled opacity-100 mr-2");
				}			
			modal.style.display = "none";
		}
		function ss(page_count,source, brand){
			var cat;
			cat=$("#cat").val();
			var cat_sec;
			cat_sec=$("#cat_sec").val();
			var action = 'data'; 
			var category = get_filter_data('category');
			if (source=='max' || source=='sort'){
				var price_op='filtr';
				price[1]=$("#max").val();
				price[0]=$("#min").val();
				}
				else
				{
				price=[0,1000000];
				}
			if (category=="")
				{
				category=get_filter_data_empty('category');
				if ( ($("#max").val()!=$("#bmax").val() &amp;&amp; nocategory==1)|| ($("#min").val()!=$("#bmin").val() &amp;&amp; nocategory==1))
				{
					price[1]=$("#max").val();
					price[0]=$("#min").val();
				}
				if (nocategory==0)
				{
					price=[0,1000000];
					nocategory=1;
				}
				else
				{			
					price[1]=$("#max").val();
					price[0]=$("#min").val();
				}
			}
			else
			{
				nocategory=0;
			}
			
			if (!(source=='all'))
			{
			var make = get_filter_data('make');	
			if (brand!=1)
				{
					if (brand==2)
					{
						var cond= get_filter_data('cond');			
					}
					else
					{
						var vstd= get_filter_data('vstd');	
						var cond= get_filter_data('cond');			
					}
				}
			}
			var sorting = $("#sorting").val();
			if (typeof sorting === 'undefined')
			{
				sorting='licznik desc';
			}
			const queryString = window.location.search;
			const urlParams = new URLSearchParams(queryString);
			const cname = urlParams.get('cname')
			var modal = document.getElementById("myModal");
			modal.style.display = "block";
			//console.log (category);
			$.ajax({
				url:'/pages/category-grid-content.php?cname='+cname+'&amp;sorting='+sorting+'&amp;pg='+page_count+'&amp;view='+pg_style,
				method: 'POST',
				data: {action: action, cat:cat,cat_sec:cat_sec, price_min:price[0], price_max:price[1], make:make,category:category, vstd:vstd, cond:cond},
				success:function(response){
				$("#category_page").html(response);
				}
			});
			$.ajax({
				url:'/pages/category-grid-sidebar.php?cname='+cname+'&amp;cat='+cat,
				method: 'POST',
				data: {action: action, cat:cat,cat_sec:cat_sec, price_min:price[0], price_max:price[1], price_op:price_op, make:make,category:category, vstd:vstd, cond:cond},
				success:function(response){
				$("#brand_price").html(response);
				modal.style.display = "none";
				}
			});
			
			
		$('html, body').animate({scrollTop:220}, 'slow');
		}
			
			
		function ssearch(page_count,source, brand){
			var cat="";
			//cat=$("#cat").val();
			var cat_sec=get_filter_data('scategory2');
			var action = 'data'; 
			var category = get_filter_data('scategory');
			if (source=='max' || source=='sort'){
				var price_op='filtr';
				price[1]=$("#max").val();
				price[0]=$("#min").val();
				}
				else
				{
				price=[0,1000000];
				}
			if (!(source=='all'))
			{
				var make = get_filter_data('smake');
				if (brand!=1)
				{
					if (brand==2)
					{
						var cond= get_filter_data('scond');			
					}
					else
					{
						var vstd= get_filter_data('svstd');	
						var cond= get_filter_data('scond');			
					}
				}
			}
			var sorting = $("#sorting").val();
			if (typeof sorting === 'undefined')
			{
				sorting='licznik desc';
			}
			


			var params = window.location.pathname.split('/').slice(1);
			//console.log(window.location.pathname);
			
			//var queryString = window.location.search;
			//var urlParams = new URLSearchParams(queryString);
			
		
			if (params[3]!=undefined)
			{
				var searchtxt = params[3];
			}
				else
			{
				var url1 = new URL(document.URL);
				var urlsp = url1.searchParams;
				var searchtxt = encodeURI(urlsp.get("keyword"));
			}	
			console.log( "search:"+searchtxt);
			const search=searchtxt;
			var modal = document.getElementById("myModal");
			modal.style.display = "block";
			$.ajax({
				url:'/pages/category-grid-content.php?keyword='+search+'&amp;sorting='+sorting+'&amp;pg='+page_count+'&amp;view='+pg_style,
				method: 'POST',
				data: {action: action, cat:cat,cat_sec:cat_sec, price_min:price[0], price_max:price[1], make:make,category:category, vstd:vstd, cond:cond},
				success:function(response){
				$("#category_page").html(response);
				}
			});
			$.ajax({
				url:'/pages/search-sidebar.php?keyword='+search+'&amp;cat='+cat,
				method: 'POST',
				data: {action: action, cat_sec:cat_sec, price_min:price[0], price_max:price[1], price_op:price_op, make:make,category:category, vstd:vstd, cond:cond},
				success:function(response){
				$("#brand_price").html(response);
				modal.style.display = "none";
				}
			});
		$('html, body').animate({scrollTop:220}, 'slow');
		}
		
		
		
		function get_filter_data(text_id){
			var filterdata = [];
			$('.'+text_id+':checked').each(function(){
			filterdata.push($(this).val());	
			});
			return filterdata;
		}
		function get_filter_data_empty(text_id){
			var filterdata = [];
			$('.'+text_id+':not(:checked)').each(function(){
			filterdata.push($(this).val());	
			});
			return filterdata;
		}
		
		
		function button_enable(id){
			document.getElementById(id).disabled = false; 
			$("#button_filtr").removeClass("btn-outline-secondary disabled").addClass("btn-light-primary-2");
		}
   $(document).ready(function () {
		$(".cz-range-slider-ui").on("mouseup keydown touchend", function(){
		button_enable('button_filtr');
		});
		
		
		$(".product").click(function() {
		ss(1);	
		});
		$(".brand").click(function() {
		ss(1,'',1);	
		});
		$(".product1").click(function() {
		ss(1,'max');	
		});
		$(".product2").click(function() {
		ss(1,'all');	
		});
		$(".cond").click(function() {
		ss(1,'',2);	
		});
		$(".sproduct").click(function() {
		ssearch(1);	
		});
		$(".sbrand").click(function() {
		ssearch(1,'',1);	
		});
		$(".sproduct1").click(function() {
		ssearch(1,'max');	
		});
		$(".sproduct2").click(function() {
		ssearch(1,'all');	
		});
		$(".scond").click(function() {
		ssearch(1,'',2);	
		});
    });
	
//login-loguot
			
				function login(target){
				$('#signin-tab').submit(function(event) {
				event.preventDefault();
				});
					if ($('#signin-tab')[0].checkValidity() === false) {
					event.stopPropagation();
					} 
					else 
					{	
					var stay=0;
					if ($("#si-remember").is(":checked") == true){
						stay=1;
					}
				$.ajax({
					type: "POST",
					dataType: "json",
					url: '/pages/sign-in.php',
					data: {
						task: "login",
						username: $("#si-email").val(),
						password: $("#si-password").val(),
						stay: stay,
						},
					success: function(response)
						{
							if (response.status === 'Login') {
							$('#signin_content').html(response.res+response.logout_label_inside);
							$("#login_label").html("&lt;small&gt;Hello, "+response.name+"&lt;/small&gt;My Account");
							$("#login_label_inside").hide();
							$(".logout_label_inside").html(response.logout_label_inside);
								setTimeout(() =&gt; {location.reload();}, 1000);	
				
							
							}
							else {
								$("#si-status").addClass("status-error");								
								$("#si-status").html('Invalid Credentials or your account is not yet active');
								setTimeout(() =&gt; { $("#si-status").html(" "); $("#si-status").removeClass("status-error");}, 6000);	
							
							}
						}
				});
					}
				}
		
		function logout(){
			$.ajax({
					type: "POST",
					url: '/pages/sign-in.php',
					data: {
						task: "logout",
						},
						success: function(response)
						{
						$("#signin_content").html(response);
						$("#login_label").html("&lt;small&gt;Hello, Sign in&lt;/small&gt;Your Account");
						$("#login_label_inside").show();
						$("#logout_label_inside").hide();
						location.reload(); 						
						}
				});
		}
		
			
		function recovery_psw(){
			$('#pr-tab').submit(function(event) {
				event.preventDefault();
				});
					if ($('#pr-tab')[0].checkValidity() === false) {
					event.stopPropagation();
					} 
					else 
					{	
					$("#btn-pr").prop('disabled', true);
					$("#btn-pr").html("working, please wait...");
						$.ajax({
						type: "POST",
						url: '/pages/password-recovery.php',
						data: {
							task: "sendmail",
							recoveremail: $("#recover-email").val()
							},
						success: function(response)
							{
								$("#main-div").html(response);
							}
						});
					
					}
		}		
		
		function save_psw(hash){
			$('#pr-tab-psw').submit(function(event) {
				event.preventDefault();
				});
					if ($('#pr-tab-psw')[0].checkValidity() === false || $("#psw-password").val()!=$("#psw-password-confirm").val()) {
					event.stopPropagation();
					$("#btn-psw").html("password not match");
					setTimeout(() =&gt; {$("#btn-psw").html("save new password");}, 2000);		
					} 
					else 
					{	
					$("#btn-psw").prop('disabled', true);
					$("#btn-psw").html("working, please wait...");
						$.ajax({
						type: "POST",
						url: '/pages/password-recovery.php',
						data: {
							task: "save_psw",
							password: $("#psw-password").val(),
							hash: hash			
							},
						success: function(response)
							{
								$("#main-div").html(response);
								setTimeout(() =&gt; {window.location.href = '/page/my-account/';}, 1000);		
							}
						});
					
					}
		}
		
		function send_again_rec_pass(id){
					$("#send_again_rec_pass_button").prop('disabled', true);
					$("#send_again_rec_pass_button").html("working, please wait...");
					setTimeout(() =&gt; {
					$.ajax({
					type: "POST",
					dataType: "json",
					url: '/pages/password-recovery.php',
					data: {
						id: id,
						task: "send",
						},
					success: function(response)
						{
							if (response.status === 'OK') 
							{
								setTimeout(() =&gt; {
								$("#send_again_rec_pass_info").show();
								$("#send_again_rec_pass_info").html("Password reset link was sent again");
								$("#send_again_rec_pass_button").prop('disabled', false);
								$("#send_again_rec_pass_button").html("Send again");
								}, 2000);
							}
							else
							{
								setTimeout(() =&gt; {
								$("#send_again_rec_pass_info").show();
								$("#send_again_rec_pass_info").html(response.status);
								$("#send_again_rec_pass_button").prop('disabled', false);
								$("#send_again_rec_pass_button").html("Send again");
								}, 2000);
							}
						}
					});
					},2000);
			}
		function newlogin(){
				$('#signup-tab').submit(function(event) {
				event.preventDefault();
				});		
		
				if ($('#signup-tab')[0].checkValidity() === false) {
				event.stopPropagation();
				} 
				else 
				{
					if ($("#su-password").val()==$("#su-password-confirm").val())
					{
					var maillist=0;
					if ($("#su-maillist").is(":checked") == true){
					maillist=1;	
					}
						
						$.ajax({
							type: "POST",
							dataType: "json",
							url: '/pages/sign-in.php',
							data: {
								task: "create_account",
								name:$("#su-name").val(),
								last_name: $("#su-last_name").val(),
								username: $("#su-email").val(),
								password: $("#su-password").val(),
								maillist: maillist
								},
							success: function(response)
								{	if (response.status === 'Login') {
									$("#signin_content").html(response.res);
									$("#login_label").html("&lt;small&gt;Hello, "+response.name+"&lt;/small&gt;Your Account");
									$("#login_label_inside").hide();
									$("#logout_label_inside").show();
									}
									if (response.status === 'NewLogin') {
										$("#czi-status").removeClass("status-error");
										$("#czi-status").addClass("status-success");	
										$("#czi-status").html("Please confirm your account by email.&lt;br&gt;We sent you a link to your email address provided");
										setTimeout(() =&gt; {location.reload();}, 8000);	
							
									}
									
									if (response.status === 'error') {
										$("#czi-status").addClass("status-error");								
										$("#czi-status").html('Invalid Credentials'+response.res);
										setTimeout(() =&gt; { $("#czi-status").html(" "); $("#czi-status").removeClass("status-error");}, 6000);	
									}
								}
							});
					}
					else
					{
						$("#czi-status").addClass("status-error");								
						$("#czi-status").html('Passwords do not match');
						setTimeout(() =&gt; { $("#czi-status").html(" "); $("#czi-status").removeClass("status-error");}, 6000);	
					}
				}
			}
			function update_cart_item(id,size){
					if (size=='n')
					{
						var qua=$("#quantity2_"+id).val();
					}
					else
					{
						var qua=$("#quantity2s_"+id).val();
					}
				$.ajax({
					type: "POST",
					url: '/pages/header-search-cart.php',
					data: {
						reload_cart: "update",
						id_item:id,
						quantity: qua
						},
					success: function(response)
						{
							$("#item_cart_"+id).remove();
							$("#cart_head").html(response);
							location.reload(); 	
						}
			});
			}
			function change_button_color(old_class,new_class,id){
			$("#"+id).removeClass(old_class);	
			$("#"+id).addClass(new_class);
			$("#"+id).attr('disabled',false);
			
			}
			function del_cart_item(id,price){
					$.ajax({
					type: "POST",
					url: '/pages/header-search-cart.php',
					data: {
						reload_cart: "del",
						id_item:id
						},
					success: function(response)
						{
							$("#item_cart_"+id).remove();
							$("#cart_head").html(response);
							//location.reload(); 	
							location.href="/page/cart/";
						}
					});
					$.ajax({
					type: "POST",
					url: '/pages/toolbar.php',
					data: {
						reload_cart: "add",
						},
					success: function(response)
						{
							$("#tool_data").html(response);
						}
					});
			}
			function remove_all_item(){
					$.ajax({
					type: "POST",
					url: '/pages/header-search-cart.php',
					data: {
						reload_cart: "clear"
						},
					success: function(response)
						{
							$("#cart_head").html(response);
							$(".item_cart").remove();
							$("#cart_total").html("0.00");
							$("#shipping_coast").html("$ 0.00")
							$("#sales_tax").html("$ 0.00")
							$("#button_update").prop('disabled', true); 
							//location.reload(); 	
							window.location.href = '/page/cart/';
						}
					});
					$.ajax({
					type: "POST",
					url: '/pages/toolbar.php',
					data: {
						reload_cart: "add",
						},
					success: function(response)
						{
							$("#tool_data").html(response);
						}
					});
			}
			function add_cart_item(){
					$.ajax({
					type: "POST",
					url: '/pages/header-search-cart.php',
					data: {
						reload_cart: "add",
						},
					success: function(response)
						{
							$("#cart_head").html(response);
						}
					});
					$.ajax({
					type: "POST",
					url: '/pages/toolbar.php',
					data: {
						reload_cart: "add",
						},
					success: function(response)
						{
							$("#tool_data").html(response);
						}
					});
			}			
			function del_deal(sku,deal_id){
					$.ajax({
					type: "POST",
					dataType: "json",
					url: '/pages/cart.php',
					data: {
						task: "removedeal",
						sku:sku,
						deal_id:deal_id
						},
					success: function(response)
						{
							if (response.status === 'OK') 
							{
							
							setTimeout(() =&gt; {location.reload();}, 300);	
							}						
							
							if (response.status === 'error') 
							{
							console.log(response.info);
							}
						}
					});
			}			
			function del_offer(sku,id_offer){
					$.ajax({
					type: "POST",
					dataType: "json",
					url: '/pages/cart.php',
					data: {
						task: "removeoffer",
						sku:sku,
						id_offer:id_offer
						},
					success: function(response)
						{
							if (response.status === 'OK') 
							{
							
							setTimeout(() =&gt; {location.reload();}, 300);	
							}						
							
							if (response.status === 'error') 
							{
							console.log(response.info);
							}
						}
					});
			}
			function show_create_account(){
				$("#ch_login_signin").show();
				$("#ch_login_desc").hide();	
			}		
			function ch_newlogin(){
				$('#ch-signup-tab').submit(function(event) {
				event.preventDefault();
				});		
		
				if ($('#ch-signup-tab')[0].checkValidity() === false) {
				event.stopPropagation();
				} 
				else 
				{	
					if($("#ch-password").val()==$("#ch-password-confirm").val())
					{
							var maillist=0;
							if ($("#ch-maillist").is(":checked") == true){
							maillist=1;	
							}
						$.ajax({
							type: "POST",
							dataType: "json",
							url: '/pages/sign-in.php',
							data: {
								task: "create_account",
								name:$("#ch-name").val(),
								last_name: $("#ch-last_name").val(),
								username: $("#ch-email").val(),
								password: $("#ch-password").val(),
								maillist: maillist
								},
							success: function(response)
								{	if (response.status === 'Login') 
									{
										location.reload(); 	
									}
									
									if (response.status === 'NewLogin') {
										$("#ch-status").removeClass("status-error");
										$("#ch-status").addClass("status-success");	
										$("#ch-status").html("For verification please confirm your account using a link from an email we just sent you");
									}
									
									if (response.status === 'error') 
									{
										$("#ch-status").addClass("status-error");								
										$("#ch-status").html('Invalid Credentials'+response.res);
										setTimeout(() =&gt; { $("#ch-status").html(" "); $("#ch-status").removeClass("status-error");}, 6000);								
									}
								}
								
						
							});
					}
					else
					{
						$("#ch-status").addClass("status-error");								
						$("#ch-status").html('Invalid Credentials - passwords do not match');
						setTimeout(() =&gt; { $("#ch-status").html(" "); $("#ch-status").removeClass("status-error");}, 6000);	
					}
				}
			}
			
			$(document).ready(function() {
					  $('#order-details').on('show.bs.modal', function(e) {
						var order_id = $(e.relatedTarget).data('order_id');

						console.log ("order_id"+order_id);
						$.ajax({
						  type: 'post',
						  url: '/pages/order-details.php',
						  data: 'order_id=' +order_id,
						  success: function(data) {
							$('#order_details').html(data);
							
						   }
						});	
					  });
			});			
			
			$(document).ready(function() {
			  $('#order-tracking').on('show.bs.modal', function(e) {
				 var order_nb = $(e.relatedTarget).data('ordernumber');
				var order_id = $(e.relatedTarget).data('order_id');
				$.ajax ({
				  type: 'post',
				  url: '/pages/order-tracking.php',
				  data: {
					  transaction_id: order_id,
					  task: "check_order",
						},
				  success: function(data) {
					  $('#order_number').html("Order W"+order_nb);
					  console.log(order_nb);
					$('#order_tracking').html(data);
				   }
				});	
			  });
			});
			
			function check_order(){
				$('#cz-checkorder-tab').submit(function(event) {
				event.preventDefault();
				});
					if ($('#cz-checkorder-tab')[0].checkValidity() === false) {
					event.stopPropagation();
					} 
					else
					{
						$("#orderButton").prop('disabled', true);
						$.ajax({
							type: "POST",
							//dataType: "json",
							url: '/pages/order-tracking.php',
							data: {
								task: "check_order",
								orderEmail: $("#orderEmail").val(),
								orderNumber: $("#orderNumber").val(),
								orderZip: $("#orderZip").val()
								},
							success: function(response)
								{	
									if (response!="stop")
									{
										$("#orderContent").html(response);
									}
									else
									{
										$("#orderInfo").html("Order not found. Try again");		
										setTimeout(() =&gt; { 
										$("#orderButton").prop('disabled', false);
										$("#orderInfo").html("");	
										}, 5000);	
									}
								}
						});
					}
			}
			
			function ch_login(page){
				$('#cz-signin-tab').submit(function(event) {
				event.preventDefault();
				});
					if ($('#cz-signin-tab')[0].checkValidity() === false) {
					event.stopPropagation();
					} 
					else 
					{	
					var stay=0;
					if ($("#czi-remember").is(":checked") == true){
					stay=1;
					}
					
				$.ajax({
					type: "POST",
					dataType: "json",
					url: '/pages/sign-in.php',
					data: {
						task: "login",
						username: $("#czi-email").val(),
						password: $("#czi-password").val(),
						stay: stay
						},
					success: function(response)
						{
							if (response.status === 'Login') 
							{
								if ($("#czi-id").val()!="activation")
								{
										if (page.length &gt; 0)
										{
										window.location.href = page;
										}
										else
										{
										location.reload(); 	
										}
								}
								else
								{		
									window.location.href = '/';
								}							
							}
							else 
							{	
								if ($("#czi-id").val()!="activation")
								{
									console.log("a");
								$("#czi-status").addClass("status-error");								
								$("#czi-status").html('Invalid Credentials or your account is not yet active');
								$("#czi-status-ch").addClass("status-error");								
								$("#czi-status-ch").html('Invalid Credentials or your account is not yet active');
								setTimeout(() =&gt; { $("#czi-status-ch").html(" "); $("#czi-status-ch").removeClass("status-error");}, 6000);		
								setTimeout(() =&gt; { $("#czi-status").html(" "); $("#czi-status").removeClass("status-error");}, 6000);		
								}
								else
								{
									console.log("b");
								$("#czii-status").addClass("status-error");								
								$("#czii-status").html('Invalid Credentials or your account is not yet active');
								setTimeout(() =&gt; { $("#czii-status").html(" "); $("#czii-status").removeClass("status-error");}, 6000);	
								}
							}
						}
				});
					}
			}
			function ch_loginguest(url){
				
				$.ajax({
					type: "POST",
					dataType: "json",
					url: '/pages/sign-in.php',
					data: {
						task: "guestlogin",
							},
					success: function(response)
						{
							if (response.status === 'guest') {
							window.location = url;
							//location.reload(); 	
							//console.log("test");
							}
						}
						});
			}
			function show_mod(){
			var modal = document.getElementById("myModal");
			modal.style.display = "block";	
			}
			function hide_mod(){
			var modal = document.getElementById("myModal");
			modal.style.display = "none";	
			}
			
			function addressmethod(url){
				var modal = document.getElementById("myModal");
				modal.style.display = "block";
				$('#addresspanel').submit(function(event) {
				event.preventDefault();
		
				});
					if ($('#addresspanel')[0].checkValidity() === false) {
					event.stopPropagation();
					modal.style.display = "none";	
					} 
					else 
					{	var checkoutstate="", bcheckoutstate="";	
						if ($("#checkout-country").val()=="US"){
							checkoutstate=$("#checkout-state").val(); 
							}
							else
							{
							checkoutstate="";
							}	
						if ($("#b-checkout-country").val()=="US"){
							bcheckoutstate=$("#b-checkout-state").val();
							console.log("a:"+bcheckoutstate);
							}
							else
							{
							bcheckoutstate="";
							}							
							$.ajax({
								type: "POST",
								dataType: "json",
								url: '/pages/reward-promo.php',
								data: {
										task:"address_method",
										checkoutshipping: $("#checkout-shipping").val(),
										checkoutfn: $("#checkout-fn").val(),
										checkoutln: $("#checkout-ln").val(), 
										checkoutemail: $("#checkout-email").val(), 
										checkoutphone: $("#checkout-phone").val(), 
										checkoutcompany: $("#checkout-company").val(), 
										checkoutcountry: $("#checkout-country").val(), 
										checkoutstate: checkoutstate, 
										checkoutcity: $("#checkout-city").val(), 
										checkoutzip: $("#checkout-zip").val(),
										checkoutaddress1: $("#checkout-address-1").val(), 				
										checkoutaddress2: $("#checkout-address-2").val(), 	
										addressoper:$('input[name="address_oper"]:checked').val(),
										bcheckoutbilling: $("#b-checkout-billing").val(),
										bcheckoutfn: $("#b-checkout-fn").val(),
										bcheckoutln: $("#b-checkout-ln").val(), 
										bcheckoutemail: $("#b-checkout-email").val(), 
										bcheckoutphone: $("#b-checkout-phone").val(), 
										bcheckoutcompany: $("#b-checkout-company").val(), 								
										bcheckoutcountry: $("#b-checkout-country").val(), 
										bcheckoutstate: bcheckoutstate,
										bcheckoutcity: $("#b-checkout-city").val(), 
										bcheckoutzip: $("#b-checkout-zip").val(),
										bcheckoutaddress1: $("#b-checkout-address-1").val(), 				
										bcheckoutaddress2: $("#b-checkout-address-2").val(), 									
										baddressoper:$('input[name="b_address_oper"]:checked').val(),
										},
									success: function(response){	
										if (response.status === 'ok') 
										{
										location.reload();
										}
										else
										{
										console.log(response.info);
										}
									}
								});
					}			
			}
			function addressmethodbill(){
				var modal = document.getElementById("myModal");
				modal.style.display = "block";
				$('#addresspanel').submit(function(event) {
				event.preventDefault();
				});

					if ($('#addresspanel')[0].checkValidity() === false) {
					event.stopPropagation();
					modal.style.display = "none";	
					} 
					else 
					{	var checkoutstate="", bcheckoutstate="";	
						if ($("#b-checkout-country").val()=="US"){
							bcheckoutstate=$("#b-checkout-state").val();
							}
							else
							{
							bcheckoutstate="";
							}							
							$.ajax({
								type: "POST",
								dataType: "json",
								url: '/pages/reward-promo.php',
								data: {
										task:"address_method",
										bcheckoutbilling: $("#b-checkout-billing").val(),
										bcheckoutfn: $("#b-checkout-fn").val(),
										bcheckoutln: $("#b-checkout-ln").val(), 
										bcheckoutemail: $("#b-checkout-email").val(), 
										bcheckoutphone: $("#b-checkout-phone").val(), 
										bcheckoutcompany: $("#b-checkout-company").val(), 								
										bcheckoutcountry: $("#b-checkout-country").val(), 
										bcheckoutstate: bcheckoutstate,
										bcheckoutcity: $("#b-checkout-city").val(), 
										bcheckoutzip: $("#b-checkout-zip").val(),
										bcheckoutaddress1: $("#b-checkout-address-1").val(), 				
										bcheckoutaddress2: $("#b-checkout-address-2").val(), 									
										baddressoper:$('input[name="b_address_oper"]:checked').val(),
										},
									success: function(response){	
										if (response.status === 'ok') 
										{
										location.reload();
										}
										else
										{
										console.log(response.info);
										}
									}
								});
					}			
			}
			
			function enable_billing_address(par){
				console.log("1");
				if ($('#same-address').is(":checked") == true){
					$("#b-checkout-billing").val(1); 
					$("#b-checkout-fn").prop('required', true); 
					$("#b-checkout-ln").prop('required', true); 
					$("#b-checkout-country").prop('required', true); 
					$("#b-checkout-city").prop('required', true); 
					$("#b-checkout-zip").prop('required', true); 
					$("#b-checkout-address-1").prop('required', true); 
					$("#bill_address").show();
					if (par==="guest")
					{
					$('#address_panel').show();
					$('#bill_address_2').removeClass("d-none");
					}
					$("#button_review_order").addClass("disabled"); 
				console.log("2");
				}					
				else{
					$("#b-checkout-billing").val(0); 
					$("#b-checkout-fn").prop('required', false); 
					$("#b-checkout-ln").prop('required', false); 
					$("#b-checkout-country").prop('required', false); 					
					$("#b-checkout-city").prop('required', false); 
					$("#b-checkout-zip").prop('required', false); 
					$("#b-checkout-address-1").prop('required', false); 
					$("#b-checkout-fn").val(""); 
					$("#b-checkout-ln").val(""); 
					$("#b-checkout-email").val(""); 
					$("#b-checkout-phone").val(""); 
					$("#b-checkout-company").val(""); 
					$("#b-checkout-country").val(""); 
					$("#b-checkout-state").val(""); 
					$("#b-checkout-city").val(""); 
					$("#b-checkout-zip").val("");
					$("#b-checkout-address-1").val(""); 				
					$("#b-checkout-address-2").val(""); 
					$('#select-b-address').prop('selectedIndex', 0);	
					$('#bill_address').hide();
					$.ajax({
								type: "POST",
								dataType: "json",
								url: '/pages/reward-promo.php',
								data: {
										task:"address_method",
										bcheckoutbilling: 0
										},
								});
					$("#button_review_order").removeClass("disabled"); 
				}					
			}
			function select_address(res){
				//usuwanie zbednych paneli
				$('#ship_address_panel').addClass("d-none");
				$('#ship_method').addClass("d-none");
				$('#ship_addr_err').addClass("d-none");
				$('#ship_addr_err_sm').addClass("d-none");
				//$('#ch-sidebar').addClass("d-none");
				
				$("#address_label").html("Edit Shipping Address"); 
				var response = JSON.parse(res);
				$("#checkout-shipping").val(response.id); 
				$("#checkout-fn").val(decodeEntities(response.firstname)); 
				$("#checkout-ln").val(decodeEntities(response.lastname)); 
				$("#checkout-email").val(response.emailaddress); 
				$("#checkout-phone").val(response.phonenumber); 
				$("#checkout-company").val(decodeEntities(response.company)); 
				$("#checkout-country").val(response.country);
				$("#checkout-state").prop('disabled', true); 
				$("#checkout-state").prop('required', false); 				
				if ($("#checkout-country").val()=="US"){
					$("#checkout-state").prop('disabled', false); 
					$("#checkout-state").prop('required', true); 
				}
				$("#checkout-state").val(response.state); 
				$("#checkout-city").val(response.city); 
				$("#checkout-zip").val(response.zipcode);
				$("#checkout-address-1").val(decodeEntities(response.address1)); 				
				$("#checkout-address-2").val(decodeEntities(response.address2)); 
				$('#sh_address_panel').show();
				$('#sh_address_panel').addClass("d-flex");
				$('#ship_address').removeClass("d-none");
								
			}
			
			function show_add_address_section(options){
				//wylaczanie paneli zeby nie mieszac
				$('#ship_address_panel').addClass("d-none");
				$('#ship_method').addClass("d-none");
				$('#ship_addr_err').addClass("d-none");
				$('#ship_addr_err_sm').addClass("d-none");
				$('#button_review_order').addClass("d-none");
				//$('#ch-sidebar').addClass("d-none");
				
				
				$("#address_label").html("Add Shipping Address"); 
				
				$("#checkout-shipping").val(0); 
				$("#checkout-adress_type").val(""); 
				$("#checkout-fn").val(""); 
				$("#checkout-ln").val(""); 
				$("#checkout-email").val(""); 
				$("#checkout-phone").val(""); 
				$("#checkout-company").val(""); 
				$("#checkout-country").val("US"); 
				$("#checkout-state").val("");
					if ($("#checkout-country").val()=="US") 
					{
					$("#checkout-state").prop('disabled',false); 
					$("#checkout-state").prop('required', true); 			
					}
					else
					{
					$("#checkout-state").prop('disabled', true); 
					$("#checkout-state").prop('required', false); 			
					}
				$("#checkout-city").val(""); 
				$("#checkout-zip").val("");
				$("#checkout-address-1").val(""); 				
				$("#checkout-address-2").val("");
				$("#button_daa").prop('disabled', true); 	
					if (options==='panel')
					{
						console.log("panel");
						$('#sh_address_panel').removeClass("d-flex");
						$('#sh_address_panel').addClass("d-none");
					}
				$('#address_panel').show();
				$('#ship_address').removeClass("d-none");
			}	
			
			function select_address2(res)
			{
				var modal = document.getElementById("myModal");
				modal.style.display = "block";
				var response = JSON.parse(res);
				$.ajax({
						type: "POST",
						dataType: "json",
						url: '/pages/reward-promo.php',
						data: {
								task:"address_method",
								checkoutshipping: response.id,
								checkoutfn: response.firstname,
								checkoutln: response.lastname, 
								checkoutemail: response.emailaddress, 
								checkoutphone:response.phonenumber, 
								checkoutcompany: response.company, 
								checkoutcountry: response.country, 
								checkoutstate: response.state, 
								checkoutcity: response.city, 
								checkoutzip: response.zipcode,
								checkoutaddress1: response.address1, 				
								checkoutaddress2: response.address2
								},
							success: function(response){	
								if (response.status === 'ok') 
								{
									//location.reload(true);
									location.href = "/page/checkout/sub/shipping/";
								}
								else
								{
								console.log(response.info);
								}
							}
						});
			}
			function select_b_address2(res)
			{
				var modal = document.getElementById("myModal");
				modal.style.display = "block";
				var response = JSON.parse(res);
				$.ajax({
						type: "POST",
						dataType: "json",
						url: '/pages/reward-promo.php',
						data: {
								task:"address_method",
								bcheckoutbilling: response.id,
								bcheckoutfn: response.firstname,
								bcheckoutln: response.lastname, 
								bcheckoutemail: response.emailaddress, 
								bcheckoutphone:response.phonenumber, 
								bcheckoutcompany: response.company, 
								bcheckoutcountry: response.country, 
								bcheckoutstate: response.state, 
								bcheckoutcity: response.city, 
								bcheckoutzip: response.zipcode,
								bcheckoutaddress1: response.address1, 				
								bcheckoutaddress2: response.address2
								},
							success: function(response){	
								if (response.status === 'ok') 
								{
								//location.reload();
								location.href = "/page/checkout/sub/billing-rewards/";
								}
								else
								{
								console.log(response.info);
								}
							}
						});
			}
			function show_add_b_address_section(options){
				//wylaczanie paneli zeby nie mieszac
				$('#bill_address_panel').addClass("d-none");
				//$('#ch-sidebar').addClass("d-none");
				//$('#ship_addr_err_sm').addClass("d-none");
				$('#button_review_order').addClass("d-none");
				$('#reward_points_panelek').addClass("d-none");
				
				$("#address_b_label").html("Add Billing Address"); 
				console.log("add_b");
				$("#b-checkout-shipping").val(0); 
				$("#b-checkout-adress_type").val(""); 
				$("#b-checkout-fn").val(""); 
				$("#b-checkout-ln").val(""); 
				$("#b-checkout-email").val(""); 
				$("#b-checkout-phone").val(""); 
				$("#b-checkout-company").val(""); 
				$("#b-checkout-country").val(""); 
				$("#b-checkout-state").val("");
				$("#b-checkout-state").prop('disabled', true); 
				$("#b-checkout-state").prop('required', false); 			
				$("#b-checkout-city").val(""); 
				$("#b-checkout-zip").val("");
				$("#b-checkout-address-1").val(""); 				
				$("#b-checkout-address-2").val("");
				$("#button_daa").prop('disabled', true);
					if (options==='panel')
					{
						console.log("panel");
						$('#sh_address_panel').removeClass("d-flex");
						$('#sh_address_panel').addClass("d-none");
					}
				$('#address_panel').show();
				$('#bill_address_2').removeClass("d-none");
				
 				
			}
			function select_b_address(res){
				$("#address_b_label").html("Edit Billing Address"); 
				var response = JSON.parse(res);
				$("#b-checkout-billing").val(response.id); 
				$("#b-checkout-fn").val(decodeEntities(response.firstname)); 
				$("#b-checkout-ln").val(decodeEntities(response.lastname)); 
				$("#b-checkout-email").val(response.emailaddress); 
				$("#b-checkout-phone").val(response.phonenumber); 
				$("#b-checkout-company").val(decodeEntities(response.company)); 
				$("#b-checkout-country").val(response.country); 
				if ($("#b-checkout-country").val()=="US"){
					$("#b-checkout-state").prop('disabled', false); 
					$("#b-checkout-state").prop('required', true); 
				}
				$("#b-checkout-state").val(response.state); 
				$("#b-checkout-city").val(decodeEntities(response.city)); 
				$("#b-checkout-zip").val(response.zipcode);
				$("#b-checkout-address-1").val(decodeEntities(response.address1)); 				
				$("#b-checkout-address-2").val(decodeEntities(response.address2)); 
				$('#sh_b_address_panel').show();
				$('#sh_b_address_panel').addClass("d-flex");
				$('#bill_address_2').removeClass("d-none");
			}
			function change_shipping_method(type){
				var modal = document.getElementById("myModal");
				modal.style.display = "block";				
				$.ajax({
					type: "POST",
					dataType: "json",
					url: '/pages/reward-promo.php',
					data: {
						task: "shipping_method",
						shipping_method: type
						},
					success: function(response){	
						if (response.status === 'ok') 
						{
							location.reload();
						}
						else
						{
							console.log("error ");
						}
					}
					});		
					
			}
			function shippingmethod(url){
				var shipping=$("span#shipping_coast").text();
				shipping=shipping.replace('$','');
				shipping=shipping.replace(',','');
				console.log("test: "+shipping);
				$.ajax({
					type: "POST",
					dataType: "json",
					url: '/pages/reward-promo.php',
					data: {
						task: "shipping_method",
						shipping_coast: shipping,
						shipping_method: $('input[name="shipping-method"]:checked').val(),
						},
					success: function(response){	
						if (response.status === 'ok') 
						{
						console.log("ok: "+shipping);
						window.location = url;
						}
						else
						{
							console.log("error ");
						}
					}
					});
			}
			function check_country(country){
				if (country.value=="US"){
					$("#checkout-state").prop('disabled', false); 
					$("#checkout-state").prop('required', true); 
				}
				else{
					$("#checkout-state").prop('disabled', true); 
					$("#checkout-state").prop('required', false); 
					$("#checkout-state").prop('selectedIndex', 0);	
				}		
			}
			function b_check_country(country){
				if (country.value=="US"){
					$("#b-checkout-state").prop('disabled', false); 
					$("#b-checkout-state").prop('required', true); 
				}
				else{
					$("#b-checkout-state").prop('disabled', true); 
					$("#b-checkout-state").prop('required', false); 
					$("#b-checkout-state").prop('selectedIndex', 0);	
				}
					
			}
			function enable_reward(){
				var modal = document.getElementById("myModal");
				modal.style.display = "block";
				if ($('#use_points').is(":checked") == true){
					$.ajax({
					type: "POST",
					dataType: "json",
					url: '/pages/reward-promo.php',
					data: {
						task: "en_reward",
						},
					success: function(response){	
						if (response.status === 'ok') 
						{
						location.reload(); 	
						}
					}
					});
				}
				else
				{
					$.ajax({
					type: "POST",
					dataType: "json",
					url: '/pages/reward-promo.php',
					data: {
						task: "dis_reward",
						},
					success: function(response){	
						if (response.status === 'ok') 
						{
						location.reload(); 	
						}
					}
					});
				}
			}			
			function enable_wallet(){
				if ($('#use_wallet').is(":checked") == true){
					$.ajax({
					type: "POST",
					dataType: "json",
					url: '/pages/reward-promo.php',
					data: {
						task: "en_wallet",
						},
					success: function(response){	
						if (response.status === 'ok') 
						{
						location.reload(); 	
						}
					}
					});
				}
				else
				{
					$.ajax({
					type: "POST",
					dataType: "json",
					url: '/pages/reward-promo.php',
					data: {
						task: "dis_wallet",
						},
					success: function(response){	
						if (response.status === 'ok') 
						{
						location.reload(); 	
						}
					}
					});
				}
			}
			function save_note(){
				var note=$("#order-comments").val();
				note=note.trim();
				if (note.length &lt; 5)
				{
					note="";
					$("#order-comments").val("");
				}	
				$.ajax({
					type: "POST",
					dataType: "json",
					url: '/pages/reward-promo.php',
					data: {
						task: "save_note",
						note: note,
						},
					success: function(response){	
						if (response.status === 'ok') 
						{
							console.log("save");					
						}
					}
				});
				
			}
			function applypromo(sub){
				
				$('#promo-tab').submit(function(event) {
				event.preventDefault();
				});
				if ($('#promo-tab')[0].checkValidity() === false) {
				event.stopPropagation();
				} 
				else 
				{	
				show_mod();				
				var promocode=$("#promocodevalue").val();
				$.ajax({
					type: "POST",
					dataType: "json",
					url: '/pages/reward-promo.php',
					data: {
						task: "promo_code",
						promocode: promocode,
						oper: "add",
						},
					success: function(response){	
						if (response.status === 'ok') 
						{
								location.reload(); 				
						}
						if (response.status === 'error') 
						{
							$("#promo_info").html(response.info);
							console.log(response.info);
							hide_mod();
						}
					}
					});
				}
			}	
			function applypromo_account(promocode,id){
				
					
				$.ajax({
					type: "POST",
					dataType: "json",
					url: '/pages/reward-promo.php',
					data: {
						task: "promo_code",
						promocode: promocode,
						oper: "add",
						},
					success: function(response){	
						if (response.status === 'ok') 
						{
							$(".discount").html("");
							$("#dis_"+id).html(response.info);
							
						}
						if (response.status === 'error') 
						{
							console.log(response.info);
						}
					}
					});
			}	
			function delpromo(sub){
				$('#promo-tab').submit(function(event) {
				event.preventDefault();
				});
				show_mod();	
				$.ajax({
					type: "POST",
					dataType: "json",
					url: '/pages/reward-promo.php',
					data: {
						task: "promo_code",
						oper: "del",
						},
					success: function(response){	
						if (response.status === 'ok') 
						{
								location.reload(); 				
						}
						else
						{
							console.log (response.info);
						}
					}
					});
			}
			function check_transaction_to_delete(event,task){
				show_mod();
				$("#pp_button").prop('disabled', true); 
				$('#pp_form').submit(function(event) {
				event.preventDefault();
				});
				var sum=$("#sum").val();
				$.ajax({
					type: "POST",
					dataType: "json",
					url: '/pages/reward-promo.php',
					data: {
						task: "savetr",
						sum: sum,
						},
					success: function(response){	
						if (response.status === 'ok') 
						{
							if (task==1)
							{
							$("#pp_custom").val(response.transaction_id); 
							document.getElementById('pp_form').submit();	
							}
							if (task==0)
							{
							window.location.href = '/page/checkout-complete/sub/nopay/custom/'+response.transaction_id+'/';
							}
						}
						else
						{
							console.log ("error");
							hide_mod();							
							alert (response.info);
						}
					}
					});
								
			}	
			
			function check_transaction(){
				show_mod();
				var sum=$("#sum").val();
				$.ajax({
					type: "POST",
					dataType: "json",
					url: '/pages/reward-promo.php',
					data: {
						task: "savetr",
						sum: sum,
						},
					success: function(response){	
						if (response.status === 'ok') 
						{
							window.location.href = '/page/checkout-complete/sub/nopay/custom/'+response.transaction_id+'/';
						}
						else
						{
							console.log ("error");
							hide_mod();							
							alert (response.info);
						}
					}
					});
								
			}			
			
			function confirm_order(){
				show_mod();
				$(".cfo_button").prop('disabled', true); 
				var sum=$("#sum").val();
				$.ajax({
					type: "POST",
					dataType: "json",
					url: '/pages/reward-promo.php',
					data: {
						task: "savetr",
						sum: sum,
						},
					success: function(response){	
						if (response.status === 'ok') 
						{
							setTimeout(() =&gt; {location.reload();}, 300);
						}
						else
						{
							console.log ("error");
							hide_mod();							
							alert (response.info);
						}
					}
					});
								
			}
			
			 function PrintDiv() {  
					var css="&lt;link rel='stylesheet' href='/assets/css/theme.min.css'&gt;";
					document.getElementById("button_print").style.display = "none";
					$('#button_print').hide();
					
					var divToPrint = document.getElementById('divToPrint');	
					var popupWin = window.open('', '_blank', 'width=800,height=500');
					popupWin.document.open();
					popupWin.document.write('&lt;html&gt;&lt;body onload="window.print()"&gt;' + divToPrint.innerHTML + '&lt;/html&gt;');
					popupWin.document.head.innerHTML = css;					
					popupWin.document.close();
					$('#button_print').show();
            }
			
			$(document).ready(function() {
					  $('#confirm-whls-modal').on('show.bs.modal', function(e) {
						var id=$(e.relatedTarget).data('whls-id');
						$('#whls_id').val(id);
						$('#modal-whls-title').html($(e.relatedTarget).data('whls-title'));
			  });
			});	
			
			function del_whls_item(id){
					var id=$('#whls_id').val();
					$('#wslt_button_remove').html('Removing ...');
					$.ajax({
					type: "POST",
					url: '/pages/toast-wishlist.php',
					data: {
						id_item:id,
						},
					success: function(response)
						{
						location.reload(); 	
						}
					});
			}
			
			function ADD_WHLT(sku){		
					$.ajax({
						  type: 'post',
						  url: '/pages/toast-wishlist.php',
						  data: 'tsku='+sku,
						  success: function(data) {
							$('#wishlist_toast').html(data);
							setTimeout(() =&gt; { $('#wishlisttoast').toast('show');location.reload(); }, 2000);
							
						   }
						});	
	
			}	
			function ADD_WHLT_GRID(sku){		
					$.ajax({
						  type: 'post',
						  url: '/pages/toast-wishlist.php',
						  data: 'tsku='+sku,
						  success: function(data) {
							$('#wishlist_toast').html(data);
							//setTimeout(() =&gt; { $('#wishlisttoast').toast('show'); }, 4000);
							$('#Add_'+sku).hide();
							$('#Rem_'+sku).show();
							$('#Add_l_'+sku).hide();
							$('#Rem_l_'+sku).show();
						   }
						});	
	
			}			
			function ADD_WHLT_DYN(sku){		
					$.ajax({
						  type: 'post',
						  url: '/pages/toast-wishlist.php',
						  data: 'tsku='+sku,
						  success: function(data) {
								$("#quickview-status").addClass("status-success");	
								$("#quickview-status").html("This item has been added to your wishlist.");
								setTimeout(() =&gt; { 	
							
							$.ajax({
						  type: 'post',
						  url: '/pages/quick-view.php',
						  data: 'sku=' +sku,
						  success: function(data) {
							$('#q_view').html(data);
						   }
								});
							
							}, 2000);	
							
						   }
						});	
		
			}
			function REM_WHLT(sku){		
					$.ajax({
						  type: 'post',
						  url: '/pages/toast-wishlist.php',
						  data: {
							  tsku:sku,
							  oper:"rem",
								},
						  success: function(data) {
							$('#wishlist_toast').html(data);
							setTimeout(() =&gt; { $('#wishlisttoast').toast('show');location.reload(); }, 2000);
						   }
						});
			}
			function REM_WHLT_GRID(sku){		
					$.ajax({
						  type: 'post',
						  url: '/pages/toast-wishlist.php',
						  data: {
							  tsku:sku,
							  oper:"rem",
								},
						  success: function(data) {
							$('#wishlist_toast').html(data);
							//setTimeout(() =&gt; { $('#wishlisttoast').toast('show'); }, 4000);
							$('#Rem_'+sku).hide();
							$('#Add_'+sku).show();	
							$('#Rem_l_'+sku).hide();
							$('#Add_l_'+sku).show();								
						   }
						});
			}			
			function REM_WHLT_DYN(sku){		
					$.ajax({
						  type: 'post',
						  url: '/pages/toast-wishlist.php',
						  data: {
							  tsku:sku,
							  oper:"rem",
								},
						  success: function(data) {
							$("#quickview-status").addClass("status-error");	
								$("#quickview-status").html("This item has been removed from your wishlist.");
								setTimeout(() =&gt; { 	
							$.ajax({
						  type: 'post',
						  url: '/pages/quick-view.php',
						  data: 'sku=' +sku,
						  success: function(data) {
							$('#q_view').html(data);
						   }
								});	
						}, 2000);	
						   }
						});
			}			
			function move_all_item_wishlist(){
					$.ajax({
					type: "POST",
					dataType: "json",
					url: '/pages/toast-wishlist.php',
					data: {
						task: "moveWSHL",
						},
					success: function(response)
						{
							if (response.status === 'ok') 
							{
							location.reload();
							}
							else
							{
							console.log(response.info);
							}
						}
					});
			}			
			
			function decodeEntities(encodedString) {
			  var textArea = document.createElement('textarea');
			  textArea.innerHTML = encodedString;
			  return textArea.value;
			}
			
			function select_account_address(res){
				console.log ("test");
				console.log (res);
				var response = JSON.parse(res);
				$("#checkout-shipping").val(response.id); 
				$("#checkout-adress_type").val(response.adress_type); 
				$("#checkout-fn").val(decodeEntities(response.firstname)); 
				$("#checkout-ln").val(decodeEntities(response.lastname)); 
				$("#checkout-email").val(response.emailaddress); 
				$("#checkout-phone").val(response.phonenumber); 
				$("#checkout-company").val(decodeEntities(response.company)); 
				$("#checkout-country").val(response.country); 
				if ($("#checkout-country").val()=="US"){
					$("#checkout-state").prop('disabled', false); 
					$("#checkout-state").prop('required', true); 
				}
				else
				{
					$("#checkout-state").prop('disabled', true); 
					$("#checkout-state").prop('required', false); 
				}
				
				$("#checkout-state").val(response.state); 
				$("#checkout-city").val(decodeEntities(response.city)); 
				$("#checkout-zip").val(response.zipcode);
				$("#checkout-address-1").val(decodeEntities(response.address1)); 				
				$("#checkout-address-2").val(decodeEntities(response.address2)); 
				$("#button_daa").prop('disabled', false); 
				
				$('#address_panel').show();		
			}
			

			
			
			function delete_account_address(){
				$('#accountaddress').submit(function(event) {
				event.preventDefault();
				});
				$.ajax({
						type: "POST",
						dataType: "json",
						url: '/pages/my-account.php',
						data: {
								task:"deleteaddress",
								checkoutshipping: $("#checkout-shipping").val(),
								},
								success: function(response){	
									if (response.status === 'ok') 
									{
									location.reload();
									}
									else
									{
									console.log(response.info);
									}
								}
						});
			}
			function save_account_address(){
				$('#accountaddress').submit(function(event) {
				event.preventDefault();
				});
					if ($('#accountaddress')[0].checkValidity() === false) {
					event.stopPropagation();
					
					} 
					else 
					{		if ($("#checkout-country").val()=="US"){
								var checkoutstate=$("#checkout-state").val();
							}
							else
							{
								var checkoutstate="";
							}
							$.ajax({
								type: "POST",
								dataType: "json",
								url: '/pages/my-account.php',
								data: {
										task:"saveaddress",
										checkoutshipping: $("#checkout-shipping").val(),
										checkouttypeadress: $("#checkout-adress_type").val(),
										checkoutfn: $("#checkout-fn").val(),
										checkoutln: $("#checkout-ln").val(), 
										checkoutemail: $("#checkout-email").val(), 
										checkoutphone: $("#checkout-phone").val(), 
										checkoutcompany: $("#checkout-company").val(), 
										checkoutcountry: $("#checkout-country").val(), 
										checkoutstate: checkoutstate, 
										checkoutcity: $("#checkout-city").val(), 
										checkoutzip: $("#checkout-zip").val(),
										checkoutaddress1: $("#checkout-address-1").val(), 				
										checkoutaddress2: $("#checkout-address-2").val(), 	
										},
									success: function(response){	
										if (response.status === 'ok' ) 
										{
										location.reload();
										}
										if (response.status === 'error') 
										{
										console.log(response.info);
										}
									}
								});
					}			
			}
			
			function update_profile(){
				$('#updateprofile').submit(function(event) {
				event.preventDefault();
					
				});
					if ($('#updateprofile')[0].checkValidity() === false) {
					event.stopPropagation();
					
					} 
					else 
					{		
							$.ajax({
								type: "POST",
								dataType: "json",
								url: '/pages/my-account.php',
								data: {
										task:"updateprofile",
										accountfn: $("#account-fn").val(),
										accountln: $("#account-ln").val(),
										accountphone: $("#account-phone").val(),
										},
									success: function(response){	
										if (response.status === 'ok') 
										{
										$("#pass-status").addClass("status-success");	
										$("#pass-status").html(response.info);
										setTimeout(() =&gt; { $("#pass-status").html(" "); $("#pass-status").removeClass("status-success");location.reload();}, 3000);			
										
										}
										if (response.status === 'error') 
										{
										console.log(response.info);
										}
									}
								});
					}			
			}
			
		function enable_change_password(){
				if ($('#change-password').is(":checked") == true){
					$('#account-password').show();
				}					
				else
				{
					$('#account-password').hide();					
				}
		}
		function save_password(){
				$('#savepassword').submit(function(event) {
				event.preventDefault();				
				});
					if ($('#savepassword')[0].checkValidity() === false) {
					event.stopPropagation();	
				
					} 
					else 
					{
						if(($("#account-pass").val())!=($("#account-confirm-pass").val()))
						{	
						$("#pass-status").addClass("status-error");								
						$("#pass-status").html("Passwords do not match");
						setTimeout(() =&gt; { $("#pass-status").html(" "); $("#pass-status").removeClass("status-error");}, 9000);								
						}
						else
						{
				
							$.ajax({
								type: "POST",
								dataType: "json",
								url: '/pages/my-account.php',
								data: {
										task:"savepassword",
										accountpass: $("#account-pass").val(),
										},
									success: function(response){	
										if (response.status === 'ok') 
										{
										$("#pass-status").addClass("status-success");	
										$("#pass-status").html(response.info);
										setTimeout(() =&gt; { $("#pass-status").html(" "); $("#pass-status").removeClass("status-success");location.reload();}, 3000);						
										//location.reload();
										}
										if (response.status === 'error') 
										{
										console.log(response.info);
										}
									}
								});
						}
					}					
			}	
			//modal make_offer
			$(document).ready(function() {
				$('#make-offer').on('show.bs.modal', function(e) {
					$('#quick-view').modal('hide');
					var sku2 = $(e.relatedTarget).data('sku2');				
					$.ajax({
					  type: 'post',
					  url: '/pages/make-offer.php',
					  data: {sku2:sku2,},
					  success: function(data) {
						$('#makeoffer').html(data);
						}
					});	
				});
			});		
			
			function send_offer(sku){
				$('#offer-form').submit(function(event) {
				event.preventDefault();
				});
					if ($('#offer-form')[0].checkValidity() === false) {	
						event.stopPropagation();
						$("#offer-form")[0].classList.add('was-validated');
					} 
					else 
					{	
						$("#offer-form")[0].classList.add('was-validated');
						var scountry= JSON.parse($("#checkout-country").val());
						$.ajax({
								type: "POST",
								dataType: "json",
								url: '/pages/make-offer.php',
								data: {
										task:"send",
										sku:sku,
										note:$("#checkout-note").val(),
										offer:$("#checkout-offer").val(),
										quantity:$("#checkout-qty").val(),
										shipping:$("#checkout-shipping-offer").val(),									
										country:scountry[0],									
										region:scountry[1],									
										},
									success: function(response){	
										if (response.status === 'ok') 
										{
											$.ajax({
											type: 'post',
											url: '/pages/make-offer.php',
											data: {sku2:sku,},
											success: function(data) {
											$('#makeoffer').html(data);
											$("#offer_info").html("Your offer has been sent, we will contact you shortly !");
											$("#offer_info").removeClass("alert-danger");
											$("#offer_info").addClass("alert-info");
											}
											});	
										}
										if (response.status === 'error') 
										{
										console.log(response.info);
										}
									}
								});
					}			
			}
			
			var id_offer_to_cancel=0;
			var id_offer_to_accept=0;
			var id_offer_to_reject=0;
			
			
			$(document).ready(function() {
						
					$('.btn-confirmcart').on('click', function(e) {
						console.log("add");
						show_mod();
						var tempid=$(this).attr("data-id-offer");
						var url="/pages/check-session.php";
						$.get(url, function(data) {
						if (data=="NS") 
						{
						location.reload();	
						}
						else
						{
							$.ajax({
							type: 'post',
							url: '/pages/make-offer.php',
							data: {
								sku_mdl: tempid,
								},
								success: function(odp) {
									
										if (odp=="NS") 
										{
										location.reload();							
										}
										else									
										{
										$('#offeradd-confirm-modal-content').html(odp);
										$('#offeradd-confirm-modal').modal("show");
										hide_mod();										
											$.ajax({
												type: "POST",
												dataType: "json",
												url: '/pages/make-offer.php',
												data: {
														task:"add-to-cart",
														id_offer: tempid
														},
													success: function(response){	
														if (response.status === 'ok') 
														{
															$('#add-cart-info').html(response.info);
															setTimeout(() =&gt; {location.reload();}, 1300);
											
														}
														if (response.status === 'error') 
														{
															$('#add-cart-info').html(response.info);
														}
													}
											});
										}
									
								}
							});	
						}
						});
							
							
					});	

					  $('.btn-rectract').on('click', function(e) {

						  show_mod();
							id_offer_to_cancel = $(this).attr("data-id-offer");
							var url="/pages/check-session.php";
							$.get(url, function(data) {
							if (data=="NS") 
							{
							location.reload();	
							}
							else
							{
								$.ajax({
								type: 'post',
								url: '/pages/make-offer.php',
								data: {
									sku_mdl: id_offer_to_cancel,
									},
									success: function(odp) {
										
										if (odp=="NS") 
										{
										location.reload();							
										}
										else									
										{
										$('#cancel-confirm-modal-content').html(odp);
										$('#cancel-confirm-modal').modal("show");
										hide_mod();
										}
									}
								});
							}
							});														
						});
						
						$('#btn-confirmaccept').on('click', function(e) {
							console.log("accep");
							 show_mod();
							id_offer_to_accept = $(this).attr("data-id-offer");	
							var url="/pages/check-session.php";
							$.get(url, function(data) {
							if (data=="NS") 
							{
							location.reload();	
							}
							else
							{
								$('#modal-accept-modal-title').html($(this).attr("data-offer-title"));
								
								$.ajax({
									type: 'post',
									url: '/pages/make-offer.php',
									data: {
										sku_mdl: id_offer_to_accept,
										},
									success: function(odp) {	
								
											$('#accept-confirm-modal-content').html(odp);
											$('#accept-confirm-modal').modal("show");
											hide_mod();
									}
								});	
							}
							});					
						});
						
						$('#btn-confirmreject').on('click', function(e) {
							console.log("reje");
							show_mod();
							id_offer_to_reject = $(this).attr("data-id-offer");	
							var url="/pages/check-session.php";
							$.get(url, function(data) {
							if (data=="NS") 
							location.reload();	
							});
							$('#modal-reject-modal-title').html($(this).attr("data-offer-title"));
							$.ajax({
							type: 'post',
							url: '/pages/make-offer.php',
							data: {
								sku_mdl: $(this).attr("data-id-offer"),
								},
							success: function(odp) {
									$('#reject-confirm-modal-content').html(odp);
									$('#reject-confirm-modal').modal("show");
									hide_mod();
							}
							});								
						});
						
			});	
			
			function cancel_offer(){
				var offer_id=id_offer_to_cancel;
				var url="/pages/check-session.php";
				$.get(url, function(data) {
				if (data=="NS") 
				location.reload();	
				});
					$.ajax({
								type: "POST",
								dataType: "json",
								url: '/pages/make-offer.php',
								data: {
										task:"cancel",
										sku:offer_id
										},
									success: function(response){	
										if (response.status === 'ok') 
										{
										$("#offer_"+offer_id).html('');
										$("#offer_status_"+offer_id).html('');
										//$('#confirm-modal').modal('hide');
										setTimeout(() =&gt; {location.reload();}, 500);
										
										}
										if (response.status === 'error') 
										{
										console.log(response.info);
										}
									}
								});
	
			}
			function reject_offer(){
				var offer_id=id_offer_to_reject;
				var url="/pages/check-session.php";
				$.get(url, function(data) {
				if (data=="NS") 
				location.reload();	
				});
					$.ajax({
								type: "POST",
								dataType: "json",
								url: '/pages/make-offer.php',
								data: {
										task:"reject",
										sku:offer_id
										},
									success: function(response){	
										if (response.status === 'ok') 
										{
										$("#offer_"+offer_id).html('');
										$("#offer_status_"+offer_id).html('');
										setTimeout(() =&gt; {$('#reject-confirm-modal').modal('hide');location.reload();}, 500);
										}
										if (response.status === 'error') 
										{
										console.log(response.info);
										}
									}
								});
	
			}
			
			function accept_offer(){
				var offer_id=id_offer_to_accept;
				var url="/pages/check-session.php";
				$.get(url, function(data) {
				if (data=="NS") 
				location.reload();	
				});				
						$.ajax({
								type: "POST",
								dataType: "json",
								url: '/pages/make-offer.php',
								data: {
										task:"accept",
										sku:offer_id
										},
									success: function(response){	
										if (response.status === 'ok') 
										{
										$("#offer_"+offer_id).html('');
										$("#offer_status_"+offer_id).html('');
										setTimeout(() =&gt; {$('#accept-confirm-modal').modal('hide');location.reload();}, 500);
										
										
										}
										if (response.status === 'error') 
										{
										console.log(response.info);
										}
									}
								});
	
			}
			
			$(document).ready(function() {
					
				$('.btn-counteroffer').on('click', function(e) {
					console.log("counter");
					//show_mod();
					$('#counteroffer-modal-content').html("");
					var offer_id = $(this).attr("data-id-offer");		
					var url="/pages/check-session.php";
					$.get(url, function(data) {
					if (data=="NS") 
					location.reload();	
					});									
					$.ajax({
					  type: 'post',
					  url: '/pages/make-offer.php',
					  data: {sku2:offer_id,source:'counter',},
					  success: function(data) {
						  	if (data=="NS") 
							{
								location.reload();							
							}
							else	
							{
								$('#counteroffer-modal-content').html(data);
								$('#counteroffer-modal').modal("show");
								hide_mod();
							}
						}
					});	
				});
			});
			
			function send_counter_offer(sku,id_offer){
				$('#offer-form').submit(function(event) {
				event.preventDefault();
				});
					if ($('#offer-form')[0].checkValidity() === false) {	
						event.stopPropagation();
						$("#offer-form")[0].classList.add('was-validated');
					} 
					else 
					{	
						$("#offer-form")[0].classList.add('was-validated');
						$.ajax({
								type: "POST",
								dataType: "json",
								url: '/pages/make-offer.php',
								data: {
										task:"send_counter",
										id_offer:id_offer,
										sku:sku,
										note:$("#checkout-note").val(),
										offer:$("#checkout-offer").val(),
										quantity:$("#checkout-qty").val(),
										shipping:$("#checkout-shipping").val(),									
										},
										success: function(response){	
											if (response.status === 'ok') 
											{
												$("#offer_"+id_offer).html('');
												$("#offer_status_"+id_offer).html('');
												$.ajax({
												type: 'post',
												url: '/pages/make-offer.php',
												data: {sku_mdl:response.sku_mdl},
												success: function(odp) {
													
													$.ajax({
														type: 'post',
														url: '/pages/make-offer.php',
														data: {sku2:sku,},
														success: function(data) {
														$('#counteroffer-modal-content').html(data);
														$("#offer_info").html("Your offer has been sent, we will contact you shortly !");
														$("#offer_info").removeClass("alert-danger");
														$("#offer_info").addClass("alert-info");
														}
														});	
												}
												});	
											setTimeout(() =&gt; { $('#make-offer').modal('hide'); location.reload();}, 3000);
											}
											if (response.status === 'error') 
											{
											console.log(response.info);
											}
										}
								});
					}			
			}
			
			
			function update_newsletter(){
				if($("#subscribe_me").is(":checked") == true)
				{
					$.ajax({
								type: "POST",
								dataType: "json",
								url: '/pages/my-account.php',
								data: {
										task:"newsletter",
										cmd: "enable",
									 },
								success: function(response)	{	
									if (response.status === 'error') 
									{
										console.log(response.info);
									}
									else
									{
										$("#subscribe_me_info").html("&lt;span class='text-info font-weight-bold'&gt;SUBSCRIBED&lt;/span&gt;");
										$(".subinput").prop('checked',true);
										$(".subscribe").show();
									}
								}
							
							});
				}
				else
				{
					$.ajax({
								type: "POST",
								dataType: "json",
								url: '/pages/my-account.php',
								data: {
										task:"newsletter",
										cmd: "disable",
									 },
								success: function(response)	{	
									if (response.status === 'error') 
									{
										console.log(response.info);
									}
									else
									{
										$("#subscribe_me_info").html("UNSUBSCRIBED");
										$(".subscribe").hide();
									}
								}			
							});
				}
			}
			function change_newsletter(id_category){
				var checkboxname="subscribe_"+id_category;
				if($("#"+checkboxname).is(":checked") == true)
				{
					var stat="on";
				}
				else
				{
					var stat="off";	
				}
					$.ajax({
								type: "POST",
								dataType: "json",
								url: '/pages/my-account.php',
								data: {
										task:"newsletter",
										cmd: "changecategory",
										category:id_category,
										stat:stat,
									 },
								success: function(response)	{	
									if (response.status === 'error') 
									{
										console.log(response.info);
									}
									if (response.status === 'ok' &amp;&amp; response.info === 'off_all')  
									{
										console.log("off_all");
										$("#subscribe_me_category").hide();
										$(".subinput").prop('checked',true);
										$("#subscribe_me").prop('checked',false);
										$("#subscribe_me_info").html("&lt;span class='d-block ml-2 small text-warning'&gt; - CURRENTLY UNSUBSCRIBED&lt;/span&gt;");
									}
								}
							
							});
				
			}
			function subscribe_maillist(){	
				$('#mc-subscribe-form').submit(function(event) {
				event.preventDefault();
					
				});
					if ($('#mc-subscribe-form')[0].checkValidity() === false) {
					event.stopPropagation();
					} 
					else 
					{
						var rcres = grecaptcha.getResponse();
						if(rcres.length)
						{	
								$('#mc-subscribe').attr("disabled",true);
								$.ajax({
									  type: "POST",
									  dataType: "json",
									  url: '/pages/verification.php',
									  data: {
										  email:$("#mc-email").val(),
										  fname:$("#mc-fname").val(),
										  rcres:rcres,
										  action:"confirm_m_email",
											},
									  success: function(response) {	
											if(response.status=="ok"){
											$("#mc-status").addClass("status-success");	
											$("#mc-status").html(response.res);
											setTimeout(() =&gt; { $("#mc-status").html(" "); $("#mc-status").removeClass("status-success");$("#mc-email").val(""); $("#mc-fname").val(""),$('#mc-subscribe').attr("disabled",false);}, 7000);							
												}
											if(response.status=="error"){	
											$("#mc-status").addClass("status-error");								
											$("#mc-status").html(response.res);
											setTimeout(() =&gt; { $("#mc-status").html(" "); $("#mc-status").removeClass("status-error");$('#mc-subscribe').attr("disabled",false);}, 7000);								
												}
											}	
									});
						}
					}
			}	
			
			function SortOrder(id){
			show_mod();
			window.location.href = '/page/my-account/sub/orders/custom/'+id+'/cpage/1/';	
			}
				$(document).ready(function() {   
					$('.bt_log').on('click', function(){
						$('#signin-tab').addClass('show active');
						$('#nav_log').addClass('active');
						$('#signup-tab').removeClass('show active');
						$('#nav_create').removeClass('active');
						
					})
					$('.bt_create').on('click', function(){
						$('#signup-tab').addClass('show active');
						$('#signin-tab').removeClass('show active');
						$('#nav_log').removeClass('active');
						$('#nav_create').addClass('active');
				
						console.log("sign");
					})
					var account=0;
					account=$('#acc_enable').val();
					if (account==='1')
					{
						// Waldek - to do aktywacji ktory TAB jest aktywny
						console.log("log");
						$('#signin-tab').addClass('show active');
						$('#nav_log').addClass('active');
						$('#signup-tab').removeClass('show active');
						$('#nav_create').removeClass('active');
						// Waldek	
						$('#signin-modal').modal({
								show: true
						})
					}
				});
			function CancelOrder(id){
				$.ajax({
				type: "POST",
				dataType: "json",
				url: '/pages/my-account.php',
				data: {
					task: "CancelOrder",
					trans_id: id
					},
					success: function(response)
					{
						location.reload();
					}
				});
			}
			function RenewPayment(id){
				
				$("#pp_"+id).removeClass("pp");	
				$("#cp_"+id).removeClass("d-none");	
				$(".pp").addClass("d-none");	
				
				$("#transaction_pp_div").removeClass("d-none");	
				$("#transaction_id_input").val(id);
			}
				
			function close_cookie(){
			var date = new Date();
			date.setTime(date.getTime() + (7*24*60*60*1000)); //7 days  
			expires = "; expires=" + date.toUTCString();
			//expires=""; //only session
			var name = "CR_akc";
			var value=true;
			document.cookie = name + "=" + value + expires + "; path=/";
			$('#cookie-rules').remove();
			}	
			function register_cc(){
			$('#cc-account').submit(function(event) {
			event.preventDefault();
			});
				if ($('#cc-account')[0].checkValidity() === false) {
				event.stopPropagation();
				} 
				else 
				{	
			$.ajax({
				type: "POST",
				dataType: "json",
				url: '/pages/sign-in.php',
				data: {
					task: "cc_account",
					username: $("#cci-email").val(),
					password: $("#cci-password").val(),
					fname: $("#cci-fname").val(),
					lname: $("#cci-lname").val(),
					ordernb: $("#cci-ordernb").val()
					},
				success: function(response)
					{
						if (response.status === 'OK') {
							$("#cci-status").addClass("status-success");								
							$("#cci-status").html('Your account is now active. Please log-in');
							setTimeout(() =&gt; { $("#cci-status").html(" "); $("#cci-status").removeClass("status-success");}, 6000);
						}
						else {
							$("#cci-status").addClass("status-error");								
							$("#cci-status").html('Error: '+response.res);
							setTimeout(() =&gt; { $("#cci-status").html(" "); $("#cci-status").removeClass("status-error");}, 6000);	
						
						}
					}
			});
				}
			}	

function text_counter(){
	var text_max = 250;
	$('#count_message').html('0 / ' + text_max );
	var text_length = $('#order-comments').val().length;
	var text_remaining = text_max - text_length;
	$('#count_message').html(text_length + ' / ' + text_max);
}
			
$(document).ready(function(){
var oper_drop=0;
	$(".dropp").click(function() {
		oper_drop=1;
	});
	$(document).click(function() {
		if (oper_drop==0){
			var suggest = document.getElementById("searcher-content");
			suggest.style.display = "none";	
		}else
		{
			oper_drop=0;
		}
	});
	
	$('#searcher').on('keydown keyup click', function() {
		var suggest = document.getElementById("searcher-content");
			suggest.style.display = "none";	
		$('#searcher').autocomplete({
			minLength: 3,
			source: function(request, response) {
				$('#searcher-content').html(" ");
				$.ajax({
				url: "/pages/suggest.php",
				type: 'post',
				data: {
					search_text: request.term
				},
				success: function(data) {
				$('#searcher-content').addClass("dropdown-menu");
				$('#searcher-content').html(data);
				suggest.style.display = "block";	
				}
				});
			},
		});
			if ($('#searcher').val().length&gt;=3)
			{
				suggest.style.display = "block";
			}
	});
});	

function search(inp)
{
	var inputdata=$("#"+inp).val();
	inputdata=inputdata.replaceAll('"',' ');
	inputdata=inputdata.replaceAll('\"',' ');
	inputdata=inputdata.replaceAll('\'',' ');
	inputdata=inputdata.replaceAll('/','+');
	inputdata=inputdata.replaceAll('  ','+');
	inputdata=inputdata.replaceAll(' ','+');
	inputdata=inputdata.replaceAll('?','');
	inputdata=inputdata.replaceAll('%','+');
	inputdata=inputdata.replaceAll(' ','+');
	inputdata=inputdata.replaceAll('|','+');
	inputdata=inputdata.replaceAll('$','+');
	inputdata=inputdata.replaceAll('!','+');
	inputdata=inputdata.replaceAll(',','+');
	inputdata=inputdata+'/';
location.href = '/page/search/keyword/'+inputdata;
}
	function cf(){	
		$('#cf-form').submit(function(event) {
		event.preventDefault();
			
		});
		
			if ($('#cf-form')[0].checkValidity() === false) {
			event.stopPropagation();
			} 
			else 
			{
				var rcres = grecaptcha.getResponse();
				if(rcres.length)
				{
					$("#cf-button").prop('disabled', true);
					$("#cf-button").html("Working, please wait...");			
					$.ajax({
						  type: "POST",
						  dataType: "json",
						  url: '/pages/contact-us.php',
						  data: {
							  cfname:$("#cf-name").val(),
							  cfemail:$("#cf-email").val(),
							  cfphone:$("#cf-phone").val(),
							  cfsubject:$("#cf-subject").val(),
							  cfmessage:$("#cf-message").val(),
							  rcres:rcres,
							  task:"send"
								},
						  success: function(response) {	
								if(response.ack)
									{
									$("#cf-reply").removeClass("d-none");	
									$("#cf-content").remove();
									}	
								else
									{
									$("#cf-button").prop('disabled', false);
									$("#cf-button").html("Send message");		
									}
						  }
						});
				}
			}
			
			
	}
	

	
	
	function helpsend(){	
		$('#help-form').submit(function(event) {
		event.preventDefault();

		});
			if ($('#help-form')[0].checkValidity() === false) {
			event.stopPropagation();
			} 
			else 
			{	
				var rcres = grecaptcha.getResponse();
				if(rcres.length)
				{
						 var files = document.getElementById("help-file").files;
						   if(files.length &gt; 0 ){

							  var formData = new FormData();
							  formData.append("file", files[0]);
							  formData.append("task", "upload");

							  var xhttp = new XMLHttpRequest();

							  // Set POST method and ajax file path
							  xhttp.open("POST", "/pages/contact-us.php", true);

							  // call on request changes state
							  xhttp.onreadystatechange = function() {
								 if (this.readyState == 4 &amp;&amp; this.status == 200) {

								   var response = this.responseText;
								   if(response == 1){
									  $("#help-button").prop('disabled', true);
										$("#help-button").html("Working, please wait...");			
										$.ajax({
											  type: "POST",
											  dataType: "json",
											  url: '/pages/contact-us.php',
											  data: {
												  cfname:$("#help-name").val(),
												  cftopic:$("#help-topic").val(),
												  cfemail:$("#help-email").val(),
												  cfphone:$("#help-phone").val(),
												  cfsubject:$("#help-subject").val(),
												  cfmessage:$("#help-message").val(),
												  cfurl:$("#help-url").val(),
												  cffile:1,
												  rcres:rcres,
												  cfform:"help",
												  task:"send"				  
													},
											  success: function(response) {	
													if(response.ack)
														{
														$("#help-reply").removeClass("d-none");	
														$("#help-content").remove();
														}	
													else
														{
														$("#help-button").prop('disabled', false);
														$("#help-button").html("Send message");		
														}
											  }
											});
									  
								   }else{
									  alert("File not uploaded.");
								   }
								 }
							  };

							  // Send request with data
							  xhttp.send(formData);

						   }
						   else
						   {
								$("#help-button").prop('disabled', true);
								$("#help-button").html("Working, please wait...");			
								$.ajax({
									  type: "POST",
									  dataType: "json",
									  url: '/pages/contact-us.php',
									  data: {
										  cfname:$("#help-name").val(),
										  cftopic:$("#help-topic").val(),
										  cfemail:$("#help-email").val(),
										  cfphone:$("#help-phone").val(),
										  cfsubject:$("#help-subject").val(),
										  cfmessage:$("#help-message").val(),
										  cfurl:$("#help-url").val(),
										  rcres:rcres,
										  cffile:0,
										  cfform:"help",
										  task:"send"				  
											},
									  success: function(response) {	
											if(response.ack)
												{
												$("#help-reply").removeClass("d-none");	
												$("#help-content").remove();
												}	
											else
												{
												$("#help-button").prop('disabled', false);
												$("#help-button").html("Send message");		
												}
									  }
								});
						   }
				}
			}
	}

$(document).ready(function(){
var oper_drop1=0;
	$(".dropp1").click(function() {
		oper_drop1=1;
	});
	$(document).click(function() {
		if (oper_drop1==0){
			var suggest1 = document.getElementById("searcher1-content");
			suggest1.style.display = "none";	
		}else
		{
			oper_drop=0;
		}
	});
	
	$('#searcher1').on('keydown keyup click', function() {
		var suggest1 = document.getElementById("searcher1-content");
			suggest1.style.display = "none";	
		$('#searcher1').autocomplete({
			minLength: 3,
			source: function(request, response) {
				$('#searcher1-content').html(" ");
				$.ajax({
				url: "/pages/suggest.php",
				type: 'post',
				data: {
					search_text: request.term
				},
				success: function(data) {
				$('#searcher1-content').addClass("dropdown-menu");
				$('#searcher1-content').html(data);
				suggest1.style.display = "block";	
				}
				});
			},
		});
			if ($('#searcher1').val().length&gt;=3)
			{
				suggest1.style.display = "block";
			}
	});
});
$(document).ready(function () {
	$('.collapse')
		.on('shown.bs.collapse', function() {
			$(this)
				.parent().parent()
				.find(".fa-plus-square-o")
				.removeClass("fa-plus-square-o")
				.addClass("fa-minus-square-o");
		})
		.on('hidden.bs.collapse', function() {
			$(this)
				.parent().parent()
				.find(".fa-minus-square-o")
				.removeClass("fa-minus-square-o")
				.addClass("fa-plus-square-o");
		});
});
	
	</pre></body></html>