/* 
 * kobala.js: Kobala javascript library.
 * Supported browsers: IE4+, NN6+, konqueror.
 *
 * Copyright (c) 2002 WiseGuys Internet BV.
 * All rights reserved.
 */

function isChildNode(p, c)
{
    while (parentNode(c) && (parentNode(c) != p))
	c = parentNode(c);
    return parentNode(c) != null;
}

function _open(url, name, width, height, top, left, options)
{
    if (top == null)
    {
	if (window.screenX)
	{
	    var x = window.screenX;
	    var y = window.screenY;
	    var w = window.outerWidth;
	    var h = window.outerHeight;
	} else
	{
	    var x = window.screenLeft;
	    var y = window.screenTop;
	    var w = window.document.body.offsetWidth;
	    var h = window.document.body.offsetHeight;
	}
	left = x + ((w - width) >> 1);
	top = y + ((h - height) >> 2);
    }
    features = "width=" + width;
    features += ",height=" + height;
    features += ",top=" + top;
    features += ",left=" + left;
    if (options != null)
	features += "," + options;
    window.open(url, name, features);
}

function openDialog(url, width, height, name, options)
{
    if (name == null)
	name = 'dialog';
    features = "resizable=yes,dependent=yes";
    if (options != null)
	features += "," + options;
    _open(url, name, width, height, null, null, features);
}

function openWindow(url, width, height, name, options)
{
    if (name == null)
	name = "window";
    features = "resizable=yes,dependent=yes,status=yes";
    if (options != null)
	features += "," + options;
    _open(url, name, width, height, null, null, features);
}

function openTooltip(url, name, width, height)
{
    if (name == null)
	name = "help";
    if (width == null)
	width = 400;
    if (height == null)
	height = 500;
    features = "resizable=yes,dependent=yes,scrollbars=yes";
    _open(url, name, width, height, 1, 1, features);
}

function openLocation(url)
{
    self.window.location.href = url;
}
