// Patches for Prototype library to extend to IE 5.5 compatibility
// descendants() adds node.all to find all children of the node.
// IE 5.5 does not recognize '*' as a valid argument to getElements...TagName();
//

	var methods = {
		descendants: function( element ) {
			var node = $(element);
			return $A(node.all || node.getElementsByTagName('*'));
		}
	}
	
	Object.extend( Element.Methods , methods );
	
	
	document.getElementsByClassName = function(className, parentElement) { 
	  if (Prototype.BrowserFeatures.XPath) { 
		var q = ".//*[contains(concat(' ', @class, ' '), ' " + className + " ')]";
		return document._getElementsByXPath(q, parentElement);
	  } else { 
	  
	  // Using our patched method descendants(); to find all childrend
	  //
		var node = $( parentElement || document.body );
		var children = node.descendants();
		var elements = [], child;
		for (var i = 0, length = children.length; i < length; i++) {
		  child = children[i];
		  if (Element.hasClassName(child, className))
			elements.push(Element.extend(child));
		}
		return elements;
	  }
	};

// Helper methods to get all elements by a particular attribute
// found at http://unspace.ca/discover/attributes/
//
	document.getElementsByAttribute = function(attribute, parentElement) {
	  var children = ($(parentElement) || document.body).getElementsByTagName('*');
	  return $A(children).inject([], function(elements, child) {
		if (child.getAttribute(attribute))
		  elements.push(Element.extend(child));
		return elements;
	  });
	}
	
	Object.extend(Enumerable, {
	  pluck: function(property) {
		var results = [];
		this.each(function(value, index) {
		  results.push(value.getAttribute ? value.getAttribute(property) || value[property] : value[property]);
		});
		return results;
	  }
	});
	
	Object.extend(Array.prototype, Enumerable);

// Helper method to insert any element after a particular element / node
// found at http://www-128.ibm.com/developerworks/xml/library/x-matters41.html
//
	document.insertAfter = function( node, referenceNode ) {
		var parent = $(referenceNode).up();
		if(referenceNode.nextSibling) {
			parent.insertBefore(node, referenceNode.nextSibling);
		} else {
			parent.appendChild(node);
		}
	}









