toggleNav_running = false;	toggleNav = function(e) {			if(!toggleNav_running) {			toggleNav_running = true;						if($('nav').visible()) {				$('nav').fade({					duration: 0.1, 					afterFinish: function() {						toggleNav_running = false;					}				});			}						else {							if($$('#nav a.active')[0]) {					window.setTimeout(function() {						$('nav').scrollTop = $$('#nav a.active')[0].offsetTop-20;					}, 50);				}							$('nav').appear({					duration: 0.1, 					afterFinish: function() {						toggleNav_running = false;					}				});			}				}		}		closeNav = function() {			if(!toggleNav_running) {			toggleNav_running = true;				$('nav').fade({				duration: 0.1,				afterFinish: function() {					toggleNav_running = false;				}			});					}	}				docMouseDown = function(e) {			elmt = Event.element(e);				if(elmt != $$('#nav_current a')[0] && elmt != $('nav')) {			if($('nav').visible()) {				closeNav();			}		}			}	enlargeImg = function(e) {			elmt = Event.element(e);			if($('enlarged')) { $('enlarged').remove(); }		if($('disable_ui')) { $('disable_ui').remove(); }				new Insertion.Before('container', '<div id="disable_ui" style="display: none;">&nbsp;</div><div id="enlarged" style="display: none;"><img src="/imgs/loading.gif" alt="" class="loading" /></div>');				$('enlarged').clonePosition(elmt.previous());		$('enlarged').setStyle('width: '+($('enlarged').getWidth()-parseInt(elmt.previous().getStyle('padding-right')))+'px;');				pWidth = $('content').getWidth();		pHeight = $('content').getHeight();				$('disable_ui').appear({			duration: 0.5,			to: 0.01		});				$('enlarged').appear({			duration: 0.5,			to: 0.8		});				newImgSrc = elmt.href;		newImgSrc += '?'+Math.round(Math.random()*10000);				newImg = new Image();		newImg.src = newImgSrc;		newImg.onload = function() {			enlargeImgNow(newImgSrc);		};		}								closeImg = function() {			$('enlarged').fade({			duration: 0.6,			afterFinish: function() {				$('enlarged').remove();			}		});		$('container').appear({			duration: 1		});		}document.observe('dom:loaded', function() { 	var Browser = {		detect: function() {			var UA = navigator.userAgent;			this.isKHTML = /Konqueror|Safari|KHTML/.test(UA);			this.isGecko = (/Gecko/.test(UA) && !this.isKHTML);			this.isOpera = /Opera/.test(UA);			this.isMSIE = (/MSIE/.test(UA) && !this.isOpera);			this.isMSIE7 = this.isMSIE && !(/MSIE 6\./.test(UA) && !this.isOpera);			this.isMSIE6 = this.isMSIE && !this.isMSIE7;		}	}	Browser.detect();	if((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPad/i)) || (navigator.userAgent.match(/iPod/i))) {		$$('html')[0].addClassName('mobile-safari');	}		if(navigator.userAgent.match(/iPad/i)) {		$$('html')[0].addClassName('ipad');	}	// Navigationselemente initialisieren	if($('nav')) {		$('nav_current').observe('click', toggleNav);		$('nav_current').onclick = function() { return false; };				Event.observe(window, 'click', docMouseDown);	}		// Portfolio	if($('portfolio_imgs')) { 			imgs = $$('#portfolio_imgs img');		loadedImgs = new Array();		imgCount = imgs.length;				new Insertion.Bottom('head', '<div class="loading"><img src="/imgs/loading.gif" alt="" /> <span id="loading_percent">0 %</span></div>');				new Insertion.Top('portfolio_imgs', '<div id="progress">&nbsp;</div>');			checkLoadInterval = window.setInterval(function() {					imgs.each(function(a) {							if(a.complete && loadedImgs.indexOf(a.id) == -1) {										loadedImgs.push(a.id);					loadingProgress(imgCount);										if(loadedImgs.length == imgCount) {											window.clearInterval(checkLoadInterval);										}									}						});				}, 100);		}			progressEffect = false;	currentProgressCount = 0;	loadingProgress = function(imgCount) {				currentProgressCount++;		currentProgress = Math.round(currentProgressCount * (100/imgCount));				if(progressEffect) { progressEffect.cancel(); }				progressNewWidth = Math.round((currentProgress/100)*$('portfolio_imgs').getWidth());				$('loading_percent').update(currentProgress + ' %');				if(currentProgressCount % 2 == 0 || currentProgressCount == imgCount) {			progressEffect = new Effect.Morph('progress', {				duration: 1,				style: { width: progressNewWidth+'px' },				afterFinish: function() {					if(currentProgressCount == imgCount) {						allImgsWidth = 0;						$$('#portfolio_imgs div').each(function(a) {							a.setStyle('visibility: visible');							allImgsWidth += a.getWidth();						});												$$('#portfolio_imgs div a.enlarge').each(function(a) {							a.observe('mouseover', function() {								if($(this).next()) {									$(this).next().show();								}							});							a.observe('mouseout', function() {								if($(this).next()) {									$(this).next().hide();								}							});							a.observe('click', enlargeImg);							a.onclick = function() { return false; };						});												if($$('html')[0].hasClassName('mobile-safari')) {							allImgsWidth -= document.viewport.getWidth();						}						$('portfolio_imgs').setStyle('width: '+allImgsWidth+'px; background: #fff;');						$$('.loading').each(function(a) {							a.remove();						});						$('progress').fade({							duration: 0.4,							afterFinish: function() {								$('progress').remove();							}						});						initSlider(allImgsWidth);					}				}			});		}		}							_scrollEffect = false;	mousescrollPortfolio = function(e) {		w = Event.wheel(e);				if(_scrollEffect) { _scrollEffect.cancel(); }				if(w > 0) {			newLeft = (parseInt($('portfolio_imgs').getStyle('left'))+(50*w))+'px';			$('portfolio_imgs').setStyle('left: '+newLeft);		}		else {			newLeft = (parseInt($('portfolio_imgs').getStyle('left'))+(50*w))+'px';			$('portfolio_imgs').setStyle('left: '+newLeft);		}		}			initSlider = function(streamWidth) {			if($('portfolio_imgs')) {			var distance = 0;			var prevX = 0;			new Draggable('portfolio_imgs', {				starteffect: function() { return false; },				endeffect: function() { return false; },				change: function() {					_top = parseInt($('portfolio_imgs').getStyle('top'));										if((_top-250) < 0) {						$('portfolio_imgs').setStyle('top: 250px;');					}										if((_top-250) > ($('content').getHeight()-500-32)) {						$('portfolio_imgs').setStyle('top: '+($('content').getHeight()-250-32)+'px');					}									}			});									if(Browser.isGecko) { $('portfolio_imgs').setStyle('cursor: -moz-grab;'); }			else { $('portfolio_imgs').setStyle('cursor: url(/imgs/openhand.cur);'); }						Event.observe('portfolio_imgs', 'mousedown', docMouseDown);						Event.observe('portfolio_imgs', 'mousedown', function() { 				if(Browser.isGecko) { $('portfolio_imgs').setStyle('cursor: -moz-grabbing;'); }				else { $('portfolio_imgs').setStyle('cursor: url(/imgs/closedhand.cur);'); }			});						Event.observe('portfolio_imgs', 'mouseup', function() { 				if(Browser.isGecko) { $('portfolio_imgs').setStyle('cursor: -moz-grab;'); }				else { $('portfolio_imgs').setStyle('cursor: url(/imgs/openhand.cur);'); }			});						Event.observe('content', 'mousewheel', mousescrollPortfolio, false);			Event.observe('content', 'DOMMouseScroll', mousescrollPortfolio, false); // Firefox		}		}			Object.extend(Event, {		wheel:function (event){			var delta = 0;			if (!event) event = window.event;			if (event.wheelDelta) {				delta = event.wheelDelta/120; 				if (window.opera) delta = -delta;			} else if (event.detail) { delta = -event.detail/3;	}			return Math.round(delta); //Safari Round		}	});	enlargeImgNow = function(src) {			$('disable_ui').remove();		$('enlarged').update('');		$('container').fade({			duration: 0.5		});		$('enlarged').appear({ duration: 0.5 });		new Effect.Morph('enlarged', {			duration: 0.5,			style: 'text-align: center; top: 0px; left: 0px; width: '+pWidth+'px; height: '+pHeight+'px;',			transition: Effect.Transitions.Cubic,			afterFinish: function() {							$('enlarged').setStyle('width: 100%; height: 100%');								$('enlarged').update('<img src="'+newImgSrc+'" alt="" style="display: none; height: 100%; width: auto;" onclick="closeImg(); return false;" />');								/*if(Browser.isGecko) { $$('#enlarged img')[0].setStyle('cursor: -moz-zoom-out;'); }				else { $$('#enlarged img')[0].setStyle('cursor: url(/imgs/zoomout.cur);'); }*/				$$('#enlarged img')[0].setStyle('cursor: url(/imgs/zoomout.png), -moz-zoom-out;');								$$('#enlarged img')[0].appear({					duration: 0.5				});			}		});			}	// Textpages	if($('textpage')) {			$$('body')[0].setStyle('background: #7F7F7F;');		if(Browser.isGecko) { $('textpage').setStyle('cursor: -moz-grab;'); }		else { $('textpage').setStyle('cursor: url(/imgs/openhand.cur);'); }				Event.observe('textpage', 'mousedown', function() { 			if(Browser.isGecko) { $('textpage').setStyle('cursor: -moz-grabbing;'); }			else { $('textpage').setStyle('cursor: url(/imgs/closedhand.cur);'); }		});		Event.observe('textpage', 'mouseup', function() { 			if(Browser.isGecko) { $('textpage').setStyle('cursor: -moz-grab;'); }			else { $('textpage').setStyle('cursor: url(/imgs/openhand.cur);'); }		});				new Draggable('textpage', {			starteffect: function() { return false; },			endeffect: function() { return false; }		});				textPageToggle_running = false;		$$('h3.first a').each(function(a) {					a.onclick = function() {							if(!textPageToggle_running) {									textPageToggle_running = true;									if(a.parentNode.next().visible()) {											a.parentNode.next().blindUp({ 							duration: 0.2,							afterFinish: function() { textPageToggle_running = false; }						});						a.className = 'closed';											}					else {											a.parentNode.next().blindDown({ 							duration: 0.2,							afterFinish: function() { textPageToggle_running = false; }						});						a.className = '';											}									}								return false;			};				});				// ie workaround		if(Browser.isMSIE) {			$$('h3.first a').each(function(a) {				a.className = 'iefix';				a.onclick = function() { return false; };			});			$$('div.section').each(function(a) {				a.show();			});		}		}	});
