jQuery.extend( jQuery.easing, { def: 'smooth', smooth: function (x, t, b, c, d) { if ((t/=d/2) < 1) return c/2*t*t*t + b; return c/2*((t-=2)*t*t + 2) + b; }});
;(function(d){var k=d.scrollTo=function(a,i,e){d(window).scrollTo(a,i,e)};k.defaults={axis:'xy',duration:parseFloat(d.fn.jquery)>=1.3?0:1};k.window=function(a){return d(window)._scrollable()};d.fn._scrollable=function(){return this.map(function(){var a=this,i=!a.nodeName||d.inArray(a.nodeName.toLowerCase(),['iframe','#document','html','body'])!=-1;if(!i)return a;var e=(a.contentWindow||a).document||a.ownerDocument||a;return d.browser.safari||e.compatMode=='BackCompat'?e.body:e.documentElement})};d.fn.scrollTo=function(n,j,b){if(typeof j=='object'){b=j;j=0}if(typeof b=='function')b={onAfter:b};if(n=='max')n=9e9;b=d.extend({},k.defaults,b);j=j||b.speed||b.duration;b.queue=b.queue&&b.axis.length>1;if(b.queue)j/=2;b.offset=p(b.offset);b.over=p(b.over);return this._scrollable().each(function(){var q=this,r=d(q),f=n,s,g={},u=r.is('html,body');switch(typeof f){case'number':case'string':if(/^([+-]=)?\d+(\.\d+)?(px|%)?$/.test(f)){f=p(f);break}f=d(f,this);case'object':if(f.is||f.style)s=(f=d(f)).offset()}d.each(b.axis.split(''),function(a,i){var e=i=='x'?'Left':'Top',h=e.toLowerCase(),c='scroll'+e,l=q[c],m=k.max(q,i);if(s){g[c]=s[h]+(u?0:l-r.offset()[h]);if(b.margin){g[c]-=parseInt(f.css('margin'+e))||0;g[c]-=parseInt(f.css('border'+e+'Width'))||0}g[c]+=b.offset[h]||0;if(b.over[h])g[c]+=f[i=='x'?'width':'height']()*b.over[h]}else{var o=f[h];g[c]=o.slice&&o.slice(-1)=='%'?parseFloat(o)/100*m:o}if(/^\d+$/.test(g[c]))g[c]=g[c]<=0?0:Math.min(g[c],m);if(!a&&b.queue){if(l!=g[c])t(b.onAfterFirst);delete g[c]}});t(b.onAfter);function t(a){r.animate(g,j,b.easing,a&&function(){a.call(this,n,b)})}}).end()};k.max=function(a,i){var e=i=='x'?'Width':'Height',h='scroll'+e;if(!d(a).is('html,body'))return a[h]-d(a)[e.toLowerCase()]();var c='client'+e,l=a.ownerDocument.documentElement,m=a.ownerDocument.body;return Math.max(l[h],m[h])-Math.min(l[c],m[c])};function p(a){return typeof a=='object'?a:{top:a,left:a}}})(jQuery);

