<?php 
function flist($gro,$userid,$wapid){
$sql = "SELECT `fid`,`userid`,`friendid`,`groid`,`siteid`,`remarks`,`black` FROM `my_friend` WHERE groid='{$gro}' AND siteid='{$wapid}' AND userid ='{$userid}'";
$lists = mysql_query($sql);
if($lists && mysql_num_rows($lists)>0){
	while(list($fid,$userid,$friendid,$groid,$siteid,$remarks,$black) = mysql_fetch_row($lists)){
	$zai=u_online($friendid,$wapid);
if($zai==1){
  $zai='在线';
  }else{
   $zai='离线';
   }
     $html.=' <li>
	 <table width="100%" border="0" cellpadding="0" cellspacing="0"><tr><td class="left"><a href="#"><img src="'.user('head','id',$friendid).'"></a></td><td class="right"><a href="ask.php?uid='.user('xid','id',$friendid).'#ask_bottom"><h2>'.user('nc','id',$friendid).'['.$zai.']</h2><h3>'.user('qianm','id',$friendid).'</h3></a></td></tr></table>
	 </li>
';
}
}else{
$html='';
}
return $html;
}
function myflist($userid,$siteid,$type){
$sql="SELECT id,userid,siteid,name,xuhao FROM myfgro WHERE siteid='{$siteid}' AND userid='{$userid}' ORDER BY xuhao ASC"; 
$list = mysql_query($sql);
if($list && mysql_num_rows($list)>0){
	$i=3;
	while(list($id,$userid2,$siteid2,$name,$xuhao)=mysql_fetch_row($list)){
$html.='<div id="CollapsiblePanel'.$i.'" class="CollapsiblePanel">
  <div class="CollapsiblePanelTab" tabindex="0">'.$name.'</div>
<div class="CollapsiblePanelContent"><ul class="f_list">
    '.flist($id,$userid,$siteid2).'</ul>
</div></div>';
$js.='var CollapsiblePanel'.$i.' = new Spry.Widget.CollapsiblePanel("CollapsiblePanel'.$i.'", {contentIsOpen:false});';

$i++;
}
}else{
$html=NULL;
}
$html='
  <div id="CollapsiblePanel1" class="CollapsiblePanel">
  <div class="CollapsiblePanelTab" tabindex="0">我的好友</div>
  <div class="CollapsiblePanelContent">
  <ul class="f_list">'.flist(0,$userid,$siteid).'</ul>
  </div></div>'.$html.'<div id="CollapsiblePanel2" class="CollapsiblePanel">
  <div class="CollapsiblePanelTab" tabindex="0">黑名单</div>
<div class="CollapsiblePanelContent">
<ul class="f_list">'.
   flist(0,$userid,$siteid).'
   </ul>
</div></div>';
$js='<script type="text/javascript">
var CollapsiblePanel1 = new Spry.Widget.CollapsiblePanel("CollapsiblePanel1", {contentIsOpen:false});
var CollapsiblePanel2 = new Spry.Widget.CollapsiblePanel("CollapsiblePanel2", {contentIsOpen:false});
'.$js.'
</script>';
if($type=='html'){
return $html;
}else{
return $js;
}
}
?>