var top_picture_bg;

$(document).ready(function(){

	$('.top-menu .td-margin').css('width', (100/$('.top-menu .td-margin').length)+'%');
	$('.top-menu .selected .level1-gray-line').css( 'width', $('.top-menu td.selected').width()+'px' );
	
	if (/MSIE (5\.5|6).+Win/.test(navigator.userAgent))	
	{
		$('.top-menu td[class!=td-margin]').hover(
			function(){
				$('.level2', this).show();
			},
			function(){
				$('.level2', this).hide();
			}
		);


		$('.top-menu li').hover(
			function(){
				$(this).css('backgroundColor', '#F93E15' );
				$('a', this).css('color', 'white' );
				$('span', this).css('color', 'white' );
			},
			function(){
				$(this).css('backgroundColor', 'transparent' );
				$('a', this).css('color', '#767676' );
				$('span', this).css('color', '#767676' );
			}
		);
	}
	
	
	var phrase_bg_color = $("#picture.regular-picture-block .top-inc-right .transparent").css('background-color');
	var phrase_opacity = $("#picture.regular-picture-block .top-inc-right .transparent").css('opacity');
	// исправление ошибки при определении прозрачности в IE
	if(
		/MSIE (5\.5|6|7).+Win/.test(navigator.userAgent)
		&& $("#picture.regular-picture-block .top-inc-right .top-inc-cont li").length > 0
		)
		phrase_opacity = 0.5;
	
	$('.top-menu li:[color]').hover(
		function(){
			$(this).css('backgroundColor', $(this).attr('color') );
			$("#picture.regular-picture-block .top-inc-right .transparent").css({backgroundColor: $(this).attr('color'), opacity: 1});
		},
		function(){
			$(this).css('backgroundColor', 'transparent' );
			$("#picture.regular-picture-block .top-inc-right .transparent").css({backgroundColor: phrase_bg_color, opacity: phrase_opacity});
		}
	);

	var top_picture_bg = $("#picture").css('backgroundImage');
	$('.top-menu li[image]').hover(
		function(){
			$('#picture .picture-collage').hide();
			$('#picture').css('backgroundColor', $(this).attr('color') );
			$('#picture').css('backgroundImage', 'url('+$(this).attr('image')+')' );
		},
		function(){
			$('#picture').css('backgroundImage', top_picture_bg );
			$('#picture .picture-collage').show();
		}
	);
	/**/
	
	var PHRASE = $("#picture.regular-picture-block .top-inc-right .top-inc-cont td").html();
	$('.top-menu li[phrase]').hover(
		function(){
			$("#picture.regular-picture-block .top-inc-right .top-inc-cont td").html('<p>'+$(this).attr('phrase')+'</p>');
		},
		function(){
			$("#picture.regular-picture-block .top-inc-right .top-inc-cont td").html(PHRASE);
		}
	);

});