var section_code = "";
var query = "";
var page = 2;

$(function() 
{
	page = parseInt($("#current_page").val(), 10) + 1;

	$("#catalog_get_more").on("click", function()
	{
		var url = section_code+"page-"+page+"/";
		url += query !== "" ? "?"+query+"&ajax" : "?ajax";

		$.get(url, {}, function(response)
		{
			page++;
			$(".pagination").replaceWith(JSON.parse(response['PAGINATION']));
			$("#catalog_positions_list").append(JSON.parse(response['ITEMS']));

			if(parseInt(response['PAGE_COUNT'], 10) === parseInt(response['PAGE_CURRENT'], 10))
			{
				$("#catalog_get_more").empty();
			}
		});
	});
});