<?php
include("includes/site_info.php");
include('session_handler.inc');

if(!preg_match("/\/home.php/",$_SERVER['HTTP_REFERER'])){
	echo "<script>location.href='" . $CONST_LINK_ROOT . "/home.php#mcover'</script>"; die;
}

include_once __INCLUDE_CLASS_PATH."/class.Picture.php";
$picture = new Picture();

//print_r($_SERVER);

$WUserID = $_SESSION['Sess_UserId'];

$myhahaper_query=mysql_query("SELECT mem_userid FROM my_friends LEFT JOIN members ON (friend_uid=mem_userid) WHERE uid='$WUserID' and approved='1'") or die(mysql_error());
$myhahaper_TOTAL = mysql_num_rows($myhahaper_query);
if( $myhahaper_TOTAL > 0) {
$friends[] = $WUserID;
while ($hahaper_pic = mysql_fetch_object($myhahaper_query)) {
$friends[] = $hahaper_pic->mem_userid;
}
$friends = implode(',', $friends);

$activeS_query=mysql_query("SELECT postID FROM market_Post A LEFT JOIN market_category_for on (optionFor=forID) LEFT JOIN members USING (mem_userid) LEFT JOIN Geo_Countries C on (A.Country=C.CountryId) LEFT JOIN market_Post_click USING ( postID ) LEFT JOIN market_category_data D on (subCat=D.dataID) LEFT JOIN market_category_data E on (subCatsub=E.dataID) where approve=1 and expDate > now() and mem_userid in ($friends) order by expDate desc") or die(mysql_error());
$activeS_total = mysql_num_rows($activeS_query);

$activeM_query=mysql_query("SELECT postID FROM market_Post A LEFT JOIN market_category_for on (optionFor=forID) LEFT JOIN members USING (mem_userid) LEFT JOIN Geo_Countries C on (A.Country=C.CountryId) LEFT JOIN market_Post_click USING ( postID ) LEFT JOIN market_category_data D on (subCat=D.dataID) LEFT JOIN market_category_data E on (subCatsub=E.dataID) where approve=1 and expDate > now() and mem_userid not in ($friends) order by expDate desc") or die(mysql_error());
$activeM_total = mysql_num_rows($activeM_query);
}

?>

<div id="top_panel" class="submenu2">
	<?php include ("panel_top_main.php"); ?>
</div>
<script type="text/javascript" src="http://cdn.socialtwist.com/2010091044975-2/script.js"></script>
<script type="text/javascript">
jQuery.noConflict();

jQuery(document).ready(function($){
$('#loading').show();
$("#showContent").load("summaryAction.php", {mode: "hotPost"}, function(){;
$('#loading').hide();	
});
});


jQuery(".staticMenu").ready(function($) {
	$(".staticMenu dt a").click(function() {
		$(this).parents(".staticMenu").find("ul").toggle();
		$(".staticMenu dt a").not($(this)).removeClass("selected");
		if($(this).parents(".staticMenu").find("ul").css("display") == "none"){
			$(this).removeClass("selected");
		}else{
			$(this).addClass("selected");
		}
	});

	$(".staticMenu dd ul li a").click(function() {
		var text = $(this).html();
		$(".staticMenu dt a span").html(text);
		$(".staticMenu dd ul").hide();
		$(".staticMenu dt a").removeClass("selected");
		$(".staticMenu dd ul li a").not($(this)).removeClass("selected");
		$(this).addClass("selected");
	}); 

	$(document).bind('click', function(e) {
		var $clicked = $(e.target);
		if (! $clicked.parents().hasClass("staticMenu")){
			$(".staticMenu dd ul").hide();
			$(".staticMenu dt a").removeClass("selected");
		}

	});
});

		var fetching = false;	
	
		function last_msg_funtion() 
		{ 
		   fetching = true;
			var value = jQuery("#search_result").attr("rel");
         var ID = jQuery(".content4:last").attr("id");
			jQuery('#paginate_loading').show();
			jQuery.post("summaryAction.php?mode="+value+"&lastID="+ID,
			
			function(data){
				if (data == "There are no more items to show at the moment") {
				jQuery('div#loadMore').empty();
				jQuery('div#noMore').show();
				jQuery('div#noMore').html(data);
				} 
				else if (data != "") {
				jQuery(".content4:last").after(data);			
				fetching = false;
				} 
				jQuery('#paginate_loading').hide();	
			});
		};  
		
		jQuery(window).scroll(function(){
			if  (!fetching && (jQuery(window).scrollTop() == jQuery(document).height() - jQuery(window).height())){
			   last_msg_funtion();
			}
		}); 
		
function hidePost(itemID) {

	jQuery("#"+itemID).fadeOut(500);
}
		
  </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>
							Popular by </div>
						<div class="right"><dl class="staticMenu">
                           <dt><a href="javascript:void(null)" onclick="return false;"><span>Hot Post</span> <img src="images/arrow_down.gif" border="0" align="baseline" /></a></dt>
                             <dd>
                                    <ul class="mainMenuSub">
                                        <li><a href="javascript:void(null)" onclick="javascript: callboxBottom('hotPost');">Hot Post</a></li>
                                        <li><a href="javascript:void(null)" onclick="javascript: callboxBottom('recentPost');">Recent Post</a></li>
                                        <?php if($activeS_total>0){ ?><li><a href="javascript:void(null)" onclick="javascript: callboxBottom('social');">Your Social Network</a></li><?php } ?>
                                        <?php if($activeM_total>0) {?><li><a href="javascript:void(null)" onclick="javascript: callboxBottom('marketer');">Marketers</a></li><?php } ?>
                                    </ul>
                             </dd>
                       </dl></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 id="showContent"></div></td>
				</tr>
			</table></td>
	</tr>
</table>
