/*
  (C) 2004-2006 netea GmbH, Hannover
*/

function isMSIE()
{
  if (window.opera)
    return false;
  if (navigator.userAgent.indexOf("MSIE") >= 0)
    return true;
  return false;
}

function browserIsNotAlphChannelCapable()
{
  if (isMSIE()) {
    if (navigator.userAgent.indexOf("MSIE 7") >= 0)
      return false;
    if (navigator.userAgent.indexOf("MSIE 8") >= 0) // The future is near.
      return false;
    return true;
  }
  return false;
}

function init()
{
  if (browserIsNotAlphChannelCapable())
    document.getElementById("logo").src = "/res/images/site/netea_gmbh.gif";
  hiliteTopic();
  hiliteHash();
}


function clean()
{
}

/* hilight menu item and set title */ 
function hiliteTopic() {
  if (!document.getElementById)
    return;
  var title="";
  var curURL=document.URL;
  var elTop=document.getElementById("topic");
  if (elTop) {
    var topic=elTop.getAttribute("title");
    var elLink=document.getElementById("t_"+topic);
    if(elLink) {
      elLink.className="mhi";
      if (elLink.href==curURL)
	elLink.className="hi";
    }
    if (elTop.firstChild)
      title=elTop.firstChild.data;
  }
  if (title=="") {
    var doc=document;
    var refs=doc.getElementsByTagName("h1");
    if (refs)
      if (refs.length>0)
	title=refs[0].firstChild.data;
    if (!title)
      title="";
  }
  if (title!="")
    if (document.title == "netea GmbH")
      document.title = "netea GmbH - " + title;
}

function hiliteHash() {
  if (location.hash.length==0) return;
  var idHi=location.hash.slice(1);
  var elHi=document.getElementById(idHi);
  if(elHi) {
    elHi.className="sect-hi";
    window.scrollTo(0, elHi.offsetTop);
  }
}

var wNpp=null;
function npp(elLi, nW, nH) {
  if(wNpp) wNpp.close();
  var sOpts="width="+nW+",height="+nH+",resizable=no,dependent=yes";
  wNpp=window.open(elLi.title, "npp", sOpts);
  wNpp.focus();
}

function npz(img) {
  var srcCurr=img.src;
  var posTh=srcCurr.lastIndexOf("_th.");
  var posDot=srcCurr.lastIndexOf(".");
  var srcNew="";
  if (posTh>-1) {
    srcNew=srcCurr.slice(0, posTh)+srcCurr.slice(posTh+3);
  } else {
    srcNew=srcCurr.slice(0, posDot)+"_th"+srcCurr.slice(posDot);	
  }
  img.src=srcNew;
  if (img.parentNode) {
    bubbleCaptionOff (img.parentNode);
    bubbleCaptionOn (img.parentNode);
  }
}

/* write e-mail address and links */
function ema (ma)
{
  var domain = "netea.de";
  var user = "info";
  if (ma == "abe")
    user = "berge";
  if (ma == "mfr")
    user = "fromme";
  document.write ('<a href="mailto:');
  document.write (user);
  document.write ('@');
  document.write (domain);
  document.write ('">');
  document.write (user);
  document.write ('@');
  document.write (domain);
  document.write ('</a>');
}

function bubbleCaptionOn (myself, text)
{
  var img = null;
  var elArr = myself.getElementsByTagName ("img");
  if (elArr)
    if (elArr.length > 0)
      img = elArr[0];
  var el = getCaptionElement (myself);
  if (el) {
    if (img) {
      el.width = img.width;
    }
    el.style.visibility = "visible";
  }
}

function bubbleCaptionOff (myself)
{
  var el = getCaptionElement (myself);
  if (el) {
    el.style.visibility = "hidden";
  }
}

function getCaptionElement (myself)
{
  var elArr = null;
  elArr = myself.getElementsByTagName ("span");
  if (elArr)
    if (elArr.length > 0)
      return elArr[0];
  elArr = myself.getElementsByTagName ("div");
  if (elArr)
    if (elArr.length > 0)
      return elArr[0];
  return null;
}

