;(function($) {
	$(function(){
		// Positionen Freiluft Auslegeordnung
		var $paneTarget = $('#pane-target');
		
		// apply scrollview
		$paneTarget.scrollview();
		
		//borrowed from jQuery easing plugin
		//http://gsgd.co.uk/sandbox/jquery.easing.php
		$.easing.elasout = function(x, t, b, c, d) {
			var s=1.70158;var p=0;var a=c;
			if (t==0) return b;  if ((t/=d)==1) return b+c;  if (!p) p=d*.3;
			if (a < Math.abs(c)) { a=c; var s=p/4; }
			else var s = p/(2*Math.PI) * Math.asin (c/a);
			return a*Math.pow(2,-10*t) * Math.sin( (t*d-s)*(2*Math.PI)/p ) + c + b;
		};
		// back links
		$('a.back').click(function(event){
			event.preventDefault();
			$(this).parents('div.pane').scrollTo( 0, 2500, { queue:true } );
			$(this).parents('div.section').find('span.message').text( this.title );
			return false;
		});
		
		//just for the example, to stop the click on the links.
		$('#navigation a').click(function(event){
			event.preventDefault();
			var link = event.target;
			link.blur();
			if( link.title )
				$(this).parent().find('span.message').text(link.title);
		});
		
		// Reset all scrollable panes to (0,0)
		$paneTarget.scrollTo( 0 );
		// Reset the screen to (0,0)
		$.scrollTo( 0 );
		
		/* Un-comment this if dragging should not be enabled on clickable images
		$('.elements a, .elements area').mousedown(function(event){
			event.stopPropagation();
		});
		// */
		
		$(window).resize(function(event){
			// recalculate scroll coordinates at window resize
			$paneTarget.stop().scrollTo({
				top: $paneTarget.scrollTop(),
				left: $paneTarget.scrollLeft()
			}, 0 );
		});
		
		$('#oeko').click(function(){
			$paneTarget.stop().scrollTo( { top:0,left:2800} , 3000 );
		});
		
		$('#gebaut').click(function(){
			$paneTarget.stop().scrollTo( { top:2325,left:800} , 1500 );
		});
		
		$('#arbeit').click(function(){
			$paneTarget.stop().scrollTo( { top:750,left:1770} , 1000 );
		});
		
		$('#studien').click(function(){
			$paneTarget.stop().scrollTo( { top:800,left:250} , 1000 );
		});
		
		$('#wettbewerbe').click(function(){
			$paneTarget.stop().scrollTo( { top:2550,left:0} , 1500 );
		});
		
		$('#publikationen').click(function(){
			$paneTarget.stop().scrollTo( { top:725,left:950} , 2000 );
		});
		
		$('#projektliste').click(function(){
			$paneTarget.stop().scrollTo( { top:1000,left:0} , 1000 );
		});
		
		$('#freiluft').click(function(){
			$paneTarget.stop().scrollTo( { top:3000,left:2500} , 2500 );
		});
		
		$('#wolke7').click(function(){
			$paneTarget.stop().scrollTo( { top:0,left:0} , 500 );
		});
		
		$('#home').click(function(){
			$paneTarget.stop().scrollTo( { top:0,left:0} , 500 );
			
		});
		
	});
})(jQuery);
