hide_id = null;
hide_allowed = true;

function showSearch() { 
	document.getElementById('search_popup').style.visibility = 'visible';
	startHideSearch(false);
}

function stopHideSearch(full) {
	if (full) hide_allowed = false;
	clearTimeout(hide_id);
}

function startHideSearch(full) {
	if (full) hide_allowed = true;
	hide_id = setTimeout("hideSearch()", 1000);
}

function hideSearch() {
		if (!hide_allowed) return;
		document.getElementById('search_popup').style.visibility = 'hidden';
}


/** код для подменю */

cur_menu = -1;
timer = null;

function activeSub(num, state) {
	if (!state) {
			timer = setTimeout("hideSub("+num+")", 500);
	}
	if (state) {
		clearTimeout(timer);
		timer = null;
	}
}

function hideSub(num) {
	showSubMenu(-1);
	if (timer) clearTimeout(timer);
	timer = null;
}

function showSubMenu(id) {
	if (id==cur_menu) return;
	obj = document.getElementById('sub_'+cur_menu);
	if (obj) {
		obj.style.display='none';
//		document.getElementById('main_'+cur_menu).style.visibility = 'visible';
	}
	cur_menu = id;
	obj = document.getElementById('sub_'+id);
	if (!obj) return;
	obj.style.display = 'block';
	if (document.all) obj.style.marginLeft = - obj.clientWidth/2;//-obj.parentNode.clientWidth/2 - obj.clientWidth/4; // IE
	else {
		obj.style.marginLeft = obj.parentNode.clientWidth/2 - obj.clientWidth/2; // firefox	
	}
//	document.getElementById('main_'+id).style.visibility = 'hidden';
}