<!--	
// Copyright (c) 2008. Interfax.  All rights reserved.

function exposeItem(id)
{    
   obj = document.getElementById(id);
   if (obj != null)
    obj.style.display = (obj.style.display == "" ? "none" : "");            
}


function openNewWin(url, name, scr, w, h)
{
	var w1 = window.open(url, name, 'toolbar=no,location=no,status=no,menubar=no,resizable=yes,directories=no,scrollbars=yes,width='+w+',height='+h+'');
	w1.focus();
}



var g_activeMenus = new Array();
var g_menuTimer = null;
var g_mainObj = null;
var g_timerScroll = null;

////////////////////////////////////////////////////////////////////////////////
//	Show menu for selected item.
////////////////////////////////////////////////////////////////////////////////
function ShowMenu(name, obj, direction)
{
    objLeft   = obj.offsetLeft;
	objTop    = obj.offsetTop;
	objParent = obj.offsetParent;

	while(objParent.tagName.toUpperCase() != 'BODY') 
	{
		objLeft  += objParent.offsetLeft;
		objTop   += objParent.offsetTop;
		objParent = objParent.offsetParent;
	}			
	
	divElem = document.getElementById(name);
	divElem.style.left = objLeft + (direction != null && direction == 1 ? obj.offsetWidth : 0);
	divElem.style.top  = objTop + (direction != null && direction == 1 ? 0 : obj.offsetHeight);
	divElem.style.display = "";
	
	g_activeMenus[divElem.Level] = divElem;	
	ShowAllItems(divElem);
	fullWidth = divElem.offsetWidth;
	if (document.body.clientHeight < divElem.clientHeight + divElem.style.posTop)
	{
		AddScrollButtons(divElem);		
		divElem.getElementsByTagName('TABLE')[0].style.pixelWidth = fullWidth;
	}
}

////////////////////////////////////////////////////////////////////////////////
//	Show all items of menu and remove scroll buttons.
////////////////////////////////////////////////////////////////////////////////
function ShowAllItems(elem)
{	
	var table = elem.getElementsByTagName("TABLE")[0];
	RemoveScrollButtons(table)			
	
	for (i = 0; i < table.rows.length; i++)
		table.rows[i].style.display = "";			
}

////////////////////////////////////////////////////////////////////////////////
//	Remove scroll buttons from menu.
////////////////////////////////////////////////////////////////////////////////
function RemoveScrollButtons(table)
{
	if (table.hasScroll != null && table.hasScroll)
	{
		table.deleteRow(0);
		table.deleteRow(table.rows.length - 1);
		table.hasScroll = false;
	}
}

////////////////////////////////////////////////////////////////////////////////
//	Prepare for menu hiding.
////////////////////////////////////////////////////////////////////////////////
function HideMenu(num, obj, classOut)
{	
	g_startTime = new Date();
	g_menuTimer = setTimeout("DoHide(" + num + ", true)", 500);
	
	if (obj != null)
	{
		g_mainObj = obj;
		g_mainObj.classOut = classOut;
	}
}

////////////////////////////////////////////////////////////////////////////////
//	Hide menu.
////////////////////////////////////////////////////////////////////////////////
function DoHide(num, hideMain)
{
	for (i = 10; i >= num; i--)	
		if (g_activeMenus[i] != null)
		{
			g_activeMenus[i].style.display = "none";			
			g_activeMenus[i] = null;
		}
	
	if (g_mainObj != null && hideMain)
		g_mainObj.className = g_mainObj.classOut;	
}

//-->

function centerPopup(itemId) {
	var windowWidth = document.documentElement.clientWidth;
	var windowHeight = document.documentElement.clientHeight;
	var popupHeight = $j("#" + itemId).height();
	var popupWidth = $j("#" + itemId).width();

	$j("#" + itemId).css({
		"position": "absolute",
		"top": (windowHeight - popupHeight) / 4 + document.documentElement.scrollTop,
		"left": (windowWidth - popupWidth) / 2
	});

	$j("#" + itemId).css({
		"height": popupHeight,
		"width": popupWidth
	});
}

var popupStatus = 0;
function loadPopup(itemId) {
	if (popupStatus == 0) {
		$j("#backgroundPopup").css({
			"opacity": "0.7"
		});
		$j("#backgroundPopup").fadeIn("slow");
		$j("#" + itemId).fadeIn("slow");
		popupStatus = 1;
	}
}

function disablePopup(itemId) {
	if (popupStatus == 1) {
		$j("#backgroundPopup").fadeOut("slow");
		$j("#" + itemId).fadeOut("slow");
		popupStatus = 0;
	}
}

