// autoload-stuff
window.addEvent('domready', function() {  

  // IE6 Bugfix, Suckerfishstyle for Dropdownmenues
  if(Browser.Engine.trident) {
    $$('#globalnaviliste li, #themenmenue li').each(function(li) {
      li.addEvent('mouseover', function(e) {
        li.addClass('sfhover');
      });
      li.addEvent('mouseout', function(e) {
        li.removeClass('sfhover');
      });
    });
  }
   
  //=============================================================

  // Suchfeld wird leer, wenn man reinklickt
  if ($('searchformInput')) {
    $('searchformInput').addEvent('click', function() {
      $('searchformInput').setProperty('value', '')
    });
  }
  
  // font-size setzen, notwendig fuer spaetere inc/dec-Operationen
  $$('body').each(function(b) {
    b.setStyle('font-size', '100.01%')
  })
  
  // AAA-Fontresizing script
  var fontStep = 5;
  $('increaseFontSize').addEvent('click', function(e) {
    changeFontSize(fontStep, 'increase');
  });
  $('decreaseFontSize').addEvent('click', function(e) {
    changeFontSize(fontStep, 'decrease');
  });
  $('resetFontSize').addEvent('click', function(e) {
    changeFontSize(fontStep, 'reset');
  });

	// Videos auf der Startseite resizen und wmode=opaque wegen dropdownmenus
	$$('#videoteaser .videocode object').each(function(object) {
		object.set('width', '172');
		object.set('height', '139');
		
		// add the param-tag
		var opaqueParam = new Element('param', {name: 'wmode', value: 'transparent'});
		opaqueParam.inject(object);
		
		// change the embed-element
		object.getElement('embed').set('wmode', 'transparent');
	});
});

/**
 * Diese Funktion verringert/erhoeht die Schriftgroesse.
 * 
 * @param {int} Schrittweise Erhoehung/Verringerung in %
 * @param {String} type increase, decrease oder reset.
 */
function changeFontSize(step, type) {
  $$('body').each(function(body) {
    if (type == 'reset') {
      body.setStyle('font-size', '100.01%');
    }
    
    var curSize = body.getStyle('font-size');
    var curSize = parseInt(curSize.replace('%', ''));

    if (type == 'decrease') {
      body.setStyle('font-size', (curSize - step) + '%');
    }

    if (type == 'increase') {
      body.setStyle('font-size', (curSize + step) + '%');
    }
  });
}



function resetFontSize(org) {
  $$('#content p, #leftMenu ul li a').each(function(e) {
    e.setStyle('font-size', org + 'px');
  });  
}
