
	window.addEvent('domready',function() {
		
		if($$('.kundStartHidden')[0]) {
			$$(".kundStartHidden").each(function(e) {
				e.set('opacity',0.01);
				var showStart = new Fx.Tween(e,{duration: 1});
				var showEnd = new Fx.Tween(e,{duration: 600});
				e.addEvent('mouseover',function() {
					showEnd.cancel();
					showStart.start('opacity',1);
				});
				e.addEvent('mouseleave',function() {
					showStart.cancel();
					showEnd.start('opacity',0.01);
				});
			})
		}
		
		$$(".hover").each(function(e) {
			var showStart = new Fx.Tween(e,{duration: 1});
			var showEnd = new Fx.Tween(e,{duration: 600});
			e.addEvent('mouseover',function() {
				showEnd.cancel();
				showStart.start('opacity',0.01);
			});
			e.addEvent('mouseleave',function() {
				showStart.cancel();
				showEnd.start('opacity',1);
			});
		})
		
		$$(".hoverHalf").each(function(e) {
			var showStart = new Fx.Tween(e,{duration: 300});
			var showEnd = new Fx.Tween(e,{duration: 300});
			e.addEvent('mouseover',function() {
				showEnd.cancel();
				showStart.start('opacity',0.9);
			});
			e.addEvent('mouseleave',function() {
				showStart.cancel();
				showEnd.start('opacity',1);
			});
		})
		
		$$('.moognify').each(function(element) {
			element.addEvent('click', function() { new Moognify(element,{source: '/cycle/server/data/files/'+element.get('name')}) });
		});
		
		$$('.galleryThumb').each(function(element) {
			element.addEvent('click',function() {
				changePicture(element);
			});
		});
		
	});
	
	
	function changePicture(image) {
	
		var imageSrc = image.get('name');
		var imageContainer = $('galleryContainer');
		var imageHeight = imageContainer.getFirst().getCoordinates().height;
		
		imageContainer.set('styles',{
			'height': imageHeight,
			'background-image': 'url('+imageContainer.getFirst().get('src')+')'
		});
		
		var newImage = new Element('img',{
			'src': imageSrc
		});
		newImage.set('opacity',0);
		
		imageContainer.empty();
		
		newImage.inject(imageContainer);
		
		new Fx.Tween(newImage).start('opacity',1);
	
	}
