<?php

/**
 * @package SJ Filter for JS Jobs
 * @version 1.0.0
 * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
 * @copyright (c) 2014 YouTech Company. All Rights Reserved.
 * @author YouTech Company http://www.smartaddons.com
 *
 */
error_reporting(0);
defined('_JEXEC') or die;
//JHtml::_('behavior.framework');;
use Joomla\CMS\Factory;
$doc = JFactory::getDocument();
$basepath = JURI::root(true).'/modules/' . $module->module . '/assets/';
JHtml::stylesheet('modules/' . $module->module . '/assets/css/style.css');
if ($params->get('use_fontawesome', 0)) {
	JHtml::stylesheet('modules/' . $module->module . '/assets/css/font-awesome.min.css');
}
$doc->addScript($basepath.'js/sjjsjobfilter.js');
$app  = Factory::getApplication();
$tag_id = 'sj_jsjob_filter'.rand().time();

$formid = 'sj-jsjob-filter-form-'.$module->id;
$itemid = $params->get('set_itemid',0)?$params->get('set_itemid',0):$app->input->getInt('Itemid',0);
$class_sfx = $params->get('moduleclass_sfx');
$ajax_filter = $params->get('ajax_filter', 0);
$auto_filter = (int) $params->get('auto_filter');

$catMode = (int) $params->get('catMode', 0);

