jQuery(document).ready(function()
{
	if (jQuery(".block .tabs .selected").length > 0)
	{
		var eq = jQuery(".block .tabs a").index(jQuery(".block .tabs a.selected"));
		jQuery(".block .block-content .tab").css({'display': 'none'});
		jQuery(".block .block-content .tab:eq(" + eq + ")").css({'display': 'block'});
	}
	else
	{
		jQuery(".block .tabs a:first").addClass("selected");
		jQuery(".block .block-content .tab:first").css({'display': 'block'});
	}
	
	jQuery(".block .tabs a").click(function()
	{
		var eq = jQuery(".block .tabs a").index(jQuery(this));
		jQuery(".block .tabs a").removeClass("selected");
		jQuery(this).addClass("selected");
		jQuery(".block .block-content .tab").css({'display': 'none'});
		jQuery(".block .block-content .tab:eq(" + eq + ")").css({'display': 'block'});
		
		return false;
	});
	
	jQuery(".scrolls").each(function()
	{
		var scrollingOffset = jQuery(this).find(".scroll-content").css("margin-top");
		scrollingOffset = scrollingOffset.substr(0,scrollingOffset.length - 2);
		scrollingOffset = parseInt(scrollingOffset);
		if (scrollingOffset < 0)
		{
			jQuery(this).find("a.arrow-up").css({'display': 'block'});
		}
		if (scrollingOffset >= 265 - jQuery(".block .scrolls .scroll-content").height())
		{
			jQuery(this).find("a.arrow-down").css({'display': 'block'});
		}
	});
	
	jQuery(".scrolls a.arrow-up").click(function()
	{
		jQuery(this).parent().find("a.arrow-down").css({'display': 'block'});
		var scrollingOffset = jQuery(this).parent().find(".scroll-content").css("margin-top");
		scrollingOffset = scrollingOffset.substr(0,scrollingOffset.length - 2);
		scrollingOffset = parseInt(scrollingOffset);
		if (scrollingOffset < 0)
		{
			newOffset = scrollingOffset + 30;
			jQuery(this).parent().find(".scroll-content").css("margin-top", newOffset + "px");
			if (newOffset >= 0)
			{
				jQuery(this).parent().find("a.arrow-up").css({'display': 'none'});
			}
		}
		
		return false;
	});
	
	jQuery(".scrolls a.arrow-down").click(function()
	{
		jQuery(this).parent().find("a.arrow-up").css({'display': 'block'});
		var scrollingOffset = jQuery(this).parent().find(".scroll-content").css("margin-top");
		scrollingOffset = scrollingOffset.substr(0,scrollingOffset.length - 2);
		scrollingOffset = parseInt(scrollingOffset);
		if (scrollingOffset >= 265-jQuery(this).parent().find(".scroll-content").height())
		{
			newOffset = scrollingOffset - 30;
			jQuery(this).parent().find(".scroll-content").css("margin-top", newOffset + "px");
			if (newOffset <= 295-jQuery(this).parent().find(".scroll-content").height())
			{
				jQuery(this).parent().find("a.arrow-down").css({'display': 'none'});
			}
		}
		
		return false;
	});
});