<?php
include("includes/site_info.php");
include('session_handler.inc');
include_once __INCLUDE_CLASS_PATH."/class.Picture.php";
$picture = new Picture();

$WUserID = $_SESSION['Sess_UserId'];

$friend_folder_query=mysql_query("SELECT folder_id, name FROM my_friend_folder WHERE user_id='0' order by name",$link) or die(mysql_error());

$create_folder_query=mysql_query("SELECT folder_id, name FROM my_friend_folder WHERE user_id='$WUserID' order by name",$link) or die(mysql_error());
?>

<div id="top_panel" class="grey_row_back">
  <?php include ("panel_top.php"); ?>
</div>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="5" class="white_back_t_xb">
        <?php 
	 while ($friend_folder= mysql_fetch_object($friend_folder_query)) {
	 ?>
        <tr>
          <td><div class="light_orang_h">
              <div style="background-color:#0000FF; width:10px; height:10px; float:left; margin-top:3px; margin-right:5px;"><img src="images/spacer.gif" width="10" height="10" /></div>
              <?=$friend_folder->name;?>
            </div>
            <div>
              <!--<a class="button right" title="Edit List" href="javascript:void(null)" onclick="Modalbox.show('<?=$CONST_LINK_ROOT?>/edit.php?list_id=3', {title: this.title, width: 460}); return false;">Edit List</a>-->
              <a href="javascript: void(null)" class="button right" title="Edit List" onclick="javascript: jQuery.facebox({iframe:'<?=$CONST_LINK_ROOT?>/edit_list.php?list_id=<?=$friend_folder->folder_id;?>'}, 'Edit&nbsp;List');" rel="facebox">Edit List</a></div>
            <div class="dot_line"><img src="images/spacer.gif" width="1" height="1" /></div>
            <div class="solid_line"><img src="images/spacer.gif" width="1" height="1" /></div></td>
        </tr>
        <tr>
          <td><table width="100%" border="0" cellpadding="5" cellspacing="0" class="white_back_t_xb">
              <tr>
                <td><?php 
	$friend_query=mysql_query("SELECT mem_userid, mem_profileid, mem_username FROM my_friends LEFT JOIN members ON (friend_uid=mem_userid) LEFT JOIN my_friend_folder_list ON (id=fid) WHERE my_friends.uid='$WUserID' and approved='1' and folder='$friend_folder->folder_id' order by mem_username",$link) or die(mysql_error());
	 while ($ret_pic = mysql_fetch_object($friend_query)) {
if ($WUserID==$ret_pic->mem_userid) {
$photo_query=mysql_query("SELECT * FROM pictures WHERE pic_userid = '$ret_pic->mem_userid' and pic_default='Y'") or die(mysql_error()); 
} else {
$photo_query=mysql_query("SELECT * FROM pictures WHERE pic_userid = '$ret_pic->mem_userid' and pic_default='Y' and pic_private='N'") or die(mysql_error()); 
}
$pics_count = mysql_num_rows($photo_query);
$aPicture = mysql_fetch_object($photo_query);
if ($pics_count > 0) {
	$medium = $aPicture->pic_picture."_ps.".$aPicture->ext;
	$male1_picture1 = "$SITE_MAIN_WWW_ROOT/members/$ret_pic->mem_username/picture/$medium";
             }else{
$male1_picture1=$CONST_LINK_ROOT."/".$picture->GetProfilePicture($ret_pic->mem_userid);
}

if ($ret_pic->mem_profileid != null) { $male1_name1= $ret_pic->mem_profileid; }
else { $male1_name1= $ret_pic->mem_username; }
?>
                  <div class="left padding_5 grey_10"><a href="javascript:;" onclick="javascript: callMyprofileInfo(<?=$ret_pic->mem_userid?>);"><img src="<?=$male1_picture1?>" border="0" title="Name:&nbsp;<?=ucwords($ret_pic->mem_username)?>" class="img_b_p3"/></a><br />
                    <?=ucwords($ret_pic->mem_username)?>
                  </div>
                  <? 
				$i++;
				} ?></td>
              </tr>
            </table></td>
        </tr>
        <?php
	 }?>
        <?php 
	 while ($friend_folder= mysql_fetch_object($create_folder_query)) {
	 ?>
        <tr>
          <td><div class="light_orang_h">
              <div style="background-color:#0000FF; width:10px; height:10px; float:left; margin-top:3px; margin-right:5px;"><img src="images/spacer.gif" width="10" height="10" /></div>
              <?=$friend_folder->name;?>
            </div>
            <div>
              <!--<a class="button right" title="Edit List" href="javascript:void(null)" onclick="Modalbox.show('<?=$CONST_LINK_ROOT?>/edit.php?list_id=3', {title: this.title, width: 460}); return false;">Edit List</a>-->
              <a class="button right" title="Edit List" href="javascript: jQuery.facebox({iframe:'<?=$CONST_LINK_ROOT?>/edit_list.php?list_id=<?=$friend_folder->folder_id;?>'}, 'Edit&nbsp;List');" rel="facebox">Edit List</a></div>
            <div class="dot_line"><img src="images/spacer.gif" width="1" height="1" /></div>
            <div class="solid_line"><img src="images/spacer.gif" width="1" height="1" /></div></td>
        </tr>
        <tr>
          <td><table width="100%" border="0" cellpadding="5" cellspacing="0" class="white_back_t_xb">
              <tr>
                <td><?php 
	$friend_query=mysql_query("SELECT mem_userid, mem_profileid, mem_username FROM my_friends LEFT JOIN members ON (friend_uid=mem_userid) LEFT JOIN my_friend_folder_list ON (id=fid) WHERE my_friends.uid='$WUserID' and approved='1' and folder='$friend_folder->folder_id' order by mem_username",$link) or die(mysql_error());
	 while ($ret_pic = mysql_fetch_object($friend_query)) {
if ($WUserID==$ret_pic->mem_userid) {
$photo_query=mysql_query("SELECT * FROM pictures WHERE pic_userid = '$ret_pic->mem_userid' and pic_default='Y'") or die(mysql_error()); 
} else {
$photo_query=mysql_query("SELECT * FROM pictures WHERE pic_userid = '$ret_pic->mem_userid' and pic_default='Y' and pic_private='N'") or die(mysql_error()); 
}
$pics_count = mysql_num_rows($photo_query);
$aPicture = mysql_fetch_object($photo_query);
if ($pics_count > 0) {
	$medium = $aPicture->pic_picture."_ps.".$aPicture->ext;
	$male1_picture1 = "$SITE_MAIN_WWW_ROOT/members/$ret_pic->mem_username/picture/$medium";
             }else{
$male1_picture1=$CONST_LINK_ROOT."/".$picture->GetProfilePicture($ret_pic->mem_userid);
}

if ($ret_pic->mem_profileid != null) { $male1_name1= $ret_pic->mem_profileid; }
else { $male1_name1= $ret_pic->mem_username; }
?>
                  <div class="left padding_5 grey_10"><a href="javascript:;" onclick="javascript: callMyprofileInfo(<?=$ret_pic->mem_userid?>);"><img src="<?=$male1_picture1?>" border="0" title="Name:&nbsp;<?=ucwords($ret_pic->mem_username)?>" class="img_b_p3"/></a><br />
                    <?=ucwords($ret_pic->mem_username)?>
                  </div>
                  <? 
				$i++;
				} ?></td>
              </tr>
            </table></td>
        </tr>
        <?php
	 }?>
        <tr>
          <td>&nbsp;</td>
        </tr>
      </table></td>
  </tr>
</table>
