









	if($('sub_' + sess_s)) { 
		if(sess_s != previous_site) {
			new Effect.Appear('sub_' + sess_s);
		}
		else {
			Element.show('sub_' + sess_s);
		}
	}



	morphBG = function() {
		if($('switchbg')) {
			new Effect.Fade('switchbg', { duration:0.5 });
		}
	}
	
	
	
	new Effect.Appear('content', { afterFinish:function() {
		morphBG();
	}});
	




	window.onload = function() {
	
		$('b_suche').onclick = function() { toggleSearch(); return false; };
	
		projects = document.getElementsByClassName('project-item');
		if(projects.length > 0) {

			movieframe = '<div id="movie_frame" style="width:512px; height:303px; display:none;">&nbsp;</div><div id="b_close" style="display:none;"><a href="#" onclick="closeMovie(); return false;">close</a></div>';
			new Insertion.After('container', movieframe);

			projects_nav = '<ul id="nav_projects">';
			for(i=0; i<projects.length; i++) {

				projects_nav += '<li><a ';
				if(i == 0) { projects_nav += 'class="active" '; }
				projects_nav += 'href="#' + (i+1) + '" onclick="new Effect.Morph(\'project_container\', { style:\'left:-'+ (i*881) +'px\', duration:0.3 }); updateNavClassNames(\''+i+'\'); return false;">' + (i+1) + '</a></li>';
				
				document.getElementsByClassName('play')[i].onclick = function() { return false; };
				
				Event.observe(document.getElementsByClassName('play')[i], 'click', function() { playMovie(this.href); });

			}
			projects_nav += '</ul>';

			new Insertion.After('content', projects_nav);

		}
		
	}
	
	
	
	updateNavClassNames = function(exception) {
	
		navItems = $('nav_projects').getElementsByTagName('a');
		for(i=0; i<navItems.length; i++) {
		
			Element.removeClassName(navItems[i], 'active');
		
		}
		
		Element.addClassName(navItems[exception], 'active');
	
	}
	
	
	
	
	
	playMovie = function(which) {
	
		// Movie oder Image?
		ttype = (which.indexOf('.jpg') != -1) ? 'image' : 'movie';
		
		// Movie oder Flash?
		if(ttype == 'movie') {
			ttype = (which.indexOf('.swf') != -1) ? 'flash' : 'movie';
		}
		
		$('movie_frame').className = '';
		$('b_close').className = '';
		
		if(ttype == 'image') {
			$('movie_frame').className = 'movie_frame-image';
			$('b_close').className = 'b_close-image';
			Event.observe('overlay', 'click', function() { closeMovie(); });
		}
		
		if(ttype == 'movie') {
			$('movie_frame').className = 'movie_frame-movie';
			$('b_close').className = 'b_close-movie';
			Event.stopObserving('overlay', 'click', function() { closeMovie(); });
		}
	
		new Effect.Fade('content', { duration:0.5 });
		new Effect.Fade('nav_projects', { duration:0.5 });
		new Effect.Appear('overlay', { duration:0.5, to:0.8, afterFinish:function() {
			
			new Effect.Appear('b_close', { duration:0.5 });
			new Effect.Appear('movie_frame', { duration:0.5, afterFinish:function() {
			
				if(ttype == 'image') {
					
					window.setTimeout(function() { Element.update('movie_frame', '<img src="'+which+'" alt="" />'); }, 500);
					
				}
				
				if(ttype == 'movie') {
				
					window.setTimeout(function() { 
					
						classid_string = (Browser.isMSIE) ? ' classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B"' : ' ';
					
						Element.update('movie_frame', '<object type="video/quicktime"'+classid_string+'data="'+which+'" width="512" height="303" codebase="http://www.apple.com/qtactivex/qtplugin.cab"><param name="src" value="'+which+'" /><param name="autoplay" value="true" /></object>'); 
					}, 500);
					
				}
				
				if(ttype == 'flash') {
				
					window.setTimeout(function() { 
				
						Element.update('movie_frame', '<object type="application/x-shockwave-flash" data="'+which+'" width="512" height="303"><param name="movie" value="'+which+'" /></object>');
						
					}, 500);

				}
			
			}});
		
		}});
	
	}
	
	
	
	closeMovie = function() {
	
		Element.hide('b_close');
		Element.update('movie_frame', ' ');
		new Effect.Fade('movie_frame', { duration:0.5, afterFinish:function() {
		
			new Effect.Fade('overlay', { duration:0.5 });
			new Effect.Appear('content', { duration:0.5 });
			new Effect.Appear('nav_projects', { duration:0.5 });

		}});

	}
	
	
	
	
	toggleSearch = function() {
	
		if(Element.visible('b_suche')) {
		
			Element.hide('b_suche');
			Element.show('b_suchfeld');
			$('suchbegriff').focus();
		
		}
	
	}
	
	
	
	
	
	
	
	
	document.observe('dom:loaded', function() {
		if($('cinema')) { new Cinema(); }
	});
	
	
	
	
	Cinema = function() {
	
		init = function() {
		
			this.imgs = $$('div#cinema_imgs img');
			this.currentImg = 0;
			this.maxImg = (this.imgs.length - 1);
			this.nextImg = 1;
			this.zIndex = 10;
			
			window.setInterval('this.swapImg()', 4000);
			
		}
		
		
		swapImg = function() {

			this.nextImg = ((this.currentImg + 1) > this.maxImg) ? 0 : (this.currentImg + 1);
			this.currentImg = this.nextImg;
			this.zIndex++;

			this.imgs[this.nextImg].hide();
			this.imgs[this.nextImg].setStyle('z-index: '+ this.zIndex);
			new Effect.Appear(this.imgs[this.nextImg], {
				duration: 0.5
			});

		}
	
	
		init();
	
	}
	
	
	
	
	
	
	
	
	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();
