/*
Name:       ImageFlow
Version:    1.0.2 (November 10 2008)
Author:     Finn Rudolph
Support:    http://finnrudolph.de/ImageFlow

Licence:    ImageFlow is licensed under a Creative Commons 
            Attribution-Noncommercial 3.0 Unported License 
            (http://creativecommons.org/licenses/by-nc/3.0/).

            You are free:
                + to Share — to copy, distribute and transmit the work
                + to Remix — to adapt the work

            Under the following conditions:
                + Attribution. You must attribute the work in the manner specified by the author or licensor 
                  (but not in any way that suggests that they endorse you or your use of the work). 
                + Noncommercial. You may not use this work for commercial purposes. 

            + For any reuse or distribution, you must make clear to others the license terms of this work.
            + Any of the above conditions can be waived if you get permission from the copyright holder.
            + Nothing in this license impairs or restricts the author's moral rights.

Credits:    This script is based on Michael L. Perrys Cover flow in Javascript [1].
            The reflections are generated server-sided by a slightly hacked version 
            of Richard Daveys easyreflections [2] written in PHP. The mouse wheel 
            support is an implementation of Adomas Paltanavicius JavaScript mouse 
            wheel code [3]. It also uses the domReadyEvent from Tanny O'Haley [4].

            [1] http://www.adventuresinsoftware.com/blog/?p=104#comment-1981
            [2] http://reflection.corephp.co.uk/v2.php
            [3] http://adomas.org/javascript-mouse-wheel/
            [4] http://tanny.ica.com/ICA/TKO/tkoblog.nsf/dx/domcontentloaded-for-browsers-part-v

You successfully bought a commercial ImageFlow license
Thank you for using ImageFlow on your commercial website and purchasing a license.
*/

