
// JavaScript für dvv-Mastertemplates 3.3.03.02

// Unless otherwise noted: Copyright (c) 2003-2009 dvv-bw

// Sort-Funktion unabhängig Groß-/Kleinschrift
function compareCaseIndependent(s1, s2)
{
  try
  {
    var temp1 = s1.toLowerCase()+"";
    var temp2 = s2.toLowerCase()+"";
    return (temp1 < temp2) ? -1 : ((temp1 == temp2) ? 0 : 1);
  }
  catch (e)
  {
  }
  return 0;
}
function showProps(obj, prefix, showEmpty, showNull)
{
  alert(show_Props(obj, prefix, showEmpty, showNull));
}

function show_Props(obj, prefix, showEmpty, showNull)
{
  if (typeof showEmpty == "undefined")
  {
    showEmpty = true;
  }
  if (typeof showNull == "undefined")
  {
    showNull = true;
  }
  var result = "";
  if (prefix != null)
  {
    result = prefix + "\n\n";
  }
  var type = typeof obj;
  if (type != "object")
  {
    result += "(" + type + ")\r\n" + obj + "\r\n";
  }
  var attributeNames = new Array();
  var attributeName;
  for (attributeName in obj)
  {
    attributeNames[attributeNames.length] = attributeName;
  }
  attributeNames.sort(compareCaseIndependent);

  for (var ixAttribute = 0; ixAttribute < attributeNames.length; ixAttribute++)
  {
    attributeName = attributeNames[ixAttribute];
    var objAttribute = "[not available]";
    if (attributeName.indexOf("DOM_VK") != 0)
    {
      try
      {
        try
        {
          objAttribute = obj[attributeName];
        }
        catch(except)
        {
        }
        if ((attributeName == "outerHTML") || (attributeName == "innerHTML"))
        {
          objAttribute = objAttribute.replace(/&/g, "&amp;");
          objAttribute = objAttribute.replace(/"/g, "&quot;");
          objAttribute = objAttribute.replace(/</g, "&lt;");
          objAttribute = objAttribute.replace(/>/g, "&gt;");
          objAttribute = objAttribute.replace(/'/g, "&#39;");
        }
      }
      catch(except)
      {
      }
      var showThis = true;
      if (objAttribute == null)
      {
        showThis = showNull;
      }
      else if (typeof objAttribute == "object")
      {
      }
      else if (typeof objAttribute == "number")
      {
      }
      else if (objAttribute == "")
      {
        showThis = showEmpty;
      }
      if (showThis)
      {
        result += attributeName + " = " + objAttribute + "\r\n";
      }
    }
  }
  return result;
}
String.prototype.trim = function ()
{
  return (this.replace(/\s+$/,"").replace(/^\s+/,""));
};
var scrollerControls = new Array();
function ScrollerControl(elementId)
{
  var element = document.getElementById(elementId);
  var childNodes = element.childNodes;
  this.element = element;
  this.childNodes = childNodes;
  this.height = element.clientHeight;
  this.width = element.clientWidth;
  this.initialized = false;
  this.type = 1; // 0=no scroll; 1=vertical scroll; 2=horizontal scroll
  this.timerId = 0;
  this.timeDelta = 50;
  this.pause = 2000;
  this.step = 1;
  this.distance = 0;
  this.clickstatus = null;
  this.description = "";
  scrollerControls[elementId] = this;
  element.onmouseover = new Function("stopScroll('" + this.element.id + "')");
  element.onmouseout = new Function("continueScroll('" + this.element.id + "')");
  element.onclick = new Function("doScrollClick('" + this.element.id + "')");
}

function scrollerDoInit()
{
  if (this.initialized)
  {
    return;
  }
  var i;
  var childNodes;
  var node;

  childNodes = this.childNodes;
  //  Must go backwards because of positioning:
  for (i = childNodes.length - 1; i >= 0; i--)
  {
    node = childNodes[i];
    try
    {
      if (node.nodeType == 8) // Comment-Node
      {
        node.parentNode.removeChild(node);
        continue;
      }
      if (node.nodeType == 3) // Text-Node
      {
        if (node.data.trim() == "")
        {
          node.parentNode.removeChild(node);
          continue;
        }

        var spanElement = document.createElement("span");
        spanElement.appendChild(node.cloneNode(true));
        node.parentNode.replaceChild(spanElement, node);
        node = spanElement;
      }
      else if (node.nodeType == 1) // Element
      {
        if ("DIV" == node.nodeName || "SPAN" == node.nodeName)
        {
          if ("" == node.innerHTML && "" == node.innerText)
          { // Leeres Element
            node.parentNode.removeChild(node);
            continue;
          }
        }
        else if (this.type == "2" && "HR" == node.nodeName)
        {
          node.parentNode.removeChild(node);
          continue;
        }
      }
      node.style.position = "absolute";
      node.style.top = node.offsetTop + "px";
      node.style.left = node.offsetLeft + "px";
    }
    catch (e)
    {
    }
  }

  childNodes = this.childNodes;
  //var elementId        = this.element.id;
  var currentChildCount = childNodes.length;
  var lastNode = childNodes[currentChildCount - 1];
  var bottom = lastNode.offsetTop + lastNode.clientHeight;
  var right = lastNode.offsetLeft + lastNode.clientWidth;

  if (this.type == 1)
  {
    if (bottom < this.height)
    {
      this.distance = Math.max(this.distance, (this.height - bottom));
    }
  }
  else if (this.type == 2)
  {
    if (right < this.width)
    {
      this.distance = Math.max(this.distance, (this.width - right));
    }
  }
  if (this.distance > 0)
  {
    var distanceElement = document.createElement("div");
    this.element.appendChild(distanceElement);
    distanceElement.className = "scrollerDistanceElement";
    distanceElement.style.position = "absolute";
    if (this.type == 1)
    {
      distanceElement.style.top = bottom + "px";
      distanceElement.style.left = 0 + "px";
      distanceElement.style.height = this.distance + "px";
      distanceElement.style.width = this.width + "px";
    }
    else if (this.type == 2)
    {
      distanceElement.style.top = 0 + "px";
      distanceElement.style.left = right + "px";
      distanceElement.style.height = this.height + "px";
      distanceElement.style.width = this.distance + "px";
    }
  }

  currentChildCount = childNodes.length;
  lastNode = childNodes[currentChildCount - 1];
  bottom = lastNode.offsetTop + lastNode.clientHeight;
  right = lastNode.offsetLeft + lastNode.clientWidth;

  var cloneOffsetTop = bottom;
  var cloneOffsetLeft = 0;
  if (this.type == 2)
  {
    cloneOffsetTop = 0;
    cloneOffsetLeft = right;
  }

  for (i = 0; i < currentChildCount; i++)
  {
    node = childNodes[i];
    var dolly = node.cloneNode(true);
    try
    {
      dolly.style.top = (node.offsetTop + cloneOffsetTop) + "px";
      dolly.style.left = (node.offsetLeft + cloneOffsetLeft) + "px";
      this.element.appendChild(dolly);
    }
    catch (e)
    {
    }
  }

  this.scrollerReset();
  this.initialized = true;
}

function scrollerStart(startDelay)
{
  if (this.childNodes.length == 0)
  {
    return;  // Nothing to scroll
  }
  clearTimeout(this.timerId);        // Cancel previous timer (in case of restart).
  this.doInit();
  var delay = startDelay;
  if (isNaN(delay))
  {
    delay = this.pause;
  }
  if (this.type == 1)
  {
    this.timerId = window.setTimeout("performYScroll('" + this.element.id + "')", delay);
  }
  if (this.type == 2)
  {
    this.timerId = window.setTimeout("performXScroll('" + this.element.id + "')", delay);
  }
}

function scrollerReset()
{
  this.step = - Math.abs(this.step); // Currently, only one direction allowed.
  clearTimeout(this.timerId);        // Cancel previous timer (in case of restart).

  var left = 0;
  var top = 0;

  var childNodes = this.childNodes;
  // Bring elements to start position
  for (var i = 0; i < childNodes.length; i++)
  {
    var node = childNodes[i];
    try
    {
      node.style.top = top + "px";
      node.style.left = left + "px";
      if (this.type == 1)
      {
        var h = node.height;
        if (isNaN(h)) // MAS-1148-B
        {
          h = node.clientHeight;
        }
        if (isNaN(h)) // MAS-1119
        {
          h = 0;
        }
        top = top + h;
      }
      if (this.type == 2)
      {
        var w = node.width;
        if (isNaN(w)) // MAS-1148-B
        {
          w = node.clientWidth;
        }
        if (isNaN(w))
        {
          w = 0;
        }
        left = left + w;
      }
    }
    catch(e) {}
  }

}

ScrollerControl.prototype.scrollerStart = scrollerStart;
ScrollerControl.prototype.scrollerReset = scrollerReset;
ScrollerControl.prototype.doInit = scrollerDoInit;

String.prototype.leftTrim = function ()
{
  return (this.replace(/^\s+/, ""));
};
String.prototype.rightTrim = function ()
{
  return (this.replace(/\s+$/, ""));
};
String.prototype.trim = function ()
{
  return (this.replace(/\s+$/, "").replace(/^\s+/, ""));
};

function doScrollClick(elementId)
{
  var scroller = scrollerControls[elementId];
  if (scroller.clickstatus == null)
  {
    scroller.clickstatus = "stopped";
    clearTimeout(scroller.timerId);
    return;
  }
  if (scroller.clickstatus == "stopped")
  {
    scroller.clickstatus = null;
    scroller.scrollerStart(0);
  }
}

function startScroll(elementId)
{
  var scroller = scrollerControls[elementId];
  scroller.clickstatus = null;
  scroller.scrollerStart(0);
}

function stopScroll(elementId)
{
  var scroller = scrollerControls[elementId];
  if (scroller.clickstatus == "stopped")
  {
    return;
  }
  clearTimeout(scroller.timerId);
}

function continueScroll(elementId)
{
  var scroller = scrollerControls[elementId];
  if (scroller.clickstatus == "stopped")
  {
    return;
  }
  scroller.scrollerStart(0);
}

function performYScroll(elementId)
{
  // Scrolls up
  var scroller = scrollerControls[elementId];
  var zeroPosition = false;
  var lastBottom = scroller.height;
  var childNodes = scroller.childNodes;
  var currentStep = scroller.step;
  var i, node;
  // Evaluate max scrolling rate
  for (i = 0; i < childNodes.length; i++)
  {
    node = childNodes[i];
    try
    {
      var prevTop = parseInt(node.style.top);
      var nextTop = prevTop + currentStep;
      // Be shure to stop at zero-position on greater step values
      if ((prevTop > 0) && (nextTop < 0))
      {
        if ("scrollerDistanceElement" != node.className)
        {
          currentStep = - prevTop;
        }
      }
    }
    catch(e) {}
  }
  // Scroll elements
  for (i = 0; i < childNodes.length; i++)
  {
    node = childNodes[i];
    try
    {
      prevTop = parseInt(node.style.top);
      nextTop = prevTop + currentStep;
      if (nextTop == 0)
      {
        if ("scrollerDistanceElement" != node.className)
        {
          zeroPosition = true;
        }
      }
      node.style.top = nextTop + "px";
      lastBottom = Math.max(lastBottom, nextTop + node.clientHeight);
    }
    catch(e) {}
  }
  // Seek for "lost" elements
  for (i = 0; i < childNodes.length; i++)
  {
    node = childNodes[i];
    try
    {
      prevTop = parseInt(node.style.top);
      if (prevTop <= (0 - node.clientHeight))
      {
        node.style.top = lastBottom + "px";
        lastBottom = Math.max(lastBottom, lastBottom + node.clientHeight);
      }
    }
    catch(e) {}
  }

  var timerMs = (zeroPosition) ? scroller.pause : scroller.timeDelta;
  scroller.timerId = window.setTimeout("performYScroll('" + elementId + "')", timerMs);

}

function performXScroll(elementId)
{
  // Scrolls left
  var scroller = scrollerControls[elementId];
  var zeroPosition = false;
  var lastRight = scroller.width;
  var childNodes = scroller.childNodes;
  var currentStep = scroller.step;
  var i, node;

  // Evaluate max scrolling rate
  for (i = 0; i < childNodes.length; i++)
  {
    node = childNodes[i];
    try
    {
      var prevLeft = parseInt(node.style.left);
      var nextLeft = prevLeft + currentStep;
      // Be shure to stop at zero-position on greater step values
      if ((prevLeft > 0) && (nextLeft < 0))
      {
        if ("scrollerDistanceElement" != node.className)
        {
          currentStep = - prevLeft;
        }
      }
    }
    catch(e) {}
  }
  // Scroll elements
  for (i = 0; i < childNodes.length; i++)
  {
    node = childNodes[i];
    try
    {
      prevLeft = parseInt(node.style.left);
      nextLeft = prevLeft + currentStep;
      if (nextLeft == 0)
      {
        if ("scrollerDistanceElement" != node.className)
        {
          zeroPosition = true;
        }
      }
      node.style.left = nextLeft + "px";
      lastRight = Math.max(lastRight, nextLeft + node.clientWidth);
    }
    catch(e) {}
  }
  // Seek for "lost" elements
  for (i = 0; i < childNodes.length; i++)
  {
    node = childNodes[i];
    try
    {
      prevLeft = parseInt(node.style.left);
      if (prevLeft <= (0 - node.clientWidth))
      {
        node.style.left = lastRight + "px";
        lastRight = Math.max(lastRight, lastRight + node.clientWidth);
      }
    }
    catch(e) {}
  }

  var timerMs = (zeroPosition) ? scroller.pause : scroller.timeDelta;
  scroller.timerId = window.setTimeout("performXScroll('" + elementId + "')", timerMs);
}

var starting = true;

function startStopScrollers()
{
  starting = !starting;
  for (var elementId in scrollerControls)
  {
    if (starting)
    {
      startScroll(elementId);
    }
    else
    {
      stopScroll(elementId);
    }
  }
}

function initContentExtern() {}; // Dummy function. Kann von externen Modulen überladen werden.

function initContent() // Wird von body-onLoad aufgerufen
{
  initContentExtern();
}
function leaveContentExtern() {}; // Dummy function. Kann von externen Modulen überladen werden.

function leaveContent() // Wird von body-onUnload aufgerufen
{
  leaveContentExtern();
}

function chgImg(imgID, src, bMOver)
{
  document.images[imgID].src = src;
}

function oWin(url,title,sizeH,sizeV)
{
  winHandle=top.open(url,title,'toolbar=no,directories=no,status=yes,scrollbars=no,menubar=no,resizable=no,width='+sizeH+',height='+sizeV);
  if(navigator.appVersion.indexOf("MSIE 3",0)==-1) id = setTimeout('winHandle.focus()',1000);
}

/*****************************************************************
 Name    :  bWin
 Date    :  08.10.2002
 Author    :  Thu Le
 Description  :  get a window handle and open

 ******************************************************************/

function bWin(url, title, sizeH, sizeV, bReturnValue, prop)
{
  if (prop == null)
  {
    winHandle = oWinInner(url, title, 'toolbar=no,directories=no,status=no,scrollbars=yes,menubar=yes,resizable=yes,width=' + sizeH + ',height=' + sizeV);
  }
  else
  {
    winHandle = oWinInner(url, title, prop + ',width=' + sizeH + ',height=' + sizeV);
  }

  if (navigator.appVersion.indexOf("MSIE 3", 0) == -1)
  {
    id = setTimeout('winHandle.focus()', 1000);
  }
  else
  {
    return;
  }

  return(false);
}

/*****************************************************************
 Name    :  oWinInner
 Date    :  08.10.2002
 Author    :  Thu Le
 Description  :  open the window by url

 ******************************************************************/
function oWinInner(url, title, prop)
{
  var newWin;
  newWin = window.open(url, title, prop);

  if (newWin != null)
  {
    if (newWin.opener == null)
    {
      newWin.opener = self;
    }
  }

  return newWin;
}

var dvv_contextLanguageID = 3;


