//Projektspezifische Einstellungen werden ca. ab Zeile 270 vorgenommen
//in der Seite, in der dieser Script eingebunden wird, dürfen keine actions im body-tag vorkommen
//und die notwendigen layers müssen vorkommen

var nav6 = (document.getElementById && !document.all) ? true : false;
var nav = (document.layers) ? true : false;
var iex = (document.all) ? true : false;
var ua=navigator.userAgent.toLowerCase();
	if (ua.indexOf("win")>-1) this.platform="win";
	else if (ua.indexOf("mac")>-1) this.platform="mac";
	else this.platform="other";

var isDOM = document.getElementById?1:0;
var isIE = document.all?1:0;
var isNS4 = (navigator.appName=='Netscape' && !isDOM)?1:0;
var isIE4 = (isIE && !isDOM)?1:0;
var isDyn = (isDOM||isIE4||isNS4);

function getRef(id, par)
{
 par = (!par ? document : (par.navigator ? par.document : par));
 return (isIE ? par.all[id] :
  (isDOM ? (par.getElementById?par:par.ownerDocument).getElementById(id) :
  par.layers[id]));
}

function getSty(id, par)
{
 return (isNS4 ? getRef(id, par) : getRef(id, par).style);
}

if (!window.LayerObj) var LayerObj = new Function('id', 'par',
 'this.ref=getRef(id, par); this.sty=getSty(id, par); return this');
function getLyr(id, par) { return new LayerObj(id, par) }

function LyrFn(fn, fc)

{
 LayerObj.prototype[fn] = new Function('var a=arguments,p=a[0]; with (this) { '+fc+' }');

}
LyrFn('x','if (!isNaN(a[0])) sty.left=p; else return parseInt(sty.left)');
LyrFn('y','if (!isNaN(a[0])) sty.top=p; else return parseInt(sty.top)');
LyrFn('w','if (p) (isNS4?sty.clip:sty).width=p; ' +
 'else return (isNS4?ref.document.width:ref.offsetWidth)');
LyrFn('h','if (p) (isNS4?sty.clip:sty).height=p; ' +
 'else return (isNS4?ref.document.height:ref.offsetHeight)');
LyrFn('vis','sty.visibility=p');
LyrFn('clip','if (isNS4) with(sty.clip) {left=a[0]; top=a[1]; right=a[2]; bottom=a[3] } ' +
 'else{sty.clip="rect("+a[1]+"px "+a[2]+"px "+a[3]+"px "+a[0]+"px)"} ');

function scrLoad(fName) { with (this)
{
 if (!fName || !loaded || !isDyn) return;

 loadingFile = fName;
 if (onbeforeload) onbeforeload();

 if (isIE || isDOM) with (bufRef.document)
 {
  write('<html><body onload="parent.' + myName + '.fileLoaded()">' +
   '<iframe name="nestBuf" src="' + fName + '"></iframe></body></html>');
  close();
  if (!bufRef.nestBuf)
  {
   bufRef.location.href = fName;
   setTimeout(myName + '.fileLoaded()', 5000);
  }
 }
 else if (isNS4)
 {
  if (window.ns4LayerLoading) setTimeout(myName + '.load("' + fName + '")', 100);
  window.ns4LayerLoading = true;

  div.ref.onload = new Function(myName + '.fileLoaded()');
  div.ref.load(fName, cWidth);
 }
}}

function scrFileLoaded() { with (this)
{
 activeScr = null;

 if (isNS4) window.ns4LayerLoading = false;

 if ((isDOM || isIE) && loadingFile)
 {
  div.ref.innerHTML = (bufRef.nestBuf ? bufRef.nestBuf.document.body.innerHTML :
   bufRef.document.body.innerHTML);
  bufRef.location.replace('about:blank');
 }

 loadedFile = loadingFile;

 setTimeout('with(' + myName + ') { scrollTo(0); if (onload) onload() }', 1);
}}

function scrScrollTo(pos) { with (this)
{
 if (!isDyn || !loaded) return;

 cTop = parseInt(pos);

 divHeight = div.h() + padTop + padBot;
 if (divHeight == 0) divHeight = 1;

 if (cTop + cHeight > divHeight) cTop = divHeight - cHeight;
 if (cTop < 0) cTop = 0;

 div.y(eval(divs[0][2]) - cTop + padTop);
 div.clip(0, cTop - padTop, cWidth, cTop - padTop + cHeight);

 thmHeight = Math.ceil(barHeight * (cHeight / divHeight));

 if (thmHeight < minThmHeight) thmHeight = minThmHeight;
 if (thmHeight > barHeight) thmHeight = barHeight;

 thm.h(thmHeight);

 if (onscroll) onscroll();

 if (activeScr) return;

 fracDivDown = (cTop / (divHeight - cHeight));
 thm.y(bar.y() + fracDivDown * (barHeight - thmHeight));
}}

