//
//	jquery.bren.rollover
//
//	Usage:
//		$(function() {
//			$('.target a').bren_rollover({
//				width	: false,
//				height	: true,
//				opacity	: true,
//				speed	: 200
//			});
//		});
//

jQuery.fn.bren_rollover = function(myconfig)
{
	$(this).each(function()
		{
			var config = jQuery.extend(
				{
					width			: true,
					height			: true,
					opacity			: true,
					speed			: 500,
					easing			: null,
					newClass		: "hover-js",
					removeClass		: "hover-css",
					sliderElement	: "div"
				},
				myconfig
			);

			var css_clear = {};
			var css_anime = {};

			if (config.width && config.height) {
				css_clear.width		= "0px";
				css_clear.height	= "0px";
				css_anime.width		= $(this).outerWidth() + "px";
				css_anime.height	= $(this).outerHeight() + "px";
			}
			else if (config.width) {
				css_clear.width		= "0px";
				css_clear.height	= $(this).outerHeight() + "px";
				css_anime.width		= $(this).outerWidth() + "px";
				css_anime.height	= $(this).outerHeight() + "px";
			}
			else if (config.height) {
				css_clear.width		= $(this).outerWidth() + "px";
				css_clear.height	= "0px";
				css_anime.width		= $(this).outerWidth() + "px";
				css_anime.height	= $(this).outerHeight() + "px";
			}
			if (config.opacity) {
				css_clear.opacity	= 0;
				css_anime.opacity	= 1;
			}

			$(this)
				.removeClass(config.removeClass)
					.prepend($('<' + config.sliderElement + '>'))
						.find(config.sliderElement)
							.addClass(config.newClass)
								.css(css_clear);

			$(this)
				.hover(
					function() {
						$('.' + config.newClass, this).stop().animate(
							css_anime,
							config.speed,
							config.easing
						);
					},
					function() {
						$('.' + config.newClass, this).stop().animate(
							css_clear,
							config.speed,
							config.easing
						);
					}
				);

			return this;
		}
	);
}


