/**
 * Ara's JavaScript Library: DOM
 */

var ARA = window.ARA || {};
ARA.dom = ARA.dom || {};

/**
 * getElement receives an element of unknown type and determines whether it's 
 * an element ID or a reference to an element in the DOM. If it's an ID it 
 * fetches and returns a reference to the element in the DOM with that ID.
 * If it's a reference to an element in the DOM it just returns it without
 * doing anything.
 *
 * @param    {String/Object}  el  An element ID or element reference in the DOM
 * @returns  {Object}
 */
ARA.dom.getElement = function(el){
	switch(typeof el){
		case "string":
			return document.getElementById(el);
		break;

		case "object":
		default:
			return el;
		break;
	}
}

ARA.dom.getElementsByClassName = function(className, scope){
	scope = scope || document;
	var returnElements = [];
	var allElements = document.getElementsByTagName("*");
	for(var i=0; i<allElements.length; i++){
		var classNames = allElements[i].className.split(" ");
		for(var j=0; j<classNames.length; j++){
			if(classNames[j] == className){
				returnElements.push(allElements[i]);
			}
		}
	}
	return returnElements;
}