/**
* $Id: ad-00.js 120 2006-10-26 09:26:35Z twagner $
**/

var deb = false;
var theShadowImage = "/res/styles/images/shadow1.png";

init();
function init()
{

  try
  {
    addEvent( window, "onerror", returnError );

    addEvent( window, "onload", addAreaEvents );
    addEvent( window, "onload", addLinkEvents );
    //addEvent( window, "onload", checkFlash );

  }
  catch (err)
  {
    if ( deb == true )
    {
      returnError(err);
    }
  }
}




//THE AREAS /////////////////////////////////////////////////////////////////////
function addAreaEvents()
{   
    var theArea = document.getElementsByTagName("area");
    for (var i = 0; i < theArea.length; i++ )
  {
        theArea[i].onmouseover = areaTT;
        theArea[i].onmouseout = areaHideTT;
        theArea[i].onclick = goExt;
    }
}

//THE LINKS //////////////////////////////////////////////////////////////////////
function addLinkEvents()
{
  var theLinks = document.getElementsByTagName("a");
  for (var i = 0; i < theLinks.length; i++ )
  {
      if ( theLinks[i].className == "ext")
      {
          theLinks[i].onclick = goExt;
      }
      else if ( theLinks[i].className == "pop")
      {
          theLinks[i].onclick = goPop;
          theLinks[i].onmouseover = goTT;
          theLinks[i].onmouseout = oTT.hideToolTip;
      }
      else if ( theLinks[i].className == "largeimg")
      {
          theLinks[i].onclick = goLargeImg;
      }
      else if ( theLinks[i].className == "img")
      {
          theLinks[i].onclick = goLargeImg;
      }
  }
}


function goTT(e)
{
  if (!e) var e = window.event;
  oTT.showToolTip( "Popup: " + this.href );
}

function labelTT(e)
{
  if (!e) var e = window.event;
  oTT.showToolTip( "Label fuer: " + this.innerHTML );
}

function areaTT(e)
{
  if (!e) var e = window.event;
  $myID = this.id;
  $txt = document.getElementById($myID + 'Txt').innerHTML;
  oTT.showToolTip( $txt );
}

function areaHideTT(e)
{
  if (!e) var e = window.event;
  oTT.hideToolTip();
}

function goExt(e)
{
  if (!e) var e = window.event;
  openWin( this.href, 'large' ); 
  return false;
}

function goPop(e)
{
  if (!e) var e = window.event;
  openWin( this.href, 'small' );
  return false;
}

function goLargeImg(e)
{
  if (!e) var e = window.event;
  openLargeImage(this);
  return false;
}

function initImage(e)
{
  if (!e) var e = window.event; 
  setOpacity(this, 0);
  fadeIn(this,100);
}


//OPEN WIN ///////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////

function openWin( theTarget, theParam ) 
{
  if (theParam == 'small') {    
      newwindow = window.open(theTarget,'theParam','width=560, height=660, location=no, menubar=no, status=no, toolbar=yes, scrollbars=yes, resizable=yes');
    if (window.focus) {
        newwindow.focus();
    }
  } else if (theParam == 'special') {   
      newwindow = window.open(theTarget,'theParam','width=560, height=660, location=no, menubar=no, status=no, toolbar=yes, scrollbars=yes, resizable=yes');
    if (window.focus) {
        newwindow.focus();
    }
  } else if (theParam == 'large') {   
      newwindow = window.open(theTarget,'theName','location=yes, menubar=yes, status=yes, toolbar=yes, scrollbars=yes, resizable=yes');
    if (window.focus) {
        newwindow.focus();
    }
  } else {
      newwindow = window.open(theTarget,'theName','location=yes, menubar=yes, status=yes, toolbar=yes, scrollbars=yes, resizable=yes');
    if (window.focus) {
        newwindow.focus();
    }
  }
} 





function setOpacity(obj, opacity) 
{
    opacity = (opacity == 100)?99.999:opacity;
    obj.style.filter = "alpha(opacity:"+opacity+")";
    obj.style.KHTMLOpacity = opacity/100;
    obj.style.MozOpacity = opacity/100;
    obj.style.opacity = opacity/100;
}

function fadeIn(obj,opacity) 
{
  if (opacity <= 100) 
  {
      setOpacity(obj, opacity);
      opacity += 2;
      document.setTimeout("fadeIn('"+objId+"',"+opacity+")", 100);
  }
}

