(function($){

    $.fn.linearGradient = function(orientation, startColor, endColor) {
        if ($.browser.mozilla) {
            orientation = (orientation == 'v') ? 'top' : 'left';            
            var value = '-moz-linear-gradient(' + orientation + ',' + startColor + ',' + endColor + ')';
            this.css('background-image', value);
        } else if ($.browser.webkit) {
            orientation = (orientation == 'v') ? 'left top,left bottom' : 'left top,right top';
            var value = '-webkit-gradient(linear,' + orientation + ',from(' + startColor + '),to(' + endColor + '))';
            this.css('background-image', value);
        } else if ($.browser.msie) {
          this.each(function(i, el){
            if (el.className.search(/DD_roundy/) != -1) {
                // Play nice with DD_roundies
                window.setTimeout(function() {
                    var fill = el.vml.color.fill;
                    fill.type = 'gradient';
                    fill.angle = (orientation == 'v') ? 180 : 270;
                    fill.color = startColor;
                    fill.color2 = endColor;
                }, 100);  // this wait value is rather arbitrary, but do we really want to do polling?
            } else {
                var fillOrientation = (orientation == 'v') ? 'GradientType=0' : 'GradientType=1';
                var value = "progid:DXImageTransform.Microsoft.gradient(enabled='true'," + fillOrientation + ',startColorstr=' + startColor + ',endColorstr=' + endColor + ')';
                if (el.filters.length) {
                    el.style.filter = el.currentStyle.filter + value;	
                } else {
                    el.style.filter = value;
                }
            }
          });
        }

        return this;
    };
    
})(jQuery);


