// init documentready-function
jQuery(document).ready(function($) {

  // TODO check for native/font-face first, before using cufon
  Cufon.replace('#headerNav a, #footerNav a, #searchbox label, #contactInfo nav a', { fontFamily: 'Myriad Pro Bold Condensed' });
  Cufon.replace('#nav a, #productsNav a', { fontFamily: 'Myriad Pro Condensed' });
  Cufon.replace('h1, #multilang p, .products #content h1, .tx-indexedsearch-whatis', { fontFamily: 'Myriad Pro Light' });

  // adding the classes home, aktuelles, produkte, gonis-ich to parent-lis
  $('#nav > ul > li > a').each(function() {
    var parentClass = $(this).attr('href');
    var pathItems = parentClass.split('/');
    if (pathItems[0] != '') {
      // it can happen that we land on pages like /de/home or /it/produkte, so check those
      if (pathItems[0] == 'de' || pathItems[0] == 'it' || pathItems[0] == 'fr') {
        $(this).parent().addClass(pathItems[1]);
      } else {
        $(this).parent().addClass(pathItems[0]);
      }
    }
  });


  // add the galleria to the products-page
  if ($('#gallery').length) {
    head.js('fileadmin/templates/js/galleria-1.2.2.min.js', function() {
      Galleria.loadTheme('fileadmin/templates/js/galleria.gonis.js');
      $('#gallery').galleria();
    });
  }

  if ($('#productsNav').length) {
    $('#productsNav a').each(function() {
      $(this).text($(this).text() + ' »');
    });
  }

  // IE and stupid browsers bugfixing
  if (head.boxshadow !== true) {
    head.js('fileadmin/templates/js/PIE.js', function() {
      $('.no-boxshadow .index #imageContainer, .no-boxshadow #main, .lt-ie9.no-boxshadow #subContent, .no-boxshadow .homepage #imageContainer > div').each(function() {
        PIE.attach(this);
      });
    });

  }

}); // end documentready