function returnStr( str )
{
  try
  {
    if (!document.getElementById("msg"))
    {
      msg = document.createElement("div");
      theBody = document.getElementsByTagName( "body" )[0];
      theBody.appendChild( msg );
      msg.id = "msg";
      msg.className = "msg";
    }
    desc = "<strong> " + str + " </strong>";
    innerString = "<p>" + desc + "</p>";
    msg.innerHTML = innerString;
    return true;
  }
  catch (err)
  {
    returnError(err);
  }
}


function returnError(err)
{
  try
  {
    if ( !document.getElementById( "errormsg" ))
    {
      thisErr = document.createElement("div");
      theBody = document.getElementsByTagName( "body" )[0];
      theBody.appendChild( thisErr );
      thisErr.className = "error";
      thisErr.id = "errormsg";
    }
    else
    {
      thisErr = document.getElementById( "errormsg" );
      thisErr.className = "error";
    }
    errNumber = "Fehler " + ( err.number & 0xFFFF ) + " ";
    errDesc = "<strong> " + err.message + " </strong>";
    innerString = "<p>" + errNumber +  errDesc + "</p>";
    thisErr.innerHTML = innerString;
    return true;
  }
  catch (err)
  {
    //
  }
}



//  HELPERS ///////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////

function getInnerHeight()
{
  if (self.innerHeight) // all except Explorer
  {
    return self.innerHeight;
  }
  else if (document.documentElement && document.documentElement.clientHeight)
  {
    return document.documentElement.clientHeight;
  }
  else if (document.body) // other Explorers
  {
      return document.body.clientHeight;
  }
}

function getInnerWidth()
{
  if (self.innerHeight) // all except Explorer
  {
      return self.innerWidth;
  }
  else if (document.documentElement && document.documentElement.clientHeight)
  {
      return document.documentElement.clientWidth;
  }
  else if (document.body) // other Explorers
  {
      return document.body.clientWidth;
  }
}

function getYScrollOffset()
{
    if (self.pageYOffset) // all except Explorer
    {
        return self.pageYOffset;
    }
    else if (document.documentElement && document.documentElement.scrollTop)
      // Explorer 6 Strict
    {
      return document.documentElement.scrollTop;
    }
    else if (document.body) // all other Explorers
    {
        return document.body.scrollTop;
    }
}




function getPageHeight()
{
    var test1 = document.body.scrollHeight;
    var test2 = document.body.offsetHeight
    if (test1 > test2) // all but Explorer Mac
    {
        return document.body.scrollHeight;
    }
    else // Explorer Mac;
         //would also work in Explorer 6 Strict, Mozilla and Safari
    {
        return document.body.offsetHeight;
    }
}



//OPEN DIV WITH LARGE IMG /////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////

function openLargeImage(node) 
{
  
  var offsetTrail = node;
  var offsetLeft = 0;
  var offsetTop = 0;
  var thisLargeImageLeft = 0;
  var thisLargeImageTop = 0;
 
  while (offsetTrail) {
      offsetLeft += offsetTrail.offsetLeft;
      offsetTop += offsetTrail.offsetTop;
      offsetTrail = offsetTrail.offsetParent;
  }
  


  thisLargeImageLeft = offsetLeft;
  thisLargeImageTop = offsetTop;
 
  thisBody = document.getElementsByTagName("body").item(0);
 
  thisSrc = node.href;
  thisLargeContent = document.createElement("img");
  thisLargeImg = new Image();
  thisLargeImg.src = thisSrc;
  thisLargeContent.id = "largeimg";
  thisLargeContent.src = thisLargeImg.src;
  
  thisLargeContainer = document.createElement("div");
  thisLargeContainer.id = "imgcontainer";
  
  thisLargeContainer.appendChild( thisLargeContent );
  thisLargeContainer.style.display = "none";
  thisLargeContainer.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\""+$theShadowImage+"\",sizingMethod=\"scale\")";
  
  
  thisBody.appendChild( thisLargeContainer );
  setTimeout('thisLargeContainer.style.display = "block"',78);
  setTimeout('openLargeImageShadow( '+thisLargeImageTop+' )',80);

} 

