addBodyendEvent(function () {

  // functions for search box
  backgroundText('#search_text');

  // size switching
  if ($('#sizePath').length) {
    var html  = '';
    var index = 0;
    var text  = '';
    $('#sizes').find('a').each(function(key, value) {
      text = $(this).text();
      if (text == $('#sizePath').text()) {index = key;}
      html += '<a href="'+$(this).attr('href')+'" title="'+$(this).attr('title')+'" index="'+key+'">'+text+'</a>';
    });
    $('#sizePath').before('<div id="sizeChooser"><div>'+html+'</div></div>');
    $('#sizePath').mouseenter(showSizeSwitcher);
    $('#sizePath').click(function () {return false;});
    $('#sizeChooser').css('bottom', (index*14+3)+'px');
    $('#sizeChooser').mouseleave(hideSizeSwitcher);
    $('#sizeChooser a').click(function () {
      $('#sizePath').html($(this).text());
      $('#sizePath').unbind('mouseenter');
      hideSizeSwitcher($(this).attr('index'));
    });
  }
});

// functions for size switching
function showSizeSwitcher() {
  $('#sizeChooser').css('opacity', '0');
  $('#sizeChooser').css('display', 'inline-block');
  $('#content-top-image .over-content').css('overflow', 'visible');
  $('#sizeChooser').animate({opacity: 0.9}, 250);
  return false;
}
function hideSizeSwitcher(index) {
  var cssTo = {opacity: 0};

  if (!empty(index) && !isNaN(parseInt(index))) {
    cssTo['bottom'] = (index*14+3)+'px';
  }
  
  $('#sizeChooser').animate(cssTo, 250, function () {
    $('#sizeChooser').css('display', 'none');
    $('#content-top-image .over-content').css('overflow', 'hidden');
  });

  return false;
}