?>
<div class="sj_jsjob_filter_shopby <?php echo $params->get('mod_layout'); ?>" id="<?php echo $tag_id; ?>">
	<h3 class="block-subtitle filter-subtitle"><?php echo JText::_('MOD_SJ_FILTER_JSJOBS_SHOP_BY'); ?></h3>
	<div class="sj_filter_shopby_content">
		<form id="<?php echo $formid; ?>" name="<?php echo $formid; ?>" method="POST" action="<?php echo JRoute::_('index.php?option=com_sjjsjobfilter&view=job'); ?>">
			<input type="hidden" name="task" value="search">
			<div class="list-filter">
				<ul id="sjjsjobsfilter<?php echo $module->id; ?>" class="filter-options filter-list">
					<?php 
						$j = 0;
						$clear = '';
						$style = '';

						if ($params->get('filter_by_keyword', 0)) {
							if($params->get('mod_column') >0 && (($j) % $params->get('mod_column')) == 0){
								$clear = " clear:both;";
							}
							if($mod_column || $clear){
								$style ='style="'.$mod_column.$clear.'"';
							}
							$j++;
			            	foreach($fieldsordering AS $field) {
			            		$title = JText::_($field->fieldtitle);
			            		if ($field->field == 'jobtitle') {?>
			            			<li <?php echo $style; ?> class="item-box">
			            				<div class="filter-input filter-field">
			            					<div class="filter-options-title"><span><?php echo JText::_($title); ?></span></div>
			            					<div class="filter-options-content">
			            						<input type="text" name="jobtitle" id="jobtitle<?php echo $module->id; ?>" class="inputbox" value="<?php echo htmlspecialchars($app->input->getVar('jobtitle','')); ?>" placeholder="<?php echo JText::_($title); ?>" />
			            					</div>
			            				</div>
			            			</li>
								<?php $clear = '';}
			            	}
			            	$clear = '';
			            }

			            if ($params->get('search_by_date', 0)) {
			            	$style = '';
							if($params->get('mod_column') >0 && (($j) % $params->get('mod_column')) == 0){
								$clear = " clear:both;";
							}
							if($mod_column || $clear){
								$style ='style="'.$mod_column.$clear.'"';
							}
							$j++;?>

							<li <?php echo $style; ?> class="item-box">
								<div class="filter-input filter-field">
									<div class="filter-options-title"><span><?php echo JText::_('MOD_SJ_FILTER_JSJOBS_DATE_POSTED')?></span></div>
									<div class="filter-options-content ">
						                <div class="filter-list filter-by-date">
						                	<?php if ($params->get('filter_by_date_fieldtype', 'radio') == 'select') {?>
						                		<select class="" name="date_posted">
						                			<option value=""><?php echo JText::_('MOD_SJ_FILTER_JSJOBS_PLEASE_CHOOSE'); ?></option>
						                			<option value="hours" <?php echo $app->input->getVar('date_posted','') == 'hours' ? 'selected="selected"' : ''; ?>><?php echo JText::_('MOD_SJ_FILTER_JSJOBS_24_HOURS'); ?> <?php echo JobFilterHelper::getCountJobByDate('hours', $params) ? JobFilterHelper::getCountJobByDate('hours', $params) : ''; ?></option>
						                			<option value="days" <?php echo $app->input->getVar('date_posted','') == 'days' ? 'selected="selected"' : ''; ?>><?php echo JText::_('MOD_SJ_FILTER_JSJOBS_3_DAYS'); ?> <?php echo JobFilterHelper::getCountJobByDate('days', $params) ? JobFilterHelper::getCountJobByDate('days', $params) : ''; ?></option>
						                			<option value="weeks" <?php echo $app->input->getVar('date_posted','') == 'weeks' ? 'selected="selected"' : ''; ?>><?php echo JText::_('MOD_SJ_FILTER_JSJOBS_7_DAYS'); ?> <?php echo JobFilterHelper::getCountJobByDate('weeks', $params) ? JobFilterHelper::getCountJobByDate('weeks', $params) : ''; ?></option>
						                			<option value="months" <?php echo $app->input->getVar('date_posted','') == 'months' ? 'selected="selected"' : ''; ?>><?php echo JText::_('MOD_SJ_FILTER_JSJOBS_30_DAYS'); ?> <?php echo JobFilterHelper::getCountJobByDate('months', $params) ? JobFilterHelper::getCountJobByDate('months', $params) : ''; ?></option>
						                		</select>
						                	<?php }else if ($params->get('filter_by_date_fieldtype', 'radio') == 'checkbox') {?>
						                		<ul>
													<li>
														<label>
															<input type="checkbox" name="date_posted[]" value="hours" <?php echo ($app->input->getVar('date_posted','') == 'hours') ? 'checked="checked"' : ''; ?> /> <?php echo JText::_('MOD_SJ_FILTER_JSJOBS_24_HOURS'); ?>
														</label>
													</li>
													<li>
														<label>
															<input type="checkbox" name="date_posted[]" value="days" <?php echo ($app->input->getVar('date_posted','') == 'days') ? 'checked="checked"' : ''; ?> /> <?php echo JText::_('MOD_SJ_FILTER_JSJOBS_3_DAYS'); ?>
														</label>
													</li>
													<li>
														<label>
															<input type="checkbox" name="date_posted[]" value="weeks" <?php echo ($app->input->getVar('date_posted','') == 'weeks') ? 'checked="checked"' : ''; ?> /> <?php echo JText::_('MOD_SJ_FILTER_JSJOBS_7_DAYS'); ?>
														</label>
													</li>
													<li>
														<label>
															<input type="checkbox" name="date_posted[]" value="months" <?php echo ($app->input->getVar('date_posted','') == 'months') ? 'checked="checked"' : ''; ?> /> <?php echo JText::_('MOD_SJ_FILTER_JSJOBS_30_DAYS'); ?>
														</label>
													</li>
												</ul>
						                	<?php }else {?>
												<ul>
													<li>
														<label>
															<input type="radio" name="date_posted" value="hours" <?php echo ($app->input->getVar('date_posted','') == 'hours') ? 'checked="checked"' : ''; ?> /> <?php echo JText::_('MOD_SJ_FILTER_JSJOBS_24_HOURS'); ?> <?php echo JobFilterHelper::getCountJobByDate('hours', $params) ? JobFilterHelper::getCountJobByDate('hours', $params) : ''; ?>
														</label>
													</li>
													<li>
														<label>
															<input type="radio" name="date_posted" value="days" <?php echo ($app->input->getVar('date_posted','') == 'days') ? 'checked="checked"' : ''; ?> /> <?php echo JText::_('MOD_SJ_FILTER_JSJOBS_3_DAYS'); ?> <?php echo JobFilterHelper::getCountJobByDate('hours', $params) ? JobFilterHelper::getCountJobByDate('days', $params) : ''; ?>
														</label>
													</li>
													<li>
														<label>
															<input type="radio" name="date_posted" value="weeks" <?php echo ($app->input->getVar('date_posted','') == 'weeks') ? 'checked="checked"' : ''; ?> /> <?php echo JText::_('MOD_SJ_FILTER_JSJOBS_7_DAYS'); ?> <?php echo JobFilterHelper::getCountJobByDate('hours', $params) ? JobFilterHelper::getCountJobByDate('weeks', $params) : ''; ?>
														</label>
													</li>
													<li>
														<label>
															<input type="radio" name="date_posted" value="months" <?php echo ($app->input->getVar('date_posted','') == 'months') ? 'checked="checked"' : ''; ?> /> <?php echo JText::_('MOD_SJ_FILTER_JSJOBS_30_DAYS'); ?> <?php echo JobFilterHelper::getCountJobByDate('hours', $params) ? JobFilterHelper::getCountJobByDate('months', $params) : ''; ?>
														</label>
													</li>
												</ul>
											<?php }?>
										</div>
						            </div>
								</div>
							</li>
			            <?php $clear = '';}

			            foreach($fieldsordering as $field){
			            	$title = JText::_($field->fieldtitle);
							
							switch ($field->field) {
								case 'company':
					            	if ($params->get('search_by_company', 0)) {
					            		$style = '';
										if($params->get('mod_column') >0 && (($j) % $params->get('mod_column')) == 0){
											$clear = " clear:both;";
										}
										if($mod_column || $clear){
											$style ='style="'.$mod_column.$clear.'"';
										}
										$j++;
					            		$html = '<li '.$style.' class="item-box">';
											$html .= '<div class="filter-input filter-field">';
												$html .= '<div class="filter-options-title"><span>'.JText::_($title).'</span></div>';
												$html .= '<div class="filter-options-content ">';
													if ($params->get('filter_by_company_fieldtype', 'radio') == 'select') {
														$html .= '<select name="jobcompany" class="inputbox">';
															$html .= '<option value="">'.JText::_('MOD_SJ_FILTER_JSJOBS_PLEASE_CHOOSE').'</option>';
															foreach (JobFilterHelper::getJobCompanies($params) as $key => $com) {
																$html .= '<option value="'.$com['value'].'" '.($app->input->getVar('jobcompany','') == $com['value'] ? 'selected="selected"' : '').'>'.$com['text'].' '.($com['count'] ? $com['count'] : '').'</option>';
															}
														$html .= '</select>';
													}
													else if ($params->get('filter_by_company_fieldtype', 'radio') == 'radio') {
														$html .= '<ul>';
															foreach (JobFilterHelper::getJobCompanies($params) as $key => $com) {
																$html .= '<li '.($key > 7 ? 'class="hidden" style="display: none;"' : '').'>';
																	$html .= '<label>';
																		$html .= '<input type="radio" name="jobcompany" class="inputbox" value="'.$com['value'].'" '.($app->input->getVar('jobcompany','') == $com['value'] ? 'checked="checked"' : '').' /> '.$com['text'] . " " . ($com['count'] ? $com['count'] : '');
																	$html .= '</label>';
																$html .= '</li>';
															}
															if (count(JobFilterHelper::getJobCompanies($params)) > 7) {
																$html .= '<li class="show-more"><a href="javascript:void(0);" id="more_company">'.JText::_('MOD_SJ_FILTER_JSJOBS_VIEW_MORE').'</a></li>';
															}
														$html .= '</ul>';
													}
													else {
														$html .= '<ul>';
															foreach (JobFilterHelper::getJobCompanies($params) as $key => $com) {
																$html .= '<li '.($key > 7 ? 'class="hidden" style="display: none;"' : '').'>';
																	$html .= '<label>';
																		$html .= '<input type="checkbox" name="jobcompany[]" class="inputbox" value="'.$com['value'].'" '.($app->input->getVar('jobcompany','') == $com['value'] ? 'checked="checked"' : '').' /> '.$com['text'] . " " . ($com['count'] ? $com['count'] : '');
																	$html .= '</label>';
																$html .= '</li>';
															}
															if (count(JobFilterHelper::getJobCompanies($params)) > 7) {
																$html .= '<li class="show-more"><a href="javascript:void(0);" id="more_company">'.JText::_('MOD_SJ_FILTER_JSJOBS_VIEW_MORE').'</a></li>';
															}
														$html .= '</ul>';
													}
												$html .= '</div>';
											$html .= '</div>';
										$html .= '</li>';$clear = '';
									}
									echo $html;
					            break;
					            case 'jobcategory':
					                if ($params->get('search_by_category', 0)) {
					                	$style = '';
										if($params->get('mod_column') >0 && (($j) % $params->get('mod_column')) == 0){
											$clear = " clear:both;";
										}
										if($mod_column || $clear){
											$style ='style="'.$mod_column.$clear.'"';
										}
										$j++;
					                	$html = '<li '.$style.' class="item-box">';
										$html .= '<div class="filter-input filter-field">';
										$html .= '<div class="filter-options-title"><span>'.JText::_($title).'</span></div>';
										$html .= '<div class="filter-options-content ">';
										if ($params->get('filter_by_category_fieldtype', 'radio') == 'select') {
											$html .= '<select name="job_cat" class="inputbox">';
												$html .= '<option value="">'.JText::_('MOD_SJ_FILTER_JSJOBS_PLEASE_CHOOSE').'</option>';
												foreach (JobFilterHelper::getJobCategories($params) as $key => $cat) {
													$html .= '<option value="'.$cat['value'].'" '.($app->input->getVar('job_cat','') == $cat['value'] ? 'selected="selected"' : '').'>'.$cat['text'].' '.($cat['count'] ? $cat['count'] : '').'</option>';
												}
											$html .= '</select>';
										}
										else if ($params->get('filter_by_category_fieldtype', 'radio') == 'radio') {
											$html .= '<ul>';
												foreach (JobFilterHelper::getJobCategories($params) as $key => $cat) {
													$html .= '<li '.($key > 7 ? 'class="hidden" style="display: none;"' : '').'>';
														$html .= '<label>';
															$html .= '<input type="radio" name="job_cat" class="inputbox" value="'.$cat['value'].'" '.($app->input->getVar('job_cat','') == $cat['value'] ? 'checked="checked"' : '').' /> '.$cat['text'].' '.($cat['count'] ? $cat['count'] : '');
														$html .= '</label>';
													$html .= '</li>';
												}
												if (count(JobFilterHelper::getJobCategories($params)) > 7) {
													$html .= '<li class="show-more"><a href="javascript:void(0);" id="more_cat">'.JText::_('MOD_SJ_FILTER_JSJOBS_VIEW_MORE').'</a></li>';
												}
											$html .= '</ul>';
										}
										else {
											$html .= '<ul>';
												foreach (JobFilterHelper::getJobCategories($params) as $key => $cat) {
													$html .= '<li '.($key > 7 ? 'class="hidden" style="display: none;"' : '').'>';
														$html .= '<label>';
															$html .= '<input type="checkbox" name="job_cat[]" class="inputbox" value="'.$cat['value'].'" '.($app->input->getVar('job_cat','') == $cat['value'] ? 'checked="checked"' : '').' /> '.$cat['text'].' '.($cat['count'] ? $cat['count'] : '');
														$html .= '</label>';
													$html .= '</li>';
												}
												if (count(JobFilterHelper::getJobCategories($params)) > 7) {
													$html .= '<li class="show-more"><a href="javascript:void(0);" id="more_cat">'.JText::_('MOD_SJ_FILTER_JSJOBS_VIEW_MORE').'</a></li>';
												}
											$html .= '</ul>';
										}
										$html .= '</div>';
										$html .= '</div>';
										$html .= '</li>';$clear = '';
									}
									echo $html;
					            break;
					            /*case 'subcategory':
					                $html = '';
									$html .= '<div class="filter-heading-title"><span>'.JText::_($title).'</span></div>';
									$html .= '<div class="filter-list filter-by-subcat">';
										$html .= '<ul>';
											foreach (JobFilterHelper::getJobSubCategories() as $key => $subcat) {
												$html .= '<li '.($key > 7 ? 'class="hidden"' : '').'>';
													$html .= '<label>';
														$html .= '<input type="checkbox" name="job_sucat[]" class="inputbox" value="'.$subcat['value'].'" /> '.$subcat['text'];
													$html .= '</label>';
												$html .= '</li>';
											}
											if (count(JobFilterHelper::getJobSubCategories()) > 7) {
												$html .= '<li class="show-more"><a href="javascript:void(0);" id="more_subcat">'.JText::_('MOD_SJ_FILTER_JSJOBS_VIEW_MORE').'</a></li>';
											}
										$html .= '</ul>';
									$html .= '</div>';
									echo $html;
					            break;*/
					            case 'jobtype':
					                if ($params->get('search_by_jobtype', 0)) {
					                	$style = '';
										if($params->get('mod_column') >0 && (($j) % $params->get('mod_column')) == 0){
											$clear = " clear:both;";
										}
										if($mod_column || $clear){
											$style ='style="'.$mod_column.$clear.'"';
										}
										$j++;
					                	$html = '<li '.$style.' class="item-box">';
										$html .= '<div class="filter-input filter-field">';
										$html .= '<div class="filter-options-title"><span>'.JText::_($title).'</span></div>';
						                $html .= '<div class="filter-options-content ">';
						                	if ($params->get('filter_by_jobtype_fieldtype', 'radio') == 'select') {
												$html .= '<select name="job_type" class="inputbox">';
													$html .= '<option value="">'.JText::_('MOD_SJ_FILTER_JSJOBS_PLEASE_CHOOSE').'</option>';
													$html .= '<option value="all">'.JText::_('JALL').'</option>';
													foreach ($jsjobstypes as $key => $type) {
														$html .= '<option value="'.$type['value'].'" '.($app->input->getVar('job_type','') == $type['value'] ? 'selected="selected"' : '').'>'.$type['text'].' '.($type['count'] ? $type['count'] : '').'</option>';
													}
												$html .= '</select>';
											}
											else if ($params->get('filter_by_jobtype_fieldtype', 'radio') == 'checkbox') {
												$html .= '<ul>';
													foreach ($jsjobstypes as $key => $type) {
														$html .= '<li '.($key > 7 ? 'class="hidden" style="display: none;"' : '').'>';
															$html .= '<label>';
																$html .= '<input type="checkbox" name="job_type[]" class="inputbox" value="'.$type['value'].'" '.($app->input->getVar('job_type','') == $type['value'] ? 'checked="checked"' : '').' /> '.$type['text'].' '.($type['count'] ? $type['count'] : '');
															$html .= '</label>';
														$html .= '</li>';
													}
													if (count($jsjobstypes) > 7) {
														$html .= '<li class="show-more"><a href="javascript:void(0);" id="more_cat">'.JText::_('MOD_SJ_FILTER_JSJOBS_VIEW_MORE').'</a></li>';
													}
												$html .= '</ul>';
											}
											else {
							                	$html .= '<ul>';
							                		$html .= '<li>';
														$html .= '<label>';
															$html .= '<input type="radio" name="job_type" value="all" /> '.JText::_('JALL');
														$html .= '</label>';
													$html .= '</li>';
													foreach ($jsjobstypes as $type) {
														$html .= '<li>';
															$html .= '<label>';
																$html .= '<input type="radio" name="job_type" value="'.$type['value'].'" '.($app->input->getVar('job_type','') == $type['value'] ? 'checked="checked"' : '').' /> '.$type['text'].' '.($type['count'] ? $type['count'] : '');
															$html .= '</label>';
														$html .= '</li>';
													}
							                	$html .= '</ul>';
							                }
						                $html .= '</div>';
						                $html .= '</div>';
						                $html .= '</li>';$clear = '';
						            }
									echo $html;
					            break;
					            case 'jobsalaryrange':
					            	$config = JSModel::getJSModel('configurations')->getConfig('');

							        foreach ($config as $conf) {
							            if ($conf->configname == 'currency_align')
							                $currency_align = $conf->configvalue;
							        }

							        $currency_symbol = '';
							        $currencies = JobFilterHelper::getCurrency();
							        foreach ($currencies as $key => $cur) {
							        	if ($cur->id == $currency_align) {
							        		$currency_symbol = $cur->symbol;
							        	}
							        }

							        if ($params->get('search_by_salary', 0)) {
							        	$style = '';
										if($params->get('mod_column') >0 && (($j) % $params->get('mod_column')) == 0){
											$clear = " clear:both;";
										}
										if($mod_column || $clear){
											$style ='style="'.$mod_column.$clear.'"';
										}
										$j++;

							        	$html = '<li '.$style.' class="item-box">';
										$html .= '<div class="filter-input filter-field">';
										$html .= '<div class="filter-options-title"><span>'.JText::_($title).'</span></div>';
						            	$html .= '<div class="filter-options-content ">';
						            	if ($params->get('filter_by_salary_fieldtype', 'radio') == 'select') {
						            		$html .= '<select name="salaryrange">';
						            			$html .= '<option value="">'.JText::_('MOD_SJ_FILTER_JSJOBS_PLEASE_CHOOSE').'</option>';
						            			foreach ($salaryrange as $sal) {
						            				$html .= '<option value="'.$sal['value'].'" '.($app->input->getVar('salaryrange','') == $sal['value'] ? 'selected="selected"' : '').'>'.$currency_symbol.' '.$sal['text'].' '.($sal['count'] ? $sal['count'] : '').'</option>';
						            			}
						            		$html .= '</select>';
						            	}
						            	else if ($params->get('filter_by_salary_fieldtype', 'radio') == 'checkbox') {
						            		$html .= '<ul>';
						                		foreach ($salaryrange as $key => $sal) {
													$html .= '<li '.($key > 7 ? 'class="hidden" style="display: none;"' : '').'>';
														$html .= '<label>';
															$html .= '<input type="checkbox" name="salaryrange[]" value="'.$sal['value'].'" '.($app->input->getVar('salaryrange','') == $sal['value'] ? 'checked="checked"' : '').' /> '.$currency_symbol.' '.$sal['text'].' '.($sal['count'] ? $sal['count'] : '');
														$html .= '</label>';
													$html .= '</li>';
												}
												if (count($salaryrange) > 7) {
													$html .= '<li class="show-more"><a href="javascript:void(0);" id="more_salary">'.JText::_('MOD_SJ_FILTER_JSJOBS_VIEW_MORE').'</a></li>';
												}
						                	$html .= '</ul>';
						            	}
						            	else {
							            	$html .= '<ul>';
						                		foreach ($salaryrange as $key => $sal) {
													$html .= '<li '.($key > 7 ? 'class="hidden" style="display: none;"' : '').'>';
														$html .= '<label>';
															$html .= '<input type="radio" name="salaryrange" value="'.$sal['value'].'" '.($app->input->getVar('salaryrange','') == $sal['value'] ? 'checked="checked"' : '').' /> '.$currency_symbol.' '.$sal['text'].' '.($sal['count'] ? $sal['count'] : '');
														$html .= '</label>';
													$html .= '</li>';
												}
												if (count($salaryrange) > 7) {
													$html .= '<li class="show-more"><a href="javascript:void(0);" id="more_salary">'.JText::_('MOD_SJ_FILTER_JSJOBS_VIEW_MORE').'</a></li>';
												}
						                	$html .= '</ul>';
						                }
						            	$html .= '</div>';
						            	$html .= '</div>';
						            	$html .= '</li>';$clear = '';
						            }
					            	echo $html;
					            break;
					            case 'jobstatus':
					                if ($params->get('search_by_status', 0)) {
					                	$style = '';
										if($params->get('mod_column') >0 && (($j) % $params->get('mod_column')) == 0){
											$clear = " clear:both;";
										}
										if($mod_column || $clear){
											$style ='style="'.$mod_column.$clear.'"';
										}
										$j++;
					                	$html = '<li '.$style.' class="item-box">';
										$html .= '<div class="filter-input filter-field">';
										$html .= '<div class="filter-options-title"><span>'.JText::_($title).'</span></div>';
										$html .= '<div class="filter-options-content ">';
											if ($params->get('filter_by_status_fieldtype', 'radio') == 'select') {
												$html .= '<select name="jobstatus" class="inputbox">';
													$html .= '<option value="">'.JText::_('MOD_SJ_FILTER_JSJOBS_PLEASE_CHOOSE').'</option>';
													foreach (JobFilterHelper::getJobStatus($params) as $key => $status) {
														$html .= '<option value="'.$status['value'].'" '.($app->input->getVar('jobstatus','') == $status['value'] ? 'selected="selected"' : '').'>'.$status['text'].' '.($status['count'] ? $status['count'] : '').'</option>';
													}
												$html .= '</select>';
											}
											else if ($params->get('filter_by_status_fieldtype', 'radio') == 'radio') {
												$html .= '<ul>';
													foreach (JobFilterHelper::getJobStatus($params) as $key => $status) {
														$html .= '<li '.($key > 7 ? 'class="hidden" style="display: none;"' : '').'>';
															$html .= '<label>';
																$html .= '<input type="radio" name="jobstatus" class="inputbox" value="'.$status['value'].'" '.($app->input->getVar('jobstatus','') == $status['value'] ? 'checked="checked"' : '').' /> '.$status['text'].' '.($status['count'] ? $status['count'] : '');
															$html .= '</label>';
														$html .= '</li>';
													}
													if (count(JobFilterHelper::getJobStatus($params)) > 7) {
														$html .= '<li class="show-more"><a href="javascript:void(0);" id="more_cat">'.JText::_('MOD_SJ_FILTER_JSJOBS_VIEW_MORE').'</a></li>';
													}
												$html .= '</ul>';
											}
											else {
												$html .= '<ul>';
													foreach (JobFilterHelper::getJobStatus($params) as $key => $status) {
														$html .= '<li '.($key > 7 ? 'class="hidden"' : '').'>';
															$html .= '<label>';
																$html .= '<input type="checkbox" name="jobstatus[]" class="inputbox" value="'.$status['value'].'" '.($app->input->getVar('jobstatus','') == $status['value'] ? 'checked="checked"' : '').' /> '.$status['text'].' '.($status['count'] ? $status['count'] : '');
															$html .= '</label>';
														$html .= '</li>';
													}
													if (count(JobFilterHelper::getJobStatus($params)) > 7) {
														$html .= '<li class="show-more"><a href="javascript:void(0);" id="more_jobstatus">'.JText::_('MOD_SJ_FILTER_JSJOBS_VIEW_MORE').'</a></li>';
													}
												$html .= '</ul>';
											}
										$html .= '</div>';
										$html .= '</div>';
										$html .= '</li>';$clear = '';
									}
									echo $html;
					            break;
					            case 'careerlevel':
					                if ($params->get('search_by_careerlevel', 0)) {
					                	$style = '';
										if($params->get('mod_column') >0 && (($j) % $params->get('mod_column')) == 0){
											$clear = " clear:both;";
										}
										if($mod_column || $clear){
											$style ='style="'.$mod_column.$clear.'"';
										}
										$j++;
					                	$html = '<li '.$style.' class="item-box">';
										$html .= '<div class="filter-input filter-field">';
										$html .= '<div class="filter-options-title"><span>'.JText::_($title).'</span></div>';
										$html .= '<div class="filter-options-content ">';
											if ($params->get('filter_by_careerlevel_fieldtype', 'radio') == 'select') {
												$html .= '<select name="careerlevel" class="inputbox">';
													$html .= '<option value="">'.JText::_('MOD_SJ_FILTER_JSJOBS_PLEASE_CHOOSE').'</option>';
													foreach (JobFilterHelper::getCareerLevel($params) as $key => $level) {
														$html .= '<option value="'.$level['value'].'" '.($app->input->getVar('careerlevel','') == $level['value'] ? 'selected="selected"' : '').'>'.$level['text'].' '.($level['count'] ? $level['count'] : '').'</option>';
													}
												$html .= '</select>';
											}
											else if ($params->get('filter_by_careerlevel_fieldtype', 'radio') == 'radio') {
												$html .= '<ul>';
													foreach (JobFilterHelper::getCareerLevel($params) as $key => $level) {
														$html .= '<li '.($key > 7 ? 'class="hidden" style="display: none;"' : '').'>';
															$html .= '<label>';
																$html .= '<input type="radio" name="careerlevel" class="inputbox" value="'.$level['value'].'" '.($app->input->getVar('careerlevel','') == $level['value'] ? 'checked="checked"' : '').' /> '.$level['text'].' '.($level['count'] ? $level['count'] : '');
															$html .= '</label>';
														$html .= '</li>';
													}
													if (count(JobFilterHelper::getCareerLevel($params)) > 7) {
														$html .= '<li class="show-more"><a href="javascript:void(0);" id="more_cat">'.JText::_('MOD_SJ_FILTER_JSJOBS_VIEW_MORE').'</a></li>';
													}
												$html .= '</ul>';
											}
											else {
												$html .= '<ul>';
													foreach (JobFilterHelper::getCareerLevel($params) as $key => $level) {
														$html .= '<li '.($key > 7 ? 'class="hidden"' : '').'>';
															$html .= '<label>';
																$html .= '<input type="checkbox" name="careerlevel[]" class="inputbox" value="'.$level['value'].'" '.($app->input->getVar('careerlevel','') == $level['value'] ? 'checked="checked"' : '').' /> '.$level['text'].' '.($level['count'] ? $level['count'] : '');
															$html .= '</label>';
														$html .= '</li>';
													}
													if (count(JobFilterHelper::getCareerLevel($params)) > 7) {
														$html .= '<li class="show-more"><a href="javascript:void(0);" id="more_careerlevel">'.JText::_('MOD_SJ_FILTER_JSJOBS_VIEW_MORE').'</a></li>';
													}
												$html .= '</ul>';
											}
										$html .= '</div>';
										$html .= '</div>';
										$html .= '</li>';
									}
									echo $html;
					            break;
							}
						}
					?>
					<?php
						$style='';
						if($params->get('mod_column') >0 && (($j) % $params->get('mod_column')) == 0){
							$clear = " clear:both;";
						}
						if($mod_column || $clear){
							$style ='style="'.$mod_column.$clear.'"';
						}
						$j++;
					?>
					<li <?php echo $style;?> class="last-item item-box box-submit">
				    	<?php if($params->get('auto_filter',1) == 0) {?>
			        		<button class="search_button btn submit" id="submit_btn" name="btnSubmit" type="submit" onclick="this.form.submit();"><?php echo JText::_('Search'); ?></button>
		        		<?php }?>
		        		<?php if($params->get('enable_reset_button',1) == 1) { ?>
		        			<button class="search_button btn reset" id="reset_btn" name="btnReset" onclick="sjJSJOBResetSearch('<?php echo $module->id;?>', '<?php echo $formid; ?>', true);"><?php echo JText::_('Reset'); ?></button>
			        	<?php }?>
					</li>
				</ul>
			</div>
			<?php if($params->get('ajax_filter', 0) == 1) { ?>
				<input type="hidden" name="tmpl" value="component"/>
			<?php } ?>

			<?php if($catMode) { ?>
			<input type="hidden" name="isc" value="1" />
			<?php } ?>
		</form>
		<?php if ($params->get('mod_layout') == 'horizontal-layout') {?>
			<span class="buton_collap">Close</span>
		<?php }?>
	</div>