function openLargeImageShadow( thisLargeImageTop  ) 
{
  thisLargeBGImg = document.createElement("img");
  thisLargeBGImg.id = "largeimgbg";
  thisLargeBGImg.src = $theShadowImage;
  thisLargeBGImg.style.position = "absolute";

  thisLargeBGImg.style.left = "-48px";
  thisLargeBGImg.style.top = "-48px";
  
  thisLargeBGImg.style.width = thisLargeContent.offsetWidth + 128 +"px";
  thisLargeBGImg.style.height = thisLargeContent.offsetHeight + 98 +"px";
  
  thisLargeContainer.style.width = thisLargeContent.offsetWidth + 150 +"px";
  thisLargeContainer.style.height = thisLargeContent.offsetHeight + 110 +"px";
  
  document.getElementById('imgcontainer').style.visibility = "visible";
  thisLargeContainer.appendChild( thisLargeBGImg );

  $thisLCHeight = thisLargeImageTop + document.getElementById("largeimg").offsetHeight;
  if( $thisLCHeight > getInnerHeight())
  {
      thisLargeContainer.style.top = thisLargeImageTop - document.getElementById("largeimg").offsetHeight +"px";
  } 
  else 
  {
      thisLargeContainer.style.top = thisLargeImageTop +"px";
  }
  
  
  thisLargeDescription = document.createElement("div");
  thisLargeDescription.id = "largeimgdesc";
  
  subLargeButton = document.createElement("button");
  subLargeButton.id = "largeimgbutton";
  subLargeButton.innerHTML = "zurueck";
  subLargeButton.style.cursor = "pointer";
  
  thisLargeDescription.appendChild(subLargeButton);
  thisLargeDescription.style.top = thisLargeContent.offsetHeight - 32 +"px";
  thisLargeDescription.style.left = thisLargeContent.offsetWidth - 66 +"px";
  
  
  thisLargeContainer.appendChild(thisLargeDescription);
  thisLargeContainer.appendChild(thisLargeBGImg);
  
  browserID = getBrowser();   
  if(browserID == "msie") {
    thisLargeContainer.attachEvent('onclick', closeLargeImage);
    }  else {
    subLargeButton.addEventListener("click", closeLargeImage, false);
    }
  setTimeout('closeLargeImage()',44800);
  
}

function closeLargeImage() 
{
    if( document.getElementById("imgcontainer") )
  {
      thisLargeContainer = document.getElementById("imgcontainer");
      thisLargeContainer.parentNode.removeChild(thisLargeContainer);
  }
}


// FLASH DETECTION ////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////

function checkFlash() 
{
  var swfObject = new Object();
  swfObject.installed = false;
  swfObject.version = '0.0';
  
  if (navigator.plugins && navigator.plugins.length) {
    for (x = 0; x < navigator.plugins.length; x++) {
      if (navigator.plugins[x].name.indexOf('Shockwave Flash') != -1) {
        swfObject.version = navigator.plugins[x].description.split('Shockwave Flash ')[1];
        swfObject.installed = true;
        break;
      }
    }
  } else if (window.ActiveXObject) {
    for (x = 2; x < 10; x++) {
      try {
        theFlash = eval("new ActiveXObject('ShockwaveFlash.ShockwaveFlash."+x+"');");
        if (theFlash) {
          swfObject.version = x+'.0';
                  swfObject.installed = true;
        }
      } catch(e) {}
    }
  }

  swfVersion4  = (swfObject.installed && parseInt(swfObject.version) >= 4)  ? true:false;
  swfVersion5  = (swfObject.installed && parseInt(swfObject.version) >= 5)  ? true:false;
  swfVersion6  = (swfObject.installed && parseInt(swfObject.version) >= 6)  ? true:false;
  swfVersion7  = (swfObject.installed && parseInt(swfObject.version) >= 7)  ? true:false;
  swfVersion8  = (swfObject.installed && parseInt(swfObject.version) >= 8)  ? true:false;
  swfVersion9  = (swfObject.installed && parseInt(swfObject.version) >= 9)  ? true:false;
  swfVersion10 = (swfObject.installed && parseInt(swfObject.version) >= 10) ? true:false;
  
  if ( !swfVersion6 && window.ActiveXObject )
  {
      var flash_array = document.getElementsByTagName("object");
      for ( i = 0; i <= flash_array.length; i++ )
      {
      try 
      {
          replacement = Array();
          replacement[i] = document.createElement("p");
          replacement[i].innerHTML = "Bitte installieren Sie Flash";          
          flash_array[i].parentNode.appendChild( replacement[i] );
          flash_array[i].style.display = "none"; 
      } 
      catch(e) 
      {
      }
    }
  }
}


//   WORD DETECTION ///////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////

