<?php 
	$page = get_page($post->ID);
	$current_page_id = $page->ID;
	$page_slider = get_post_meta($current_page_id, 'page_slider', true); 

	global $redux_demo, $maximRange; 
	$max_range = $redux_demo['max_range'];	
	$headerV2Title = $redux_demo['homepage-v2-title'];
	$headerV2Desc = $redux_demo['homepage-v2-desc'];
	$allCatURL = $redux_demo['all-cat-page-link'];
	$trnsCatVAll = $redux_demo['trns-cat-viewall-btn'];
	$catSecTitle = $redux_demo['cat-sec-title'];
	$catSecDesc = $redux_demo['cat-sec-desc'];
	$ad_desc = $redux_demo['ad-desc'];

	if(!empty($max_range)) {
		$maximRange = $max_range;
	} else {
		$maximRange = 1000;
	}
	$category_icon_code = "";
	$category_icon_color = "";
	$your_image_url = "";
	$caticoncolor="";
	$category_icon="";

?>
<section class="customBg">
	<div class="customBgText">
		<h1><?php echo $headerV2Title; ?></h1>
		<p><?php echo $headerV2Desc; ?></p>
	</div><!--End customBgText Div -->
	<div class="row">
		<div class="large-12 columns">
			<div class="customBgSearch">
				<form action="<?php echo home_url(); ?>" method="get" id="views-exposed-form-search-view-other-ads-page" accept-charset="UTF-8">
					<div class="row">
					<?php $turnonsearchcat = $redux_demo['turnonsearchcat']; ?>
					<?php $turnonsearchloc = $redux_demo['turnonsearchloc']; ?>
					<?php 
					if($turnonsearchcat != 1 && $turnonsearchloc == 1){
						$keyclass = "large-6";
					}
					if($turnonsearchloc !=1 && $turnonsearchcat == 1){
						$keyclass = "large-8";
					}
					if($turnonsearchcat != 1 && $turnonsearchloc != 1){
						$keyclass = "large-10";
					}
					if($turnonsearchcat == 1 && $turnonsearchloc == 1){
						$keyclass = "large-4";
					}
					?>
						<div class="<?php echo $keyclass; ?> columns">
							<div class="inner-addon right-addon">
								<input placeholder="<?php esc_html_e( 'Enter keyword...', 'classiera' ); ?>" type="text" id="edit-search-api-views-fulltext" name="s" value="" size="30" maxlength="128" class="form-text classieraSearchAJax">
								<span class="load-gif load-gif-v2"><img src="<?php echo get_template_directory_uri().'/images/load.gif' ?>" alt="classiera loader"></span>
								<ul class="classieraAjaxResult"></ul>
							</div>
						</div><!--large-4 columns -->
						<?php $turnonsearchcat = $redux_demo['turnonsearchcat']; ?>
						<?php if($turnonsearchcat == 1){?>
						<div class="large-2 columns">
							<div class="inner-addon right-addon">
								<select id="edit-field-category" name="category_name" class="form-select homeCategoryv2" data-placeholder="<?php esc_html_e('Select Category..', 'classiera'); ?>">
									<option value="All" selected disabled><?php esc_html_e('Select Category..', 'classiera'); ?></option>
									<?php
									$args = array(
										'hierarchical' => '0',
										'hide_empty' => '0'
									);
									$categories = get_categories($args);
									foreach ($categories as $cat) {
										if ($cat->category_parent == 0) { 
											$catID = $cat->cat_ID;
											?>
											<option value="<?php echo $cat->slug; ?>"><?php echo $cat->cat_name; ?></option>
											<?php 
											$args2 = array(
												'hide_empty' => '0',
												'parent' => $catID
											);
											$categories = get_categories($args2);
											foreach ($categories as $cat) { ?>
											<option value="<?php echo $cat->slug; ?>">- <?php echo $cat->cat_name; ?></option>
											<?php } ?>
										<?php } else { ?>
										<?php }
									} ?>
								</select>
							</div><!--End inner-addon right-addon -->
						</div><!--End large-2 columns -->
						<?php } ?>
						<?php 
						$turnonsearchloc = $redux_demo['turnonsearchloc']; 
						$locShownBy = $redux_demo['location-shown-by'];	
						?>
						<?php if($turnonsearchloc == 1){?>
						<div class="large-4 columns">
							<div class="inner-addon right-addon">
								<i class="icon fa fa-map-marker"></i>
								<select id="edit-ad-location" name="post_location" class="form-select homeCategoryv2" data-placeholder="<?php esc_html_e('Select Location..', 'classiera'); ?>">
									<option value= "All" selected disabled><?php esc_html_e('Select Location..', 'classiera'); ?></option>
									<?php
									$args_location = array( 'posts_per_page' => -1, 'order' =>'ASC', 'orderby' =>'title' );
									$lastposts = get_posts( $args_location );
									$all_post_location = array();
									foreach( $lastposts as $post ) {
										//$all_post_location[] = get_post_meta( $post->ID, 'post_location', true );
										$all_post_location[] = get_post_meta( $post->ID, $locShownBy, true );
									}
									$directors = array_unique($all_post_location);
									foreach ($directors as $director) { ?>
										<option value="<?php echo $director; ?>"><?php echo $director; ?></option>
									<?php }?>
									<?php wp_reset_query(); ?>
								</select>
							</div><!--End inner-addon right-addon -->
						</div><!--End large-4 columns -->
						<?php }?>
						<div class="large-2 columns">
							<div class="inner-addon left-addon search">
								<button class="btn btn-primary form-submit submit" id="edit-submit-search-view" name="search" value="Search" type="submit">
									<span><?php esc_html_e( 'Search', 'classiera' ); ?></span>
									<i class="fa fa-search"></i>
								</button>
							</div>
						</div><!--End large-2 columns -->
					</div><!--End form inner Row -->
				</form>
			</div><!--End customBgSearch -->
		</div><!--End large-12 columns -->
	</div><!--End Row -->
</section><!--End Section customBg -->
<script>
jQuery(document).ready(function(){
	jQuery(".homeCategoryv2").chosen();	
});
</script>