/*
Author: Joe Tan (joe.tan@trinetsolutions.com)
*/

// Add some missing functions to Prototype 1.5.0 library


// Add DOMContentLoaded event handler
// Usage: Event.onReady(callbackFunction);
Object.extend(Event, {
  onReady : function(f) { document.observe('dom:loaded', f); } // just delegate to prototype
});

// prototype 1.5 doesn't have Element.wrap()
if (typeof Element.wrap == 'undefined') Object.extend(Element, {
	wrap: function(element, wrapper, attributes) {
		element.parentNode.replaceChild(wrapper, element);
		wrapper.appendChild(element);
		return wrapper;
	}
});
if (typeof Element.wrapInner == 'undefined') Object.extend(Element, {
	wrapInner: function(element, wrapper, attributes) {
		//element.parentNode.replaceChild(wrapper, element);
		//wrapper.appendChild(element);
		
		return wrapper;
	}
});
if (typeof Element.insertAfter == 'undefined') Object.extend(Element, {
	insertAfter : function(element, node, otherNode) {
		element = $(element);
		return element.insertBefore(node, otherNode.nextSibling);
	}
});