function openTemplate( documentName )
{
    var wordObject = new Object();
  wordObject.installed = false;
  wordObject.version = '0';
  var doDoc = '0';

  //eraseCookie( "SFGDoc" );
  if ( window.ActiveXObject ) 
  {
      if ( !readCookie( "SFGDoc" ) )
    {
          for ( x = 11; x <= 12; x++ )
        {
              try 
              {
                  theWord = new ActiveXObject('Word.Application.'+x+'');
                  theWord.quit(0);
          if ( theWord ) 
          {
              wordObject.version = x;
              wordObject.installed = true;
          }
        } 
              catch(e) {}
        }
    }
          
        //wordObject97 = (wordObject.installed && parseInt(wordObject.version) <= 10) ? true:false;
        wordObject11 = (wordObject.installed && parseInt(wordObject.version) == 11) ? true:false;
      
      if ( ( readCookie( "SFGDoc" ) == "wordObject11" ) || wordObject11 )
      {
      doDoc = '1';
        text =  " Word 2003 ist verfuegbar. oeffne: " + documentName;
      openMessage( text, documentName, doDoc );
      createCookie( "SFGDoc", "wordObject11", 10 )
    }
    else
    {
        openMessage( "Bitte auf Word 2003 aktualisieren", documentName, doDoc );
        createCookie( "SFGDoc", "wordObject97", 10 )
    }

  }
  else 
  {
      doDoc = '1';
      text = "Bitte im Download-Dialog auf \"Oeffnen\" klicken. Oeffne: " + documentName;
      openMessage( text, documentName, doDoc ); 
  }
}

function goDoc( documentName )
{

    browserID = getBrowser();
    if ( browserID == "msie" && window.ActiveXObject ) 
  {
    OpenDoc( documentName );
  } 
    else 
  {
    downloadDoc( documentName );
  }
  abort();

}

function abort()
{
  thisMsgContainer = document.getElementById("msgcontainer");
  thisMsgContent = document.getElementById("msgcontent");
  thisMsgBGImg = document.getElementById("msgbg");
  thisMsgText = thisMsgContent.getElementsByTagName("p")[0];
  
  setTimeout('thisMsgContainer.style.display = "none"',79);
  setTimeout('thisMsgContainer.removeChild( thisMsgBGImg )',80);
  setTimeout('thisMsgText.removeChild( thisMsgText.childNodes[0] )',80);
}

function downloadDoc( documentName )
{
  window.location.href = documentName;
}

function openMessage( text, documentName, doDoc ) 
{
  documentName = documentName;
  thisMsgContainer = document.getElementById("msgcontainer");
  thisMsgContent = document.getElementById("msgcontent");
  thisGoButton = document.getElementById("go");
  thisMsgBGImg = document.createElement("img");

  thisMsgText = thisMsgContent.getElementsByTagName("p")[0];
  msgtxt = document.createTextNode( text );
  thisMsgText.id = "msgtxt";
  thisMsgBGImg.id = "msgbg";
  thisMsgBGImg.src = $theShadowImage;
  thisMsgText.appendChild( msgtxt );

  if ( doDoc == '0' )
  {
      thisGoButton.parentNode.removeChild( thisGoButton );
  }
  
  setTimeout('thisMsgContainer.style.display = "block"',79);
  setTimeout('thisMsgContainer.appendChild( thisMsgBGImg )',80);
} 


//  WAIT FUNCTION /////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////

function jsWait( Amount )
{
  d = new Date() //today's date
  while (1)
  {
    mill=new Date() // Date Now
    diff = mill-d //difference in milliseconds
    if( diff > Amount ) 
    {
        break;
    }
  }
}


