/* 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) return;
		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;
			if (blurRadius != 0) {
				$(div).css("filter", "progid:DXImageTransform.Microsoft.Blur(pixelRadius="+(blurRadius)+", enabled='true')");
				var ow = $(this).outerWidth();
				var oh = $(this).outerHeight();
				
				var pos  = $(this).position();
				var ml = parseFloat($(this).css('marginLeft').replace('px',''));
				var mt = parseFloat($(this).css('marginTop').replace('px',''));
				
				_top = 		pos.top+mt+yOffset-blurRadius;
				_left =		pos.left+ml+xOffset-blurRadius;
				_width =	ow;
				_height =	oh;
			} else {
				_top = 		yOffset;
				_left =		xOffset;
				_width = 	ow.outerWidth();
				_height = 	oh.outerHeight();
			}
			$(div).css({				
				top: 		_top,
				left:		_left,
				width:		_width,
				height:		_height,
				background:	shadowColor,
				position:	"absolute",
				zIndex:		1
			});	
	  });
	};
})(jQuery);
