<?php
/*
 * 注意：此文件由tpl_engine编译型模板引擎编译生成。
 * 如果您的模板要进行修改，请修改 templates/default/modules/start.html
 * 如果您的模型要进行修改，请修改 models/modules/start.php
 *
 * 修改完成之后需要您进入后台重新编译，才会重新生成。
 * 如果您开启了debug模式运行，那么您可以省去上面这一步，但是debug模式每次都会判断程序是否更新，debug模式只适合开发调试。
 * 如果您正式运行此程序时，请切换到service模式运行！
 * 
 * 如有您有问题请到官方论坛（http://tech.jooyea.com/bbs/）提问，谢谢您的支持。
 */
?><?php
//引入心情模块公共方法
	require("foundation/module_mood.php");
	require("foundation/module_users.php");
	require("foundation/auser_mustlogin.php");
	require("foundation/agrade.php");
	require("foundation/fdnurl_aget.php");
	require("api/base_support.php");
	
//引入语言包
	$mo_langpackage=new moodlp;
	$u_langpackage=new userslp;
	$rf_langpackage=new recaffairlp;
	$user_id=get_sess_userid();

	//数据表定义区
	$t_mood=$tablePreStr."mood";
	$t_users=$tablePreStr."users";
	$t_remind=$tablePreStr."remind";

	$dbo=new dbex;
	//读写分离定义方法
	dbtarget('r',$dbServs);

	//获得最新的心情
	$last_mood_rs=get_last_mood($dbo,$t_mood,$user_id);
	$last_mood_txt='';
	if(isset($last_mood_rs['mood'])){
		$last_mood_txt=$last_mood_rs['mood'].' [<a href="modules.php?app=mood_more">'.$mo_langpackage->mo_more_label.'</a>]';
	}else{
		$last_mood_txt=$mo_langpackage->mo_null_txt;
	}
		$select_items=array('guest_num','integral');
		$user_info=get_user_info_item($dbo,$select_items,$t_users,$user_id);
		$remind_rs=api_proxy("message_get","remind",1,5);//取得空间提醒
		$remind_count=api_proxy("message_get_remind_count");//取得空间提醒数量
?><!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></title>
<link rel="stylesheet" type="text/css" href="skin/<?php echo $skinUrl;?>/css/iframe.css">
<link rel="stylesheet" type="text/css" href="skin/<?php echo $skinUrl;?>/css/user_ico_small.css">
<!--[if lt IE 7]>
<style type="text/css">
.uico_photo_small span { behavior: url(skin/<?php echo $skinUrl;?>/css/ie_png_fix.htc);}
</style>
<![endif]-->
<script language=JavaScript src="skin/default/js/jooyea.js"></script>
<SCRIPT language=JavaScript src="servtools/ajax_client/ajax.js"></SCRIPT>
<script type='text/javascript'>
	function fixImage(i,w,h){
		return true;
	}

	 function show_set_state(){
	     var set_state=document.getElementById("set_state");
	     set_state.style.display='';
	 }

	 function hidden_set_state(){
	     var set_state=document.getElementById("set_state");
	     set_state.style.display='none';
	 }

	 function set_state_view(set_ol_hidden){
	 		var ol_state_ico=document.getElementById("ol_ioc_gif");
			var ol_state_label=document.getElementById("ol_label_txt");
			var ol_state_reset=document.getElementById("set_state");

			  if(set_ol_hidden==1){
			  	  ol_state_ico.src='skin/<?php echo $skinUrl;?>/images/latent-now.gif';
			      ol_state_label.innerHTML='<?php echo $u_langpackage->u_hidden;?>';
			      ol_state_reset.innerHTML='<a href="javascript:set_ol_state(0);"><?php echo $u_langpackage->u_set_onl;?></a>';
			  }else if(set_ol_hidden==0){
			  	  ol_state_ico.src='skin/<?php echo $skinUrl;?>/images/online-now.gif';
			      ol_state_label.innerHTML='<?php echo $u_langpackage->u_onl;?>';
			      ol_state_reset.innerHTML='<a href="javascript:set_ol_state(1);"><?php echo $u_langpackage->u_set_hidden;?></a>';
			  }

	 }

	 function set_ol_state(set_ol_hidden)
	 {
				var url="do.php?act=user_ol_reset&is_hidden="+set_ol_hidden; //
				ajax=InitAjax();//实例化Ajax
				ajax.open("GET", url, true);
				ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
				ajax.send(null);

		    //获取执行状态
			  ajax.onreadystatechange = function() {
			      //如果执行状态成功，那么就把返回信息写到指定的层里
			     if (ajax.readyState==4&&ajax.status==200) {
			        set_state_view(set_ol_hidden);
			     }
			  }
   }

	 function submit_new_mood()
	 {
		var url="do.php?act=mood_add&ajax=1";
		var last_mood_div=document.getElementById("the_last_mood");
		var mood_text=trim(document.getElementById("mood_txt").value);
		if(mood_text==''){
			  parent.Dialog.alert("<?php echo $mo_langpackage->mo_add_err;?>");
		}else{
			  last_mood_div.innerHTML='<?php echo $u_langpackage->u_data_post;?>';
				var postStr="mood="+document.getElementById("mood_txt").value;
				ajax=InitAjax();//实例化Ajax
				ajax.open("POST", url, true);
				ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
				ajax.send(postStr);
			  ajax.onreadystatechange = function() {
			      //如果执行状态成功，那么就把返回信息写到指定的层里
			     if (ajax.readyState==4&&ajax.status==200) {
			        last_mood_div.innerHTML=ajax.responseText;
			        document.getElementById("mood_txt").value="";
			     }
			  }
			}
   }

