// JavaScript Document

$(document).ready(function(){
	$(".content_main_mh").css("min-height", $(document).height() - $("#header").height() - $("#footer").height() - 210);
	$("#content").css("min-height", $(document).height() - $("#header").height() - $("#footer").height() - 40);
	if( $("#right_part").height() < $("#left_part").height() ) {
		$("#right_part").css("height", $("#left_part").height());		
	}
	
	$delta = 0;
	$block_width = $('.mmenu').width() - 10;
	td_length = Math.ceil( $(".mmenu table td").length / 2 );
	/* 10 - пустое место от фона таблички слева */

	for( $i = 1; $i <= td_length; $i++ )
	{
		$left_pos = $("#sl"+$i).position().left + Math.ceil( $("#sl"+$i).width()/2 - $("#ib"+$i).width()/2 ) - 10;
		$right_pos = $left_pos + $("#ib"+$i).width();
		if( $right_pos > $block_width )
		{
			$delta = $right_pos - $block_width;
		}
		$left_pos -= $delta;
		if( $left_pos < 0 )
		{
			$left_pos = 0;
		}
		$("#ib"+$i).css("left", $left_pos+"px");
		$("#ib"+$i+" .corner").css( "left", ( $("#sl"+$i).position().left - $left_pos + Math.ceil($("#sl"+$i).width()/2) - 18 )+"px" );
	}	
	
	$inline = ($.browser.msie && $.browser.msie && $.browser.version <= 7) ? "inline" : "inline-block" ;
	$("#sl1").hover( function(){ $("#ib1").css("display", $inline) }, function(){ $("#ib1").css("display", "none") } );	
	$("#ib1").hover( function(){ $("#ib1").css("display", $inline) }, function(){ $("#ib1").css("display", "none") } );	
	$("#sl2").hover( function(){ $("#ib2").css("display", $inline) }, function(){ $("#ib2").css("display", "none") } );	
	$("#ib2").hover( function(){ $("#ib2").css("display", $inline) }, function(){ $("#ib2").css("display", "none") } );	
	$("#sl3").hover( function(){ $("#ib3").css("display", $inline) }, function(){ $("#ib3").css("display", "none") } );	
	$("#ib3").hover( function(){ $("#ib3").css("display", $inline) }, function(){ $("#ib3").css("display", "none") } );	
	$("#sl4").hover( function(){ $("#ib4").css("display", $inline) }, function(){ $("#ib4").css("display", "none") } );	
	$("#ib4").hover( function(){ $("#ib4").css("display", $inline) }, function(){ $("#ib4").css("display", "none") } );	
	$("#sl5").hover( function(){ $("#ib5").css("display", $inline) }, function(){ $("#ib5").css("display", "none") } );	
	$("#ib5").hover( function(){ $("#ib5").css("display", $inline) }, function(){ $("#ib5").css("display", "none") } );	
	$("#sl6").hover( function(){ $("#ib6").css("display", $inline) }, function(){ $("#ib6").css("display", "none") } );	
	$("#ib6").hover( function(){ $("#ib6").css("display", $inline) }, function(){ $("#ib6").css("display", "none") } );	
	$("#sl7").hover( function(){ $("#ib7").css("display", $inline) }, function(){ $("#ib7").css("display", "none") } );	
	$("#ib7").hover( function(){ $("#ib7").css("display", $inline) }, function(){ $("#ib7").css("display", "none") } );	
	$("#sl8").hover( function(){ $("#ib8").css("display", $inline) }, function(){ $("#ib8").css("display", "none") } );	
	$("#ib8").hover( function(){ $("#ib8").css("display", $inline) }, function(){ $("#ib8").css("display", "none") } );	
	$("#sl9").hover( function(){ $("#ib9").css("display", $inline) }, function(){ $("#ib9").css("display", "none") } );	
	$("#ib9").hover( function(){ $("#ib9").css("display", $inline) }, function(){ $("#ib9").css("display", "none") } );	
	$("#sl10").hover( function(){ $("#ib10").css("display", $inline) }, function(){ $("#ib10").css("display", "none") } );	
	$("#ib10").hover( function(){ $("#ib10").css("display", $inline) }, function(){ $("#ib10").css("display", "none") } );	
	$("#sl11").hover( function(){ $("#ib11").css("display", $inline) }, function(){ $("#ib11").css("display", "none") } );	
	$("#ib11").hover( function(){ $("#ib11").css("display", $inline) }, function(){ $("#ib11").css("display", "none") } );	
	
});


