$(document).ready(function()
{	
	$('#buttons td').hover(
		function()
		{		
			if( $(this).hasClass('button') )
				$(this).css('background-image', '');
		},
		function()
		{
			if( $(this).hasClass('button') )
			{
				var id = $(this).attr('id');
				$(this).css('background-image', 'url(./img/'+id+'.png)');
			}
		}
	);
	$('#buttons td').click(function()
	{
		window.location.href = String($(this).find('a').attr('href'));
	});
	$('#menu_left div').each(function(idx)
	{
		var block = $(this).find('.block');
		var self = this;
		$(this).find('.text_submenu').click(function()
		{
			var blk = block;
			var parent = self;
			$(blk).slideToggle('slow', function(){$(window).scroll();});
			var img = $(parent).find('img');
			var str = $(img).attr('src');
			var str1 = "_dn";
			var str2 = "_rt";
			if( str.indexOf(str1) == -1 )
			{
				str = str.replace(str2, str1);
			}
			else
			{
				str = str.replace(str1, str2);
			}
			$(img).attr('src', str);					
		});
	});	
	function ChangePos()
	{
		//alert($(document).height()+' | ' +$(window).height());
		if( $(window).height() <= $(document).height() )
		{
			var hgh = $(window).height()-86;
			$('#container').css('height',  hgh+'px');
		}
	}

	$(window).scroll(function()
	{
		scrollTop = window.pageYOffset || document.documentElement.scrollTop || 0;
		$('.bg_container').css('top', scrollTop);
		$('.bg_container').css('width', parseInt(window.height)-parseInt(86)+'px');
		//ChangePos();		
	});
	$(window).resize(function()
	{
		scrollTop = window.pageYOffset || document.documentElement.scrollTop || 0;
		$('.bg_container').css('top', scrollTop);
		$('.bg_container').css('width', parseInt(window.height)-parseInt(86)+'px');
		//ChangePos();
	});
	//ChangePos();
	//$('#container').height());
	//$(".gallery").lightBox({fixedNavigation:true});	$("a#example4").fancybox();
	$(".gallery").fancybox({overlayColor: '#0c001d'});
	//$(".gallery a[rel^='prettyPhoto']").prettyPhoto();
});