function fliessbild ()
{
	/* TERMINI DEFINIEREN */
	this.defaults =
	{
		fliessbildID:             'bildgaleria',   
		vorausladBilder:      true,               /* Schaltet das Laden (false: requires img attributes height and width) */
		reflexionen:             false,             /* Reflexionen einschalten */
		reflexionP:              0.0,                /* Höhe der Reflexionen in Prozent des Originalbildes */
		reflexionPNG:         false,              /* reflect2.php bzw reflect3.php */
		reflexionGET:         '',                    /* Variable der Reflexionen an das reflect_.php script senden */
		bildFokusMax:        4,                   /* maximale Anzahl von Bilder auf jeder Seite */
		bildFokusM:           1.0,                 /* Verhältnis des Mittelbildes in Prozent */
		bildZeiger:             'default',           /* bildZeigertyp pointer default */
		startID:                  7,                    /* Startbild */
		startAnimation:      false,               /* bei Start Bilder von rechts hereinbewegen */
		schieber:               false,               /* Schieberegler */
		schieberZeiger:     'e-resize',        /* bildZeiger des Schiebereglers */
		schieberDicke:      14,                  /* Groesse des Schiebereglers in px */
		xSchritt:                147,                 /* Schritte fuer Bilderabstand auf x-Achse in px */
		legenden:               true,               /* Beschriftung schalten */
		opak:                     false,              /* Opak schalten */
		opakBereich:         [10,8,6,4,2],   /* Bild Opazitaet (Bereich: 0 to 10) erster Wert fuers Mittelbild */
		onClick:                 function() { document.location = this.url; }     /* Onclick Verhalten */
	};

	/* Beschluss */
	var thisObject = this;

	/* FLIESSBILD INITIEREN */
	this.init = function (options)
	{
		/* Werte festlegen */
		var optionsArray = new Array('fliessbildID', 'vorausladBilder', 'reflexionen', 'reflexionP', 'reflexionPNG', 'reflexionGET', 'bildFokusMax', 'bildFokusM', 'bildZeiger', 'startID', 'startAnimation', 'schieber', 'schieberZeiger', 'schieberDicke', 'xSchritt', 'legenden', 'opak', 'opakBereich', 'onClick');
		var max = optionsArray.length;
		for (var i = 0; i < max; i++)
		{
			var name = optionsArray[i];
			this[name] = (options !== undefined && options[name] !== undefined) ? options[name] : thisObject.defaults[name];
		}

		/* fliessbild div */
		var fliessbildDiv = document.getElementById(thisObject.fliessbildID);
		if(fliessbildDiv)
		{
			/* im fliessbild Bereich */
			fliessbildDiv.style.visibility = 'visible';
			this.fliessbildDiv = fliessbildDiv;

			/* xhtml Struktur einrichten */
			if(this.createStructure())
			{
				this.bilderDiv = document.getElementById(thisObject.fliessbildID+'_bilder');
				this.legendeDiv = document.getElementById(thisObject.fliessbildID+'_legende');
				this.schiebestrichDiv = document.getElementById(thisObject.fliessbildID+'_schiebestrich');
				this.schieberDiv = document.getElementById(thisObject.fliessbildID+'_schieber');
			
				this.indexArray = [];
				this.current = 0;
				this.bildID = 0;
				this.target = 0;
				this.memTarget = 0;
				this.firstRefresh = true;
				this.firstCheck = true;
				this.busy = false;

				/* schiebestrich einrichten */
				if(this.schieber === false)
				{
					this.schiebestrichDiv.style.display = 'none';
				}

				/* Hoehe des fliessbild div und zentrieren */
				var width = this.fliessbildDiv.offsetWidth;
				var height = Math.round(width * 0.5085);
				document.getElementById(thisObject.fliessbildID+'_loading_txt').style.paddingTop = ((height * 0.5) -22) + 'px';
				fliessbildDiv.style.height = height + 'px';

				/* Init loading progress */
				this.loadingProgress();
			}
		}
	};

	/* HTML STRUKTUR EINRICHTEN */
	this.createStructure = function()
	{
		/* Bild div einrichten */
		var bilderDiv = document.createElement('div');		
		bilderDiv.setAttribute('id',thisObject.fliessbildID+'_bilder');
		bilderDiv.setAttribute('class','bilder');
		bilderDiv.setAttribute('className','bilder');

		/* alle Bilder ins bilder div */
		var node = null;
		var max = this.fliessbildDiv.childNodes.length;
		for(var index = 0; index < max; index++)
		{ 
			node = this.fliessbildDiv.childNodes[index];
			if (node && node.nodeType == 1 && node.nodeName == 'IMG')
			{
				/* nur fuer 'reflect.php?img=' */
				if(thisObject.reflexionen === true)
				{
					var version = '2';
					if(thisObject.reflexionPNG === true)
					{
						version = '3';
					}
					var src = node.getAttribute('src',2);
					src =  'reflect'+version+'.php?img='+src+thisObject.reflexionGET;
					node.setAttribute('src',src);
				}

				var bildNode = node.cloneNode(true);
				bilderDiv.appendChild(bildNode);
			}
		}
					
		/* text-lade div einrichten */
		var loadingP = document.createElement('p');
		var loadingText = document.createTextNode(' ');
		loadingP.setAttribute('id',thisObject.fliessbildID+'_loading_txt');
		loadingP.appendChild(loadingText);
		
		/* lade div einrichten */
		var loadingDiv = document.createElement('div');
		loadingDiv.setAttribute('id',thisObject.fliessbildID+'_loading');
		loadingDiv.setAttribute('class','loading');
		loadingDiv.setAttribute('className','loading');
			
		/* im Lade div den Ladebereich einrichten */
		var loadingBarDiv = document.createElement('div');
		loadingBarDiv.setAttribute('id',thisObject.fliessbildID+'_loading_bar');
		loadingBarDiv.setAttribute('class','loading_bar');
		loadingBarDiv.setAttribute('className','loading_bar');
		loadingDiv.appendChild(loadingBarDiv);

		/* legenden div einrichten */
		var legendeDiv = document.createElement('div');
		legendeDiv.setAttribute('id',thisObject.fliessbildID+'_legende');
		legendeDiv.setAttribute('class','legende');
		legendeDiv.setAttribute('className','legende');

		/* schiebestrich div und schieber div einrichten */
		var schiebestrichDiv = document.createElement('div');
		schiebestrichDiv.setAttribute('id',thisObject.fliessbildID+'_schiebestrich');
		schiebestrichDiv.setAttribute('class','schiebestrich');
		schiebestrichDiv.setAttribute('className','schiebestrich');
		var schieberDiv = document.createElement('div');
		schieberDiv.setAttribute('id',thisObject.fliessbildID+'_schieber');
		schieberDiv.setAttribute('class','schieber');
		schieberDiv.setAttribute('className','schieber');
		schiebestrichDiv.appendChild(schieberDiv);
		
		/* die Gesamtstruktur erneuern und falls korrekt ausgeben */
		var success = false;
		if (thisObject.fliessbildDiv.appendChild(bilderDiv) && 
			thisObject.fliessbildDiv.appendChild(loadingP) && 
			thisObject.fliessbildDiv.appendChild(loadingDiv) && 
			thisObject.fliessbildDiv.appendChild(legendeDiv) && 
			thisObject.fliessbildDiv.appendChild(schiebestrichDiv))
		{
			/* Bilder ausserhalb des Bereichs aussondern */
			for(index = 0; index < max; index++)
			{ 
				node = this.fliessbildDiv.childNodes[index];
				if (node && node.nodeType == 1 && node.nodeName == 'IMG')
				{
					this.fliessbildDiv.removeChild(node);
				}				
			}
			success = true;
		}
		return success;
	};


	/* LADEPROZESS AUSFUEHREN UND ERNEUERUNGSFUNKTION AUFRUFEN */
	this.loadingProgress = function()
	{
		var p = thisObject.loadingStatus();
		if(p < 100 || thisObject.firstCheck === true && thisObject.vorausladBilder === true)
		{
			/* warten einfuegen falls zu schnell aus Zwischenspeicher geladen */
			if(thisObject.firstCheck === true && p == 100)
			{
				thisObject.firstCheck = false;
				window.setTimeout(thisObject.loadingProgress, 100);
			}
			else
			{
				window.setTimeout(thisObject.loadingProgress, 40);
			}
		}
		else
		{
			/* Ladeelemente verstecken */
			document.getElementById(thisObject.fliessbildID+'_loading_txt').style.display = 'none';
			document.getElementById(thisObject.fliessbildID+'_loading').style.display = 'none';

			/* fliessbild auf Fenstergroesse setzen - fuer den lieben IE */
			window.setTimeout(thisObject.addResizeEvent, 1000);
						
			/* bei Verlassen auf Null */
			window.onunload = function()
			{
				document = null;
			};

			/* Maus und Tastaturunterstuetzung */
			thisObject.initMouseWheel();
			thisObject.MouseDrag.init();
			thisObject.Key.init();

			/* Erneuern-Funktion */
			thisObject.refresh(true);

			/* Schieber sichtbar machen */
			document.getElementById(thisObject.fliessbildID+'_schiebestrich').style.visibility = 'visible';

			/* zum Anfangsbild gleiten */
			var startID = thisObject.startID-1;
			if (startID < 0 )
			{
				startID = 0;
			}
			if (startID > thisObject.max)
			{
				startID = thisObject.max -1;
			}
			thisObject.glideTo(startID);

			/* Bildlauf von rechts */
			if(thisObject.startAnimation === true)
			{
				thisObject.moveTo(5000);
			}
		}
	};

	
	/* GELADENE BILDER AUSGEBEN, LADESTREIFEN UND LEGENDEN */
	this.loadingStatus = function()
	{
		var max = thisObject.bilderDiv.childNodes.length;
		var i = 0, completed = 0;
		var bild = null;
		for(var index = 0; index < max; index++)
		{
			bild = thisObject.bilderDiv.childNodes[index];
			if (bild && bild.nodeType == 1 && bild.nodeName == 'IMG')
			{
				if (bild.complete === true)
				{
					completed++;
				}
				i++;
			}
		}
		var finished = Math.round((completed/i)*100);
		var loadingBar = document.getElementById(thisObject.fliessbildID+'_loading_bar');
		loadingBar.style.width = finished+'%';

		var loadingP = document.getElementById(thisObject.fliessbildID+'_loading_txt');
		var loadingTxt = document.createTextNode('Die Bilder werden geladen, '+completed+' von '+i);
		loadingP.replaceChild(loadingTxt,loadingP.firstChild);
		return finished;
	};


	/* ZWISCHENSPEICHERN */
	this.refresh = function()
	{
		/* zwischenspeichern aller Variablen */
		this.iWidth = thisObject.bilderDiv.offsetWidth;
		this.maxHeight = Math.round(thisObject.iWidth * 0.51);
		this.maxFokus = thisObject.bildFokusMax * thisObject.xSchritt;
		this.size = thisObject.iWidth * 0.5;
		this.schiebestrichWidth = Math.round(thisObject.iWidth * 0.6);
		this.schieberDicke = thisObject.schieberDicke * 0.5;
		
		/* fliessbild div Eigenschaften anpassen */
		thisObject.fliessbildDiv.style.height = thisObject.maxHeight + 'px';
		
		/* Bilder div Eigenschaften anpassen */
		thisObject.bilderDiv.style.height = Math.round(thisObject.iWidth * 0.338) + 'px';

		/* Legenden div Eigenschaften anpassen */
		thisObject.legendeDiv.style.width = thisObject.iWidth + 'px';
		thisObject.legendeDiv.style.marginTop = Math.round(thisObject.iWidth * 0.02) + 'px';

		/* schiebestrich div Eigenschaften anpassen */
		thisObject.schiebestrichDiv.style.width = thisObject.schiebestrichWidth + 'px';
		thisObject.schiebestrichDiv.style.marginTop = Math.round(thisObject.iWidth * 0.02) + 'px';
		thisObject.schiebestrichDiv.style.marginLeft = Math.round(thisObject.iWidth * 0.2) + 'px';
		
		/* Schieber Attribute setzen */
		thisObject.schieberDiv.style.bildZeiger = thisObject.schieberZeiger;
		thisObject.schieberDiv.onmousedown = function () { thisObject.MouseDrag.start(this); return false;};
		
		/* Reflektionsattribute setzen */
		var multi = (thisObject.reflexionen === true) ? thisObject.reflexionP + 1 : 1;
		
		/* Bildattribute setzen */
		var max = thisObject.bilderDiv.childNodes.length;
		var i = 0;
		var bild = null;
		for (var index = 0; index < max; index++)
		{ 
			bild = thisObject.bilderDiv.childNodes[index];
			if(bild !== null && bild.nodeType == 1 && bild.nodeName == 'IMG')
			{
				this.indexArray[i] = index;
				
				/* Bild Attribute speichern */
				bild.url = bild.getAttribute('longdesc');
				bild.xPosition = (-i * thisObject.xSchritt);
				bild.i = i;
				
				/* einmal die Breite und Hoehe der Bilder festlegen */
				if(thisObject.firstRefresh)
				{
					if(bild.getAttribute('width') !== null && bild.getAttribute('height') !== null)
					{
						bild.w = bild.getAttribute('width');
						bild.h = bild.getAttribute('height') * multi;
					}
					else{
						bild.w = bild.width;
						bild.h = bild.height;
					}
				}
				/* Bildformat abgleichen und Reflexionenhoehe */
				if((bild.w) > (bild.h / (thisObject.reflexionP + 1))) 
				{
					/* Querformat */
					bild.pc = 118;
					bild.pcMem = 118;
				}
				else
				{
					/* Hochformat */
					bild.pc = 100;
					bild.pcMem = 100;
				}

				/* bildZeigertypus */
				bild.style.bildZeiger = thisObject.bildZeiger;
				i++;
			}
		}
		this.max = thisObject.indexArray.length;
		
		/* Variable erneuern */
		if(thisObject.firstRefresh)
		{
			thisObject.firstRefresh = false;
		}

		/* Bilder in Reihenfolge zeigen */
		thisObject.moveTo(thisObject.current);
		thisObject.glideTo(thisObject.bildID);
	};
	

	/* ANIMIEREN */
	this.moveTo = function(x)
	{
		this.current = x;
		this.zIndex = thisObject.max;

		/* Hauptschleife */
		for (var index = 0; index < thisObject.max; index++)
		{
			var bild = thisObject.bilderDiv.childNodes[thisObject.indexArray[index]];
			var currentbild = index * -thisObject.xSchritt;

			/* unfokussierte Bilder nicht anzeigen */
			if ((currentbild + thisObject.maxFokus) < thisObject.memTarget || (currentbild - thisObject.maxFokus) > thisObject.memTarget)
			{
				bild.style.visibility = 'hidden';
				bild.style.display = 'none';
			}
			else 
			{
				var z = Math.sqrt(10000 + x * x) + 100;
				var xs = x / z * thisObject.size + thisObject.size;

				/* nichtangezeigte Bilder verbergen und bevorraten */
				bild.style.display = 'block';
			
				/* Hoehe und Breite neuer Bilder */
				var newbildH = (bild.h / bild.w * bild.pc) / z * thisObject.size;
				var newbildW = 0;
				switch (newbildH > thisObject.maxHeight)
				{
					case false:
						newbildW = bild.pc / z * thisObject.size;
						break;

					default:
						newbildH = thisObject.maxHeight;
						newbildW = bild.w * newbildH / bild.h;
						break;
				}
				var newbildTop = (thisObject.iWidth * 0.34 - newbildH) + ((newbildH / (thisObject.reflexionP + 1)) * thisObject.reflexionP);

				/* Eigenschaften neuer Bilder einrichten */
				bild.style.left = xs - (bild.pc / 2) / z * thisObject.size + 'px';
				if(newbildW && newbildH)
				{ 
					bild.style.height = newbildH + 'px'; 
					bild.style.width = newbildW + 'px'; 
					bild.style.top = newbildTop + 'px';
				}
				bild.style.visibility = 'visible';

				/* Bilder in zIndex */
				switch ( x < 0 )
				{
					case true:
						this.zIndex++;
						break;

					default:
						this.zIndex = thisObject.zIndex - 1;
						break;
				}
				
				/* zIndex wechseln und aufs Mittelbild klicken */
				switch ( bild.i == thisObject.bildID )
				{
					case false:
						bild.onclick = function() { thisObject.glideTo(this.i);};
						break;

					default:
						this.zIndex = thisObject.zIndex + 1;
						if(bild.url !== '')
						{
							bild.onclick = thisObject.onClick;
						}
						break;
				}
				bild.style.zIndex = thisObject.zIndex;
			}
			x += thisObject.xSchritt;
		}
	};


	/* BILDLAUF EINRICHTEN */
	this.glideTo = function(bildID)
	{	
		/* Bildposition */
		var x = -bildID * thisObject.xSchritt;
		this.target = x;
		this.memTarget = x;
		this.bildID = bildID;

		/* neue legende */
		var legende = thisObject.bilderDiv.childNodes[bildID].getAttribute('alt');
		if (legende === '' || thisObject.legenden === false)
		{
			legende = '&nbsp;'; 
		}
		thisObject.legendeDiv.innerHTML = legende;

		/* Rutscher in neue Position */
		if (thisObject.MouseDrag.busy === false)
		{
			this.newschieberX = (bildID * thisObject.schiebestrichWidth) / (thisObject.max-1) - thisObject.MouseDrag.newX;
			thisObject.schieberDiv.style.marginLeft = (thisObject.newschieberX - thisObject.schieberDicke) + 'px';
		}
		
		/* nur bei opak */
		if(thisObject.opak === true || thisObject.bildFokusM !== thisObject.defaults.bildFokusM)
		{
			/* Mittelbild opak */
			thisObject.setopak(thisObject.bilderDiv.childNodes[bildID], thisObject.opakBereich[0]);
			thisObject.bilderDiv.childNodes[bildID].pc = thisObject.bilderDiv.childNodes[bildID].pc * thisObject.bildFokusM;
			
			/* andere Bilder opak */
			var opakValue = 0;
			var rightID = 0;
			var leftID = 0;
			var last = thisObject.opakBereich.length;

			for (var i = 1; i < (thisObject.bildFokusMax+1); i++)
			{
				if((i+1) > last)
				{
					opakValue = thisObject.opakBereich[last-1];
				}
				else
				{
					opakValue = thisObject.opakBereich[i];
				}

				rightID = bildID + i;
				leftID = bildID - i;				

				if (rightID < thisObject.max)
				{
					thisObject.setopak(thisObject.bilderDiv.childNodes[rightID], opakValue);
					thisObject.bilderDiv.childNodes[rightID].pc = thisObject.bilderDiv.childNodes[rightID].pcMem;
				}
				if (leftID >= 0)
				{
					thisObject.setopak(thisObject.bilderDiv.childNodes[leftID], opakValue);
					thisObject.bilderDiv.childNodes[leftID].pc = thisObject.bilderDiv.childNodes[leftID].pcMem;
				}
			}
		}

		/* in neue x-Achsen-Position */
		if (thisObject.busy === false)
		{
			window.setTimeout(thisObject.animate, 50);
			thisObject.busy = true;
		}
	};

	
	/* BILDGLEITEN */
	this.animate = function()
	{
		switch (thisObject.target < thisObject.current-1 || thisObject.target > thisObject.current+1) 
		{
			case true:
				thisObject.moveTo(thisObject.current + (thisObject.target-thisObject.current)/3);
				window.setTimeout(thisObject.animate, 50);
				thisObject.busy = true;
				break;

			default:
				thisObject.busy = false;
				break;
		}
	};


	/* BILD OPAK */
	this.setopak = function(object, value)
	{
		if(thisObject.opak === true)
		{
			object.style.opak = value/10;
			object.style.filter = 'alpha(opak=' + value*10 + ')';
		}
	};

	
	/* MAUSRADUNTERSTUETZUNG */
	this.initMouseWheel = function()
	{
		if(window.addEventListener)
		{
			thisObject.fliessbildDiv.addEventListener('DOMMouseScroll', thisObject.eventMouseWheel, false);
		}
		thisObject.fliessbildDiv.onmousewheel = thisObject.eventMouseWheel;
	};


	/* EVENT HANDLER FUER MAUSRAD */
	this.eventMouseWheel = function(event)
	{
		var delta = 0;
		if (!event)
		{
			event = window.event;
		}
		if (event.wheelDelta)
		{
			delta = event.wheelDelta / 120;
		}
		else if (event.detail)
		{
			delta = -event.detail / 3;
		}
		if (delta)
		{
			thisObject.handleMouseWheel(delta);
		}
		if (event.preventDefault)
		{
			event.preventDefault();
		}
		event.returnValue = false;
	};


	/* MAUSRADWINKEL (DELTA) */
	this.handleMouseWheel = function(delta)
	{
		var change = false;
		var newbildID = 0;
		if(delta > 0)
		{
			if(thisObject.bildID >= 1)
			{
				newbildID = thisObject.bildID -1;
				change = true;
			}
		}
		else
		{
			if(thisObject.bildID < (thisObject.max-1))
			{
				newbildID = thisObject.bildID +1;
				change = true;
			}
		}

		/* Glide to next (mouse wheel down) / previous (mouse wheel up) bild */
		if (change === true)
		{
			thisObject.glideTo(newbildID);
		}
	};

	
	/* MAUSBEWEGUNG */
	this.MouseDrag =
	{
		object: null,
		objectX: 0,
		mouseX: 0,
		newX: 0,
		busy: false,
		
		/* Mausbewegung abhorchen */
		init: function() 
		{
			thisObject.addEvent(thisObject.fliessbildDiv,'mousemove',thisObject.MouseDrag.drag);
			thisObject.addEvent(thisObject.fliessbildDiv,'mouseup',thisObject.MouseDrag.stop);
			thisObject.addEvent(document,'mouseup',thisObject.MouseDrag.stop);
	
			/* Text und Bildauswahl vermeiden */
			thisObject.fliessbildDiv.onselectstart = function () 
			{
				var selection = true;
				if (thisObject.MouseDrag.busy === true)
				{
					selection = false;
				}
				return selection;
			};
		},

		start: function(o) 
		{
			thisObject.MouseDrag.object = o;
			thisObject.MouseDrag.objectX = thisObject.MouseDrag.mouseX - o.offsetLeft + thisObject.newschieberX;
			
		},

		stop: function()
		{
			thisObject.MouseDrag.object = null;
			thisObject.MouseDrag.busy = false;
		},

		drag: function(e) 
		{
			var posx = 0;
			if (!e)
			{ 
				e = window.event;
			}
			if (e.pageX)
			{
				posx = e.pageX;
			}
			else if (e.clientX)
			{
				posx = e.clientX + document.body.scrollLeft	+ document.documentElement.scrollLeft;
			}
			thisObject.MouseDrag.mouseX = posx;

			if(thisObject.MouseDrag.object !== null)
			{
				var newX = (thisObject.MouseDrag.mouseX - thisObject.MouseDrag.objectX) + thisObject.schieberDicke;

				/* Rutscher mit Bildlauf abgleichen */
				if(newX < ( - thisObject.newschieberX))
				{
					newX = - thisObject.newschieberX;
				}
				if(newX > (thisObject.schiebestrichWidth - thisObject.newschieberX))
				{
					newX = thisObject.schiebestrichWidth - thisObject.newschieberX;
				}
				
				/* neue Rutscherposition */
				var step = (newX + thisObject.newschieberX) / (thisObject.schiebestrichWidth / (thisObject.max-1));
				var bildID = Math.round(step);
				thisObject.MouseDrag.newX = newX;
				thisObject.MouseDrag.object.style.left = newX + 'px';
				thisObject.glideTo(bildID);

				thisObject.MouseDrag.busy = true;
			}
		}
	};
	
	/* TASTATURUNTERSTUETZUNG */
	this.Key =
	{
		/* Tastatur abhorchen */
		init: function() 
		{
			document.onkeydown = function(event){ thisObject.Key.handle(event); };
		},

		/* PfeilbildZeiger */
		handle: function(event)
		{
			var charCode  = thisObject.Key.get(event);
			switch (charCode)
			{
				/* Right arrow key */
				case 39:
					thisObject.handleMouseWheel(-1);
					break;
				
				/* Left arrow key */
				case 37:
					thisObject.handleMouseWheel(1);
					break;
			}
		},
		
		/* Tastaturcode */
		get: function(event)
		{
			event = event || window.event;
			return event.keyCode;
		}
	};


	/* EREIGNISSE */
	this.addEvent = function( obj, type, fn )
	{
		if (obj.addEventListener)
		{
			obj.addEventListener( type, fn, false );
		}
		else if (obj.attachEvent)
		{
			obj["e"+type+fn] = fn;
			obj[type+fn] = function() { obj["e"+type+fn]( window.event ); };
			obj.attachEvent( "on"+type, obj[type+fn] );
		}
	};	

	/* ZUSAETZLICHE FUNKTIONEN ZU WINDOW.ONRESIZE - GEHT NICHT MIT ADDEVENT */
	this.addResizeEvent = function()
	{
		var otherFunctions = window.onresize;
		if(typeof window.onresize != 'function')
		{
			window.onresize = function()
			{
				thisObject.refresh();
			};
		}
		else
		{
			window.onresize = function(){
				if (otherFunctions)
				{
					otherFunctions();
				}
				thisObject.refresh();
			};
		}
	};
}


