
document.observe('dom:loaded', function() {
	var doc = document.viewport.getWidth()-180;
	var doc2 = (document.viewport.getHeight()-$('wrap').getHeight()-42)/2;
	$('wrap').setStyle({ width: (doc*0.95) + 'px', marginTop: doc2 + 'px' });
	$('body').setStyle({ backgroundPosition: 
		($('outro').viewportOffset()[0]-108) + 'px ' 
		+ ($('outro').viewportOffset()[1]-108) + 'px'
	});
	if ($('gallery')) {
		s = 0; $$('#gallery .photo').each(function(el, i) {
			var layout = el.getLayout(); s2 = i+1;
			s += layout.get('margin-box-width');
		}); $('gallery').setStyle({ width: (s+18) + 'px' });

		$('tip').setStyle({
			marginTop: ($('matter').getHeight()-$('tip').getHeight())/1.2 + 'px', 
			marginLeft: ($('matter').getWidth()-$('tip').getWidth())/2 + 'px'
		}).appear({ after: function() {
			$('tip').fade({ delay: 5 }); } });

		au = new S2.FX.Morph('gallery', { duration: s2*2.5, transition: 'webkitEaseInOut', style: 'left:' + (doc*0.95-10-s) + 'px' }).play();
		g = new S2.FX.Morph('gallery', { duration: s2/2, transition: 'webkitEaseInOut', style: 'left:0px' });
		g2 = new S2.FX.Morph('gallery', { duration: s2*1.5, transition: 'webkitEaseInOut', style: 'left:' + (doc*0.95-10-s) + 'px' });

		document.on('mousemove', function() {
			g.cancel(); g2.cancel();
		});
		$('matter').on('mousemove', function(event) {
			var x = Event.pointerX(event); au.cancel();
			var doc = document.viewport.getWidth();
			var elm = $('matter').getWidth(), elm2 = (elm-80)/2;
			if (x > doc-elm && x < doc-elm+elm2) { g.play();
			} else if (x > doc-elm2 && x < doc) { g2.play();
			} else { g.cancel(); g2.cancel(); }
		});
		$('matter').on('mouseout', function(event) {
			au.play();
		});
		$('info').setStyle({ marginTop: (doc2+80) + 'px' }).on('click', function(event) {
			this.hide(); $('more').show();
		});
		$('more').setStyle({ marginTop: (doc2+80) + 'px' }).on('click', function(event) {
			this.hide(); $('info').show();
		});
	}
	if ($('static')) {
		if ($('poster')) {
			$('static').setStyle({ width: (doc*0.95-348) + 'px' });
		} else { $('static').setStyle({ width: (doc*0.95-48) + 'px' }); }
	}
});

function cc() {
	$('load').addClassName('load');
	$('cc').observe('submit', function(event) {
		Event.stop(event);
	}).request({
		onComplete: function(response) {
			$('load').removeClassName('load');
			if (response.responseText == 'err') {
				$('msg').update('Bitte vollständig ausfüllen.');
			} else { $('cc').reset(); $('msg').update('Vielen Dank für Ihre Nachricht.'); }
		}
	}); return false;
}

