function footerFix() {
  $('footer').setStyles('display', 'none');
  $('footer').setStyles({
    'position': 'absolute',
    'bottom': '0'
  });
  $('footer').setStyles('display', 'block');
}

window.addEvent('load', function() {
/**
 *  Internet Explorer 6 sometimes has problems with the foot...
 *  After the page is loaded, I'll push the CSS settings *again* to
 *  the div#foot element.
 */
  function footerFix() {
    $('footer').setStyles({
      'position': 'absolute',
      'bottom': '0'
    });
  }
  footerFix();
});

window.addEvent('resize', function() {
    footerFix();
});


/* Image preload and rollover function... */
window.addEvent('domready', function() {
  var aPreLoad  = new Array();
  var aPreLoadi = 0;

  $$('img.roll', 'input.roll').each(function(el){
    aPreLoad[aPreLoadi]     = new Image();
    aPreLoad[aPreLoadi].src = el.src.replace(el.src.replace('_off', '_on'));
    aPreLoadi++;

    el.addEvent('mouseover',function(){
      this.setAttribute('src',this.src.replace('_off', '_on'));
    });

    el.addEvent('mouseout',function(){
      this.setAttribute('src',this.src.replace('_on','_off'));
    });
  });

  var modellImg = $$('.modell-img');
  if (modellImg.length) {
    modellImg.setStyle('opacity', '0.6');
    modellImg.each(function(el) {
      var myFx = new Fx.Tween(el, {duration: 300});
      el.addEvents({
        'mouseenter': function() {
          myFx.start('opacity', 1);
        },
        'mouseleave': function() {
          myFx.start('opacity', '0.6');
        }
      })
    });
  }

});

/* Popup */
var pop = null;

function popdown() {
  if (pop && !pop.closed) pop.close();
}

function popup(obj,w,h) {
  var url = (obj.getAttribute) ? obj.getAttribute('href') : obj.href;
  if (!url) return true;
  w = (w) ? w += 20 : 150;
  h = (h) ? h += 25 : 150;
  var args = 'width='+w+',height='+h+',resizable=yes,scrollbars=1';
  popdown();
  pop = window.open(url,'',args);
  return (pop) ? false : true;
}

/* Mail Crypter */
function decodeMail(l, shift) {
  g = "";c = "";
  for ( i=0;i < l.length;i++) {
    c = l.charAt(i);
    g += String.fromCharCode( c.charCodeAt(0) - shift );
  }
  window.location.href = g;
}


/* Menu */
var lastOver      = '';
var hideMenuFlag  = 1;
var timeout       = '';

function showMenu(name) {
  if (name==lastOver) { return false; }
  lastOver = name;
  $$('.level2').setStyle('display', 'none');
  if (lastOver!='') {
    var showDiv = 'level2-'+name;
    $(showDiv).setStyles({
        display:'block',
        opacity:0
    });
    new Fx.Tween(showDiv, {property: 'opacity', duration: 400}).start(1);
  }
  return true;
}

function hideMenu(name) {
  if (timeout) {
    $clear(timeout);
  }
  timeout = (function(){
    if (hideMenuFlag) {
        showMenu(name);
    }
  }).delay(400);
}

/* FAQ Accordion */
window.addEvent('domready', function() {
  var myAccordion = new Accordion($('accordion'), 'div.accordion_head', 'div.accordion_text', {
    opacity: false,
    alwaysHide: true,
    show: 0,
    display: -1,
    onActive: function(toggler, element){
      toggler.getChildren()[0].addClass('accordion_active');
      element.setStyles({
        'padding-bottom': '7px'
        });
    },
    onBackground: function(toggler, element){
      toggler.getChildren()[0].removeClass('accordion_active');
      element.setStyles({
        'padding-bottom': '0'
        });
    }
  });
});

/* Illustration */
function showIllu(id) {
  for(i=1;i<=9;i++) {
    $('illu-'+i).setStyle('display', 'none');
  }
  $('illu-'+id).setStyle('display', 'block');
  $('overlay-img').src='img/illustration_'+id+'.gif'
}


function mailto(str) {
    var mailto='';
    for (n=0;s=str.substring(n*2,2*n+2);n++) {
        mailto+= unescape('%'+s) ;
    }
    location.href = "mailto:" + mailto;
}

