var bIsNs4 = (navigator.appName.indexOf("Netscape") >= 0 && parseFloat(navigator.appVersion) >= 4) ? true : false;
var bIsNs6 = (!document.all && document.getElementById) ? true : false;
function getPageLeft(layer) {
	var x = 0;
	if (document.layers) {
		return layer.pageX;
	} else if (!document.all && document.getElementById) {
		return layer.offsetLeft;
	} else {
    while (layer.offsetParent != null) {
      x += layer.offsetLeft;
      layer = layer.offsetParent;
    }
    x += layer.offsetLeft;
		return x;
	}
	return -1;
}
function getPageTop(layer) {
	var y = 0;
	if (document.layers) {
		return layer.pageY;
	} else if (!document.all && document.getElementById) {
		return layer.offsetTop;
	} else {
    while (layer.offsetParent != null) {
      y += layer.offsetTop;
      layer = layer.offsetParent;
    }
    y += layer.offsetTop;
		return y;
	}
	return -1;
}
var oContendMenu = null;
function windowOnload() {
  with (oContendMenu = document.getElementById('ContendMenu').cbe) {
    zIndex(1);
    addEventListener('dragResize');
  }
  init();
  window.cbe.addEventListener('scroll', scrollListener);
}
function init() {
  with (oContendMenu) {
    zIndex(1);
    resizeTo(300,545); // 525_OLD
    show();
  }
  scrollListener();
}
function scrollListener(e) {
	if (oContendMenu != null) {
    var strPageLeft = '';
    var strPageTop = 35 + iHPg_Height_Pic + oContendMenu.parentNode.scrollTop();
		if (document.all) { // IE
		  strPageLeft = (getPageLeft(BorderTable) + 8);
		} else if (document.layers) { // NS 4
		  strPageLeft = getPageLeft(document.layers['BorderLayer']);
		} else if (!document.all && document.getElementById) { // NS 6
		  strPageLeft = getPageLeft(document.getElementById('BorderLayer'));
		}
		// Passt das Menü an die Seitengröße an
		oContendMenu.resizeTo(300,545); // 525_OLD
		// Scrollt Menü, wenn es nicht abgeschnitten wird
		if (oContendMenu.parentNode.height() - ((document.layers) ? 75 : (35 + iHPg_Height_Pic)) >= oContendMenu.height()) {
			oContendMenu.slideTo(strPageLeft,strPageTop,0);
		  if (document.all && document.all.oCellH != null) {
        document.all.oCellH.height = '100%';
      }
		} else {
 		  oContendMenu.slideTo(strPageLeft,(35 + iHPg_Height_Pic),0);
		  if (document.all && document.all.oCellH != null) {
		    document.all.oCellH.height = oContendMenu.height() + 15;
		  }
		}
	}
	//OLD_TOP (oContendMenu.parentNode.height()/2 + oContendMenu.parentNode.scrollTop() - 332.5)
}
CrossBrowserElement.prototype.slideBy = function(dX, dY, totalTime, endListener) {
  var targetX, targetY;
  dX = parseInt(dX); dY = parseInt(dY); targetX = this.left() + dX; targetY = this.top() + dY;
  this.slideTo(targetX, targetY, totalTime, endListener)
}
CrossBrowserElement.prototype.slideTo = function(x, y, totalTime, endListener) {
  if (this.onslidestart) cbeEval(this.onslidestart, this);
  this.xTarget = parseInt(x); this.yTarget = parseInt(y);
  this.slideTime = parseInt(totalTime);
  if (isNaN(this.xTarget)) {
    var outside=false;
    if (isNaN(this.yTarget)) { y = 0; outside = true; }
    this.cardinalPosition(x, y, outside); this.xTarget = this.x; this.yTarget = this.y;
  }
  if (endListener && window.cbeEventJsLoaded) { this.autoRemoveListener = true; this.addEventListener('slideend', endListener); }
  this.stop = false;
  this.yA = this.yTarget - this.top(); this.xA = this.xTarget - this.left(); // A = distance
  this.B = Math.PI / (2 * this.slideTime); // B = period
  this.yD = this.top(); this.xD = this.left(); // D = initial position
  if (this.slideRate == cbeSlideRateLinear) { this.B = 1/this.slideTime; }
  else if (this.slideRate == cbeSlideRateCosine) {
    this.yA = -this.yA; this.xA = -this.xA; this.yD = this.yTarget; this.xD = this.xTarget;
  }
  var d = new Date(); this.C = d.getTime();
  if (!this.moving) this.slide();
}
CrossBrowserElement.prototype.slide = function() {
  var now, s, t, newY, newX;
  now = new Date();
  t = now.getTime() - this.C;
  if (this.stop) { this.moving = false; }
  else if (t < this.slideTime) {
    setTimeout("window.cbeAll["+this.index+"].slide()", this.timeout);
    if (this.slideRate == cbeSlideRateLinear) s = this.B * t;
    else if (this.slideRate == cbeSlideRateSine) s = Math.sin(this.B * t);
    else s = Math.cos(this.B * t); // this.slideRate == cbeSlideRateCosine
    newX = Math.round(this.xA * s + this.xD);
    newY = Math.round(this.yA * s + this.yD);
    if (this.onslide) cbeEval(this.onslide, this, newX, newY, t);
    this.moveTo(newX, newY);
    this.moving = true;
  }  
  else {
    this.moveTo(this.xTarget, this.yTarget);
    this.moving = false;
    if (this.onslideend) {
      var tmp = this.onslideend;
      if (this.autoRemoveListener && window.cbeEventJsLoaded) {
        this.autoRemoveListener = false;
        this.removeEventListener('slideend');
      }
      cbeEval(tmp, this);
    }
  }  
}
CrossBrowserElement.prototype.ellipse = function(xRadius, yRadius, radiusInc, totalTime, startAngle, stopAngle, endListener) {
  if (this.onslidestart) cbeEval(this.onslidestart, this);
  this.stop = false;
  this.xA = parseInt(xRadius);
  this.yA = parseInt(yRadius);
  this.radiusInc = parseInt(radiusInc);
  this.slideTime = parseInt(totalTime);
  startAngle = cbeRadians(parseFloat(startAngle));
  stopAngle = cbeRadians(parseFloat(stopAngle));
  if (endListener && window.cbeEventJsLoaded) {
    this.autoRemoveListener = true;
    this.addEventListener('slideend', endListener);
  }
  var startTime = (startAngle * this.slideTime) / (stopAngle - startAngle);
  this.stopTime = this.slideTime + startTime;
  this.B = (stopAngle - startAngle) / this.slideTime;
  this.xD = this.left() - Math.round(this.xA * Math.cos(this.B * startTime)); // center point
  this.yD = this.top() - Math.round(this.yA * Math.sin(this.B * startTime)); 
  this.xTarget = Math.round(this.xA * Math.cos(this.B * this.stopTime) + this.xD); // end point
  this.yTarget = Math.round(this.yA * Math.sin(this.B * this.stopTime) + this.yD); 
  var d = new Date();
  this.C = d.getTime() - startTime;
  if (!this.moving) this.ellipse1();
}
CrossBrowserElement.prototype.ellipse1 = function() {
  var now, t, newY, newX;
  now = new Date();
  t = now.getTime() - this.C;
  if (this.stop) { this.moving = false; }
  else if (t < this.stopTime) {
    setTimeout("window.cbeAll["+this.index+"].ellipse1()", this.timeout);
    if (this.radiusInc) {
      this.xA += this.radiusInc;
      this.yA += this.radiusInc;
    }
    newX = Math.round(this.xA * Math.cos(this.B * t) + this.xD);
    newY = Math.round(this.yA * Math.sin(this.B * t) + this.yD);
    if (this.onslide) cbeEval(this.onslide, this, newX, newY, t);
    this.moveTo(newX, newY);
    this.moving = true;
  }  
  else {
    if (this.radiusInc) {
      this.xTarget = Math.round(this.xA * Math.cos(this.B * this.slideTime) + this.xD);
      this.yTarget = Math.round(this.yA * Math.sin(this.B * this.slideTime) + this.yD); 
    }
    this.moveTo(this.xTarget, this.yTarget);
    this.moving = false;
    if (this.onslideend) {
      var tmp = this.onslideend;
      if (this.autoRemoveListener && window.cbeEventJsLoaded) {
        this.autoRemoveListener = false;
        this.removeEventListener('slideend');
      }
      cbeEval(tmp, this);
    }
  }  
}
CrossBrowserElement.prototype.stopSlide = function() { this.stop = true; }
CrossBrowserElement.prototype.startSequence = function(uIndex) {
  if (!this.moving) {
    if (!uIndex) this.seqIndex = 0;
    else this.seqIndex = uIndex;
    this.addEventListener('slideEnd', cbeSlideSequence);
    cbeSlideSequence(this);
  }
}
CrossBrowserElement.prototype.stopSequence = function() {
  this.stop=true;
  this.removeEventListener('slideEnd', cbeSlideSequence);
}
function cbeSlideSequence(cbe) {
  var
    pw = cbe.parentNode.width(),
    ph = cbe.parentNode.height(),
    w = cbe.width(),
    h = cbe.height();
  if (cbe.seqIndex >= cbe.sequence.length) cbe.seqIndex = 0;
  eval('cbe.'+cbe.sequence[cbe.seqIndex++]);
}
var cbeSlideRateLinear=0, cbeSlideRateSine=1, cbeSlideRateCosine=2;
CrossBrowserElement.prototype.slideRate = cbeSlideRateSine;
CrossBrowserElement.prototype.seqIndex = 0;
CrossBrowserElement.prototype.radiusInc = 0;
CrossBrowserElement.prototype.t = 0;
CrossBrowserElement.prototype.xTarget = 0;     
CrossBrowserElement.prototype.yTarget = 0;     
CrossBrowserElement.prototype.slideTime = 1000;
CrossBrowserElement.prototype.xA = 0;
CrossBrowserElement.prototype.yA = 0;
CrossBrowserElement.prototype.xD = 0;
CrossBrowserElement.prototype.yD = 0;
CrossBrowserElement.prototype.B = 0;
CrossBrowserElement.prototype.C = 0;
CrossBrowserElement.prototype.moving = false;
CrossBrowserElement.prototype.stop = true;
CrossBrowserElement.prototype.timeout = 35;
CrossBrowserElement.prototype.autoRemoveListener = false;
CrossBrowserElement.prototype.onslidestart = null;
CrossBrowserElement.prototype.onslide = null;
CrossBrowserElement.prototype.onslideend = null;
var cbeSlideJsLoaded = true;
// End cbe_slide.js

