/* Auf und Zuklappen ____________________________________________________________ */
	
    function Slide(id) {
        new Effect.toggle(document.getElementById(id),'slide');
    }
	
    function SlideUp(id) {
        new Effect.SlideUp(document.getElementById(id));
    }
	
    function SlideDown(id) {
        new Effect.SlideDown(document.getElementById(id));
    }

    function Hide(id) {
		Element.hide($(id));
    }
	

function Extended (Objectname) {

/* Sperren der Elemente ____________________________________________________________ */


	/* Lock zum sperren des Input (Private) */
	
	this.LockedID = null;
	this.Objectname = Objectname;
	
	this.OpacityMin = 0.01;
	this.OpacityMax = 1.0;
	
	this.Scroll = 'none';
	this.Scrollx = 10;
	this.Scrolly = 10;
	
	Extended.prototype.Lock = function(id) {
		this.LockedID = id;
	}
	
	Extended.prototype.UnLock = function() {
		this.LockedID = null;
	}
	
	
/* Element Scroll _________________________________________________________________ */
	
	
	/* Scroll zum element mit der ID, opt: dauer (sec), lock (bool) */ 
	
	Extended.prototype.ScrolltoElement = function(id, duration, noLock) {
	
		if (noLock == null) {
			noLock = false;
		}
		
		if (duration == null) {
			duration = 1;
		}
		
		if ((this.LockedID == null) || (noLock)) {
		
		    var left = 0;
		    var top = 0;
			
			var parent = document.getElementById(id).parentNode;
			var target = document.getElementById(id);
	        left -= parent.offsetLeft + target.offsetLeft;
	        top -= parent.offsetTop + target.offsetTop;
			
	        new Effect.Move(parent, {x: left, y: top, mode: 'relative', duration: duration});
			
			if (!noLock) {
				this.Lock(id);
				window.setTimeout(this.Objectname + '.UnLock()', duration * 1000);
			}
		}
    }
	
	
/* Element Scroll Gallery ____________________________________________________ */

	
	/* ScrollGallerie IDPrefix, Counter, opt: dauer (sec) */ 
	
	this.SetScrollGallerie_idPrefix = '';
	this.SetScrollGallerie_nCount = 0;
	this.SetScrollGallerie_nDisplay = 0;
	
	Extended.prototype.SetScrollGallerie = function(idPrefix, nCount, duration) {
	
		if (duration == null) {
			duration = 1;
		}
		
		this.SetScrollGallerie_idPrefix = idPrefix;
		this.SetScrollGallerie_nCount = nCount;
		this.SetScrollGallerie_duration = duration;
		this.SetScrollGallerie_nDisplay = 1
		
	}
	
	
	Extended.prototype.ScrollGalleriePrevious = function(idPrefix) {
		
		if ((this.SetScrollGallerie_idPrefix == idPrefix) && (this.SetScrollGallerie_nCount > 1) && (this.SetScrollGallerie_nDisplay != 0) && (this.LockedID == null)) {
			
			this.SetScrollGallerie_nDisplay --;
			if (this.SetScrollGallerie_nDisplay < 1) {
				this.SetScrollGallerie_nDisplay = this.SetScrollGallerie_nCount;
			}
			this.ScrolltoElement(this.SetScrollGallerie_idPrefix + this.SetScrollGallerie_nDisplay, this.SetScrollGallerie_duration, true);
			this.Lock(this.SetScrollGallerie_idPrefix + this.SetScrollGallerie_nDisplay);
			window.setTimeout(this.Objectname + '.UnLock()', this.SetScrollGallerie_duration * 1000);
		}
	}
	
	
	Extended.prototype.ScrollGallerieNext = function(idPrefix) {
		
		if ((this.SetScrollGallerie_idPrefix == idPrefix) && (this.SetScrollGallerie_nCount > 1) && (this.SetScrollGallerie_nDisplay != 0) && (this.LockedID == null)) {
			
			this.SetScrollGallerie_nDisplay ++;
			if (this.SetScrollGallerie_nDisplay > this.SetScrollGallerie_nCount) {
				this.SetScrollGallerie_nDisplay = 1;
			}
			this.ScrolltoElement(this.SetScrollGallerie_idPrefix + this.SetScrollGallerie_nDisplay, this.SetScrollGallerie_duration, true);
			this.Lock(this.SetScrollGallerie_idPrefix + this.SetScrollGallerie_nDisplay);
			window.setTimeout(this.Objectname + '.UnLock()', this.SetScrollGallerie_duration * 1000);
		}
	}
	
	
	Extended.prototype.FadeIn = function(id, duration) {
		
		if (duration == null) {
			duration = 1.5;
		}
		
		Effect.Appear(id, {duration: duration, from: this.OpacityMin, to: this.OpacityMax});
	}
	
	
	Extended.prototype.FadeOut = function(id, duration) {
		
		if (duration == null) {
			duration = 1.5;
		}
		
		Effect.Fade(id, {duration: duration, form: this.OpacityMax, to: this.OpacityMin});
	}
	
	Extended.prototype.StartScrollUp = function(id, duration) {
	
		if (duration == null) {
			duration = 0.1;
		}
		
		this.Scroll = 'up';
		this.ScrollUp(id, duration)
		
	}
	
	Extended.prototype.StartScrollDown = function(id, duration) {
	
		if (duration == null) {
			duration = 0.1;
		}
		
		this.Scroll = 'down';
		this.ScrollDown(id, duration)

	}
	
	Extended.prototype.ScrollUp = function(id, duration) {
	
		if (duration == null) {
			duration = 0.1;
		}
		if (parseInt($(id).getStyle('top')) < 0) {
			new Effect.Move(id, {x: 0, y: this.Scrollx, mode: 'relative', duration: duration});
		}
		
		if (this.Scroll == 'up') {
			window.setTimeout(this.Objectname + '.ScrollUp("' + id + '",' + duration + ')', duration * 1000);
		}
		
	}
	
	Extended.prototype.ScrollDown = function(id, duration) {
	
		if (duration == null) {
			duration = 0.1;
		}
		
		var nPos
		
		nPos = 0;
		
		if (Element.Methods.getHeight(id) != null) {
			nPos += parseInt(Element.Methods.getHeight(id));
		}
		
		if ($(id).getStyle('top') != null) {
			nPos += parseInt($(id).getStyle('top'));
		}
		
		if ($(id).parentNode.clientHeight != null) {
			nPos -= parseInt($(id).parentNode.clientHeight);
		}
		
		if (nPos > 0) {		
			new Effect.Move(id, {x: 0, y: -this.Scrollx, mode: 'relative', duration: duration});
		}
		
		if (this.Scroll == 'down') {
			window.setTimeout(this.Objectname + '.ScrollDown("' + id + '",' + duration + ')', duration * 1000);
		}

	}
	
	Extended.prototype.ScrollStop = function() {
	
		this.Scroll = 'none';
	
	}
	
}

