/* Created by Martin Hintzmann 2008 martin [a] hintzmann.dk
 * MIT (http://www.opensource.org/licenses/mit-license.php) licensed.
 *
 * Version: 0.1
 *
 * Requires:
 *   jQuery 1.2+
 */
(function($) {
	$.fn.boxShadow = function(xOffset, yOffset, blurRadius, shadowColor) {
		if (!$.browser.msie){
			$(this).css({
				'-webkit-box-shadow':xOffset+'px '+yOffset+'px '+blurRadius+'px '+shadowColor,
				'-moz-box-shadow':xOffset+'px '+yOffset+'px '+blurRadius+'px '+shadowColor,
				'box-shadow':xOffset+'px '+yOffset+'px '+blurRadius+'px '+shadowColor
			});
			return this;
		}
		return this.each(function(){
			$(this).css({
				position:	"relative",
				zoom: 		1,
				zIndex:		"2"
			});
			$(this).parent().css({
					position:	"relative"
			});
			
			var div=document.createElement("div");
			$(this).parent().append(div);

			var _top, _left, _width, _height;
			//blurRadius = 0;
			if (blurRadius != 0) {
				$(div).css("filter", "progid:DXImageTransform.Microsoft.Blur(pixelRadius="+(blurRadius)+", enabled='true')");
				_top = 		$(this).position().top+yOffset-(blurRadius/2);
				_left =		$(this).position().left+xOffset-(blurRadius/2);
				_width = 	$(this).outerWidth()-blurRadius;
				_height = 	$(this).outerHeight()-blurRadius;
			} else {
				_top = 		$(this).position().top+yOffset;
				_left =		$(this).position().left+xOffset;
				_width = 	$(this).outerWidth();
				_height = 	$(this).outerHeight();
			}
			$(div).css({
				top: 		_top,
				left:		_left,
				width:		_width,
				height:		_height,
				background:	shadowColor,
				position:	"absolute",
				zIndex:		1
			});
			
	  });
	};
})(jQuery);
