function OCTgeturlparam(param) {
	var urlParams = new URLSearchParams(window.location.search);
	return urlParams.get(param) !== null ? param+'='+urlParams.get(param) : '';
}
var OCT4_GET_LANG = '';
var optprcact_ur120X = 'index.php?route=module/optprcact/';
var optprcact_url230X = 'index.php?route=extension/module/optprcact/';
var optprcact_url401X = 'index.php?route=extension/optprcact/module/optprcact|';
var optprcact_url402X = 'index.php?route=extension/optprcact/module/optprcact.';

var optprcact = {
	'setprc': function() {
		$.ajax({
			url: optprcact_url230X + 'setprc' + OCT4_GET_LANG,
			type: 'post',
			data: $('#product input[type=\'text\'], #product input[type=\'hidden\'], #product input[type=\'radio\']:checked, #product input[type=\'checkbox\']:checked, #product select, #product textarea'),
			dataType: 'json',
			beforeSend: function() {
				$('.ulprc').after('<i class="fa fa-circle-o-notch fa-solid fa-arrows-rotate fa-spin"></i>');
			},
			complete: function() {
				$('.fa-spin').remove();
			}, 
			success: function(json) {
				if(json) {
					$('.oldprc').remove();
					$('.newprc').html(json['price']);
 					if(json['tax']) { $('.extaxprc').html(json['tax']); } 
 				}
			}
		});
	},
	'initjson': function() {
		$('#product').parent().find('ul.list-unstyled').find('h2').parent().parent().addClass('ulprc');
		$('ul.ulprc li span').addClass('oldprc');
		$('ul.ulprc li h2').addClass('newprc');			
		
		if ($('ul.ulprc li').length > 2) {
			$('ul.ulprc li').eq(2).addClass('extaxprc');
		} else {
			$('ul.ulprc li').eq(1).addClass('extaxprc');
		}
		
		$('input[name="quantity"]').keyup(function() {
			optprcact.setprc();
		});
		$('input[name="quantity"]').change(function() {
			optprcact.setprc();
		});
		if ($('input[name="quantity"]').val() > 1) {
			optprcact.setprc();
		}
		$('#product select, #product input[type=\'checkbox\'], #product input[type=\'radio\']').change(function(){
			optprcact.setprc();
		});	
	}
}
$(document).ready(function(){ 
	optprcact.initjson(); 
});
/*J3*/
$(document).ready(function(){ 
	$('#product select, #product input[type=\'checkbox\'], #product input[type=\'radio\']').change(function(){
		$(document).ajaxStop(function() {
			$('.product-price-old').remove();
		});
	});
});
/*J2*/
$(document).ready(function(){ 
	$('#product select, #product input[type=\'checkbox\'], #product input[type=\'radio\']').change(function(){
		$(document).ajaxStop(function() {
			$('.price-old').remove();
		});
	});
});