$(function(){
    // Initialize scrollable.
    var subnav = $("#subnav .scrollable").scrollable({
		items: "#subnav .items",
        next: "#subnav .next",
        prev: "#subnav .prev",
        size: 1
    });
	
	// Jump to active element. Use a time of 1, to simulate a "no-animation" effect.
	var index = $("#subnav .items div").index($("#subnav .items div.active")[0]);
	if (subnav) {
		subnav.jumpTo(index, 0);
	}
	
    // Initialize scrollable.
	var mainnav = $("#mainnav .scrollable").scrollable({
		alignRight: true,
		items: "#mainnav .items",
        next: "#mainnav .next",
        prev: "#mainnav .prev",
        size: 1
    });
	
	// Click event does not work here, so we use mouseup event.
	$("#subnav .items div a").mouseup(function() {
		index = $("#subnav .items div").index($(this).parent());
		subnav.jumpTo(index);
	});
	
	/*
	$("#mainnav .items div a").mousedown(function() {
		index = $("#mainnav .items div").length - $("#mainnav .items div").index($(this).parent());
		mainnav.jumpTo(index);
	});
	*/
	
	// Jump to active element. Use a time of 1, to simulate a "no-animation" effect.
	index = $("#mainnav .items div").length - $("#mainnav .items div").index($("#mainnav .items div.active")[0]);
	if (mainnav) {
		mainnav.jumpTo(index, 0);
	}
});

var fancyBoxConfiguration = {
	overlayShow: false,
	frameWidth: 350,
	frameHeight: 450
};

$(function() {
	// Enable scrollable text
	//$(".scrollable-text").jScrollPane();
});

$(function() {
	$("#content a, .textlink").fancybox(fancyBoxConfiguration);
	
	$(".links").each(function() {
		$(this).find("a").fancybox(fancyBoxConfiguration);
		
		$(this).find("a").click(function() {
			$(this).parent().siblings().removeClass("active");
			$(this).parent().addClass("active");
		});
	});
	
	// Trigger click on content link in order to pop up FancyBox on page display. jQuery rocks, btw!
	//$("#content").show();
	$("#content a:first").trigger("click");
});