function news_magazine_top_posts()
{
    global $news_magazine_home_page, $news_magazine_general_settings_page;
    foreach ($news_magazine_general_settings_page->options_generalsettings as $value) {
        if (get_theme_mod($value['id']) === FALSE) {
            ${$value}['var_name'] = $value['std'];
        } else {
            ${$value}['var_name'] = get_theme_mod($value['id']);
        }
    }
    foreach ($news_magazine_home_page->options_homepage as $value) {
        if (isset($value['id'])) {
            if (get_theme_mod($value['id']) === FALSE) {
                ${$value}['var_name'] = $value['std'];
            } else {
                ${$value}['var_name'] = get_theme_mod($value['id']);
            }
        }
    }
    if (isset($blog_style) && $blog_style == "on") {
        ?>
								
   <style>
	 #top-posts-list li div.image-block img{
		height: 180px !important;
		width: 250px;
	 }
   </style>
<?php 
    }
    if ($hide_top_posts == 'on' && is_home()) {
        $news_magazine_query = new WP_Query('posts_per_page=' . $top_post_count . '&cat=' . $top_post_categories . '&orderby=date');
        if ($news_magazine_query->have_posts()) {
            ?>
	<div  id="top-posts"  class="content-inner-block">
		<ul id="top-posts-list">				
		 <?php 
            while ($news_magazine_query->have_posts()) {
                $news_magazine_query->the_post();
                ?>
				
			<li>
			   <div class="image-block">
					<?php 
                if ($grab_image && $date_enable) {
                    echo news_magazine_posted_on_blog();
                }
                ?>
	
					<a href="<?php 
                the_permalink();
                ?>
">
					<?php 
                if ($grab_image) {
                    echo news_magazine_display_thumbnail(240, 182);
                } else {
                    echo news_magazine_thumbnail(240, 182);
                }
                ?>
					</a>
			   </div>							
			   <div class="text">
					<a href="<?php 
                the_permalink();
                ?>
">
						<h3 class="heading"><?php 
                the_title();
                ?>
</h3>
					</a>	
						<p><?php 
                news_magazine_the_excerpt_max_charlength(250);
                ?>
</p>
			   </div>					
			</li>
			<?php 
            }
            ?>
					
		</ul>
	</div>
			
	<?php 
        }
    }
    wp_reset_postdata();
}
    function widget($args, $instance)
    {
        extract($args);
        $title = empty($instance['title']) ? '' : esc_html($instance['title']);
        $categ_id = empty($instance['categ_id']) ? '' : $instance['categ_id'];
        $post_count = empty($instance['post_count']) ? '' : $instance['post_count'];
        echo $before_widget;
        if ($title) {
            echo $before_title . $title . $after_title;
        }
        ?>
		
        <style>	
		 .cat_widg p {
			margin: 0 0 13px !important;
         }
		 .cat_widg {
            padding-bottom: 10px;
			margin-bottom: 5px;
            border-bottom: 1px solid #ededed;
			float: left;
			width: 100%;
         }			
         .widget_news_magazine_categ div:last-child div{
		    border-bottom:none !important;
         } 
         .cat_widg_cont {		 		  
           width: 100%;
		 }
		 .cat_widg_cont h3{
		   font-size: 19px !important;
		   margin-top: 0;
           line-height: 15px;
           margin-bottom: 8px !important;
		 }
		 .cat_widg_cont h3 a{
		   font-size:19px !important;
		 }
		 .widget-title{
		   margin-bottom: 0;
		 }
		 .cat_widg-img{
		    width: 75px;
			height: 70px;
			float: left;
			overflow: hidden;
			margin: 0 10px 10px 0 !important;
		}
		.cat_widg-img img{
		    width: 100%;
			height: 100%;
		}
        </style>		
		<?php 
        $wp_query = null;
        $wp_query = new WP_Query();
        if (!isset($post_count)) {
            $post_count = 0;
        }
        $wp_query->query('posts_per_page=' . $post_count . '&cat=' . $categ_id);
        while ($wp_query->have_posts()) {
            $wp_query->the_post();
            ?>
		
			    <div class="cat_widg_cont">
					  <a href="<?php 
            the_permalink();
            ?>
">
						  <h3><?php 
            the_title();
            ?>
</h3>
					  </a>
                      
		              
					  <div class="cat_widg">
						   <a href="<?php 
            the_permalink();
            ?>
">	
							  <div class="cat_widg-img">
								 <?php 
            echo news_magazine_display_thumbnail(140, 130);
            ?>
							  </div>
						  </a>	  
						  <p>
							  <?php 
            echo news_magazine_the_excerpt_max_charlength(90);
            ?>
						  </p>	
					  </div>
                      <div style="clear:both;"></div>				   
				</div>
					
	<?php 
        }
        echo $after_widget;
    }