(function ($)
{
   $.fn.extend({

      customStyle: function (addStyle)
      {
         if (!$.browser.msie || ($.browser.msie && $.browser.version > 6))
         {
            return this.each(function ()
            {
               var baseName = $(this).attr("class");
               var currentSelected = $(this).find(':selected');

               $(this).after('<div class="' + baseName + '"><div class="' + baseName + 'Inner">' + currentSelected.text() + '</div></div>').css({ position: 'absolute', opacity: 0, fontSize: $(this).next().css('font-size') });

               var selectBoxSpan = $(this).next();
               //alert($(this).css("width"));
               var selectBoxWidth = parseInt($(this).css("width"));
               var selectBoxHeight = parseInt($(this).css("height"));
               if (!selectBoxWidth)
                  selectBoxWidth = parseInt($(this).width()) - parseInt(selectBoxSpan.css('padding-left')) - parseInt(selectBoxSpan.css('padding-right'));
               if (!selectBoxHeight)
                  selectBoxHeight = parseInt(selectBoxSpan.height()) + parseInt(selectBoxSpan.css('padding-top')) + parseInt(selectBoxSpan.css('padding-bottom'));

               var selectBoxSpanInner = selectBoxSpan.find(':first-child');

               selectBoxSpan.css({ width: selectBoxWidth, display: 'inline-block' });
               selectBoxSpanInner.css({width: selectBoxWidth, display: 'inline-block' });

               $(this).height(selectBoxHeight).change(function ()
               {
                  selectBoxSpanInner.text($(this).find(':selected').text()).parent().addClass('changed');
               });

            });
         }
      }
   });
})(jQuery);


