$(function() {
	//when a tab is clicked, check its class, if it's unselected alter the attributes of the clicked tab and the unclicked tab
	$("#tabs").tabs();

	fn = function()
	{
		$(".selectedTab").addClass("unselectedTab");
		$(".selectedTab").removeClass("selectedTab");
		$(this).addClass("selectedTab");
		$(this).removeClass("unselectedTab");
	};

	$("#allMomentsTabLink").click(fn);
	$("#greatMomentsTabLink").click(fn);
});

ChangePage = function(pageNum, perPage) {
	
	var id = $(".selectedTab").attr('id');
	var type = id.replace("MomentsTabLink", "");
	
	var destId = "#" + type + "MomentsTab";
	$(destId).html("<div class='clear'><img src='templates/here4life/images/spinner.gif'></div>");
	
	var url="index.php?option=com_here4life&controller=moment&task=AjaxGallery&type="+type+"&page="+pageNum+"&perPage="+perPage;
	
	$.ajax({
		type: "get",
		url: url,
		cache: false,
		success: function( html ) {
			$(destId).html(html);
			$("html,body").animate({scrollTop: $("#galleryLeft").offset().top}, 0);
		}
	});
}