
activeItemId = false;
function menu_showItem(typeId,itemId)
{
	if( activeItemId && activeItemId != itemId ){
		//can only happen if js lags so that out does not re-act
		menu_hideAll();
	}
	activeTypeId = typeId;
	activeItemId = itemId;
	menu_toogleActiveItem('visible');
}

function menu_hideAll()
{
	if( activeRowId ){
		menu_toogleRow(activeRowId, activeRowLabel, activeRowIsMarked, 0);
		activeTypeId = false;
		activeRowId = false;
		activeRowLabel = false;
		activeRowIsMarked = false;
	}
	menu_toogleActiveItem('hidden');
	activeItemId = false;
}

function menu_toogleActiveItem(state)
{
	document.getElementById(activeItemId + '-out').style.visibility = state;
	document.getElementById(activeItemId + '-tb1').style.visibility = state;
	if( document.getElementById(activeItemId + '-tb2') ){
		document.getElementById(activeItemId + '-tb2').style.visibility = state;
	}
}

activeTypeId = false;
activeRowId = false;
activeRowLabel = false;
activeRowIsMarked = false;
function menu_hover(rowId, label, isMarked)
{
	if( activeRowId && activeRowId != rowId ){
		menu_toogleRow(activeRowId, activeRowLabel, activeRowIsMarked, 0);
	}
	activeRowId = rowId;
	activeRowLabel = ( label )? label : activeTypeId + '_subItem';
	activeRowIsMarked = ( isMarked )? isMarked : false;
	menu_toogleRow(activeRowId, activeRowLabel, activeRowIsMarked, 1);
}

function menu_toogleRow(rowId, label, isMarked, action)
{
	var clsId,imgSrc,mark;
	mark = ( isMarked )? isMarked : '';
	if( rowId > 0 ){
		clsId = 1;
		document.getElementById(activeItemId + '-l-' + rowId).className = mark + activeTypeId + '-' + clsId + '-lTd-' + action;
		document.getElementById(activeItemId + '-r-' + rowId).className = mark + activeTypeId + '-' + clsId + '-rTd-' + action;
	}else{
		clsId = 0;
	}
	if( document.images[activeItemId + '-ic-' + rowId] ){
		imgSrc = CORE_IMAGES + 'icons/';
		if( label == activeTypeId + '_subItem' ){
			imgSrc += mark;
		}
		imgSrc += label + '-0_' + action + '.gif';
		document.images[activeItemId + '-ic-' + rowId].src = imgSrc;
	}
	document.getElementById(activeItemId + '-ic-' + rowId).className = mark + activeTypeId + '-' + clsId + '-iconTd-' + action;
	document.getElementById(activeItemId + '-tx-' + rowId).className = mark + activeTypeId + '-' + clsId + '-textTd-' + action;
}

function menu_goPage(url)
{
	if( top.document ){
		top.document.location.href = url;
	}else{
		document.location.href = url;
	}
}