//TT FUNCTION /////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////

    var oTT = new Object();
  oTT._topDivZIndex = 10000;
  oTT._oBody = null;
  oTT._oIF = null;
  oTT._oTTMsg = null;
  oTT._oTTTxt = null;
  oTT._oTTDiv = null;
  oTT._mousePos = new Object();
  
  oTT._init = function()
  {
    oTT._oBody = document.getElementsByTagName("body").item(0);
    
    oTT._oIF = document.createElement("iframe");
    oTT._oIF.style.border = 0;
    oTT._oIF.style.display = "none";
    oTT._oIF.style.position = "absolute";
    oTT._oIF.style.filter = "alpha(Opacity=0)";
    oTT._oIF.width = "0px";
    oTT._oIF.height = "0px";
    
    oTT._oTTDiv = document.createElement("div");
    oTT._oTTDiv.style.display = "none";
    oTT._oTTDiv.style.position = "absolute";
    oTT._oTTDiv.width = "auto";
    oTT._oTTDiv.height = "auto";
    oTT._oTTDiv.id = "dTT";
    
    oTT._oTTMsg = document.createElement("div");
    oTT._oTTTxt = document.createTextNode("");
    oTT._oTTMsg.appendChild(oTT._oTTTxt);
    oTT._oTTMsg.id = "dTTMsg";
    oTT._oTTMsg.width = "auto";
    oTT._oTTMsg.height = "auto";
    
    browserID = getBrowser();
      if ( browserID == "msie" && window.ActiveXObject ) 
    {
          oTT._oBody.appendChild(oTT._oIF);
    } 
    oTT._oTTDiv.appendChild(oTT._oTTMsg);
    oTT._oBody.appendChild(oTT._oTTDiv);
    

    addEvent(document, 'onmousemove', oTT._mousemove);
  }
  
  oTT._mousemove = function(e)
  {
    if(typeof(e) == 'undefined')e = event;

    oTT._mousePos.Y = (document.all) ? e.clientY : e.pageY;
    oTT._mousePos.X = (document.all) ? e.clientX : e.pageX;
        
    if(oTT._oTTDiv.style.display == "block")
    {
        oTT._fixTipPosition();
    }
  }
  

  oTT._fixTipPosition = function()
  {
     
    if(oTT._mousePos.Y > ( getInnerHeight() / 2))
    {
        oTT._oTTDiv.style.top =  - 8 + oTT._mousePos.Y - oTT._oTTDiv.offsetHeight + oTT._oBody.scrollTop + "px";
        oTT._oIF.style.top = oTT._oTTDiv.style.top;
    } 
    else 
    {
        oTT._oTTDiv.style.top = 8 + oTT._mousePos.Y + oTT._oBody.scrollTop + "px";
        oTT._oIF.style.top = oTT._oTTDiv.style.top;
    }
    
    if(oTT._mousePos.X > ( getInnerWidth() / 2 ))
    {
        oTT._oTTDiv.style.left = - 8 + oTT._mousePos.X - oTT._oTTDiv.offsetWidth + oTT._oBody.scrollLeft + "px";
        oTT._oIF.style.left = oTT._oTTDiv.style.left;
    } 
    else 
    {
        oTT._oTTDiv.style.left = 8 + oTT._mousePos.X  + oTT._oBody.scrollLeft + "px";
        oTT._oIF.style.left = oTT._oTTDiv.style.left;
    }
    oTT._oIF.width = oTT._oTTDiv.offsetWidth;
    oTT._oIF.height = oTT._oTTDiv.offsetHeight;
  }
  
  
  
  // Will show the div and the helper iframe.
  oTT.showToolTip = function(toolTipMessage)
  {
    //var divContent = document.createTextNode(toolTipMessage);
    //oTT._oTTMsg.replaceChild( divContent, oTT._oTTTxt );
    oTT._oTTMsg.innerHTML = toolTipMessage;
    oTT._mousePos;
    oTT._oIF.style.display = "block";
    oTT._oTTDiv.style.display = "block";
    setOpacity(oTT._oTTDiv, 88);
    oTT._fixTipPosition();
  }
  
  // Will hide the div and the helper iframe.
  oTT.hideToolTip = function(){
	oTT._oIF.style.display = "none"
    oTT._oTTDiv.style.display = "none";
  }
  
  addEvent( window, "onload", oTT._init );

//GET BROWSER ////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////

function getBrowser() 
{
  var browser = navigator.userAgent;
  
  var patternMSIE  = /(MSIE)/g;
  var patternGecko = /(Gecko)/g;
  var patternOpera = /(Opera)/g;
  var patternSafari = /(Safari)/g;
  
  var isMSIE = patternMSIE.test(browser);
  var isGecko = patternGecko.test(browser);
  var isOpera = patternOpera.test(browser);
  var isSafari = patternOpera.test(browser);
  
  if(isMSIE == true && isOpera == true)  browserID = "opera";
  if(isMSIE == true)  browserID = "msie";
  if(isGecko == true) browserID = "gecko";
  if(isOpera == true) browserID = "opera";
  if(isSafari == true) browserID = "safari";
  
  return (browserID);
}


//EVENTS //////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////

function addEvent(obj, name, func) 
{
  try
  {
    name = name.toLowerCase();
    if(obj.addEventListener)
    {
      if(name.length > 2 && name.indexOf("on") == 0) 
      {
          name = name.substring(2, name.length);
          obj.addEventListener(name, func, false);
      }
    } 
    else if (obj.attachEvent)
    {
      obj.attachEvent(name, func);
    }
  }
  catch(err)
  {
    if ( deb == true )
    {
      returnError(err);
    }
  } 
}


function removeEvent(obj, name, func)
{
  try
  {
    name = name.toLowerCase();
    if(obj.removeEventListener)
    {
      if(name.length > 2 && name.indexOf("on") == 0) 
      {
          name = name.substring(2, name.length);
          obj.removeEventListener(name, func, false);
      }
    } 
    else if (obj.detachEvent)
    {
      obj.detachEvent(name, func);
    }
  }
  catch(err)
  {
    if ( deb == true )
    {
      returnError(err);
    }
  } 
}

