/* EckenRunden _____________________________________________________ */

	function SpecialMenuRoundCorners() {
	
		var ua = navigator.userAgent;
		if(ua.indexOf("MSIE") >=0) {
		
			var settings = {
				tl: { radius: 3 },
				tr: { radius: 3 },
				bl: { radius: 0 },
				br: { radius: 0 },
				antiAlias: true
			}

			$$('#specialmenu li.aktiv a').each(function(oElement){
				curvyCorners(settings, oElement);
			});
			
		}
	
	}	

	
/* BookingPilot __________________________________________________*/

	var offen = '';
	var offenlink = '';
	var sZimmerinfoText = '';
	var sZimmerinfoausblendenText = '';

	function plusminus(id, link) {
		
		if (offen == id) {
		
			document.getElementById(link).innerHTML = sZimmerinfoText;
			document.getElementById(link).className = 'zimmerinfo infoauf';
			offen = '';
			offenlink = '';
		
		} else {
		
			if (offen != '') {
			
				document.getElementById(offenlink).innerHTML = sZimmerinfoText;
				document.getElementById(offenlink).className = 'zimmerinfo infoauf';
				document.getElementById(link).innerHTML = sZimmerinfoausblendenText;
				document.getElementById(offenlink).className = 'zimmerinfo infozu';
				offen = id;
				offenlink = link;
			
			} else {
			
				document.getElementById(link).innerHTML = sZimmerinfoausblendenText;
				document.getElementById(link).className = 'zimmerinfo infozu';
				offen = id;
				offenlink = link;
			
			}
		
		}
	}

	function angeboteFilter(oElement, sKategorieIDs, lMonat, lHideID, sUrl) {
		
		if ($(oElement)) {
		
			if($(oElement).checked == true){
			
				if (sKategorieIDs != '') sKategorieIDs = sKategorieIDs + ',';
				
				sKategorieIDs = sKategorieIDs + $F(oElement);
				
			} else {
			
				sKategorieIDs = (',' + sKategorieIDs).replace(',' + $(oElement).value, '');
				
				if(sKategorieIDs.substr(0,1) == ',') {
					sKategorieIDs = sKategorieIDs.slice(1,sKategorieIDs.length);
				}
				
				if(sKategorieIDs.substr(sKategorieIDs.length - 1,sKategorieIDs.length) == ',') {
					sKategorieIDs = sKategorieIDs.slice(0,sKategorieIDs.length - 1);
				}
				
			}
		
		}
		
		new Ajax.Updater('angebotecontent', sUrl,{ 
			parameters: { sKategorieIDs: sKategorieIDs, lMonat: lMonat, lHideID: lHideID },
			// encoding: 'windows-1252',
			evalScripts: true
		});
	
	}

	

/* Preise Scroll __________________________________________________*/
	
	var lTopDefault = 0;
	var objInhaltLinks = null;
	var objInhaltRechts = null;
	var lIEVersion = 8;
		
	function initializeInhaltRechtsScroll() {
		
		Event.observe(window, 'load', function() {
			
			startInhaltRchtsScroll();
			
		});

	}
	
	function startInhaltRchtsScroll() {
		
		lTopDefault = parseInt($('zeitraume').getStyle('top'));
		objInhaltLinks = $('preise');
		objInhaltRechts = $('zeitraume');
		
		if (/MSIE (\d+\.\d+);/.test(navigator.userAgent)){
			lIEVersion = parseInt(new Number(RegExp.$1));
		}
		
		Event.observe(window, 'resize', function() {
			
			if (document.viewport.getHeight() < $('zeitraume').getHeight()) {
			
				objInhaltRechts.setStyle({'position': 'absolute', 'marginLeft': '0px', 'left': 'auto', 'right': '0px', 'top': lTopDefault + 'px' });
			}
		});
	
		Event.observe(window, 'scroll', function() { 
			
			setPositionStyles();
		});
	
	}

	
	function setPositionStyles() {
		
		var lInhaltLinksScrollPosition = objInhaltLinks.cumulativeOffset()[1];
		var lBodySrollOffset = $$('body')[0].cumulativeScrollOffset()[1];
		
		if (objInhaltRechts.getStyle('position') == 'fixed') {
		
			if (parseInt(objInhaltRechts.getStyle('left')) > 0) {
			
				objInhaltRechts.setStyle({'left': '50%'});
			}
		
			if ((lBodySrollOffset + objInhaltRechts.getHeight()) >= (lInhaltLinksScrollPosition+objInhaltLinks.getHeight())) {
				
				objInhaltRechts.setStyle({'position': 'absolute', 'marginLeft': '-440px', 'right': '0px', 'top': (objInhaltLinks.getHeight()-objInhaltRechts.getHeight())+'px'});
			
			}
			else {
				
				if (lBodySrollOffset < lInhaltLinksScrollPosition + lTopDefault) {
					
					objInhaltRechts.setStyle({'position': 'absolute', 'marginLeft': '0px', 'left': 'auto', 'right': '0px', 'top': lTopDefault + 'px' });
									
				}
			}		
		}
		else {
		
			if (lIEVersion > 6 && document.viewport.getHeight() > objInhaltRechts.getHeight() && lBodySrollOffset >= lInhaltLinksScrollPosition && (lBodySrollOffset + objInhaltRechts.getHeight()) < (lInhaltLinksScrollPosition+objInhaltLinks.getHeight())) {
				
				objInhaltRechts.setStyle({'position': 'fixed', 'marginLeft': '-440px', 'left': '50%', 'right': 'auto', 'top': '0px'});
				
			}		
		}
	}
	
	
	
/* 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.4;
	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);
	}
	
