$( window ).load(function() {
    
   
	 $( ".listitem" ).hide();
	 var page = 1;               
//	                $('#tab-Friends').jscroll({
//	                    loadingHtml: '<img src="'+MAIN_URL+'project/files/default/loader.gif" alt="Loading" /> Loading...',
//	                    padding: 20,
//	                    autoTrigger: true
//	                    nextSelector: MAIN_URL+"user/listfriendsajax/"+page+"/"+ALIAS,
//	                    contentSelector: ''
//	                });
	$( ".jShowFriends" ).click(function() { 
//	    alert(TOTAL_PAGES); 
		page = 1;	                
       	var _throttleTimer = null;
	  	var _throttleDelay = 100;
	    $( window ).scroll(function() { 
	        //alert("hi");
	    	clearTimeout(_throttleTimer);
	        _throttleTimer = setTimeout(function () {
	        	if($(window).scrollTop() + $(window).height() > $(document).height()-100) {
	            	// $(window).unbind('scroll');
	                //	alert($(document).height());	                	  
                        
//                        if($("#membercount").val()){
//                           
//                            TOTAL_PAGES = $("#membercount").val();
//                            page = 1;
//                        }
                     
	                if(page <TOTAL_PAGES){
	                	page++;
	                	$(".listitem" ).show();	                  
	                    $.ajax({
//	                        	beforeSend: function(){page++;},
	                        	type:"POST",
	                            url: MAIN_URL+"user/listmemberajax/"+page+"/"+ALIAS,
	                            dataType:"html",
	                            success: function(res) {                                 
//	                            	alert(res);
	                                $('#community_member_holder').append(res);
	                                $('.listitem').fadeIn(3000);
	                                $('.listitem').hide();
	                                //$(window).bind('scroll');	                                    	              
	                            }
	                        });		                   
	                }
	        	}
	        },_throttleDelay);
	    });
	});
$( ".jShowInvitations" ).click(function() { 
	page = 1;	                
	var _throttleTimer = null;
	var _throttleDelay = 100;
	$( window ).scroll(function() { 
		clearTimeout(_throttleTimer);
		_throttleTimer = setTimeout(function () {
			if($(window).scrollTop() + $(window).height() > $(document).height()-100) {
				// $(window).unbind('scroll');
				//	alert($(document).height());	                	  
				
//                        if($("#membercount").val()){
//                           
//                            TOTAL_PAGES = $("#membercount").val();
//                            page = 1;
//                        }
				
				if(page <=TOTAL_PAGESS){
					page++;
					$(".listitem" ).show();	                  
					$.ajax({
//	                        	beforeSend: function(){page++;},
						type:"POST",
						url: MAIN_URL+"user/listgroupinvitationajax/"+page+"/"+ALIAS,
						dataType:"html",
						success: function(res) {      
							$('.invitation_tbl').append(res);

                            $('.listitem').fadeIn(3000);
                            $('.listitem').hide();
							//$(window).bind('scroll');	                                    	              
						}
					});		                   
				}
			}
		},_throttleDelay);
	});
});

});