module.exports = function() {

	'use strict';

	const $ = require('jquery');

	let SgJobs = {};

	SgJobs.init = function() {
		$('body').delegate('.sgjobs-select', 'change', function() {
			$.post(
				'?eID=sgAjax&extensionName=SgJobs&controller=Ajax%5CJoblist&action=filter&format=html',
				{
					parameters: {
						country: $('#filter-countries').val(),
						location: $('#filter-locations').val(),
						company: $('#filter-companies').val(),
						area: $('#filter-areas').val(),
						function: $('#filter-functions').val(),
					}
				}
			).done(function(result) {
				// replace filter & job list with result from ajax controller
				$('#sgjobs-joblist').html(result);
			});
		});
	};

	return SgJobs;
};