/*
 ADOBE CONFIDENTIAL
 ___________________

 Copyright 2013 Adobe Systems Incorporated
 All Rights Reserved.

 NOTICE:  All information contained herein is, and remains
 the property of Adobe Systems Incorporated and its suppliers,
 if any.  The intellectual and technical concepts contained
 herein are proprietary to Adobe Systems Incorporated and its
 suppliers and may be covered by U.S. and Foreign Patents,
 patents in process, and are protected by trade secret or copyright law.
 Dissemination of this information or reproduction of this material
 is strictly forbidden unless prior written permission is obtained
 from Adobe Systems Incorporated.
*/
(function(a){var b=a("#page"),c=a(window),d=function(a,b){this.elem=a;this.data=b;this.data.enterSpeedX=Muse.Utils.firstDefined(this.data.enterSpeedX,this.data.speedX,0);this.data.exitSpeedX=Muse.Utils.firstDefined(this.data.exitSpeedX,this.data.speedX,0);this.data.enterSpeedY=Muse.Utils.firstDefined(this.data.enterSpeedY,this.data.speedY,1);this.data.exitSpeedY=Muse.Utils.firstDefined(this.data.exitSpeedY,this.data.speedY,1);this.enabled="undefined"!=typeof this.data.offset;this.initialized=!1};
d.HIDDEN_CLASS="se_invi";d.prototype.clone=function(a){a.hasClass(d.HIDDEN_CLASS)||a.addClass(d.HIDDEN_CLASS);a.registerGenericScrollEffect(d,this.data)};d.prototype.update=function(a,b){var c=a<0;this.elem.css({left:a*(c?this.data.enterSpeedX:this.data.exitSpeedX)+this.elementLeft-b,top:a*-(c?this.data.enterSpeedY:this.data.exitSpeedY)+this.elementTop-this.data.offset,"-webkit-transform":"translateZ(0px)"});if(!this.initialized&&this.elem.hasClass(d.HIDDEN_CLASS))this.elem.removeClass(d.HIDDEN_CLASS),
this.initialized=!0};var f=function(a,b){this.elem=a;this.data=b;this.offset=this.getBackgroundOffset();this.vx=Muse.Utils.firstDefined(this.data.speedX,0);this.vy=Muse.Utils.firstDefined(this.data.speedY,1);0==this.vx&&0==this.vy?(this.elem.css("background-attachment","fixed"),this.enabled=!1):this.enabled=0!=this.vx||1!=this.vy};f.prototype.update=function(a){this.elem.css({"background-attachment":"scroll","background-position":this.offset.x+a*this.vx+"px "+(this.offset.y+a*(1-this.vy))+"px"})};
f.prototype.getBackgroundOffset=function(){var a=this.getBackgroundPosition(),b,c;b={x:Muse.Utils.tryParse(a.x,parseFloat,0),y:Muse.Utils.tryParse(a.y,parseFloat,0)};if(!Muse.Utils.endsWith(a.x,"%")&&!Muse.Utils.endsWith(a.y,"%"))return b;c=this.getBackgroundSize()||{};if(Muse.Utils.endsWith(a.x,"%"))b.x=b.x/100*(this.elem.width()-Muse.Utils.firstDefined(c.width,this.elem.width()));if(Muse.Utils.endsWith(a.y,"%"))b.y=b.y/100*(this.elem.height()-Muse.Utils.firstDefined(c.height,this.elem.height()));
return b};f.prototype.isValidBackgroundPosition=function(a){return Muse.Utils.endsWith(a,"%")||Muse.Utils.endsWith(a,"px")};f.prototype.getBackgroundPosition=function(){var a=this.elem.css("background-position");if(!a){var b=this.elem.css("background-position-x"),c=this.elem.css("background-position-y");b&&(a=b+" "+(c||""))}if(!a||!a.split)return{x:"0%",y:"0%"};a=a.replace(/(?:left|top)/gi,"0%").replace(/center/gi,"50%").replace(/(?:right|bottom)/gi,"100%");a=a.replace(/^\s+|\s+$/gi,"");a=a.split(" ");
1==a.length&&a.push("50%");if(!this.isValidBackgroundPosition(a[0])||!this.isValidBackgroundPosition(a[1]))Muse.Assert.fail("Invalid measurement unit for background position. Expecting px or %.");else return{x:a[0],y:a[1]}};f.prototype.getBackgroundSize=function(){var a=this.elem.css("background-size");if(a&&a.split)return a=a.split(" "),{width:Muse.Utils.tryParse(a[0],parseFloat),height:Muse.Utils.tryParse(a[1],parseFloat)}};var g=function(a,b){this.elem=a;this.data=b};g.prototype.update=function(a){var a=
(a<0?this.data.enterRotateSpeed:this.data.exitRotateSpeed)*a%360,b=Muse.Browser.Features.checkCSSFeature("transform");this.elem.css((b===!0?"":"-"+b.toLowerCase()+"-")+"transform","rotate("+a+"deg)")};var h=function(a,b){this.elem=a;this.data=b};h.prototype.update=function(a){a=100+(a<0?this.data.enterOpacityChangeSpeed:this.data.exitOpacityChangeSpeed)*a;a=Math.max(a,0);a=Math.min(a,100);0==a?this.elem.css("visibility","hidden"):(this.elem.css("visibility","visible"),this.elem.fadeTo(0,a/100))};
var j=function(){this.effects=[];this.initialCSSProperties={};this.pagePaddingTop=Muse.Utils.tryParse(a("body").css("padding-top"),parseInt,0)+Muse.Utils.tryParse(a("#page").css("border-top-width"),parseInt,0);c.scroll(this,this.onUpdate);c.resize(this,this.onUpdate)};j.prototype.getEffectProgress=function(a){return c.scrollTop()-Muse.Utils.firstDefined(a.data.offset,0)};j.prototype.getHorizontalScroll=function(){return c.scrollLeft()-b.offset().left};j.prototype.onUpdate=function(a){for(var b=null,
a=a.data,c=0,c=0;c<a.effects.length;c++)b=a.effects[c],b.update(a.getEffectProgress(b),a.getHorizontalScroll())};j.prototype.registerEffect=function(a,c,d){var f=a.attr("id")||a.attr("data-muse-tempuid")||a.attr("data-muse-tempuid",this.getRandomUID()).attr("data-muse-tempuid"),g=this,h=new c(a,d);if(!1!==h.enabled)"undefined"==typeof this.initialCSSProperties[f]&&(this.initialCSSProperties[f]={left:Muse.Utils.tryParse(a.css("left"),parseInt,0)+Muse.Utils.tryParse(b.css("border-left-width"),parseInt,
0),top:Muse.Utils.tryParse(a.css("top"),parseInt,0)+this.pagePaddingTop}),h.elementLeft=this.initialCSSProperties[f].left,h.elementTop=this.initialCSSProperties[f].top,setTimeout(function(){h.update(g.getEffectProgress(h),g.getHorizontalScroll())},0),this.effects.push(h)};j.prototype.getRandomUID=function(){return Math.round(Math.random()*1E6)};var k=new j;a.fn.registerPositionScrollEffect=function(b){return a(this).registerGenericScrollEffect(d,b)};a.fn.registerBackgroundPositionScrollEffect=function(b){return a(this).registerGenericScrollEffect(f,
b)};a.fn.registerRotateScrollEffect=function(b){return a(this).registerGenericScrollEffect(g,b)};a.fn.registerOpacityScrollEffect=function(b){return a(this).registerGenericScrollEffect(h,b)};a.fn.registerGenericScrollEffect=function(b,c){k.registerEffect(a(this),b,c);a(this).data("hasScrollEffect",!0);return this};a.fn.clearScrollEffects=function(){a(this).data("hasScrollEffect",!1);for(var b=0;b<k.effects.length;)k.effects[b].elem.is(this)?k.effects.splice(b,1):b++};a.fn.cloneScrollEffectsFrom=function(a){for(var b=
k.effects.length,c=0;c<b;c++){var d=k.effects[c];d.elem.is(a)&&d.clone&&d.clone(this)}}})(jQuery);