function scrScrollBy(amount) { with (this)
{
 scrollTo(cTop + amount);

 if (loop) setTimeout(myName + '.scrollBy(' + amount + ')', loop);
}}

function scrThumbDown(evt) { with (this)
{
 activeScr = this;

 dragOffset = (isIE ? event.offsetY : evt.layerY);

 if (onthumbdown) onthumbdown();

 return false;
}}

function scrThumbMove(evt)
{
 if (!activeScr) return (isNS4 ? document.routeEvent(evt) : true);
 else with (activeScr)
 {
  if ((cTop + cHeight > divHeight) || (thmHeight == barHeight)) return;

  var thmTop = (isIE ? document.body.scrollTop + event.clientY : evt.pageY) - dragOffset - bar.y();

  if (thmTop < 0) thmTop = 0;
  if (thmTop + thmHeight > barHeight) thmTop = barHeight - thmHeight;
  thm.y(bar.y() + thmTop);

  scrollTo((divHeight - cHeight) * (thmTop / (barHeight - thmHeight)));

  return false;
 }
}

function scrThumbUp(evt)
{
 if (activeScr) with (activeScr) if (onthumbup) onthumbup();

 activeScr = null;

 if (isNS4) return document.routeEvent(evt);
}

function scrBarClick(evt) { with (this)
{
 if (isIE) clickPos = document.body.scrollTop + event.clientY;
 else clickPos = evt.pageY;

 if (clickPos < thm.y()) scrollBy(0 - cHeight);
 if (clickPos > (thm.y() + thmHeight)) scrollBy(cHeight);

 if (isNS4) return document.routeEvent(evt);
}}

function scrLayout() { with (this)
{
 if (!isDyn || !loaded) return;

 winWidth = isIE ? document.body.clientWidth : window.innerWidth;
 winHeight = isIE ? document.body.clientHeight : window.innerHeight;

 if (winWidth < minWinWidth) winWidth = minWinWidth;
 if (winHeight < minWinHeight) winHeight = minWinHeight;

winWidth=841; //************************************************** Riesenrad-spez


 for (var i = 0; i < divs.length; i++) with (divs[i][5])
 {
  x(eval(divs[i][1])); w(eval(divs[i][3]));
  if (i) { y(eval(divs[i][2])); h(eval(divs[i][4])) }
 }

 barHeight = eval(divs[1][4]);
 cWidth = eval(divs[0][3]);
 cHeight = eval(divs[0][4]);

 scrollBy(0);
}}

function scrSetup(defaultFile) { with (this)
{
stopmoney();

 if (!isDyn) return;

 for (var i = 0; i < divs.length; i++) divs[i][5] = getLyr(divs[i][0]);

 div = divs[0][5];
 bar = divs[1][5];
 thm = divs[2][5];

 if (!isNS4) bufRef = eval('window.' + myName + 'Buf');

 if (isNS4)
 {
  bar.ref.captureEvents(Event.CLICK);
  thm.ref.captureEvents(Event.MOUSEDOWN);
 }

 bar.ref.onclick = new Function('evt', 'return ' + myName + '.barClick(evt)');
 thm.ref.onmousedown = new Function('evt', 'return ' + myName + '.thumbDown(evt)');

 var noSel = new Function('if (activeScr) return false');
 if (isIE) document.onselectstart = noSel;
 else if (isDOM) document.onselect = noSel;

 loaded = true;
 layout();
 if (onsetup) onsetup();

 var fileName = ''
 var URL = location.search.substring(1);
 if (URL)
 {
  URL = URL.split('&');
  for (var i = 0; i < URL.length; i++)
   if (URL[i].split('=')[0] == myName) fileName = URL[i].split('=')[1];
 }

 if (fileName.indexOf('.htm') != -1) load(fileName)

 else if (defaultFile) load(defaultFile);
 else fileLoaded();
}}

function addProps(obj, data, names, addNull)
{
 for (var i = 0; i < names.length; i++) if(i < data.length || addNull) obj[names[i]] = data[i];
}

