// JavaScript


// ------------------------------------------------------------------
// Image with Hover effect (OMO)
// ------------------------------------------------------------------

function changeImage( imgName, imgFile )
{
  if( document.images )  // otherwise error with older browsers
    document.images[imgName].src = imgFile;
}


// ------------------------------------------------------------------
// Tooltip Overlay Window
// ------------------------------------------------------------------

var tjs_w3c = (document.getElementById)  ? true : false;
var tjs_ie4 = (document.all && !tjs_w3c) ? true : false;
var tjs_ie5 = (document.all &&  tjs_w3c) ? true : false;
var tjs_ns4 = (document.layers)          ? true : false;
var mouseX  = 0;
var mouseY  = 0;

function tjs_getElement( id ) {
  if(      tjs_ns4 ) return findlayer( id, document );
  else if( tjs_ie4 ) return document.all[id];
  else               return document.getElementById( id );
}

function tjs_show( id ) {
  var elem = tjs_getElement( id );
  if( tjs_ns4 ) elem.visibility       = "show";
          else  elem.style.visibility = "visible";
}

function tjs_hide( id ) {
  var elem = tjs_getElement( id );
  if( tjs_ns4 ) elem.visibility       = "hide";
          else  elem.style.visibility = "hidden";
}

function tjs_move( id, x, y ) {
  var elem = tjs_getElement( id );
  if( tjs_ns4 ) elem.moveTo( x, y );
         else { elem.style.left = x + 'px';
                elem.style.top  = y + 'px'; }
}

function tjs_trackMouseEvent( evt ) {
  if( !tjs_ie4 && !tjs_ie5 ) {
    mouseX = evt.pageX;
    mouseY = evt.pageY;
  } else {
    mouseX = event.clientX;
    mouseY = event.clientY;
    if( document.body.scrollLeft ) mouseX += document.body.scrollLeft;
    if( document.body.scrollTop  ) mouseY += document.body.scrollTop;
  }
  return false;
}


// ------------------------------------------------------------------
// Open Popup Window
// ------------------------------------------------------------------

function openWindowPopupFromForm( formular )
{
  var sOptions = "width=" + formular.width.value +
               ",height=" + formular.height.value +
               ",left="   + formular.left.value +
               ",top="    + formular.top.value;
  for( var i=0; i<formular.elements.length; i++ )
    if( formular.elements[i].checked )
      sOptions += "," + formular.elements[i].name;
  openWindowPopup( formular.url.value, sOptions );
}

function openWindowPopupWithInnerSize( iWidth, iHeight, bAddMenusToolbars )
{
  iWidth += 17;
  if( ns )  iWidth += 2;
  if( ie && bAddMenusToolbars )
  {
    iWidth  +=  12;
    iHeight += 147;
  }
  var sOptions = "width=" + iWidth + ",height=" + iHeight + ",resizable,scrollbars";
  if( bAddMenusToolbars )
    sOptions += ",menubar,toolbar,location,directories,status";
  openWindowPopup( "", sOptions );
}

function openWindowPopup1024x768( bAddMenusToolbars )
{
  var sOptions = "";
  if( bAddMenusToolbars )
  {
    if(   opera )  sOptions = "width=1006,height=485";
    else if( ns )  sOptions = "width=1014,height=560";
    else           sOptions = "width=1024,height=737";
  }
  else
  {
    if(   opera )  sOptions = "width=1006,height=511";
    else if( ns )  sOptions = "width=1014,height=700";
    else           sOptions = "width=1012,height=700";
  }
  sOptions += ",left=0,top=0,resizable,scrollbars";
  if( bAddMenusToolbars )
    sOptions += ",menubar,toolbar,location,directories,status";
  openWindowPopup( "", sOptions );
}

var windowNewPopup;
function openWindowPopup( sUrl, sOptions )
{
  if( windowNewPopup )  windowNewPopup.close();
  windowNewPopup = window.open( sUrl, "MeinFensterName", sOptions );
  if( null != windowNewPopup && 2 >= sUrl.length )
  {
    with( windowNewPopup.document )
    {
      open();
      write( "<"+"html"+">"
           + "<"+"body background='../img/grid.gif'"
                +"topmargin=0 leftmargin=0 marginwidth=0 marginheight=0"
                +"><"+"b"+">\n" );
      write( "Optionen:<br>" + sOptions + "<br><br>\n" );
      write( "<" + "script language='JavaScript'" + "><" + "!--\n"
           + " if( document.body )"
           + " document.write( 'document.body.clientWidth/Height = ' + document.body.clientWidth + ' x ' + document.body.clientHeight + '<br>' );\n"
           + " if( window.innerWidth )"
           + " document.write( 'window.innerWidth/Height = ' + window.innerWidth + ' x ' + window.innerHeight + '<br>' );\n"
           + " //--" + ">" + "<" + "/script" + ">\n"
      );
      write( "<br><"+"a href='javascript:window.close()'"+">" );
      write( "Fenster schließen"+"<"+"/a"+">\n" );
      write( "<"+"/b"+"><"+"/body"+">"+"<"+"/html"+">" );
      close();
    }
  }
}


// ------------------------------------------------------------------
// Show date and time in form element
// ------------------------------------------------------------------

var bUhrAktiv = false;
var timerID   = null;
function stoppeUhr()
{
  if( bUhrAktiv )
    clearTimeout( timerID );
  bUhrAktiv = false;
}
function zeigeZeit()
{
  var date = new Date();
  var jahr = date.getYear();
  var mona = date.getMonth() + 1;
  var tag  = date.getDate();
  var stun = date.getHours();
  var minu = date.getMinutes();
  var seku = date.getSeconds()
  if( jahr < 200 )  jahr = jahr + 1900;
  if( mona <  10 )  mona = "0" + mona;
  if( tag  <  10 )  tag  = "0" + tag;
  if( minu <  10 )  minu = "0" + minu;
  if( seku <  10 )  seku = "0" + seku;
  document.uhr.ausgabeDatum.value =
    jahr + "-" + mona + "-" + tag;
  document.uhr.ausgabeZeit.value =
    stun + ":" + minu + ":" + seku;
  timerID = setTimeout( "zeigeZeit()", 1000 );
  bUhrAktiv = true;
}
function starteUhr()
{
  stoppeUhr();
  zeigeZeit();
}
