<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>首页<?php echo V('-:tpl/title');?></title>
<link href="<?php echo W_BASE_URL;?>css/base.css" rel="stylesheet" type="text/css" />
<link href="<?php echo W_BASE_URL;?>css/skin_<?php echo SITE_SKIN_TYPE;?>/skin.css" rel="stylesheet" type="text/css" />
</head>
<body id="home">
	<div id="wrapper">
    <!-- header -->
    <?php include APP::tplFile('header');?>
    <!-- end header -->
        <div id="container">
        	<div class="sidebar">
            	<?php include APP::tplFile('intro');?> 
                <?php include APP::tplFile('user_menu');?>    
            </div>
            <div class="main">
            	<?php include APP::tplFile('input');?>
				<?php if (empty($list)):?>
					<!-- 初始化页面 -->
					<div class="index-default">
						<div class="no-follow">
							<a class="close-btn2 icon-bg" href="javascript:;"></a>
							<a class="gosearch-btn" href="<?php echo URL('search.user');?>"></a>
						</div>
						<div class="no-mblog">
							<p class="mblog-icon icon-bg">您还没有微博信息。</p>
							<p>想看更多微博？<br />你可以<a href="<?php echo URL('search.user');?>">关注更多的人</a>，或者<a href="#">上方输入框</a>里，说说身边的新鲜事儿。</p>
						</div>
						<div class="hot-user">
							<h4>人气用户</h4>
							<ul id="userlist">
								<?php if ($toplist):?>
								<?php foreach ($toplist as $item):?>
								<li>
									<div class="user-pic"><a href="<?php  echo URL('ta',array('id' => $item['uid']));?>"><img src="<?php echo APP::F('profile_image_url', $item['uid']);?>" alt="" title="<?php echo htmlspecialchars($item['screen_name']);?>" /></a></div>
									<div class="hot-r"><a href="<?php  echo URL('ta',array('id' => $item['uid']));?>"><?php echo htmlspecialchars($item['screen_name']);?></a><br /><a href="#<?php  echo $item['uid']?>" rel="follow">关注他</a></div>
								</li>
								<?php endforeach;?>
								<?php endif;?>
							</ul>
							<div class="btn-area"><a class="general-btn" href="javascript:;" id="followall-btn"><span>全部关注</span></a></div>
						</div>
	<script type="text/javascript">XWEIBO={data:{},maxid:0,emotions: <?php echo json_encode(V('-:sinaWeiboEmotions'));?>}</script>
					</div>
					<!-- end 初始化页面 -->
				<?php else:?>
					<!-- 微博列表 -->
					<?php include APP::tplFile('feed_list');?>
					<!-- end 微博列表 -->
				<?php endif;?>
            </div>
        </div>
        <!-- footer -->
		<?php include APP::tplFile('footer');?>
        <!-- end footer -->
    </div>

<img src='http://beacon.x.weibo.com/a.gif?xt=pv&p=idx&akey=<?php echo WB_AKEY;?>&uid=<?php echo $uid;?>&random=<?php echo mt_rand();?>' style="display:none" />
<script type="text/javascript" src="<?php echo W_BASE_URL;?>js/jquery.min.js"></script>
<script type="text/javascript" src="<?php echo W_BASE_URL;?>js/common.js"></script>
<script type="text/javascript" src="<?php echo W_BASE_URL;?>js/ui.js"></script>
<script type="text/javascript">
 $(function(){	 
<?php if (!empty($list)):?>
	 var $feedList = $('#feed-list');

	 XWB.setList($feedList);

	 XWB.linkRender();

	 XWB.comment.init();
     
     XWB.reader.init($feedList[0]);
     
	 XWB.publisher.init($('#publish_box'), $feedList, 1);
	 setTimeout(function(){
		XWB.notifyChecker.start(XWEIBO.maxid);
	}, 3000);
    
<?php else: ?>
    function followAction($el) {
        var rel = $el.attr('rel');
        
        if(rel) {
            var uid = [];
            
            $.each($el, function(i, item) {
                uid.push($(item).attr('href').substr(1));
            });
            uid = uid.join(',');
            
            switch(rel) {
                case 'follow':                    
                    XWB.attention(uid, 1, function(rst) {
                        log(rst);
                        if(rst.errno == 0) {
                            $el.text('取消关注').attr('rel', 'unfollow');
                        }
                    });
                    break;
                case 'unfollow':
                    XWB.attention(uid, 0, function(rst) {
                        if(rst.errno == 0) {
                            $el.text('加关注').attr('rel', 'follow');
                        }
                    });
                    break;
            }
            
            return true;
        }
    }

    $('#userlist').click(function(e) {
        if(followAction($(e.target))) {
            e.preventDefault();
        }
    });
    
    $('#followall-btn').click(function() {
        var $follow = $('#userlist a[rel="follow"]');
        if($follow.length) {
            followAction($follow);
        }
        return false;
    });
    
    var noFollowLayer = $('div.no-follow');
    $('.close-btn2', noFollowLayer).click(function() {
        noFollowLayer.hide();
    });
    
	XWB.publisher.init($('#publish_box'), null, 0);
	setTimeout(function(){
		XWB.notifyChecker.start();
	}, 3000);
<?php endif;?>		
	

	XWB.bindSearch($('#search'), $('#searchSubmit'));
    
    $('#container div.user-intro strong').substrByWidth(105);
 });

if ('<?php echo $cron_follow_count?>' == '1') {
	$.get('<?php echo URL('crond.follow');?>');
}
 </script>
</body>
</html>
