$( window ).load(function() {
//$( ".jShowMessages" ).click(function() { 
	var selected = $('.member_prof_menu ul li:first-child').hasClass('active');
	
	page = 1;	                
	var _throttleTimer = null;
	var _throttleDelay = 100;
	
	$( window ).scroll(function() { 
		//alert(typeof selectedinvitation);
		if(typeof selectedinvitation != 'undefined'){
			selected = false;
		}
		if(selected==true){
		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/listmessagesajax/"+page,
						dataType:"html",
						success: function(res) {   
							$('.find_friends_list_blk').append(res);
							
							$('.listitem').fadeIn(3000);
							$('.listitem').hide();
							//$(window).bind('scroll');	                                    	              
						}
					});		                   
				}
			
			}
		},_throttleDelay);
		}
	});
	
//});
	
	$( ".jShowInvitationsinbox" ).click(function() { 
	var selectedinvitation = true;
	pages = 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(pages <=TOTAL_PAGESS){
					pages++;
					$(".listitem" ).show();	                  
					$.ajax({
//	                        	beforeSend: function(){page++;},
						type:"POST",
						url: MAIN_URL+"user/listinvitationsajax/"+page,
						dataType:"html",
						success: function(res) {   
							$('.find_friends_list_blk').append(res);
							
							$('.listitem').fadeIn(3000);
							$('.listitem').hide();
							//$(window).bind('scroll');	                                    	              
						}
					});		                   
				}
			}
		},_throttleDelay);
	});
});
});