/*
  //----------------------------------------------------------------
  // <VERSIONSINFO>
  // Modul:             <MODUL>Javascriptfunktionen</MODUL>
  // Applikation:       <APP>iforwilliams.de</APP>
  // Installationspfad: <PATH>.includes/funktionen.js</PATH>
  // Konfig-Datei:      <CONF></CONF>
  // Konfig-Pfad:       <CONF_PATH></CONF_PATH>
  // Templates:         <TEMPLATE></TEMPLATE>
  // Version:           <VERS>1.3</VERS>
  // letzte Änderung:   <CHANGEDAT>13.06.2008</CHANGEDAT>
  // Autor:             <AUTHOR>Klaus Hempen</AUTHOR>
  // </VERSIONSINFO>
  //----------------------------------------------------------------
*/

window.addEvent('domready', function(){
  $$('#navigation div').each(function(navi){
    var effect = navi.effect('background-color', {duration: 800});
    var periodical;
    var fx = function() {
      effect.start('#ffffff').chain(function() {
        effect.start('#8D8E8C');
       });
     }
   
    navi.addEvent('mouseover', function() {
      fx();
	  periodical = fx.periodical(1700);
     });
   
    navi.addEvent('mouseout', function() {
      $clear(periodical);
     });
   });
 }); 
 
function mailadr(name,domain,betreff, linkclass)
 {
  document.write('<a ' + linkclass + ' href=\"mailto:' + name + '@' + domain + '?subject=' + betreff + '\">');
  document.write(name + '@' + domain + '</a>');
 }

function div_einblenden(div_id)
 {
  document.getElementById(div_id+'_aktiv').style.display = 'block';
  document.getElementById(div_id+'_deaktiv').style.display = 'none';
 }
 
function div_ausblenden(div_id)
 {
  document.getElementById(div_id+'_aktiv').style.display = 'none';
  document.getElementById(div_id+'_deaktiv').style.display = 'block';
 }
 
function owin(datei,name,width,height, resize)
 {
  var sw = screen.width;
  var sh = screen.height;
  var width, height;
	
  if (width>sw-50)  { width = sw-50; }
  if (height>sh-100) { height = sh-100; }
   
  // Popup möglichst mittig plazieren
  mitte = bildschirmmitte();   
  var mytop = mitte[1];
  var myleft = mitte[0];
  mytop = mytop - parseInt((height/2),10);
  myleft = myleft - parseInt((width/2),10);
   
  var w = window.open(datei,name,'left='+myleft+',top='+mytop+',width='+width+',height='+height+',scrollbars=yes,directories=no,resizable='+resize+',toolbar=no,location=no,status=no,menubar=no');
  if (w) { w.focus(); }
  return(w);
 }
 
function bildschirmmitte()
 {
  mitte = new Array();
  
  // Weite
  if (window.innerWidth) { myWidth = window.innerWidth; }
  else
   {
    if (window.document.documentElement && window.document.documentElement.clientWidth) 
     { myWidth = window.document.documentElement.clientWidth; }
    else
	 { myWidth = window.document.body.offsetWidth; }
   }
  mitte[0] = parseInt(myWidth/2,10);

  // Höhe
  if (window.innerHeight)
   { myHeight = window.innerHeight; }
  else
   {
    if (window.document.documentElement && window.document.documentElement.clientHeight) 
     { myHeight = window.document.documentElement.clientHeight; }
    else
	 { myHeight = window.document.body.offsetHeight; }
   }
  mitte[1] = parseInt(myHeight/2,10);
  
  return mitte;
 }

function MeldungAktivieren(id, wert)
 {
  if (document.getElementById('speichern' + id)) { document.getElementById('speichern' + id).value = wert; }
  if (wert == 1)
   {
    if (document.getElementById('div' + id)) { document.getElementById('div' + id).style.display='block'; }
    if (document.getElementById('div_leer' + id)) { document.getElementById('div_leer' + id).style.display='none'; }
   }
  else
   {
    if (document.getElementById('div' + id)) { document.getElementById('div' + id).style.display='none'; }
    if (document.getElementById('div_leer' + id)) { document.getElementById('div_leer' + id).style.display='block'; }
   }
 }

 function show_haendler(output)
  {
   // X-Position des Divs
   divX = parseInt(document.getElementById('mausX').value,10);
   divX -= 275;
   if (divX < 0) { divX = 10; }
   document.getElementById('haendler_div').style.left = divX + 'px';
   document.getElementById('haendler_div').innerHTML = output;
   document.getElementById('haendler_div').style.display = 'block';
  }

 function hide_haendler()
  {
   document.getElementById('haendler_div').innerHTML = '';
   document.getElementById('haendler_div').style.display = 'none';
  }
  
 function Event_init ()
  {
   if (document.addEventListener)
    { 
	 // Mozilla
	 document.addEventListener("mousemove", handleMove, true);
	}
   else
    {
	 // IE
	 document.body.onmousemove = handleMove;
	}
  }
 
 function handleMove (ev)
  {
   if (!ev) { ev = window.event; }
   mauspositionX = ev.pageX ? ev.pageX : ev.clientX;
   mauspositionY = ev.pageY ? ev.pageY : ev.clientY;
   
   document.getElementById('mausX').value = mauspositionX;
   document.getElementById('mausY').value = mauspositionY;
  }
