/* Copyright (c) 2006 Brandon Aaron (brandon.aaron@gmail.com || http://brandonaaron.net)
 * Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php) 
 * and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses.
 */

/**
 * Replaces the matched elements with either an HTML String, DOM Element or a jQuery object.
 * Not only does it replace the element in the DOM but it also replaces the element 
 * within the jQuery object. That means you can continue the chain to work with
 * the new elements.
 * http://blog.brandonaaron.net/2007/06/01/jquery-snippets-replace/
 */
jQuery.fn.replace = function() {
	var stack = [];
	return this.domManip(arguments, true, 1, function(a){
		this.parentNode.replaceChild( a, this );
		stack.push(a);
	}).pushStack( stack );
};