<div id="sidebar">
	<?php get_sidebar(ad); ?>
	<h3 id="tupian">随机文章</h3>
	<div class="clear"></div>
	
		<?php $rand_posts = get_posts('numberposts=5&orderby=rand');
		foreach( $rand_posts as $post ) : ?>
			<ol>
				<div class="leftbg">
					<div class="bg1">
						<span class="month"><?php the_time('m') ?><em>月</em></span>
						
						<span class="year"><?php the_time('Y') ?></span>
					</div>
				</div>
				<li><a target="_blank" href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
			</ol>
			<div class="clear"></div>
		<?php endforeach; ?>

	<a href="#"><img style="margin:20px 0 30px 0;" src="<?php bloginfo('template_directory'); ?>/images/tg.jpg" title="网站投稿" alt="网站投稿" /></a>
	<h3>热点文章</h3>
	<ul id="hot">
		<?php $result = $wpdb->get_results("SELECT comment_count,ID,post_title FROM $wpdb->posts where post_type <> 'page' ORDER BY comment_count DESC LIMIT 0 , 5");
		    foreach ($result as $topten) {
		    $postid = $topten->ID;
		    $title = $topten->post_title;
		    $commentcount = $topten->comment_count;
		    if ($commentcount != 0) { ?>
		                <li>
		                	<div class="smallimg">
		            			<a href="<?php echo get_permalink($postid); ?>" title="<?php the_title(); ?>" target="_blank">
									<?php if ( get_post_meta($post->ID, 'show', true) ) : ?>
										<?php $image = get_post_meta($post->ID, 'show', true); ?>
										<img src="<?php echo $image; ?>"width="400" height="240" alt="<?php the_title(); ?>"/>
										<?php else: ?>
										<?php if (has_post_thumbnail()) { the_post_thumbnail('home-thumb' ,array( 'alt' => trim(strip_tags( $post->post_title )), 'title' => trim(strip_tags( $post->post_title )),'class' => 'home-thumb')); }
										else { ?>
											 <img src="<?php echo catch_first_image() ?>" alt="<?php the_title(); ?>" width="400" height="240" />
										<?php } ?>
									<?php endif; ?>
								</a>
		                	</div>
		                	<a class="righttitlt" href="<?php echo get_permalink($postid); ?>" title="<?php echo $title ?>"><?php echo $title ?></a>
		                </li>
		 <?php } } ?>
	</ul>
	<div id="link">
		<h3>合作伙伴</h3>
		<ul>	
			<?php Hcms_links("txt",24) ?>
		</ul>
	</div>
</div>