
$(document).ready(function(){
  //$.timer(1000, function (timer) {
    var font_index = 6;
    var scroll_w = 35; /* Scroll width */
    var spacer_pixel_url = 'theme/images/spacer.gif';
			
    /*
     ** Author : Ujeen
     ** 1. You must fix box height where select tag is situated.
     ** 2. The box (where select tag is situated) must have class "ie_select_fix select".
     ** 3. This script requires jQuery framework
     */
		
    if ($.browser.msie && parseInt($.browser.version) < 9) {
      var target_tag = '.ie_select_fix';
      var zindex = 10000;
      $(target_tag).each(function(){
        if ($(this).css('position') != 'absolute') {
          var css = 'position:relative;';
          if ($(this).css('display')) {
            css += 'display:'+$(this).css('display')+';';
          }
          if ($(this).css('margin-top')) {
            css += 'margin-top:'+$(this).css('margin-top')+';';
          }
          if ($(this).css('margin-right')) {
            css += 'margin-right:'+$(this).css('margin-right')+';';
          }
          if ($(this).css('margin-bottom')) {
            css += 'margin-bottom:'+$(this).css('margin-bottom')+';';
          }
          if ($(this).css('margin-left')) {
            css += 'margin-left:'+$(this).css('margin-left')+';';
          }
          if ($(this).css('height')) {
            var h = $(this).css('height')
          }
          if ($(this).css('width')) {
            var w = $(this).css('width')
          }
          if ($(this).css('vertical-align')) {
            css += 'vertical-align:'+$(this).css('vertical-align')+';';
          }
        
          //$(this).wrap('<span style="'+css+'">&nbsp;</span>')

          var left  = $(this).position().left;
          var top   = $(this).position().top;
          $(this).css({
            'position':'absolute',
            'left':left,
            'top':top,
            'z-index':'0'
          });
        }
        $(this).after('<img src="'+spacer_pixel_url+'" width='+w+' height='+h+' />');
        $(this).parent().css({
          'position':'relative'
        })
        var width = 0;
        var opts = $(this).children('option');
        opts.each(function(){
          if ($(this).text().length > width){
            width = $(this).text().length;
          }
        })
        true_width = width*font_index+scroll_w;
        true_width = (true_width.toFixed(0));
        $(this).attr('min_width',$(this).width()+2);
        if (true_width<$(this).width()+2) {
          true_width = $(this).width()+2;
        }
        $(this).attr('max_width',true_width);
      })
      .mouseover(function(){
        if ($(this).attr('max_width') != $(this).attr('min_width')) {
          $(this).css({
            'z-index':zindex++
          });
          $(this).animate({
            'width':$(this).attr('max_width')
          })
        }
      });
      $('body').mouseover(function(){
        $(target_tag).each(function(){
          $(this).css({
            'width':$(this).attr('min_width')
          })
        })
      })
    }
 // })
})

