/*
*    ____  _____ _____    _____ _____ _____ _____ _____              _   _
*   |    \|   __| __  |  |  _  |  |  |   | |  |  |_   _|   ___ _____| |_| |_
*   |  |  |   __|    -|  |   __|  |  | | | |    -| | |    | . |     | . |   |
*   |____/|_____|__|__|  |__|  |_____|_|___|__|__| |_|    |_  |_|_|_|___|_|_|
*                                                         |___|     Karlsruhe
*   by Fabian Beiner <fbe@derpunkt.de>
*
*   Default JavaScript functions (mostly useable with MooTools only!)
*/

/* Image preload and rollover function...
*
*  Useable on <img> and <input type="image">. Filenames have to be:
*  <imgfile>_off.<ext> (default) and <imgfile>_on.<ext> (rollover).
*/
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'));
    });
  });

});

/* 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;
}

function hideFlashlayer() {
    if (document.getElementById('flash_layer')) {
        document.getElementById('flash_layer').style.display = 'none';
        document.getElementById('flash_layer').innerHTML     = '';
    }
}

