function headerMenuHandler(eThis, action)
{
	if (action == 'hover' && eThis.className == 'hmLeft')
	{
		hmh_prev_class = eThis.className;
		eThis.className = 'hmLeftHover';
	}
	else if (action == 'hover')
	{
		hmh_prev_class = eThis.className;
		eThis.className = 'hmFieldHover';
	}
	
	if (action == 'out')
	{
		eThis.className = hmh_prev_class;
	}
}
call_eThis = null;
call_menu_name = null;
call_menu_type = null;
menu_timeout = null;
function headerMenuPop(eThis,menu_name, menu_type)
{
	call_eThis = eThis;
	call_menu_name = menu_name;
	call_menu_type = menu_type;
	clearTimeout(menu_timeout);
	
	enable_hide_menu = false;
	menu_timeout = setTimeout('headerMenuPop_call();',400);
}

menu_storage_skip = new Array();
function headerMenuPop_call()
{
	eThis = call_eThis;
	menu_name = call_menu_name;
	menu_type = call_menu_type;
	
	if (enable_hide_menu)
	{
		return false;
	}
	
	if (menu_type == undefined)
		menu_type = 1;

	pos = getAbsolutePos(eThis);
	
	if (cpx > pos.x && cpx < pos.x+eThis.offsetWidth && cpy > pos.y && cpy < pos.y+eThis.offsetHeight) // Ибо иногда не отлавливает увод курсора
	{
		// EMPTY
	}
	else
	{
		return false;
	}
		
	m = menu_storage[menu_name];
	out = '<iframe id="free" style="display: none; #display: block; position: absolute; top: 0;left: 0;z-index:-1;filter: mask(); border-style: none !important; margin-left: -1px; margin-right: -1px;" frameborder="0" height="280px" width="100%"></iframe><div style="width: 99%; border: 1px solid #858585; background-color: #fefefe; margin-right: 1px;"><ul class="hmList">';
	
	for (i=0; i<m.length; i++)
	{
		if (m[i] == undefined)
			continue;

		is_show = true;

		for (ii=0; ii<menu_storage_skip.length; ii++)
		{
			if (menu_storage_skip[ii] == m[i][1])
			{
				is_show = false;
			}
		}
		
		if (is_show)
		{
			out += '<li onMouseOver="this.className=\'hmHover\'" onMouseOut="this.className=\'\'" onсlick="location=\''+m[i][1]+'\';"><a href="'+m[i][1]+'">'+m[i][0]+'</a></li>';
		}
	}
	out += '</ul></div>';
	
	hm = document.getElementById('header_menu');
	pos_hm = getAbsolutePos(hm);
	
	allowed_width = pos_hm.x+hm.offsetWidth;
	//page_width = document.body.clientWidth
	
	pop_x = pos.x;
	pop_y = pos.y+eThis.offsetHeight;
	
	pop = document.getElementById('header_menu_pop');
	pop.style.overflow='hidden';
	if (menu_type == 2)
		pop.className = 'headerMenuPop2';
	else
		pop.className = 'headerMenuPop';
	pop.innerHTML = out;
	pop.style.display = '';
	
	/*
	pop.style.top = pop_y;
	pop.style.left = pop_x;
	*/

	pop_width = pop.offsetWidth;
	if (allowed_width < pop_x+pop_width)
	{
			pop_x = pos.x + eThis.offsetWidth - pop.offsetWidth;
	}
	
	if (menu_type == 2)
	{
		pop_x = pop_x+7;
		pop_y = pop_y+5;
	}
	
	pop.style.top = pop_y;
	pop.style.left = pop_x;
}

timerID = null;
function headerMenuPopHide()
{
	enable_hide_menu = true;
	clearTimeout(timerID);
	timerID = setTimeout('headerMenuPopHideDo();',500);
}

function headerMenuPopHideDo()
{
	if (enable_hide_menu)
	{
		pop = document.getElementById('header_menu_pop');
		pop.style.display = 'none';
	}
}




enable_hide_menu = true;