/* DOMCONTENTLOADED */
var domReadyEvent =
{
	name: "domReadyEvent",
	/* DOMContentLoaded event handler */
	events: {},
	domReadyID: 1,
	bDone: false,
	DOMContentLoadedCustom: null,

	/* fuegt DOMContentLoaded dem Bereich zu */
	add: function(handler)
	{
		/* gibt jedem event handler eine ID */
		if (!handler.$$domReadyID)
		{
			handler.$$domReadyID = this.domReadyID++;

			/* wenn getan ausfuehren */
			if(this.bDone)
			{
				handler();
			}

			/* den event handler in der hash table tun */
			this.events[handler.$$domReadyID] = handler;
		}
	},

	remove: function(handler)
	{
		/* den event handler von der hash table nehmen */
		if (handler.$$domReadyID)
		{
			delete this.events[handler.$$domReadyID];
		}
	},

	/* DOMContentLoaded */
	run: function()
	{
		/* verlassen wenn schon geschehen */
		if (this.bDone)
		{
			return;
		}

		/* nicht zweimal tun */
		this.bDone = true;

		/* reist durch die Funktionen */
		for (var i in this.events)
		{
			this.events[i]();
		}
	},

	schedule: function()
	{
		/* verlassen wenn bereits getan */
		if (this.bDone)
		{
			return;
		}
	
		/* nach Safari oder KHTML forschen */
		if(/KHTML|WebKit/i.test(navigator.userAgent))
		{
			if(/loaded|complete/.test(document.readyState))
			{
				this.run();
			}
			else
			{
				/* warten */
				setTimeout(this.name + ".schedule()", 100);
			}
		}
		else if(document.getElementById("__ie_onload"))
		{
			/* nach IE forschen */
			return true;
		}

		/* nach besonderen Funktionen forschen */
		if(typeof this.DOMContentLoadedCustom === "function")
		{
			/* if DOM methods are supported, and the body element exists (using a double-check 
			including document.body, for the benefit of older moz builds [eg ns7.1] in which 
			getElementsByTagName('body')[0] is undefined, unless this script is in the body section) */
			if(typeof document.getElementsByTagName !== 'undefined' && (document.getElementsByTagName('body')[0] !== null || document.body !== null))
			{
				/* Funktionen aufrufen */
				if(this.DOMContentLoadedCustom())
				{
					this.run();
				}
				else
				{
					/* warten */
					setTimeout(this.name + ".schedule()", 250);
				}
			}
		}
		return true;
	},

	init: function()
	{
		/* falls addEventListener den DOMContentLoaded unterstuetzt */
		if(document.addEventListener)
		{
			document.addEventListener("DOMContentLoaded", function() { domReadyEvent.run(); }, false);
		}

		/* Initialisierungsplan */
		setTimeout("domReadyEvent.schedule()", 100);

		function run()
		{
			domReadyEvent.run();
		}
		
		/* falls window.onload zuerst dann dem Laden hinzufuegen */
		if(typeof addEvent !== "undefined")
		{
			addEvent(window, "load", run);
		}
		else if(document.addEventListener)
		{
			document.addEventListener("load", run, false);
		}
		else if(typeof window.onload === "function")
		{
			var oldonload = window.onload;
			window.onload = function()
			{
				domReadyEvent.run();
				oldonload();
			};
		}
		else
		{
			window.onload = run;
		}
		
		/* fuer den lieben IE */
		/*@cc_on
			@if (@_win32 || @_win64)
			document.write("<script id=__ie_onload defer src=\"//:\"><\/script>");
			var script = document.getElementById("__ie_onload");
			script.onreadystatechange = function()
			{
				if (this.readyState == "complete")
				{
					domReadyEvent.run(); // call the onload handler
				}
			};
			@end
		@*/
	}
};

var domReady = function(handler) { domReadyEvent.add(handler); };
domReadyEvent.init();

/* FLIESSBILD INSTANZEN EINRICHTEN WENN DOM STRUKTUR GELADEN */
domReady(function()
{
	var instanceOne = new fliessbild();
	instanceOne.init({ fliessbildID:'bildgaleria' });
});