	</div>

	<script async src="https://cdn.nerivon.ca/nvform.js"></script>
	<script async src="/js/min/nv-tabs.min.js?v=<?php echo(PRODUCT_VERSION); ?>"></script>
	<script async src="/js/min/wickedpicker.min.js?v=<?php echo(PRODUCT_VERSION); ?>"></script>
	<script async src="/js/min/tokeninput.min.js?v=<?php echo(PRODUCT_VERSION); ?>"></script>
	<script async src="/js/min/jquery.cropit.min.js?v=<?php echo(PRODUCT_VERSION); ?>"></script>
	<script async src="/js/min/jquery-sortable.min.js?v=<?php echo(PRODUCT_VERSION); ?>"></script>
	<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js" integrity="sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49" crossorigin="anonymous"></script>
	<script async src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js" integrity="sha384-ChfqqxuZUCnJSK3+MXmPNIyE6ZbWh2IMqE241rYiqJxyMiZ6OW/JmZQ5stwEULTy" crossorigin="anonymous"></script>
	<script src="/js/min/scripts.min.js?v=<?php echo(PRODUCT_VERSION); ?>"></script>
	<script src="/js/min/admin.min.js?v=<?php echo(PRODUCT_VERSION); ?>"></script>
	<script src="/js/min/nvfinder.min.js?v=<?php echo(PRODUCT_VERSION); ?>"></script>
	<script src="/js/min/nv-sidebar.min.js?v=<?php echo(PRODUCT_VERSION); ?>"></script>
	<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.7.2/angular.min.js"></script>
	<script src="/js/min/ng-quick-date.min.js?v=<?php echo(PRODUCT_VERSION); ?>"></script>
	<script src="/js/min/app.min.js?v=<?php echo(PRODUCT_VERSION); ?>"></script>
	<script src="/js/min/ModuleController.min.js?v=<?php echo(PRODUCT_VERSION); ?>"></script>
	<script src="/js/min/ProductController.min.js?v=<?php echo(PRODUCT_VERSION); ?>"></script>

	<?php
	// Look at the upcoming output and find any AngularJS controllers being referenced. Load those files.
	/*preg_match_all('/ng\-controller\=\"(.*?)Controller\"/', $this->output->get_output(), $controllers);

	if(is_array($controllers) && is_array($controllers[1]))
	{
		foreach($controllers[1] as $c)
		{
			?><script src="/js/min/<?php echo($c); ?>Controller.min.js?v=<?php echo(PRODUCT_VERSION); ?>"></script><?php
		}
	}*/
	?>

	<script>
	//add a fancy spinning icon to the data loading popup
	jQuery(window).on("load", function()
	{
		jQuery(".nv-tabs").nvTabs({ active: <?php echo(isset($default_tab) ? $default_tab : 1); ?> });

		jQuery(".accordion > legend").each(function()
		{
			jQuery(this).html('<em class="fas fa-angle-down" aria-hidden="true"></em> ' + jQuery(this).html());
		});

		jQuery(".accordion > legend").click(function()
		{
			var open = jQuery(this).parent().hasClass("accordion-open");

			// Close all accordions.
			jQuery(".accordion-open > legend").each(function()
			{
				jQuery(this).children(".fa-angle-down").css({"transform": "rotate(0deg)"});
				jQuery(this).parent().toggleClass("accordion-open");
				jQuery(this).siblings("div").slideToggle(300);
			});

			// Open the one that was clicked, if necessary.
			// If it was not already open, open it.
			if(!open)
			{
				jQuery(this).children(".fa-angle-down").css({"transform": "rotate(270deg)"});
				jQuery(this).parent().toggleClass("accordion-open");
				jQuery(this).siblings("div").slideToggle(300);
			}
		});

		jQuery(".accordion-autofocus > legend").click();

		<?php
		if(isset($default_tab))
		{
			?>
			jQuery(".tabs").tabs(
			{
				active:<?php echo($default_tab); ?>,
				activate: function(event, ui)
				{
					var value = 0;

					switch(ui.newPanel.attr('id'))
					{
						case "tabs-info":
						{
							value = 0;
							break;
						}
						case "tabs-prices":
						{
							value = 1;
							break;
						}
						case "tabs-images":
						{
							value = 2;
							break;
						}
						case "tabs-details":
						{
							value = 3;
							break;
						}
						case "tabs-categories":
						{
							value = 4;
							break;
						}
					}
					jQuery("#default_tab").val(value);
				}
			});
			<?php
		}
		else
		{
			?>jQuery(".tabs").tabs();<?php
		}
		?>

		jQuery(".nv-sidebar").each(function()
		{
			jQuery(this).nvSidebar();
		});
	});

	var typingTimer;				//timer identifier
	var doneTypingInterval = 500;	//time in ms

	//on keyup, start the countdown
	jQuery('#search_q').keyup(function(e)
	{
		// Ignore all of these keys.  All they do is cause redundant searches to be triggered.
		if(e.keyCode == 9 ||	//tab
		   e.keyCode == 16 ||	//shift
		   e.keyCode == 17 ||	//control
		   e.keyCode == 18 ||	//alt/option
		   e.keyCode == 91 ||	//command
		   e.keyCode == 37 ||	//arrow key
		   e.keyCode == 38 ||	//arrow key
		   e.keyCode == 39 ||	//arrow key
		   e.keyCode == 40 ||	//arrow key
		   e.keyCode == 20 		//caps lock
		   )
		{
			e.preventDefault();

			return false;
		}

		// Close the search box when escape is pressed.
		if(e.keyCode == 27)
		{
			jQuery("#menu-search-result").html("").css({ opacity: 0 });
			e.preventDefault();

			return false;
		}

	    clearTimeout(typingTimer);
	    typingTimer = setTimeout(doneTyping, doneTypingInterval);
	});

	//on keydown, clear the countdown
	jQuery('#search_q').keydown(function()
	{
	    clearTimeout(typingTimer);
	});
	</script>

	<?php $this->load->view("common/footer_custom"); ?>
</body>
</html>