/* Element Fading __________________________________________________________________ */

	/* Fading Funktion idPrefix, count, opt: dauer (sec) */

	function FadeElements(idPrefix, nCount, duration) {
		
		if (duration == null) {
			duration = 4000;
		}
		if (nCount > 1) {
			window.setTimeout("new Effect.FadeElementsInLoop('" + idPrefix + "" + nCount + "', '" + idPrefix + "', " + nCount + ", " + nCount + ", " + duration + ")", duration);
		}
	}
	
	
	/* Private */
	
	Effect.FadeElementsInLoop = function(element, idPrefix, nCount, i, duration) {

		for (a = 1; a <= nCount; a++) {
			document.getElementById(idPrefix + a).style.display = 'none';
			document.getElementById(idPrefix + a).style.zIndex = '1';
		}

		if (i <= 1) {
			Element.setOpacity(idPrefix + i, 1)
			Element.setOpacity(idPrefix + nCount, 1)
			document.getElementById(idPrefix + i).style.display = 'block';
			document.getElementById(idPrefix + nCount).style.display = 'block';
			document.getElementById(idPrefix + i).style.zIndex = '3';
			document.getElementById(idPrefix + nCount).style.zIndex = '2';
		} else {
			Element.setOpacity(idPrefix + i, 1)
			Element.setOpacity(idPrefix + (i-1), 1)
			document.getElementById(idPrefix + i).style.display = 'block';
			document.getElementById(idPrefix + (i-1)).style.display = 'block';
			document.getElementById(idPrefix + i).style.zIndex = '3';
			document.getElementById(idPrefix + (i-1)).style.zIndex = '2';
		}
		
		
		var oldOpacity = Element.getInlineOpacity(element);
		var options = Object.extend({
		from: Element.getOpacity(element) || 1.0,
		to:   0.0,
		afterFinishInternal: function(effect) { with(Element) {
		
			document.getElementById(idPrefix + i).style.display = 'none';
			document.getElementById(idPrefix + i).style.zIndex = '1';
			
			if (i <= 1) {
				i = nCount;
			} else {
				i--;
			}
			
			window.setTimeout("new Effect.FadeElementsInLoop('" + idPrefix + "" + i + "', '" + idPrefix + "', " + nCount + ", " + i + ", " + duration + ")", duration);
		
		}}
		}, arguments[1] || {});
		return new Effect.Opacity(element,options);
	}
	