

/*************************************************************
 * Window Onload Manager (WOM) v1.0
 * Author: Justin Barlow - www.netlobo.com
 *
 * Description:
 * The WOM library of functions allows you to easily call multiple javascript functions when your page loads.
 *
 * Usage:
 * Add functions to WOM using the womAdd() function. Pass the name of your functions (with or without parameters) into womAdd(). Then call womOn() like this:
 *     womAdd('hideDiv()');
 *     womAdd('changeBg("menuopts","#CCCCCC")');
 *     womOn();
 * WOM will now run when your page loads and run all of the functions you have added using womAdd()
 *************************************************************/
var woms = new Array();
function womGo() {
	for(var i = 0;i < woms.length;i++)
		eval(woms[i]);
}

function womAdd(func) {
	woms[woms.length] = func;
}

window.onload = womGo;

/*************************************************************
 * getElementsByClassName()
 *
 * Returns an array of all elements of the given type, with the given class.  
 * If no tag name supplied, returns an array of all elements with the given class.
 * Usage:
 *    var myElements = getElementsByClassName('classname', DIV); //returns array of all DIV elements of class "classname"
 *    var myElements = getElementsByClassName('classname'); //returns array of all elements of class "classname"
 *************************************************************/
function getElementsByClassName(classname, tag) {
    if (!tag) {
        var obj = document.getElementsByTagName("*");
    } else {
        var obj = document.getElementsByTagName(tag);
    }
    var els = new Array();
    var a = 0;
    for (i = 0; i < obj.length; i++){
        if (obj[i].className.indexOf(classname) >= 0) {
            els[a++] = obj[i];
        }
    }
    return els;
}


/*************************************************************
 * findFirstElementByClassName(obj, cssClass)
 *
 * Returns the first HTMLElement of class cssClass
 * If no HTMLElement is found, returns false
 * Usage:
 * var first = findFirstElementByClassName(HTMLElementObject, 'cssClass');
 * if (!first) { doSomething() }
 *************************************************************/
function findFirstElementByClassName(obj, cssClass)
{
    if (empty(obj) || empty(cssClass)) return false;
    
    for (var i=0; i<obj.childNodes.length; i++)
    {
        
        if (obj.childNodes[i].nodeType == 3) continue;
        
        if (obj.childNodes[i].className == cssClass)
        {
            return obj.childNodes[i];
        }
    }
    return false;
}

/*************************************************************
 * isString()
 *
 * Returns true/false depending on whether the given object is a string.
 * Usage:
 *   var myBoolean = isString("hello"); //returns true
 *   var myBoolean = isString(document.body); //returns false
 *   var myBoolean = isString(7); //returns false
 *************************************************************/
isString = function(object) {
    return typeof object == "string";
}

/*************************************************************
 * $()
 *
 * Prototype Framework's replacement for document.getElementById(), less the dom extensions.
 * If provided with a string argument, returns the element with an id of the given value.
 * If provided with an object, returns that object.
 * If provided with multiple arguments (either strings or object references), returns an array of those elements/ids.
 * Usage:
 *    var myElement = $('john'); //returns HTMLElement with id, "john";
 *    var myElement = $(document.body) //returns HTMLBodyElement;
 *    var myElements = $('john', document.body, 'paul', 'george' 'ringo'); //returns array of HTMLElements with the given ids, and HTMLBodyElement   
 *************************************************************/
function $(element) {
  if (arguments.length > 1) {
    for (var i = 0, elements = [], length = arguments.length; i < length; i++)
      elements.push($(arguments[i]));
    return elements;
  }
  if (isString(element))
    element = document.getElementById(element);
  return element;
}

function empty () { if (arguments[0] == null || typeof arguments[0] == "undefined" || arguments[0] == "undefined" || arguments[0] == "") return true; else return false;};

//TODO: look at old cvs shared js scripts


