// Define user browser
var isNS4 = (document.layers) ? true : false;
var isIE4 = (document.all && !document.getElementById) ? true : false;
var isIE5 = (document.all && document.getElementById) ? true : false;
var isNS6 = (!document.all && document.getElementById) ? true : false;

var popUpWin=0;

function popUpWindow(URLStr, left, top, width, height)
{
	if(popUpWin)
	{
		if(!popUpWin.closed) popUpWin.close();
	}
	
	popUpWin = open(URLStr, 'popUpWin', 'toolbar=no,location=no,directories=no,status=no,menubar=no,copyhistory=no,width='+width+',height='+height+',left='+left+', top='+top+',screenX='+left+',screenY='+top+'');
	return false;
}

/*
 * Function returns element by ID
 */
function getElementById(id)
{
	if (isNS4)
	{
		objElement = document.layers[id];
	}
	else if (isIE4)
	{
		objElement = document.all[id];
	}
	else if (isIE5 || isNS6)
	{
        objElement = document.getElementById(id);
    }

	return(objElement);
}

/*
 * Function makes element visible
 */
function showObject(id)
{
	obj = getElementById(id);
	if (obj == null) return 1;
	
	obj.style.visibility = "visible";
	obj.style.display = "block";
	
	return 1;
}

/*
 * Function makes object invisible
 */
function hideObject(id)
{
	obj = getElementById(id);
	
	if (obj == null) return 1;
	
	obj.style.visibility = "hidden";
	obj.style.display = "none";
	
	return 1;
}

/*
 * Refresh
 */
function refresh()
{
	width1 = parseInt(getElementById('mainblock').offsetWidth);
	getElementById('content').style.width = (width1 - 220) + 'px';
}

/*
 * Shows blog item menu
 */
function showBlogMenu(event, text)
{
	item = getElementById('blog_menu');
	item.innerHTML = text;
	if (!event) event = window.event;
	item.style.left = (event.clientX + document.body.scrollLeft	+ document.documentElement.scrollLeft - 10) + 'px';
	item.style.top = (event.clientY + document.body.scrollTop + document.documentElement.scrollTop + 5) + 'px';
	showObject('blog_menu');
	
	blog_menu_timer = setTimeout('hideObject(\'blog_menu\')', 3000);
}


/*
 * Hides blog item menu
 */
function hideBlogMenu(event)
{
	if (!event) event = window.event;
	var target = event.relatedTarget || event.toElement;
	var item = getElementById('blog_menu');
	
	if(!isParent(target, item))
	{
		hideObject('blog_menu');
	}
}
/*
 * Function checks if child is a chald of parent
 */
function isParent(child, parent)
{
	if (!child || !parent)
	{
		return false;
	}
	
	while (true)
	{
		if (child == parent)
		{
			return true;
		}
		if (child.parentElement)
		{
			child = child.parentElement;
		}
		else if (child.parentNode)
		{
			child = child.parentNode;
		}
		else
		{
			return false;
		}
    }
}