var tooltip_obj;

function getObject(obj)
{
    if (document.getElementById)
    {
	return document.getElementById(obj);
    }
    else if (document.layers)
    {
	return document.layers[obj];
    }
    else if (document.all)
    {
	return document.all[obj];
    }
}

function open_window(url_i, width_i, height_i)
{
    window.open(url_i,'new_win', 'width=' + width_i + ',height=' + height_i + ',resizable=no,status=no,titlebar=no,scrollbars=yes');
}

function pop_tooltip(event_i, item_i)
{
    tooltip_obj = getObject(item_i + "_tip");
    
    if (tooltip_obj)
    {
	tooltip_obj.style.left = get_mouse_x(event_i) - 0;
	tooltip_obj.style.top = get_mouse_y(event_i) + 10;
	//tip.style.left = 100;
	//tip.style.top = 100;
	tooltip_obj.style.visibility = "";

	if (document.captureEvents)
	{
	    document.captureEvents(Event.MOUSEMOVE);
	}
	document.onmousemove = move_tooltip;
    }
}

function close_tooltip(event_i)
{
    //var tip = getObject(item_i + "_tip");
    if (tooltip_obj)
    {
	tooltip_obj.style.visibility = "hidden";
	tooltip_obj = null;

	if (document.releaseEvents)
	{
	    document.releaseEvents(Event.MOUSEMOVE);
	}
	document.onmousemove = null;
    }
}

function move_tooltip(event_i)
{
    if (tooltip_obj)
    {
	tooltip_obj.style.left = get_mouse_x(event_i) - 0;
	tooltip_obj.style.top = get_mouse_y(event_i) + 10;
    }
}

function get_mouse_y(event_i)
{
    if (!event_i)
    {
	if (window.event)
	{
	    event_i = window.event;
	}
	else
	{
	    return;
	}
    }
    
    if (event_i.pageY)
    {
	return event_i.pageY;
    }
    else if (event_i.clientY)
    {
	return event_i.clientY + (document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop);
    }
    else
    {
	return null;
    }
}

function get_mouse_x(event_i)
{
    if (!event_i)
    {
	if (window.event)
	{
	    event_i = window.event;
	}
	else
	{
	    return;
	}
    }

    if (event_i.pageX)
    {
	return event_i.pageX;
    }
    else if (event_i.clientX)
    {
	return event_i.clientX + (document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft);
    }
    else
    {
	return null;
    }
}

// /////////////////////////////////////////////////////////////////////
// This function limits the input to numbers
// Input: the field, an event, a decimal
// Output: restricts the field to numbers
// Created by: Feryl A. Dec. 20, 2004
// /////////////////////////////////////////////////////////////////////
function numbersonly(myfield, e, dec)
{
    var key;
    var keychar;

    // Grab the key events
    if (window.event)
    {
	key = window.event.keyCode;
    }
    else if (e)
    {
	key = e.which;
    }
    else
    {
	return true;
    }

    // Convert the character code to string
    keychar = String.fromCharCode(key);

    // control keys
    if ((key == null) || (key == 0) || (key == 8) || (key == 9) || (key == 13) || (key == 27))
    {
	return true;
    }
    // numbers
    else if ( ( ("0123456789.-").indexOf(keychar) > -1) )
    {
	return true;
    }
    // decimal point jump
    else if ( dec && (keychar == ".") )
    {
	myfield.form.elements[dec].focus();
	return false;
    }
    else
    {
	return false;
    }
}

function delete_confirm()
{
    return confirm("Are you sure you want to delete?");
}
