/*
 * Ceroc & Modern Jive Adelaide Javascript library
 * (c) 2006-2007 Ceroc & Modern Jive Adelaide Pty Ltd
 *
 * Unless you are a regular dancer you are expressly forbidden from using,
 * copying or modifying this code or learning any cool techniques from it.
 *
 * If you want to use it you must learn to dance.
 */

function duplicate_by_id(id, id_suffix, name_suffix)
{
    var dup = document.getElementById(id).cloneNode(true);
    recursive_rename_reid(dup, name_suffix, id_suffix);

    return dup;
}

function duplicate_by_name(name, name_suffix, id_suffix)
{
    var dup = document.getElementByName(name).cloneNode(true);
    recursive_rename_reid(dup, name_suffix, id_suffix);

    return dup;
}

function recursive_rename_reid(object, name_suffix, id_suffix)
{
    if (object.name) { object.name = object.name + name_suffix; }
    if (object.id) { object.id = object.id + id_suffix; }
    for (var it = object.firstChild; it; it = it.nextSibling)
    {
	recursive_rename_reid(it, name_suffix, id_suffix);
    }
}
 
/* This is not working at the moment */
function object_recurse(object, func)
{
    for (var it = object.firstChild; it; it = it.nextSibling)
    {
	func(it);
	object_recurse(it, func);
    }
}

function copy_element(f, t)
{
    var fe = document.getElementById(f);
    var te = document.getElementById(t);
    fe.selected = te.selected;
}

function make_a_href(url, text, target)
{
    var u = "";
    for (i = 0; i < url.length; i += 2) u += unescape('%' + url.substr(i, 2));
    document.write("<a target='" +target + "' href='" + u + "'>" + text + "</" + "a>");
}

function tooltip(me, title, text)
{
    me.T_LEFT = true;
    me.T_TITLE = title;
    return escape(text);
}