function DHTMLScroller()
{
 var names = ['myName', 'bufRef', 'div', 'bar', 'thm', 'loaded', 'loop', 'divHeight', 'thmHeight',
  'barHeight', 'cHeight', 'cWidth', 'dragOffset', 'onbeforeload', 'onload', 'onscroll', 'onsetup',
  'onthumbdown', 'onthumbup'];
 addProps(this, arguments, names, true);

 this.cTop = 0;

 this.loadingFile = '';
 this.loadedFile = '';

 this.divs = new Array();

 this.minThmHeight = 20;
 this.minWinWidth = 300;
 this.minWinHeight = 150;
 this.padTop = 0;
 this.padBot = 0;

 this.load = scrLoad;
 this.fileLoaded = scrFileLoaded;
 this.scrollTo = scrScrollTo;
 this.scrollBy = scrScrollBy;
 this.thumbDown = scrThumbDown;
 this.barClick = scrBarClick;
 this.setup = scrSetup;
 this.layout = scrLayout;
}

var activeScr = null, winWidth, winHeight;

var mainDiv = new DHTMLScroller('mainDiv');

// *** SCROLLER OBJECT SETUP -- START EDITING HERE ***.

// First, you have to create one or more scroller objects, syntax:
// var name = new DHTMLScroller('name');

var mainDiv = new DHTMLScroller('mainDiv');

// Then, working with its properties, we tell it the names of the relevant divs below we want it
// to use. This is accomplished by the 'divs' array, to which we add new items like so:
//
// divs[number] = new Array('id of div below', 'x', 'y', 'width', 'height');
with (mainDiv)
{

	 if (!isNS4) divs[0] = new Array('mainDivContent', '50', '180', '445', '235'); 
	 else divs[0] = new Array('mainDivContent', '(winWidth-542)', '5', '455', '240'); 
	 divs[1] = new Array('mainDivBar', '0', '0', '0', '0');
	 if (!isNS4) divs[2] = new Array('mainDivThumb', '0', '', '0', '0'); 
	 else divs[2] = new Array('mainDivThumbNav', '0', '', '0', '0'); 
	 divs[3] = new Array('mainDivUpArrows', '600', '200', '', '');
	 divs[4] = new Array('mainDivDownArrows', '600', '250', '', '');


 
 onload = loadFunction;
}


function loadFunction() { with (this)
{

 var hohe=5000;
 if(iex) hohe=document.all.mainDivContent.offsetHeight;
 else if(nav6) hohe=document.getElementById("mainDivContent").offsetHeight;
 else if(nav) hohe=5000;
 
var scrolling = true;
 if(hohe>divs[0][4] && scrolling){
 	for (var i = 0; i < divs.length; i++) divs[i][5].vis('visible');
}
}}
window.onload = new Function('mainDiv.setup("")');
window.onresize = new Function('mainDiv.layout();posLayer();');
if (isNS4) document.captureEvents(Event.MOUSEMOVE | Event.MOUSEUP);
document.onmousemove = new Function('evt', 'scrThumbMove(evt)');
document.onmouseup = new Function('evt', 'scrThumbUp(evt)');

var origWinWidth = window.innerWidth;
function ns4BugCheck()
{
 if (isNS4 && origWinWidth != window.innerWidth)
 {
  var fileName = location.href;

  if (fileName.indexOf('?') != -1) fileName = fileName.substring(0, fileName.indexOf('?'));
  location.href = fileName + '?mainDiv=' + mainDiv.loadedFile;
 }
}

function scrKeyDown(evt) { with (mainDiv)
{
 if (!loaded) return;
 if (isIE) key = event.keyCode;
 else if (isDOM) key = evt.charCode;
 else if (isNS4) key = evt.which;

 if ((key==84) || (key==116) || (key==36)) scrollTo(0);
 if ((key==83) || (key==115) || (key==33)) scrollBy(0-cHeight);
 if ((key==65) || (key==97)  || (key==38)) scrollBy(-10);
 if ((key==90) || (key==122) || (key==40)) scrollBy(10);
 if ((key==88) || (key==120) || (key==34)) scrollBy(cHeight);
 if ((key==66) || (key==98)  || (key==35)) scrollTo(divHeight);
}}
/*
if (isIE) document.onkeydown = scrKeyDown;
else
{
 if (isNS4) document.captureEvents(Event.KEYPRESS);
 document.onkeypress = scrKeyDown;

}
*/
function stopmoney(){
setTimeout('document.getElementById("bandit2").src="images/bandit3.gif"', 10000);
}