</div>
<script type="text/javascript">
//<![CDATA[
jQuery(document).ready(function($){
	;(function(element){
		var $element = $(element);
		
		$('.list-filter div.filter-options-title', $element).on('click', function() {
			if ($(this).hasClass('collapsed')) {
				$(this).removeClass('collapsed');
				$(this).next().slideDown();
			}
			else {
				$(this).removeClass('collapsed').addClass('collapsed');
				$(this).next().slideUp();
			}
		});

		$('.show-more').on('click', function() {
			if ($(this).hasClass('opened')) {
				$(this).removeClass('opened');
				$(this).children('a').text('View More');
				$(this).parent().find('li.no-hidden').addClass('hidden').hide();
				$(this).parent().find('li').removeClass('no-hidden');
			}
			else {
				$(this).removeClass('opened').addClass('opened');
				$(this).parent().find('li.hidden').addClass('no-hidden').show();
				$(this).parent().find('li').removeClass('hidden');
				$(this).children('a').text('View Less');
			}
		});

		$('.buton_collap', $element).on('click', function() {
			if ($(this).hasClass('collapsed')) {
				$(this).removeClass('collapsed');
				$(this).prev().find('#sjjsjobsfilter<?php echo $module->id; ?>').slideDown();
				$(this).text('Close');
				$(this).parent('.sj_filter_shopby_content').removeClass('noborder');
			}
			else {
				$(this).removeClass('collapsed').addClass('collapsed');
				$(this).prev().find('#sjjsjobsfilter<?php echo $module->id; ?>').slideUp();
				$(this).text('Open');
				$(this).parent('.sj_filter_shopby_content').removeClass('noborder').addClass('noborder');
			}
		})

	})('#<?php echo $tag_id; ?>');
});
//]]>
</script>

<script type="text/javascript">
//<![CDATA[
jQuery(document).ready(function($){
	<?php if ($auto_filter) { ?>
		var f = $('#<?php echo $formid; ?>');

		f.find('input').each(function(){
			$(this).change(function() {
				$('#<?php echo $formid; ?>').submit();
			});			
		})

		f.find('select').each(function(el) {
			$(this).change(function() {
                $('#<?php echo $formid; ?>').submit();
			});
		});
		f.find('textarea').each(function(el) {
			$(this).change(function() {
				$('#<?php echo $formid; ?>').submit();
			});
		});
	<?php }?>

	<?php if($ajax_filter) { ?>
		$('<?php echo $formid; ?>').on('submit', function() {
			sjJSJOBAjaxSubmit(this, '<?php echo JURI::root(true).'/'; ?>');
			return false;
		});
		jQuery('#<?php echo $formid; ?>').on('submit', function(event) {
			event.preventDefault();
			sjJSJOBAjaxSubmit(this, '<?php echo JURI::root(true).'/'; ?>');
			return false;
		});	
	<?php }else { ?>
		$('#<?php echo $formid; ?>').addEventListener('submit', function() {
			$('#<?php echo $formid; ?>').submit();
		});
	<?php } ?>
})
//]]>
</script>