/**
 * @author emmanuelle
 */
$(document).ready(function(){

  // The last tiny panel need a special CSS
  $('div.panel-pane:last div.bg-bottom').addClass('last-bg');

  $('div.panel-pane:last div.post').addClass('last-bg');

  // Only the first tiny panel got a special CSS, need to remove the background of the one between the first and last tiny-panels
  $('div.panel-pane div.col-left').slice(1).css('background','none');

  // append the bottom-gap to the last tiny panel
  $('div.wb-content div.panel-pane:last').after('<div class="bottom-gap large"></div>');

  // The last element list need a special CSS
  $('div.panel-pane div.bg-bottom ul li:last p').addClass('last-p');

  // The last two categories need a special CSS
  var nb = $('div.sm-block').length;
  if(nb/2 == Math.round(nb/2))
  {
    $('div.sm-block').slice(nb-2,nb).addClass('no-bor-bottom');
  }
  else
  {
    $('div.sm-block').slice(nb-1,nb).addClass('no-bor-bottom');
  }

  // BO js when translating a product
  if($('input#edit-field-calling-price-1-amount').length != 0)
  {
    $('select#edit-field-calling-price-0-currency').attr('disabled','disabled');
    $('input#edit-field-calling-price-0-amount').attr('disabled','disabled');
  }

  // thickbox
  $('div.print-mail div.print-i a.thickbox').each(function(){
    var url = $(this).attr('href');
    if(url.indexOf('?', 0) == -1) {
      url = url+'?KeepThis=true&TB_iframe=true&height=305&width=415';
    } else {
      url = url+'&KeepThis=true&TB_iframe=true&height=305&width=415';
    }

    $(this).attr('href',url);
  })

  $('#TB_iframeContent', parent.document).load(function(){
    $(this).contents().find('body').addClass('iframe');
  })

  // landing panel: The last pane need a special CSS
  $('body.bg-body-dif div.bg-bottom:last').addClass('last-bg');

  // landing panel : need to add a span into the h2 in order to apply CSS
  var h2 = $('body.bg-body-dif div.languages div.header-language h2').html();
  $('body.bg-body-dif div.languages div.header-language h2').html('<span>'+h2+'</span>');

  // landing panel : show the languages on over
  $('body.bg-body-dif div.languages div.header-language').mouseover(function(){
    $(this).find('ul.links').hide();
    $(this).find('div.item-list').show();
  })
  // landing panel : hide the languages on over
  $('body.bg-body-dif div.languages div.header-language').mouseout(function(){
    $(this).find('ul.links').hide();
    $(this).find('div.item-list').hide();
  })
});

