chapters =
{
	bindEventHandler: function()
		{
			// show link
			$('div.chapterLink a').click(function()
				{
					chapters.toggle();
					return false;
				});
			
			// hide link
			$('body').click(function()
				{
					chapters.hide();
				});
		},
		
	toggle: function()
		{
			if ($('div#chapter').css('display') == 'none')
				{
					chapters.show();
				}
			else
				{
					chapters.hide();
				}
		},
		
	show: function()
		{
			$('div.chapterLink a').addClass('act');
			$('div#chapter').show();
		},
		
	hide: function()
		{
			$('div.chapterLink a').removeClass('act');
			$('div#chapter').hide();
		},
		
	setPosition: function()
		{
			var chapterHeight = $('div#chapter').height();
			
			var newTopOffset = (player.height+60)-(chapterHeight/2);
			
			$('div#chapter').css('top', newTopOffset);
		}
	
}


downloads =
{
	bindEventHandler: function()
		{
			// show link
			$('div.downloadLink a').click(function()
				{
					downloads.toggle();
					return false;
				});
			
			// hide link
			$('body').click(function()
				{
					downloads.hide();
				});
		},
		
	toggle: function()
		{
			if ($('div#downloads').css('display') == 'none')
				{
					downloads.show();
				}
			else
				{
					downloads.hide();
				}
		},
		
	show: function()
		{
			$('div.downloadLink a').addClass('act');
			$('div#downloads').show();
		},
		
	hide: function()
		{
			$('div.downloadLink a').removeClass('act');
			$('div#downloads').hide();
		},
		
	setPosition: function()
		{
			var chapterHeight = $('div#downloads').height();
			
			var newTopOffset = (player.height+60)-(chapterHeight/2);
			
			$('div#downloads').css('top', newTopOffset);
		}
	
}


$(function()
	{
		chapters.bindEventHandler();
		downloads.bindEventHandler();
	});