/**
 * Peppered library
 *
 * @name peppered_library.js
 * @category jQuery
 * @version 1.0
 * @date January 22, 2008
 *
 * @author Arjen Kaldenbach <arjen@peppered.nl>
 * @author Marvin Crawford <marvin@peppered.nl>
 * @copyright Copyright (c) 2008 Peppered. All rights reserved.
 */

jQuery.fn.ImageReplace = function(options) {
	var defaults = {
		hover: false
	};
	
	options = $.extend(defaults, options);
	
	if (this.get(0).nodeName.toLowerCase() == 'body') {
		// old style replace via classnames
		$('.ir, .ir-anchors a').append('<span class="ir-aid"></span>'); // single element IR & descendant anchors of an element
		$('.ir.ir-hover span.ir-aid, .ir-anchors.ir-anchors-hover a span.ir-aid').append('<span></span>'); // append another span when it has a hover state
		$('.ir, .ir-anchors').addClass('irActive');
	} else {
		this.each(function() {
			$(this).addClass('ir');
			$(this).append('<span class="ir-aid"></span>');
			if (options.hover == true)
			$(this).children('span.ir-aid').append('<span class="ir-aid-hover"></span>');
			$(this).addClass('irActive');
		});
	}
}