// Local JS functions

// Substitute for a common function
function $(id) {
    if (typeof id === "string") {   
        var item        = null;
        if (document.getElementById) {
            item    = document.getElementById(id);
        } else if (document.all) {
            item    = document.all[id];
        }    
        if (!item) { 
            return;
        }
        return item;
    }
    return id;
}

function make_name (nameForm) {
    nameForm    = nameForm || form;
    var cat_name            = 
        (nameForm["SUP:title"].value !== "" ?
            nameForm["SUP:title"].value + " " : "") +
        (nameForm["SUP:first"].value !== "" ?
            nameForm["SUP:first"].value + " " : "") +
        (nameForm["SUP:mid"].value !== "" ?
            nameForm["SUP:mid"].value + " " : "") +
        (nameForm["SUP:nickname"].value !== "" ?
            "\'" + nameForm["SUP:nickname"].value + "\' " : "") +
        (nameForm["SUP:last"].value !== "" ?
            nameForm["SUP:last"].value : "") +
        (nameForm["SUP:suf"].value !== "" ?
            ", " + nameForm["SUP:suf"].value : "");
    return cat_name;
}

// Get META elements of document, returned as an object/hash
function getMeta () {
    var docMeta = {};
    var metaElements;
    var i;
    if (document.all) {
        metaElements = document.all.tags('META');
    } else if (document.getElementsByTagName) {
        metaElements = document.getElementsByTagName('META');
    } else {
        metaElements = [];
    }
    for (i = 0; i < metaElements.length; i++) {
        docMeta[metaElements[i].name]   = metaElements[i].content;
    }
    return docMeta;
}

// Get document keywords, returned as an array
function getMetaKeywords () {
    var metaKeywords = getMeta().keywords || [];
    return metaKeywords;
}


function wait_spinner (pre_spin_msg,post_spin_msg) {
    pre_spin_msg    = pre_spin_msg  || '';
    post_spin_msg   = post_spin_msg || '';
    var imgSrc      = getMeta().img_url + '/mozilla_spinner.gif';
    return pre_spin_msg + 
    '<img src=\'' + imgSrc + '\' alt=\'' + pre_spin_msg + '\' title=\'' + pre_spin_msg + '\' width=\'18\' height=\'18\' hspace=\'0\' vspace=\'0\' align=\'middle\' border=\'0\' style=\'\'>' +
    post_spin_msg; // + '<' + 'br>Num: 0';
}



