/*
    JavaScript support
    
    (c) 2010 Molecular Materials Informatics, Inc.

    All rights reserved
*/

// ----------------------- convenience -----------------------

// locates a node by ID code, or barfs in an ugly manner if it does not exist
function findNode(id)
{
    var el=document.getElementById(id); 
    if (!el) throw("Unable to find document element: ["+id+"]");
    return el;
}

// obtains the absolute position for an element; returns an array of [x,y]
function getAbsXY(el)
{
    var xy=[0,0];
    while (el)
    {
        xy[0]+=el.offsetLeft;
        xy[1]+=el.offsetTop;
        el=el.offsetParent;
    }
    return xy;
}