//新鲜事
function list_recent_affair(h_id,ra_type)
{		var recent_affair_div=document.getElementById("recent_affair");
		var url="modules.php?app=recent_affair&user_id="+h_id+"&t="+ra_type; //
		ajax=InitAjax();//实例化Ajax
		ajax.open("GET", url, true);
		ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
		ajax.send(null);
    recent_affair_div.innerHTML="<div style=\"width:150px; margin-left:auto; margin-right:auto; height:100px; padding:60px; *padding:30px; line-height:32px;\"><span class='right'>数据加载中...</span><img src='skin/<?php echo $skinUrl;?>/images/loading.gif'></div>";
    //获取执行状态
	  ajax.onreadystatechange = function() {
	      //如果执行状态成功，那么就把返回信息写到指定的层里
	     if (ajax.readyState==4&&ajax.status==200) {
	        recent_affair_div.innerHTML=ajax.responseText;
	        reSetIframeHeight();
	     }
	  }
}

	function clear_remind(remind_id){
		if(parseInt($("remind_count").innerHTML)==1){
			$("remind_main").style.display='none';
		}
		$("remind_count").innerHTML=parseInt($("remind_count").innerHTML)-1;
		var xmlhttp=InitAjax();
		xmlhttp.open("GET","do.php?act=message_del&id="+remind_id);
		xmlhttp.onreadystatechange=function(){
			if(xmlhttp.readyState==4&&xmlhttp.status==200){
				document.getElementById("remind_list").innerHTML=xmlhttp.responseText;
			}
		}
		xmlhttp.send(null);
	}

	parent.guide("index");
</script>
</head>
<body>
<div id="append_parent">
</div>
<div class="mycontent top10" >
<div class="myphoto left"><img src='<?php echo get_sess_userico();?>' class='user_ico'></div>
<div class="myinfo left">
	<span class="right" title='<?php echo count_level($user_info['integral']);?>'>
		<?php echo str_replace(array("{visitor_num}","{integral}","{uid}"),array($user_info['guest_num'],$user_info['integral'],$user_id),$u_langpackage->u_ustate);?>
		<?php echo grade($user_info['integral']);?>
	</span>
