function unpx(pArg){return parseInt(pArg.replace(/px/, ""));}

$(document).ready(function() {

  $('.inbox').each(function(){
    units = 0;
    operawidth = 0;
    $(this).find('.sl_img').each(function(){
      units = units + 1;
      if ($.browser.msie || $.browser.opera) {
        span = $(this).attr('name');
        $('span.title.position_'+span).css({'width':$(this).width()});
        operawidth = operawidth + $(this).width();
      } else {
        $(this).load(function(){
          span = $(this).attr('name');
          $('span.title.position_'+span).css({'width':$(this).width()});
        });
      }
    });
    if(units < 4){
      var forremove = $(this).attr('id');
      $('div.slider.'+forremove).remove();
      $(this).parent().css({'margin':'30px 0 30px 0'});
    }
    if($.browser.opera){
      operawidth = operawidth + units*10;
      $(this).css({'width':operawidth});
    }
  });
  
  $(".slider").slider({
    slide: function(event, ui){
      boxid = $(this).attr('name');
      var flo=((unpx($('#box_'+boxid).css('width'))-unpx($('.box').css('width')))/100);
      $('#box_'+boxid).css('left',-(flo*ui.value));
    }
  });
});
