// ***************************************************************************
//   Memory Highway Ltd. Copyright (C) 2007. All Rights Reserved  $Revision: 1.20 $                     
// ***************************************************************************

$(function(){
 	$.ajaxSetup({cache: false});

	$("#mosaic").flash({
	    src: "/swf/linkory.swf",
	    width: 572,
	    height: 216
	});
 	
 	// Most popular groups
	$("#topgroupscont a[rel='next']").livequery('click', function(){
		var a = this;
		var $heading = $("#topgroupscontainer .blueheadercontents");
		var text = "Most Popular Groups";	
		$("#topgroupscont").load(a.href, function(){
			var page = a.href.replace(/.*page=(\d+).*/, "$1");
			$heading.text(page > 1 ? "Next " + text + " Page " + page : text);		
		});
		return false;
	});
	 	
	// Random profiles
	$("#randomprofilecont a[rel='next']").livequery('click', function(){
		$("#randomprofilecont").load(this.href);
		return false;
	});	
	
	// Random memories
	$("#randommemorycont a[rel='next']").livequery('click', function(){
		$("#randommemorycont").load(this.href);
		return false;
	});
	
	// Most recent memories
	$("#recentthreadscont a[rel='prev'], #recentthreadscont a[rel='next']").livequery('click', function(){
		var a = this;
		var $heading = $("#recentthreadscontainer .blueheadercontents");
		var text = "Most Recent Memories";
		$("#recentthreads ul").slideUp("slow", function(){
			$("#recentthreadscont").load(a.href, function(){
				var page = a.href.replace(/.*page=(\d+).*/, "$1");
				$heading.text(page > 1 ? "Next " + text + " Page " + page : text);
			});
		});
		return false;
	});
    $("#recentthreads").livequery(function(){
    	var visible = 4;
    	if ($("#recentthreads ul li").size() >= visible){
		    $(this).jCarouselLite({
		        auto: 10000,
		        speed: 1000,
		        vertical: true,
		        visible: visible
		    });
	    }
	});
	
	// Most popular memories
	$("#topthreadcont a[rel='prev'], #topthreadcont a[rel='next']").livequery('click', function(){
		var a = this;
		var $heading = $("#topthreadscontainer .blueheadercontents");
		var text = "Most Popular Memories";	
		$("#topthreadcont").load(a.href, function(){
			var page = a.href.replace(/.*page=(\d+).*/, "$1");
			$heading.text(page > 1 ? "Next " + text + " Page " + page : text);		
		});
		return false;
	});
});