function pxparallax() {

    var pxoffset = window.pageYOffset;

    // First Section
    $('#first').children('.container').css({ 'top' : (0+(pxoffset/11))+'%' });
    $('#first').children('.sheet').css({ 'top' : (72-(pxoffset/20))+'%' });
    $('#first').children('.background').css({ 'top' : (0+(pxoffset/40))+'%' });
	
    $('#first').find('.homeCircle1').css({ 'top' : (+85-(pxoffset/10))+'%' });
    $('#first').find('.homeCircle2').css({ 'top' : (+22-(pxoffset/20))+'%' });
    $('#first').find('.homeCircle3').css({ 'top' : (+30-(pxoffset/15))+'%' });

    // Second Section
    $('#second').find('.circle1').css({ 'top' : (+85-(pxoffset/5))+'%' });
    $('#second').find('.circle2').css({ 'top' : (+42-(pxoffset/10))+'%' });
    $('#second').find('.circle3').css({ 'top' : (+80-(pxoffset/18))+'%' });
	$('#second').find('.circle4').css({ 'top' : (+70-(pxoffset/78))+'%' });
	$('#second').find('.circle5').css({ 'top' : (+115-(pxoffset/8))+'%' });
	$('#second').find('.circle5Two').css({ 'top' : (+80-(pxoffset/13))+'%' });
	$('#second').find('.circle6').css({ 'top' : (+90-(pxoffset/28))+'%' });	
    $('#second').children('.sheet').css({ 'top' : (122-(pxoffset/18))+'%' });
    $('#second').children('.background').css({ 'top' : (-25+(pxoffset/38))+'%' });
	

    // Third Section
    $('#third').find('.blue').css({ 'top' : (+215-(pxoffset/9))+'%' });
    $('#third').find('.blue2').css({ 'top' : (+170-(pxoffset/14))+'%' });
    $('#third').find('.yellow').css({ 'top' : (+150-(pxoffset/30))+'%' });
	$('#third').find('.circle22').css({ 'top' : (+175-(pxoffset/9))+'%' });
	$('#third').find('.circle23').css({ 'top' : (+285-(pxoffset/6))+'%' });
    $('#third').find('.green').css({ 'top' : (+82-(pxoffset/34))+'%' });
    $('#third').children('.sheet').css({ 'top' : (172-(pxoffset/16))+'%' });
    $('#third').children('.background').css({ 'top' : (-50+(pxoffset/42))+'%' });

    // Fourth Section
    $('#fourth').find('.yellow').css({ 'top' : (+345-(pxoffset/8))+'%' });
    $('#fourth').find('.yellow2').css({ 'top' : (+300-(pxoffset/12))+'%' });
    $('#fourth').find('.blue').css({ 'top' : (+185-(pxoffset/18))+'%' });
    $('#fourth').find('.red').css({ 'top' : (+120-(pxoffset/28))+'%' });
	$('#fourth').find('.circle9').css({ 'top' : (+105-(pxoffset/28))+'%' });
    $('#fourth').children('.sheet').css({ 'top' : (222-(pxoffset/18))+'%' });
    $('#fourth').children('.background').css({ 'top' : (-75+(pxoffset/38))+'%' });

    // Fifth Section
    $('#fifth').children('.sheet').css({ 'top' : (272-(pxoffset/20))+'%' });
    $('#fifth').children('.background').css({ 'top' : (-100+(pxoffset/40))+'%' });
    $('#fifth').find('.fifthCircle1').css({ 'top' : (+300-(pxoffset/17))+'%' });
    $('#fifth').find('.fifthCircle2').css({ 'top' : (+170-(pxoffset/28))+'%' });
	$('#fifth').find('.fifthCircle3').css({ 'top' : (+300-(pxoffset/14))+'%' });
	$('#fifth').find('.goMessage').css({ 'top' : (+254-(pxoffset/15))+'%' });
}

$(document).ready(function() {

    pxparallax();

    // Navigation
    $('#navigation span').show().animate({ opacity: 0.0 }, 0);
    $('#navigation .info').show().animate({ 'left' : '24px' }, 0);
    $('#navigation a').hover(function() {
        $(this).children('.dot').stop().animate({ opacity: 1.0 }, 240);
        $(this).parent('li').children('.info').stop().animate({ opacity: 1.0, 'left' : '30px' }, 240);
    }, function() {
        $(this).children('.dot').stop().animate({ opacity: 0.0 }, 240);
        $(this).parent('li').children('.info').stop().animate({ opacity: 0.0, 'left' : '24px' }, 240);
    });
    $("#navigation a, .button a").click(function() {
        $.scrollTo(this.hash , 1680,{easing:'smooth'});
        return false;
    });

    // Kontakt
    $('#socials a').animate({ opacity: 0.5 }, 0);
    $('#socials a').hover(function() {
        $(this).stop().animate({ opacity: 1.0 }, 240);
    }, function() {
        $(this).stop().animate({ opacity: 0.5 }, 240);
    });

});

$(window).scroll(function() {

    pxparallax();

});

$(window).resize(function() {

    pxparallax();

});
