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

$top_like_query=mysql_query("SELECT count(mem_userid) as total, mem_userid, mem_username FROM like_list LEFT JOIN members ON (fav_advid=mem_userid) group by mem_userid order by count(mem_userid) desc, fav_dateadded desc limit 10",$link) or die(mysql_error());
$top_like_count = mysql_num_rows($top_like_query);

$top_connect_query=mysql_query("SELECT count(mem_userid) as total, mem_userid, mem_username FROM my_friends LEFT JOIN members ON (uid=mem_userid) and approved='1' group by mem_userid order by count(mem_userid) desc, MAX(id) desc limit 10",$link) or die(mysql_error());
$top_connect_count = mysql_num_rows($top_connect_query);
?>
<div id="top_panel" class="darkpink_row_back">
	<?php include ("panel_top_main.php"); ?>
</div>

<script type="text/javascript">
jQuery.noConflict();

jQuery(document).ready(function(){
    jQuery("#search_plp").submit(function(){
	 	jQuery('#loading').show();
	 	jQuery('#right_loading_m').show();
		
		var q = jQuery("#q").val();
		
		q=jQuery.trim(q);
		
		jQuery("#q").val(q);

		var str = jQuery(this).serialize();

		window.location.hash = "search?tab=member&" + str;
		window.location.reload(true);
		
		return false;
    });
});

   </script>
<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">
				<tr>
					<td><div class="light_orang_h">
							<div style="background-color:#FF0000; width:10px; height:10px; float:left; margin-top:3px; margin-right:5px;"><img src="images/spacer.gif" width="10" height="10" /></div>
							Search Hahapers</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><form method="post" name="search_plp" id="search_plp" style="padding:0; margin:0; border:0;">
							<table width="100%" border="0" cellspacing="0" cellpadding="5">
								<tr>
									<td align="center"><input type="text" size="40" name="q" id="q" class="grey_12_xb"/>
										<input name="type" type="hidden" id="type" value="member" />
										<input name="init" type="submit" class="button" id="init" value="Search"/></td>
								</tr>
							</table>
						</form></td>
				</tr>
				<tr>
					<td><div id="search_result">
							<div id="result_top_like">
								<div class="style_left">
									<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>
										Hot Hahapers</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>
								</div>
								<div class="style_left padding_t_10">
									<?php
					if ($top_like_count>0){
					$i=0;
					while ($ret_pic = mysql_fetch_object($top_like_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);
}

?>
									<div class="left grey_10 padding_5 w136_h56">
										<div class="left"><a href="javascript:;" onclick="javascript: callprofileInfo(<?=$ret_pic->mem_userid?>);"><img src="<?=$male1_picture1?>" class="img_b_p3" title="Name:&nbsp;<?=ucwords($ret_pic->mem_username)?>"/></a></div>
										<div class="left padding_lr_5 w78">
											<?=ucwords($ret_pic->mem_username)?>
											<br />
											<strong><?php echo $ret_pic->total; if($ret_pic->total>1) { echo " likes"; } else { echo " like"; }?></strong> </div>
									</div>
									<? 
				$i++;
				} 
				}
				?>
								</div>
							</div>
							<div id="result_top_connect">
								<div class="style_left">
									<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>
										Top Connectors</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>
								</div>
								<div class="style_left padding_t_10">
									<?php
					if ($top_connect_count>0){
					$i=0;
					while ($ret_pic = mysql_fetch_object($top_connect_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);
}

?>
									<div class="left grey_10 padding_5 w146_h56">
										<div class="left"><a href="javascript:;" onclick="javascript: callprofileInfo(<?=$ret_pic->mem_userid?>);"><img src="<?=$male1_picture1?>" class="img_b_p3" title="Name:&nbsp;<?=ucwords($ret_pic->mem_username)?>"/></a></div>
										<div class="left padding_lr_5 w78">
											<?=ucwords($ret_pic->mem_username)?>
											<br />
											<strong><?php echo $ret_pic->total; if($ret_pic->total>1) { echo " connections"; } else { echo " connection"; }?></strong> </div>
									</div>
									<?php
				$i++;
				} 
				}
				?>
								</div>
							</div>
						</div></td>
				</tr>
				<tr>
					<td>&nbsp;</td>
				</tr>
				<tr>
					<td>&nbsp;</td>
				</tr>
			</table></td>
	</tr>
</table>
