/*
 * replaceWith - replace one element with another
 * http://snipplr.com/view/1694/jquery-plugin-replace-dom-element-and-keep-classes-and-id
*/

jQuery.fn.replaceWith = function(replacement) {

    return this.each(

		function() {

		    var origElement = $(this);

		    origElement.after(replacement).next().html(origElement.html());

		    var newElement = origElement.next();

		    newElement.attr('class', this.attributes['class'].nodeValue);

		    if (origElement.css('margin-top') != null)
		        newElement.css('margin-top', origElement.css('margin-top'));

		    origElement.remove();
		}
	)
}