</p>
              
                        </div> <!--   result detail wrapper ends -->
 </div> <!-- result car ends --> 
			<?php 
    }
} else {
    ?>
				<p style="padding:30px;"><?php 
    _e('Sorry, no listings matched your criteria.', 'language');
    ?>
</p>
			<?php 
}
?>
			<div class="bottom-pagination hideOnSearch"> <!-- Pagination starts -->
                    	<p><a href="#top"><?php 
_e('BACK TO TOP', 'language');
?>
</a></p>
                    	<p class="paging">
                        	<?php 
cps_show_pagination();
?>
                        </p>
                  </div>  <!-- Pagination ends -->	
           		</div>
           		<div style="clear:both"></div>
</div>
 <?php 
get_footer();
function cps_ajax_search($meta_boxes)
{
    $posts = cps_search_posts();
    ?>

	<div style="clear:both"></div>	
		 <div class="top-single-bar">


  <div class="searchSort"> <!-- search sort starts -->
      <div class="sort_each_item"  style="margin-right:5px"><?php 
    _e('Sort By:', 'language');
    ?>
</div>
      <div  class="sort_filters" id="filt_1">
	  <?php 
    cps_sort_by('miles');
    ?>
<span class="sort_seperator hide-for-small">&nbsp;-&nbsp;</span>
      </div>
      <div class="sort_filters" id="filt_2">
      <?php 
    cps_sort_by('year');
    ?>
<span class="sort_seperator hide-for-small">&nbsp;-&nbsp;</span>
       </div>
       <div class="sort_filters" id="filt_3">
      <?php 
    cps_sort_by('price');
    ?>
      </div>
    </div>
    
    <script>
		$('#filt_1 .sort_each_item > a').text('<?php 
    _e('Miles', 'language');
    ?>
');
		$('#filt_2 .sort_each_item > a').text('<?php 
    _e('Year', 'language');
    ?>
');
		$('#filt_3 .sort_each_item > a').text('<?php 
    _e('Price', 'language');
    ?>
');
	</script>
            <div class="clear"></div>
            </div>


<div style="clear:both"></div>
<div class="detail-page-content hideOnSearch">

<?php 
    wp_reset_postdata();
    $displayed = array();
    if (!empty($posts)) {
        foreach ($posts as $post) {
            if (in_array($post->ID, $displayed)) {
                continue;
            } else {
                $displayed[] = $post->ID;
            }
            global $options;
            $fields;
            $options2;
            $options3;
            $symbols;
            $fields = get_post_meta($post->ID, 'mod1', true);
            $options2 = get_post_meta($post->ID, 'mod2', true);
            $options3 = get_post_meta($post->ID, 'mod3', true);
            $symbols = get_option('gorilla_symbols');
            $options = my_get_theme_options();
            ?>
			
<?php 
            $blogurl = get_bloginfo('template_url');
            $surl = get_bloginfo('url');
            ?>
	
<div class="result-car"> <!-- result car -->
<a class="result-car-link" href="<?php 
            echo $post->post_name;
            ?>
" rel="bookmark" title="<?php 
            echo $post->post_title;
            ?>
"><div class="cpsAjaxLoaderResults"></div>
<?php 
            if ('user_listing' == get_post_type($post->ID)) {
                $args = array('order' => 'ASC', 'orderby' => 'menu_order', 'post_type' => 'attachment', 'post_parent' => $post->ID, 'post_mime_type' => 'image', 'post_status' => null, 'numberposts' => 1);
                $attachments = get_posts($args);
                if ($attachments) {
                    foreach ($attachments as $attachment) {
                        echo '<div class="vehicle-main-image">' . wp_get_attachment_image($attachment->ID, 'thumbnail_results') . '<span class="' . $fields['statustag'] . '"></span></div>';
                    }
                }
            } elseif ('gtcd' == get_post_type($post->ID)) {
                echo '<div class="vehicle-main-image">' . gorilla_img($post->ID, 'thumbnail_results') . '<span class="' . $fields['statustag'] . '"></span></div>';
            }
            ?>
<div class="result-detail-wrapper">  <!-- result detail wrapper -->
	<p class="vehicle-name"><span class="mini-hide"><?php 
            if ($fields['year']) {
                echo $fields['year'];
            } else {
                echo '';
            }
            ?>
</span> <?php 
            echo $post->post_title;
            ?>
</p>
	<p class="vehicle-price show-for-small"><?php 
            if ($fields['year']) {
                echo $fields['year'];
            } else {
                echo '';
            }
            ?>
 | <?php 
            if (is_numeric($fields['price'])) {
                echo '<span class="small-price">' . $symbols['currency'] . number_format($fields['price']) . '</span>';
            } else {
                echo $fields['price'];
            }
            ?>
&nbsp;|&nbsp;<?php 
            if (isset($fields['miles'])) {
                echo number_format($fields['miles'], 0, '.', ',') . ' ' . $options['miles_text'];
            } else {
                echo '';
            }
            ?>
</p>
                           
	                        <p class="vehicle-miles show-for-medium-up hide-for-small"><strong><?php 
            if (isset($fields['miles'])) {
                echo number_format($fields['miles'], 0, '.', ',') . ' ' . $options['miles_text'];
            } else {
                echo '';
            }
            ?>
</strong></p>

	                        <p class="vehicle-secondary-info"><?php 
            if (isset($fields['vehicletype'])) {
                echo $fields['vehicletype'] . ' | ';
            } else {
                echo '';
            }
            ?>
 <?php 
            if (isset($fields['transmission'])) {
                echo $fields['transmission'];
            } else {
                echo '';
            }
            ?>
							 
							<?php 
            if (isset($options2['cylinders'])) {
                echo '| ' . $options2['cylinders'] . ' ' . $options['number_cylinders_text'] . ' | ';
            } else {
                echo '';
            }
            if (isset($fields['interior'])) {
                echo '<span class="mini-hide">' . $fields['interior'] . '</span>';
            } else {
                echo '';
            }
            if (isset($fields['epamileage'])) {
                echo '| <span class="mini-hide">' . $fields['epamileage'] . '</span>';
            } else {
                echo '';
            }
            ?>
                            </p>
	                        <p class="result-price show-for-medium-up hide-for-small"><?php 
            if (is_numeric($fields['price'])) {
                echo $symbols['currency'];
                echo number_format($fields['price']);
            } else {
                echo $fields['price'];
            }
            ?>
							</p>
							 <div style="clear:both;"></div>
                        </div> <!--   result detail wrapper ends -->
          <div style="clear:both;"></div>               
</a>
 </div> <!-- result car ends --> 
			<?php 
        }
    } else {
        ?>
				<p style="padding:30px;"><?php 
        _e('Sorry, no listings matched your criteria.', 'language');
        ?>
</p>
			<?php 
    }
    ?>
			<div style="clear:both;"></div>  
			<div class="bottom-pagination"> <!-- Pagination starts -->
                    	<p><a id="link" href="#top"><?php 
    _e('BACK TO TOP', 'language');
    ?>
</a></p>
                    	<p class="paging">
                        	<?php 
    cps_show_pagination();
    ?>
                        </p>
                  </div>  <!-- Pagination ends -->	
           		</div>
	<?php 
    exit;
}