var inPrintMode = (/\?print|&print/i).match(window.location.href);

Event.observe(window, 'load', function () {
  $$('a').each(function (e) {
    if (!e.title)
      e.title = e.innerHTML.stripTags();
  });

  if ($('print') != null)
    $('print').onclick = function () {
      window.open(this.href, unescape('Lahntal%20Tourismus%20Verband%20e.%20V.%20%7C%20Die%20Lahn%20von%20der%20Quelle%20bis%20zur%20M%FCndung'), "width=904,height=600,left=100,top=200,menubar=no,location=no,toolbar=no");
      //window.open(this.href, unescape('Lahntal%20Tourismus%20Verband%20e.%20V.%20%7C%20Die%20Lahn%20von%20der%20Quelle%20bis%20zur%20M%FCndung'), "width=904px,left=100,top=200,menubar=yes,location=no,toolbar=no,scrollbars=yes,innerHeight=1500");
      return false;
    };

  if (!inPrintMode) {
    resize();

    Event.observe(window, 'resize', resize);

  } else
    window.print();
});

function resize()
{
  // Inhalt auf Fenstergröße erweitern
  var elementHeight = 0;

  if ($('barcode') != null)
    elementHeight += $('barcode').getHeight();
  if ($('top') != null)
    elementHeight += $('top').getHeight();
  if ($('submenu') != null)
    elementHeight += $('submenu').getHeight();
  if ($('breadcrumb-top') != null)
    elementHeight += $('breadcrumb-top').getHeight();

  var innerHeight = window.innerHeight || document.body.clientHeight;

  $('body').setStyle({height: (innerHeight - elementHeight) + 'px'});
  setCookie('body_height', (innerHeight - elementHeight), 1);
}

function setCookie(c_name, value, expiredays)
{
  var exdate = new Date();
  exdate.setDate(exdate.getDate() + expiredays);
  document.cookie = c_name + "=" + escape(value) + ((expiredays == null) ? "" : ";expires=" + exdate.toGMTString() + ";path=/");
}
