/* Copyright (C) YOOtheme GmbH, YOOtheme Proprietary Use License (http://www.yootheme.com/license) */

(function(f){f.fn.parallax=function(l){l=f.extend({},{ratio:8,maxdiff:!1,start:0,mode:"inview",childanimation:!0,childdir:1,childratio:3,childopacity:!0,sizeratio:0.38,mintriggerwidth:!1},l);return this.each(function(){var b=f(this).css("overflow","hidden"),a=f.extend({},l,b.data()),e=b.children().length?b.children().eq(0):b.children(),m=f(window).width(),n="undefined"!==String(window.orientation),k;f(window).on("scroll",function(){var j=function(){if(!n)if(a.mintriggerwidth&&m<parseInt(a.mintriggerwidth,
10))b.css("background-position",""),a.childanimation&&e.length&&e.css({transform:"",opacity:""});else{var d=f(window).scrollTop(),c=b.offset().top,j=f(window).height(),g=!1,h;switch(a.mode){case "dock":g=c<d;h=a.maxdiff&&d-c>a.maxdiff?a.maxdiff:d-c;break;default:g=j+d>=c,h=a.maxdiff&&Math.abs(d-c)>a.maxdiff?a.maxdiff:d-c}g?(g=h/a.ratio,b.css({"background-position":"50% "+(a.start+g)+"px"}),a.childanimation&&e.length&&("dock"==a.mode&&c<d?(h=a.maxdiff&&d-c>a.maxdiff?a.maxdiff:d-c,g=h/a.childratio,
e.css({transform:"translateY("+Math.abs(g)*a.childdir+"px)",opacity:a.childopacity?1-Math.abs(h/k):1})):"inview"==a.mode?(c=e.offset().top,j+d>=c&&(h=a.maxdiff&&d-c>a.maxdiff?a.maxdiff:d-c,g=h/a.childratio,e.css({transform:"translateY("+Math.abs(g)*a.childdir+"px)",opacity:a.childopacity?1-Math.abs(h/k):1}))):e.css({transform:"",opacity:""}))):(b.css("background-position","100% "+a.start+"px"),a.childanimation&&e.length&&e.css("transform","").css("opacity",""))}};j();f(window).on("load",j);return j}()).on("resize orientationchange",
function(){var j=function(){m=f(window).width();a.sizeratio&&("false"!==a.sizeratio&&"0"!==a.sizeratio)&&(k=b.width()*a.sizeratio,b.css("height",k));e.length&&(k=b.height(),e=b.children().length?b.children().eq(0):b.children())};j();return j}())})}})(jQuery);
