jQuery(document).ready(function($){
  $("#copyright_year").html( (new Date).getFullYear() );

  $('#menu_container a').first().addClass('no_submenu');

  // add button class links
  $('a[title=button]').each(function(index, element){
    $(element).addClass('button');
  })

  // add class to details of first products category
  $('#product_overview.main .csc-header:first').addClass('first');


  // PRODUCTS RO
  // "link:" generate links in product tables
  // "subtitle:" maximize colspan and remove empty cells
  var cells = $('table.products tr td');
  $.each(cells, function(index, value){
    var text = $(this).text().replace(/^\s+|\s+$/g,"");
    var link = text.split('link: ')[1];
    var subtitle = text.split('subtitle: ')[1];
    if (link) {
      if ($('body').hasClass('ro')){
        if (link.indexOf('.') < 0){
          extension =  '.' + (link.split(':')[1] || 'pdf');
          link = link.split(':')[0];
        } else {
          extension = '';
        }
        $(this).html("<a target='blank' href='/fileadmin/user_upload/product_sheets/" + link + extension + "'>" + link + "</a>");
      }
      // for DE, just remove prefix
      if ($('body').hasClass('de')){
        $(this).html(link);
      }
    }
    
    if (subtitle) {
      var siblings = $(this).siblings();
      siblings.remove();
      $(this).attr('colspan', 1 + siblings.size());
      $(this).html("<b>" + subtitle + "</b>");
    }    
  });
 
  // remove image borders
  var links = $('#main_part a img');
  $.each(links, function(index, value){
    $(this).parent().addClass('img');
  });

  // enable lightbox (for projects)
  if ($(".projects-list-item a").size() > 0){
  	$(".projects-list-item a").colorbox({
  	  innerHeight: '560px',
  	  innerWidth: '980px'
  	});
  }
});

