$(function(){
	$('.blogmore').live("click",function(){
		var ID = $(this).attr("id");
		
		if(ID){
		$("#blogmore_"+ID).html('<img src="images/ajax-loader.gif" />');
		
			$.ajax({
				type: "POST",
				url: "../php/ajax/more_blog.php",
				data: "lastdate="+ ID,
				cache: false,
				success: function(html){
				$("#blog").append(html);
				$("#blogmore_"+ID).remove(); // removing more button
				
				$.scrollTo("#start_"+ID, 800);
			}
			});
		}
		else
		{
		$(".blogmore_box").html('The End');// no results
		}

		return false;
	});

	$('.catsmore').live("click",function(){
		var ID = $(this).attr("id");
		//split the ID - it contains both the date and the cat_id
		
		var ID_array = ID.split('|');
		var lastdate = ID_array[0];
		var cat_id = ID_array[1];
		
		if(lastdate){
		$("#catsmore_"+lastdate).html('<img src="images/ajax-loader.gif" />');
		
			$.ajax({
				type: "POST",
				url: "../php/ajax/more_cats.php",
				data: "lastdate="+ lastdate +"&cat_id="+ cat_id,
				cache: false,
				success: function(html){
				$("#blog").append(html);
				$("#catsmore_"+lastdate).remove(); // removing old more button
			
				$.scrollTo("#start_"+ID, 800);
			}
			});

		}
		else
		{
		$(".catsmore_box").html('The End');// no results
		}
		
		return false;
	});

	$('.searchmore').live("click",function(){
		var ID = $(this).attr("id");
		//split the ID - it contains both the date and the phrase
		
		var ID_array = ID.split('|');
		var lastdate = ID_array[0];
		var phrase = ID_array[1];
		
		if(lastdate){
		$("#searchmore_"+lastdate).html('<img src="images/ajax-loader.gif" />');
		
			$.ajax({
				type: "POST",
				url: "../php/ajax/more_search.php",
				data: "lastdate="+ lastdate +"&phrase="+ phrase,
				cache: false,
				success: function(html){
				$("#blog").append(html);
				$("#searchmore_"+lastdate).remove(); // removing old more button
			
				$.scrollTo("#start_"+ID, 800);
			}
			});

		}
		else
		{
		$(".searchmore_box").html('The End');// no results
		}
		
		return false;
	});
});