<a class="strong" href="<?php echo get_uhome_url(get_sess_userid());?>" target="_blank"><?php echo filt_word(get_sess_username());?></a>
<span id='on_line_state' class='hand' onmouseover='show_set_state();' onmouseout='hidden_set_state();'>
<span class="online_status_gif"><img id='ol_ioc_gif' src='skin/<?php echo $skinUrl;?>/images/online-now.gif'></span><span id='ol_label_txt' style='color:#838383'></span>
</span>
<span id='set_state' class='hand' onmouseover='show_set_state();' onmouseout='hidden_set_state();' style="display:none;padding-left:3px;margin-left:-3px">
</span>
</div>
<div class="mysig left"><?php echo $u_langpackage->u_index;?><span><?php echo get_uhome_url(get_sess_userid());?></span></div>
<div class="mood left">
<div class="mc_t">
<div class="mc_t_l left"></div>
<div class="mc_t_r right"></div>
</div>
<div class="mc_m"><textarea name="mood_txt" maxlength="160" onkeyup="return isMaxLen(this)" id="mood_txt" class="left" type="text" onclick="showFace(this,'face_list_menu','mood_txt');" onblur="show('face_list_menu',200)"/></textarea><input class="button1 left" type="submit" name="button" id="button" value=""  onclick='submit_new_mood();'/><div class="clear"></div><div id='the_last_mood' ><?php echo filt_word($last_mood_txt);?></div></div>
<div class="mc_bt">
<div class="mc_bt_l left"></div>
<div class="mc_bt_r right"></div>
</div>
</div>
</div><!--mycontent end -->
<!-- face begin -->
<div id="face_list_menu" class="emBg" style="display:none;z-index:100;">
</div>
<!-- face end -->
<div class="clear"></div>
<?php if($remind_rs){?>
<div class="msg_box" id="remind_main">
	<div class="msg_title">
		<a href="modules.php?app=remind_message" class="more"><?php echo $rf_langpackage->rf_more;?></a>
		<?php echo $rf_langpackage->rf_space;?>(<span id='remind_count'><?php echo $remind_count[0];?></span>)
	</div>
	<ul class="msg_list" id="remind_list">
		<?php foreach($remind_rs as $rs){?>
			<li id='remind_<?php echo $rs['id'];?>'>
				<div class="photo"><a href="home.php?h=<?php echo $rs['from_uid'];?>" target="_blank"><img src="<?php echo $rs['from_uico'];?>" width="20px" height="20px" alt="" target="_blank" /></a></div>
				<div class="msg_content">
					<a href="home.php?h=<?php echo $rs['from_uid'];?>" target="_blank"><?php echo $rs['from_uname'];?></a>
					<?php echo str_replace(array("{link}","{js}"),array($rs['link'],"clear_remind(".$rs['id'].")"),filt_word($rs['content']));?>
				</div>
				<div class="msg_del"><a href="javascript:clear_remind(<?php echo $rs['id'];?>)"></a></div>
			</li>
		<?php }?>
	</ul>
</div>
<div class="clear"></div>
<?php }?>
<!--滑动门  -->
<div id="sec" class="top10">
<div id="secNav" class="sec right top10">
<a id="sec_Title0" class="active" onclick="nTabs('sec',this);list_recent_affair('',0);"><?php echo $rf_langpackage->rf_affair;?></a>
<a id="sec_Title1" class="normal" onclick="nTabs('sec',this);list_recent_affair('',1);" ><?php echo $rf_langpackage->rf_state;?></a>
<a id="sec_Title2" class="normal" onclick="nTabs('sec',this);list_recent_affair('',3);" ><?php echo $rf_langpackage->rf_blog;?></a>
<a id="sec_Title3" class="normal" onclick="nTabs('sec',this);list_recent_affair('',2);" ><?php echo $rf_langpackage->rf_album;?></a>
<a id="sec_Title4" class="normal" onclick="nTabs('sec',this);list_recent_affair('',4);" ><?php echo $rf_langpackage->rf_share;?></a>
</div>
<!--新鲜事开始!-->
<div id="recent_affair"></div>
<script type='text/javascript'>	
set_state_view(<?php echo get_sess_online();?>);
list_recent_affair('',0);
</script>
</div>
</body>
</html>