<?php
function get_restore($dbo,$type_id,$mod_id,$start_num,$show_num){
	global $tablePreStr;
  $t_share=$tablePreStr."share";
  $t_share_comment=$tablePreStr."share_comment";
  
	$t_poll=$tablePreStr."poll";
	$t_poll_comment=$tablePreStr."poll_comment";
	
	$t_album=$tablePreStr."album";
  $t_album_comment = $tablePreStr."album_comment";
  
	$t_photo=$tablePreStr."photo";
  $t_photo_comment = $tablePreStr."photo_comment";  
  
  $t_blog=$tablePreStr."blog";
  $t_blog_comment=$tablePreStr."blog_comment";
  
  $t_subject=$tablePreStr."group_subject";
  $t_subject_comment=$tablePreStr."group_subject_comment";
  
  $t_mood=$tablePreStr."mood";
  $t_mood_comment=$tablePreStr."mood_comment";	
  
switch($type_id){
		case "0":
		$t_table=$t_blog;
		$t_table_com=$t_blog_comment;
		$mod_col="log_id";
		break;
		case "1":
		$t_table=$t_subject;
		$t_table_com=$t_subject_comment;
		$mod_col="subject_id";
		break;
		case "2":
		$t_table=$t_album;
		$t_table_com=$t_album_comment;
		$mod_col="album_id";
		break;
		case "3":
		$t_table=$t_photo;
		$t_table_com=$t_photo_comment;
		$mod_col="photo_id";
		break;
		case "4":
		$t_table=$t_poll;
		$t_table_com=$t_poll_comment;
		$mod_col="p_id";
		break;
		case "5":
		$t_table=$t_share;
		$t_table_com=$t_share_comment;
		$mod_col="s_id";
		break;
		case "6":
		$t_table=$t_mood;
		$t_table_com=$t_mood_comment;
		$mod_col="mood_id";
		break;
		default:
		echo 'error';
		break;
	}
	$function="parent.get_mod_com(".$mod_id.",".$type_id.",".intval($show_num+$start_num).",10);this.innerHTML='';this.style.display='none';";
	$visitor_id=get_sess_userid();
	$info_row=array();
  $com_rs=array();
	$show_str=intval($start_num+$show_num);
	
	$sql="select comments,user_id from $t_table where $mod_col=$mod_id";
	$info_row=$dbo->getRow($sql);
	
	if($info_row['comments'] > 0){
		$sql="select * from $t_table_com where $mod_col=$mod_id order by `add_time` desc limit $start_num,$show_num";
		$com_rs=$dbo->getRs($sql);
		
		if($info_row['comments'] <= $start_num+$show_num){
			$show_str=intval($info_row['comments']);
			$function="void(0)";
		}
		
		foreach($com_rs as $rs){
		echo '<!--ajax返回!-->
			<div class="reaction" id="record_'.$type_id.'_'.$rs["comment_id"].'">';
				if($visitor_id==$rs['host_id']){
					echo '<a href="javascript:parent.del_com('.$rs["host_id"].','.$type_id.','.$mod_id.','.$rs["comment_id"].','.$rs["visitor_id"].')" class="replyclose"></a>';
				}
		echo '
				<a href="home.php?h='.$rs["visitor_id"].'" target="_blank"><img src="'.$rs["visitor_ico"].'" width="43" height="43" /></a>
				<a href="home.php?h='.$rs["visitor_id"].'" target="_blank">'.filt_word($rs["visitor_name"]).'</a><label>'.$rs["add_time"];
				if($visitor_id!=$rs["visitor_id"]){
					echo '&nbsp<a href="javascript:void(0)" onclick=parent.restore("'.$rs["visitor_name"].'",'.$type_id.','.$mod_id.','.$rs["visitor_id"].')>回复</a>';
				}
		echo '</label>';
				echo '<p class="left">'.filt_word(get_face($rs["content"])).'</p>
			</div>';
		}
		echo '<div class="reaction"><a href="javascript:void(0)" onclick="'.$function.'">共有评论<span id="total_'.$type_id.'_'.$mod_id.'">'.$info_row["comments"].'</span>条，当前显示1至<span id="max_'.$type_id.'_'.$mod_id.'">'.$show_str.'</span>条</a></div>';
	}else{
		echo '';
	}
}

?>