(function($) {
    $.fn.shadow = function(width, height, top, left, over, gDir){
        var elem = this;
        var imgPixel = 8;
        width += over;
        height += over;
        top += -(over/2);
        left += -(over/2);
        var shadowParts = [{
                position: 'absolute',
                width: width,
                height: height,
                top: top,
                left: left,
                backgroundColor: '#7f7f7f'
            },
            {
                width: width + imgPixel,
                height: imgPixel,
                top: -imgPixel,
                left: -imgPixel,
                backgroundImage: 'url(' + gDir + 'tl.png)'
            },
            {
                width: imgPixel,
                height: imgPixel,
                top: -imgPixel,
                right: -imgPixel,
                backgroundImage: 'url(' + gDir + 'tr.png)'
            },
            {
                width: imgPixel,
                height: height,
                top: '0px',
                left: -imgPixel,
                backgroundImage: 'url(' + gDir + 'l.png)',
                backgroundRepeat: 'repeat-y'
            },
            {
                width: imgPixel,
                height: height,
                top: '0px',
                right: -imgPixel,
                backgroundImage: 'url(' + gDir + 'r.png)',
                backgroundRepeat: 'repeat-y'
            },
            {
                width: width + imgPixel,
                height: imgPixel,
                top: height,
                left: -imgPixel,
                backgroundImage: 'url(' + gDir + 'bl.png)'
            },
            {
                width: imgPixel,
                height: imgPixel,
                top: height,
                right: -imgPixel,
                backgroundImage: 'url(' + gDir + 'br.png)'
        }];
        return this.each(function(){
            var container = $('<div class="shadow">').css(shadowParts.shift()).appendTo(elem.parent());
            $(shadowParts).each(function() {$('<div class="iepngfix">').appendTo(container).css($.extend({position: 'absolute', backgroundRepeat: 'no-repeat'}, this));});
            container.append(elem.css({position: 'absolute', margin: 0, top: over/2, left: over/2}));
        });
    };
})(jQuery);