animation_begin = 0;
oldcolor = "#ffffff";
newcolor = "#206ba3";
current_menu = "";
init_1 = 0;
need_close = 0;
t = 0;
menu_show = 0;

init_complit = 0;

function drop_px(str){
	str = str.replace('px','');
	return str;
}
function init()
{
	var my_menu = $("#menu");
	var my_koretka = $("#koretka");
	current_menu = $("#menu > #current");
	var target_width = current_menu.width()+16;
	my_koretka.css("top", (drop_px(my_menu.css("top"))-(my_koretka.height()/2)+my_menu.height()/2)+"px");
	var target_width = Math.max(current_menu.width()+22,$("#"+current_menu.attr("class")).width());
	$("#koretka").width(target_width+"px");
	var left_f = current_menu.offset().left+((current_menu.width()+22)/2)-(target_width/2);
	var target_width_sep = Math.max(current_menu.width(),$("#"+current_menu.attr("class")).width())-38;
	my_koretka.css("left", left_f+"px");
	menu_show = 0;
	$("#menu > #current > a").css({ color: newcolor });
	$("#koretka_sep").width(target_width_sep);
	$("#koretka").show();
	init_complit = 1;
}
function close_m()
{
	if (need_close == 1)
	{
		$("#drop_menu").html("<img src='image/b.gif' width='1' height='1' alt=''>");
		menu_show = 0;
	}
}
function close_menu(elem)
{
	clearTimeout(t);
	if (need_close == 1)
	{
		t = setTimeout('close_m()',1000);
	}
}
function move_cur(elem)
{
	if (init_complit == 1)
	{
	target_menu = $("#menu > li."+elem);
	ss = 0;
	if (init_1 == 1 || target_menu.attr('class')!=current_menu.attr('class'))
	{
	clearTimeout(t);
	current_menu = target_menu;
	all_menu = $("#menu > li > a");
	all_menu.animate( { color: oldcolor }, 100);
	$("#drop_menu").html("<img src='image/b.gif' width='1' height='1' alt=''>");
	need_close = 0;
	var target_width = Math.max((target_menu.width()+22),$("#"+elem).width());
	
	var target_width_sep = target_width-38;
	
	$("#koretka_sep").width(1);
	if (animation_begin == 1)
	{
		$("#koretka").stop();
		all_menu.stop();
	}

	
	
	var left_f = target_menu.offset().left+((target_menu.width()+22)/2)-(target_width/2);
//	alert($("#menu").offset().left);
	$("#menu > li."+elem+" > a").animate( { color: newcolor }, 300);
	
	$("#koretka").animate({width: target_width, left: left_f},300,"",function(){animation_begin = 0;$("#drop_menu").html($("#"+elem).html());
	$("#koretka_sep").width(target_width_sep);});
	animation_begin = 1;
	ss = 1;
	}
	if (menu_show == 0 && ss == 0)
	{
		$("#drop_menu").html($("#"+elem).html());
		menu_show = 1;
	}
	}
}