function getElementByClass( className )
{
	// Initialize array of all elements of the page
	var allElements = new Array();
	allElements = this.getElementsByTagName("*");
	//allElements = this.childNodes;
	
	if(this.className==className)
	{
		return this;
	}
	
	// Traverse all elements looking for elements of this class
	for(i=0; i<allElements.length; i++)
	{
		if(allElements[i].className==className)
		{
			return allElements[i];
		}
	}
	return null;
}

function getElementsByClass( className )
{
	// Initialize array of all elements of the page
	var allElements = new Array();
	allElements = this.getElementsByTagName("*");
	//allElements = this.childNodes;
	// Initialize array for elements of this class to be stored
	var classElements = new Array();
	
	// Traverse all elements looking for elements of this class
	for(i=0; i<allElements.length; i++)
	{
		if(allElements[i].className==className)// Check element class name
		{
			// We found an element of the given class!
			// Add it to the array of this classes elements
			classElements[classElements.length]=allElements[i];
		}
	}
	return classElements;// return the class elements array
}
function findPos()
{
	var el = this;
	var left =0;
	var top = 0;
	if (el.offsetParent)
	{
		left = el.offsetLeft
		top = el.offsetTop
		while (el = el.offsetParent)
		{
			left += el.offsetLeft
			top += el.offsetTop
		}
	}
	return [left,top];
}

function getAttribute(name)
{
	el=this;
	for(var i=0; i<el.attributes.length; i++)
	{
		if(el.attributes[i].nodeName.toLowerCase()==name.toLowerCase())
		{
			return el.attributes[i].nodeValue;
		}
	}
}

function toolSetup()
{
	document.getElementByClass=getElementByClass;
	document.getElementsByClass=getElementsByClass;
	//Set up each element to be able to perform this functions
	var elmnts = new Array();
	elmnts = document.getElementsByTagName("*");
	for(i=0; i<elmnts.length; i++)
	{
		elmnts[i].getElementByClass=getElementByClass;
		elmnts[i].getElementsByClass=getElementsByClass;
		elmnts[i].getAttribute=getAttribute;
		elmnts[i].findPos=findPos;
		//document.getElementById('debug').innerHTML+=i+'<br>';
	}
}
toolSetup();
