$(document).ready (function ()
{
	var i = 1;
	var $buttons = $('#tab-panel-buttons img');
	$buttons.each (
		function ()
		{
			$.preloadImages (
				'/themes/default/site-images/tbg0' + i + '.png',
				'/themes/default/site-images/but0' + i + '.gif',
				'/themes/default/site-images/but0' + i + 'a.gif'
			);
			$(this).attr ('num', i++);
		}
	).hover (
		function ()
		{
			var $this = $(this);
			if (!$this.hasClass ('current'))
				$this.attr ('src', '/themes/default/site-images/but0' + $this.attr ('num') + 'a.gif');
		},
		function ()
		{
			var $this = $(this);
			if (!$this.hasClass ('current'))
				$this.attr ('src', '/themes/default/site-images/but0' + $this.attr ('num') + '.gif');
		}
	).click (
		function ()
		{
			var $this = $(this);
			var num = $this.attr ('num');
			if ($this.hasClass ('current')) return;
			$this.attr ('src', '/themes/default/site-images/but0' + $this.attr ('num') + 'a.gif');
			$('#tab-panel-buttons img.current').each (
				function ()
				{
					$(this).attr ('src', '/themes/default/site-images/but0' + $(this).attr ('num') + '.gif');
				}
			);
			$buttons.removeClass ('current');
			$this.addClass ('current');
			$('#tab-panel').css ('background-image', 'url("/themes/default/site-images/tbg0' + num + '.png")');
			$.get (
				'/go/ajax_content/tab_panel/' + num,
				function (data)
				{
					$('#tab-content').html (data);
				}
			);
		}
	);
	$buttons.first ().trigger ('click');
});

