function widget($args, $instance)
    {
        $dealstitle = apply_filters('widget_title', empty($instance['title']) ? '' : $instance['title'], $instance, $this->id_base);
        $numdeals = apply_filters('widget_num', empty($instance['num']) ? '' : $instance['num'], $instance, $this->id_base);
        ?>
<div class="right-block">
  <div class="right-white-block mobile top-deals-mobile-wrapper">
    <h3>
      <?php 
        if (!empty($dealstitle)) {
            echo $dealstitle;
        }
        ?>
    </h3>
    <ul class="deal-rates">
      <?php 
        wp_reset_query();
        $query = new WP_Query(array('post_type' => array('gtcd', 'user_listing'), 'meta_key' => '_topdeal', 'meta_value' => 'Yes', 'posts_per_page' => $numdeals));
        if ($query->have_posts()) {
            while ($query->have_posts()) {
                $query->the_post();
                global $post, $field, $fields, $fields2, $fields3;
                $fields = get_post_meta($post->ID, 'mod1', true);
                $fields3 = get_post_meta($post->ID, 'mod3', true);
                $fields2 = get_post_meta($post->ID, 'mod2', true);
                $symbols = get_option('gorilla_symbols');
                $options = get_option('gorilla_fields');
                ?>
      <li class="new-arrivals-list"> <a class="arrivals-link" href="<?php 
                the_permalink();
                ?>
">
        <div class="image-container">
          <?php 
                gorilla_img($post->ID, 'thumbnail_gallery');
                ?>
        </div>
        <div class="arrivals-details">
        <p>
			<span class="top-deals-title"><?php 
                the_title();
                ?>
</span>
        		  
           		 <?php 
                if ($fields['year']) {
                    echo '<span class="year-style">' . $fields['year'] . '</span> | ';
                } else {
                    echo '';
                }
                if (is_numeric($fields['price'])) {
                    echo '<span class="price-style-deals">' . $symbols['currency'];
                    echo number_format($fields['price']) . '</span>';
                } else {
                    echo '<span class="price-style-deals">' . $fields['price'] . '</span>';
                }
                ?>
          
            </p>
        </div>
        
          </a> 
        <div class="clear"></div>
        </li>
      <?php 
            }
        }
        wp_reset_query();
        ?>
    </ul>
  </div>
</div>
<?php 
    }
                  <div class="title-detail-tag"></div>
                                         <?php 
        if (has_post_thumbnail()) {
            $thumb = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'featured');
            $url = $thumb['0'];
            echo '<img src="' . $url . '" />';
        } elseif ('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) {
                    arrivals_img($post->ID, 'featured');
                }
            }
        } elseif ('gtcd' == get_post_type($post->ID)) {
            gorilla_img($post->ID, 'featured');
        }
        ?>
                  </a><?php 
    }
    wp_reset_query();
    ?>
  
                        		<?php 
} else {
    ?>
   				
				<img src="<?php 
    echo get_template_directory_uri();
    ?>
/images/common/dummy/slide.jpg" alt="slideshow" width="738" height="300" />
					<div class="image-container">				 
							<div class="<?php 
        echo $fields['statustag'];
        ?>
"></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) {
                    arrivals_img($post->ID, 'arrivals');
                }
            }
        } elseif ('gtcd' == get_post_type($post->ID)) {
            gorilla_img($post->ID, 'arrivals');
        }
        ?>
 
						 
					</div></a>
                    <div class="arrivals-details">
					<p><strong><?php 
        the_title();
        ?>
</strong></p>
					<div class="meta-style"><?php 
        if ($fields['year']) {
            echo $fields['year'] . ' | ';
        } else {
            echo '';
        ?>
<div class="result-car hideOnSearch"><!-- result car -->
<a href="<?php 
        the_permalink();
        ?>
">
							<span class="<?php 
        echo $fields['statustag'];
        ?>
"></span>
						</a>
	   <a href="<?php 
        the_permalink();
        ?>
"><?php 
        gorilla_img($post->ID, 'thumbnail_results');
        ?>
<span class="<?php 
        $fields['statustag'];
        ?>
"></span></a>

                    <div class="result-detail-wrapper">  <!-- result detail wrapper -->
	                        <p><a href="<?php 
        the_permalink();
        ?>
" rel="bookmark" title="Permanent Link to <?php 
        echo $post->post_title;
        ?>
"><?php 
        echo $post->post_title;
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;
}