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

$WUserID = $_SESSION['Sess_UserId'];
$WUsername = $_SESSION['Sess_UserName'];

if (!empty($_GET["letter"])) {
$letter = $_GET["letter"];
} else {
$letter = "";
}

$query="SELECT * FROM adverts LEFT JOIN members ON (adv_userid=mem_userid) WHERE adv_approved='1' and adv_paused='N'";

if (!empty($letter)) {
if ($letter == "@") {
$query.=" and mem_username NOT RLIKE '^[A-Z]'";
} else {
$query.=" and mem_username like '$letter%' and  mem_username RLIKE '^[A-Z]'";
}
}
$query.=" order by mem_username asc";
$new_query=mysql_query($query,$link) or die(mysql_error());
$activeTotal = mysql_num_rows($new_query);

include("includes/header_noright.php");

?>
<table width="100%" border="0" cellspacing="0" cellpadding="5" class="white_back_t_xb">
				<tr>
					<td><div class="light_orang_h">
							<div style="background-color:#FF00FF; width:10px; height:10px; float:left; margin-top:3px; margin-right:5px;"><img src="images/spacer.gif" width="10" height="10" /></div>
							Browse by Hahaper's Name</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><div class="aToz"><?php
	 if ($letter == "") {
    printf('<a href="%swauhhSocList.php" class="current">All</a> | ',
    $PHP_SELF);
	 } else {
    printf('<a href="%swauhhSocList.php">All</a> | ',
    $PHP_SELF);
	 }

for ($i = 65; $i < 91; $i++) {
	 if (ord($letter) == $i) {
    printf('<a href="%swauhhSocList.php?letter=%s" class="current">%s</a> | ',
    $PHP_SELF, chr($i), chr($i));
	 } else {
    printf('<a href="%swauhhSocList.php?letter=%s">%s</a> | ',
    $PHP_SELF, chr($i), chr($i));
	 }
}
	 if ($letter == "@") {
    printf('<a href="%swauhhSocList.php?letter=%s" class="current">%s</a> | ',
    $PHP_SELF, chr(64), chr(64));
	 } else {
    printf('<a href="%swauhhSocList.php?letter=%s">%s</a> | ',
    $PHP_SELF, chr(64), chr(64));
	 }
?></div></td>
				</tr>
				<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>
							Listings</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><?php if($activeTotal>0) {?><div class="padding_lr_18">
					<?php 
	 while ($ret_pic = mysql_fetch_object($new_query)) {
if ($WUserID==$ret_pic->adv_userid) {
$photo_query=mysql_query("SELECT * FROM pictures WHERE pic_userid = '$ret_pic->adv_userid' and pic_default='Y'") or die(mysql_error()); 
} else {
$photo_query=mysql_query("SELECT * FROM pictures WHERE pic_userid = '$ret_pic->adv_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->adv_username/picture/$medium";
             }else{
$male1_picture1=$CONST_LINK_ROOT."/".$picture->GetProfilePicture($ret_pic->adv_userid);
}
if ($ret_pic->mem_profileid != null) { $male1_name1= $ret_pic->mem_profileid; }
else { $male1_name1= $ret_pic->mem_username; }

?>
               <div class="left grey_11 padding_10 w66_h66"><a href="<?=$SITE_MAIN_WWW_ROOT?>/<?=$male1_name1?>"><img src="<?=$male1_picture1?>" class="img_b_p3" title="Name:&nbsp;<?=ucwords($ret_pic->adv_username)?>"/></a><br><?=ucwords(strtolower($ret_pic->adv_username))?></div>
                <? 
				$i++;
				} ?></div><?php } else {?>
										<?php  print(NO_RECORDS_SECTION_NAME); ?>
										!
										<?php } ?>
</td>
				</tr>
				<tr>
					<td>&nbsp;</td>
				</tr>
			</table> 
<?php include("includes/footer_noright.php"); ?>
