/* = Base Functions
**************************************************/

	//Get Element by Class
	function getElementsByClass(searchClass,node,tag) {
		var classElements = new Array();
		if ( node == null )
			node = document;
		if ( tag == null )
			tag = '*';
		var els = node.getElementsByTagName(tag);
		var elsLen = els.length;
		var pattern = new RegExp("(^|\\s)"+searchClass+"(\\s|$)");
		for (i = 0, j = 0; i < elsLen; i++) {
			if ( pattern.test(els[i].className) ) {
				classElements[j] = els[i];
				j++;
			}
		}
		return classElements;
	}
	
	//Add a class to an existing element
	function addClass(element,value){
		if (!element.className){
			element.className = value;
		} else {
			newClassName = element.className;
			newClassName+= " ";
			newClassName+= value;
			element.className = newClassName;
		}
	}
	
	//Remove a class from an existing element
	function remClass(element,value){
		//check if the element has any classes assigned to it
		if (element.className){
			//check if there are any other characters (or classes) 
			//other then that which we want to remove
			if(element.className.length > value.length){
				var startPos = element.className.indexOf(value);
				var charCount = value.length;
				var endPos = startPos + charCount;
				var newClassName = element.className.substr(0, startPos) + element.className.substr(endPos);
								
				element.className = newClassName;
			} else {
				element.className = "";
			}
		}
	}
	
	//Find the position of an object and what it relates to
	function findPos(obj) {
		var curleft = topheight = parentheight = curtop = curheight = 0;
		if (obj.offsetParent) {
			curleft = obj.offsetLeft
			curtop = obj.offsetTop
			curheight = obj.offsetHeight 
			parentheight = obj.offsetParent.offsetHeight 

			while (obj = obj.offsetParent) {
				curleft += obj.offsetLeft
				curtop += obj.offsetTop
				curheight += obj.offsetHeight 
			}
		}
		curheight = curheight - parentheight;
		topheight = Number(((curtop + (parentheight * 2)) - curheight) + curtop);
		return [curleft,curtop,curheight,topheight,parentheight];
	}
	
