/* Hide und Blind _________________________________________ */

	function Slide(id) {
        new Effect.toggle(document.getElementById(id),'slide');
    }
	
	function Hide(id) {
		Element.hide($(id));
    }

/* BlurLinks ______________________________________________*/

	function blurLinks () {
	
		//if (navigator.userAgent.indexOf('Firefox') > 0) {
		
			var elements = document.getElementsByTagName('a')
			
			for (i = 0; i < elements.length; i++){
				elements[i].onfocus = function () { this.blur(); }
			}
		
		//}
	
	}
	
	Event.observe(window, 'load', blurLinks, false);
	
	
	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';
		
		}
		
	}
