// Spry.Effect.js-version 0.38-Spry Pre-Release 1.6
// Copyright (c) 2006. Adobe Systems Incorporated.
// All rights reserved.
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
// *Redistributions of source code must retain the above copyright notice, 
// this list of conditions and the following disclaimer.
// *Redistributions in binary form must reproduce the above copyright notice, 
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
// *Neither the name of Adobe Systems Incorporated nor the names of its
// contributors may be used to endorse or promote products derived from this
// software without specific prior written permission.
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.

var Spry;if(!Spry) Spry={};
Spry.forwards=1;Spry.backwards=2;if(!Spry.Effect) Spry.Effect={};
Spry.Effect.Transitions={
linearTransition: function(time,begin,change,duration){if(time > duration) return change+begin;return begin+(time/duration)*change;},
growSpecificTransition: function(time,begin,change,duration){if(time > duration) return change+begin;var pos=time/duration;
return begin+(5*Math.pow(pos,3)-6.4*Math.pow(pos,2)+2*pos)*change;}};
for (var trans in Spry.Effect.Transitions){Spry[trans]=Spry.Effect.Transitions[trans];}
if(!Spry.Effect.Utils) Spry.Effect.Utils={};
Spry.Effect.Utils.showError=function(msg){alert('Spry.Effect ERR: '+msg);};
Spry.Effect.Utils.showInitError=function(effect){
Spry.Effect.Utils.showError('The '+effect+' class can\'t be accessed as a static function anymore. '+ "\n"+'Please read Spry Effects migration documentation.');return false;};
Spry.Effect.Utils.Position=function(){this.x=0;this.y=0;this.units="px";};
Spry.Effect.Utils.Rectangle=function(){this.width=0;this.height=0;this.units="px";};
Spry.Effect.Utils.intToHex=function(integerNum){var result=integerNum.toString(16);
if(result.length==1)result="0"+result;return result;};
Spry.Effect.Utils.hexToInt=function(hexStr){return parseInt(hexStr,16);};
Spry.Effect.Utils.rgb=function(redInt,greenInt,blueInt){var intToHex=Spry.Effect.Utils.intToHex;
var redHex=intToHex(redInt);var greenHex=intToHex(greenInt);var blueHex=intToHex(blueInt);
compositeColorHex=redHex.concat(greenHex,blueHex).toUpperCase();compositeColorHex='#'+compositeColorHex;return compositeColorHex;};
Spry.Effect.Utils.longColorVersion=function(color){
if( color.match(/^#[0-9a-f]{3}$/i) ){var tmp=color.split('');var color='#';for (var i=1;i<tmp.length;i++){color += tmp[i]+''+tmp[i];}}
return color;};
Spry.Effect.Utils.camelize=function(stringToCamelize){if(stringToCamelize.indexOf('-')==-1){return stringToCamelize;}
var oStringList=stringToCamelize.split('-');var isFirstEntry=true;var camelizedString='';
for(var i=0;i<oStringList.length;i++){if(oStringList[i].length>0){if(isFirstEntry){camelizedString=oStringList[i];isFirstEntry=false;}else{var s=oStringList[i];camelizedString += s.charAt(0).toUpperCase()+s.substring(1);}}}return camelizedString;};
Spry.Effect.Utils.isPercentValue=function(value){var result=false;if(typeof value=='string'&&value.length > 0&&value.lastIndexOf("%") > 0)result=true;return result;};
Spry.Effect.Utils.getPercentValue=function(value){var result=0;try{result=Number(value.substring(0,value.lastIndexOf("%")));}
catch (e) {Spry.Effect.Utils.showError('Spry.Effect.Utils.getPercentValue: '+e);}return result;};
Spry.Effect.Utils.getPixelValue=function(value){var result=0;if(typeof value=='number') return value;var unitIndex=value.lastIndexOf("px");
if( unitIndex==-1)unitIndex=value.length;try{result=parseInt(value.substring(0,unitIndex),10);}catch (e){}return result;};
Spry.Effect.Utils.getFirstChildElement=function(node){if(node){var childCurr=node.firstChild;while (childCurr){if(childCurr.nodeType==1)return childCurr;childCurr=childCurr.nextSibling;}}return null;};
Spry.Effect.Utils.fetchChildImages=function(startEltIn,targetImagesOut){if(!startEltIn||startEltIn.nodeType!=1||!targetImagesOut)return;
if(startEltIn.hasChildNodes()){var childImages=startEltIn.getElementsByTagName('img');var imageCnt=childImages.length;for(var i=0;i<imageCnt;i++){var imgCurr=childImages[i];
var dimensionsCurr=Spry.Effect.getDimensions(imgCurr);targetImagesOut.push([imgCurr,dimensionsCurr.width,dimensionsCurr.height]);}}};
Spry.Effect.Utils.optionsAreIdentical=function(optionsA,optionsB){if(optionsA==null&&optionsB==null)return true;if(optionsA!=null&&optionsB!=null){
var objectCountA=0;var objectCountB=0;for (var propA in optionsA) objectCountA++;for (var propB in optionsB) objectCountB++;if(objectCountA!=objectCountB)return false;
for (var prop in optionsA){var typeA=typeof optionsA[prop];var typeB=typeof optionsB[prop];if( typeA!=typeB||(typeA!='undefined'&&optionsA[prop]!=optionsB[prop]))return false;}return true;}return false;};
Spry.Effect.Utils.DoEffect=function (effectName,element,options){if(!options)var options={};options.name=effectName;var ef=SpryRegistry.getRegisteredEffect(element,options);
if(!ef){ef=new Spry.Effect[effectName](element,options);SpryRegistry.addEffect(ef,element,options);}ef.start();return true;};
Spry.Effect.getElement=function(ele){var element=ele;if(typeof ele=="string")element=document.getElementById(ele);
if(element==null) Spry.Effect.Utils.showError('Element "'+ele+'" not found.');return element;};Spry.Effect.getStyleProp=function(element,prop){
var value;var camelized=Spry.Effect.Utils.camelize(prop);try{if(element.style)value=element.style[camelized];
if(!value){if(document.defaultView&&document.defaultView.getComputedStyle){var css=document.defaultView.getComputedStyle(element,null);
value=css ? css.getPropertyValue(prop) : null;}
else if(element.currentStyle) {
value=element.currentStyle[camelized];}}}
catch (e) {Spry.Effect.Utils.showError('Spry.Effect.getStyleProp: '+e);}
return value=='auto' ? null : value;};
Spry.Effect.setStyleProp=function(element,prop,value){
try{element.style[Spry.Effect.Utils.camelize(prop)]=value;}
catch (e) {Spry.Effect.Utils.showError('Spry.Effect.setStyleProp: '+e);}};
Spry.Effect.getStylePropRegardlessOfDisplayState=function(element,prop,displayElement){
var refElement=displayElement ? displayElement : element;
var displayOrig=Spry.Effect.getStyleProp(refElement,'display');
var visibilityOrig=Spry.Effect.getStyleProp(refElement,'visibility');
if(displayOrig=='none'){
Spry.Effect.setStyleProp(refElement,'visibility','hidden');
Spry.Effect.setStyleProp(refElement,'display','block');
if(window.opera)refElement.focus();}var styleProp=Spry.Effect.getStyleProp(element,prop);
if(displayOrig=='none'){Spry.Effect.setStyleProp(refElement,'display','none');Spry.Effect.setStyleProp(refElement,'visibility',visibilityOrig);}return styleProp;};
Spry.Effect.makePositioned=function(element){var pos=Spry.Effect.getStyleProp(element,'position');
if(!pos||pos=='static'){element.style.position='relative';
if(window.opera){element.style.top=0;element.style.left=0;}}};
Spry.Effect.isInvisible=function(element){var propDisplay=Spry.Effect.getStyleProp(element,'display');
if(propDisplay&&propDisplay.toLowerCase()=='none')return true;
var propVisible=Spry.Effect.getStyleProp(element,'visibility');
if(propVisible&&propVisible.toLowerCase()=='hidden')return true;return false;};
Spry.Effect.enforceVisible=function(element){var propDisplay=Spry.Effect.getStyleProp(element,'display');
if(propDisplay&&propDisplay.toLowerCase()=='none')Spry.Effect.setStyleProp(element,'display','block');
var propVisible=Spry.Effect.getStyleProp(element,'visibility');
if(propVisible&&propVisible.toLowerCase()=='hidden')
Spry.Effect.setStyleProp(element,'visibility','visible');};
Spry.Effect.makeClipping=function(element){
var overflow=Spry.Effect.getStyleProp(element,'overflow');
if(!overflow||(overflow.toLowerCase()!='hidden'&&overflow.toLowerCase()!='scroll')){
var heightCache=0;var needsCache=/MSIE 7.0/.test(navigator.userAgent)&&/Windows NT/.test(navigator.userAgent);
if(needsCache)
heightCache=Spry.Effect.getDimensionsRegardlessOfDisplayState(element).height;
Spry.Effect.setStyleProp(element,'overflow','hidden');
if(needsCache)
Spry.Effect.setStyleProp(element,'height',heightCache+'px');}};
Spry.Effect.cleanWhitespace=function(element) {
var childCountInit=element.childNodes.length;
for (var i=childCountInit-1;i >= 0;i--) {
var node=element.childNodes[i];
if(node.nodeType==3&&!/\S/.test(node.nodeValue))
try{element.removeChild(node);}
catch (e) {Spry.Effect.Utils.showError('Spry.Effect.cleanWhitespace: '+e);}}};
Spry.Effect.getComputedStyle=function(element){
return /MSIE/.test(navigator.userAgent) ? element.currentStyle : document.defaultView.getComputedStyle(element,null);};
Spry.Effect.getDimensions=function(element){
var dimensions=new Spry.Effect.Utils.Rectangle;var computedStyle=null;
if(element.style.width&&/px/i.test(element.style.width))
dimensions.width=parseInt(element.style.width,10);
else{computedStyle=Spry.Effect.getComputedStyle(element);
var tryComputedStyle=computedStyle&&computedStyle.width&&/px/i.test(computedStyle.width);
if(tryComputedStyle)
dimensions.width=parseInt(computedStyle.width,10);
if(!tryComputedStyle||dimensions.width==0) 
dimensions.width=element.offsetWidth;}
if(element.style.height&&/px/i.test(element.style.height))
dimensions.height=parseInt(element.style.height,10);
else{if(!computedStyle)
computedStyle=Spry.Effect.getComputedStyle(element);
var tryComputedStyle=computedStyle&&computedStyle.height&&/px/i.test(computedStyle.height);
if(tryComputedStyle)
dimensions.height=parseInt(computedStyle.height,10);
if(!tryComputedStyle||dimensions.height==0) dimensions.height=element.offsetHeight;}return dimensions;};
Spry.Effect.getDimensionsRegardlessOfDisplayState=function(element,displayElement){
var refElement=displayElement ? displayElement : element;
var displayOrig=Spry.Effect.getStyleProp(refElement,'display');
var visibilityOrig=Spry.Effect.getStyleProp(refElement,'visibility');
if(displayOrig=='none'){Spry.Effect.setStyleProp(refElement,'visibility','hidden');
Spry.Effect.setStyleProp(refElement,'display','block');
if(window.opera)refElement.focus();}var dimensions=Spry.Effect.getDimensions(element);
if(displayOrig=='none'){Spry.Effect.setStyleProp(refElement,'display','none');Spry.Effect.setStyleProp(refElement,'visibility',visibilityOrig);}return dimensions;};
Spry.Effect.getOpacity=function(element){var o=Spry.Effect.getStyleProp(element,"opacity");if(typeof o=='undefined'||o==null)o=1.0;return o;};
Spry.Effect.getBgColor=function(ele){return Spry.Effect.getStyleProp(ele,"background-color");};Spry.Effect.intPropStyle=function(e,prop){
var i=parseInt(Spry.Effect.getStyleProp(e,prop),10);
if(isNaN(i))return 0;return i;};
Spry.Effect.getPosition=function(element){var position=new Spry.Effect.Utils.Position;var computedStyle=null;
if(element.style.left &&/px/i.test(element.style.left))position.x=parseInt(element.style.left,10);else{computedStyle=Spry.Effect.getComputedStyle(element);
var tryComputedStyle=computedStyle&&computedStyle.left&&/px/i.test(computedStyle.left);if(tryComputedStyle)position.x=parseInt(computedStyle.left,10);
if(!tryComputedStyle||position.x==0) position.x=element.offsetLeft;}
if(element.style.top&&/px/i.test(element.style.top))position.y=parseInt(element.style.top,10);else{if(!computedStyle)computedStyle=Spry.Effect.getComputedStyle(element);
var tryComputedStyle=computedStyle&&computedStyle.top&&/px/i.test(computedStyle.top);if(tryComputedStyle)position.y=parseInt(computedStyle.top,10);
if(!tryComputedStyle||position.y==0) position.y=element.offsetTop;}return position;};Spry.Effect.getOffsetPosition=Spry.Effect.getPosition;Spry.Effect.Animator=function(options){Spry.Utils.Notifier.call(this);
this.name='Animator';this.element=null;this.startMilliseconds=0;this.repeat='none';this.isRunning=false;this.timer=null;this.cancelRemaining=0;
if(!options)var options={};if(options.toggle)this.direction=false;else this.direction=Spry.forwards;var self=this;if(options.setup!=null)
this.addObserver({onPreEffect: function(){try{self.options.setup(self.element,self);}catch(e){Spry.Effect.Utils.showError('Spry.Effect.Animator.prototype.start: setup callback: '+e);}}});
if(options.finish!=null)
this.addObserver({onPostEffect: function(){try{self.options.finish(self.element,self);}catch(e){Spry.Effect.Utils.showError('Spry.Effect.Animator.prototype.stop: finish callback: '+e);}}});
this.options={duration:1000,toggle: false,transition: Spry.linearTransition,interval:16};
this.setOptions(options);if(options.transition) this.setTransition(options.transition);if(options.fps)this.setFps(options.fps);};
Spry.Effect.Animator.prototype=new Spry.Utils.Notifier();
Spry.Effect.Animator.prototype.constructor=Spry.Utils.Animator;
Spry.Effect.Animator.prototype.notStaticAnimator=true;
Spry.Effect.Animator.prototype.setOptions=function(options){if(!options)return;
for (var prop in options) this.options[prop]=options[prop];};
Spry.Effect.Animator.prototype.setTransition=function(transition){if(typeof transition=='number'||transition=="1"||transition=="2")
switch (parseInt(transition,10)){case 1: transition=Spry.linearTransition;break;case 2: transition=Spry.sinusoidalTransition;break;
default: Spry.Effect.Utils.showError('unknown transition');}
else if(typeof transition=='string'){if(typeof window[transition]=='function')transition=window[transition];
else if(typeof Spry[transition]=='function')transition=Spry[transition];
else Spry.Effect.Utils.showError('unknown transition');}this.options.transition=transition;
if(typeof this.effectsArray!='undefined'){var l=this.effectsArray.length;for (var i=0;i<l;i++)this.effectsArray[i].effect.setTransition(transition);}};
Spry.Effect.Animator.prototype.setDuration=function(duration){this.options.duration=duration;
if(typeof this.effectsArray!='undefined'){var l=this.effectsArray.length;for (var i=0;i<l;i++){this.effectsArray[i].effect.setDuration(duration);}}};
Spry.Effect.Animator.prototype.setFps=function(fps){this.options.interval=parseInt(1000/fps,10);this.options.fps=fps;if(typeof this.effectsArray!='undefined'){
var l=this.effectsArray.length;for (var i=0;i<l;i++){this.effectsArray[i].effect.setFps(fps);}}};Spry.Effect.Animator.prototype.start=function(withoutTimer){
if(!this.element) return;if(arguments.length==0)withoutTimer=false;if(this.isRunning)this.cancel();this.prepareStart();var currDate=new Date();this.startMilliseconds=currDate.getTime();
if(this.element.id)this.element=document.getElementById(this.element.id);if(this.cancelRemaining!=0&&this.options.toggle){
if(this.cancelRemaining<1&&typeof this.options.transition=='function'){var startTime=0;var stopTime=this.options.duration;var start=0;var stop=1;var emergency=0;
this.cancelRemaining=Math.round(this.cancelRemaining*1000)/1000;var found=false;var middle=0;while (!found){if(emergency++ > this.options.duration) break;
var half=startTime+((stopTime-startTime)/2); middle=Math.round(this.options.transition(half,1,-1,this.options.duration)*1000)/1000;
if(middle==this.cancelRemaining){this.startMilliseconds -= half;found=true;}
if(middle<this.cancelRemaining){
stopTime=half;
stop=middle;}
else{startTime=half;
start=middle;}}}
this.cancelRemaining=0;}
this.notifyObservers('onPreEffect',this);
if(withoutTimer==false){
var self=this;
this.timer=setInterval(function() { self.drawEffect();},this.options.interval);}this.isRunning=true;};
Spry.Effect.Animator.prototype.stopFlagReset=function(){
if(this.timer){
clearInterval(this.timer);
this.timer=null;}this.startMilliseconds=0;};
Spry.Effect.Animator.prototype.stop=function(){
this.stopFlagReset();this.notifyObservers('onPostEffect',this);this.isRunning=false;};
Spry.Effect.Animator.prototype.cancel=function(){
var elapsed=this.getElapsedMilliseconds();
if(this.startMilliseconds > 0&&elapsed<this.options.duration)
this.cancelRemaining=this.options.transition(elapsed,0,1,this.options.duration);
this.stopFlagReset();this.notifyObservers('onCancel',this);this.isRunning=false;};
Spry.Effect.Animator.prototype.drawEffect=function(){
var isRunning=true;
this.notifyObservers('onStep',this);
var timeElapsed=this.getElapsedMilliseconds();
if(typeof this.options.transition!='function'){
Spry.Effect.Utils.showError('unknown transition');
return;}
this.animate();
if(timeElapsed > this.options.duration){
isRunning=false;
this.stop();}
return isRunning;};
Spry.Effect.Animator.prototype.getElapsedMilliseconds=function(){
if(this.startMilliseconds > 0){
var currDate=new Date();
return (currDate.getTime()-this.startMilliseconds);}
return 0;};
Spry.Effect.Animator.prototype.doToggle=function(){
if(!this.direction){
this.direction=Spry.forwards;
return;}
if(this.options.toggle==true){
if(this.direction==Spry.forwards){
this.direction=Spry.backwards;
this.notifyObservers('onToggle',this);} 
else if(this.direction==Spry.backwards){
this.direction=Spry.forwards;}}};
Spry.Effect.Animator.prototype.prepareStart=function(){
if(this.options&&this.options.toggle)
this.doToggle();};
Spry.Effect.Animator.prototype.animate=function(){};
Spry.Effect.Animator.prototype.onStep=function(el){
if(el!=this)
this.notifyObservers('onStep',this);};
Spry.Effect.Move=function(element,fromPos,toPos,options){
this.dynamicFromPos=false;
if(arguments.length==3){
options=toPos;
toPos=fromPos;
fromPos=Spry.Effect.getPosition(element);
this.dynamicFromPos=true;}
Spry.Effect.Animator.call(this,options);
this.name='Move';
this.element=Spry.Effect.getElement(element);
if(!this.element)
return;
if(fromPos.units!=toPos.units)
Spry.Effect.Utils.showError('Spry.Effect.Move: Conflicting units ('+fromPos.units+','+toPos.units+')');
this.units=fromPos.units;this.startX=Number(fromPos.x);this.stopX=Number(toPos.x);
this.startY=Number(fromPos.y);this.stopY=Number(toPos.y);};
Spry.Effect.Move.prototype=new Spry.Effect.Animator();
Spry.Effect.Move.prototype.constructor=Spry.Effect.Move;
Spry.Effect.Move.prototype.animate=function(){
var left=0;var top=0;var floor=Math.floor;
var elapsed=this.getElapsedMilliseconds();
if(this.direction==Spry.forwards){
left=floor(this.options.transition(elapsed,this.startX,this.stopX-this.startX,this.options.duration));
top=floor(this.options.transition(elapsed,this.startY,this.stopY-this.startY,this.options.duration));}
else if(this.direction==Spry.backwards){
left=floor(this.options.transition(elapsed,this.stopX,this.startX-this.stopX,this.options.duration));
top=floor(this.options.transition(elapsed,this.stopY,this.startY-this.stopY,this.options.duration));}
this.element.style.left=left+this.units;
this.element.style.top=top+this.units;};
Spry.Effect.Move.prototype.prepareStart=function(){
if(this.options&&this.options.toggle)
this.doToggle();
if(this.dynamicFromPos==true){
var fromPos=Spry.Effect.getPosition(this.element);
this.startX=fromPos.x;
this.startY=fromPos.y;
this.rangeMoveX=this.startX-this.stopX;
this.rangeMoveY= this.startY-this.stopY;}};
Spry.Effect.Size=function(element,fromRect,toRect,options){
this.dynamicFromRect=false;
if(arguments.length==3){
options=toRect;
toRect=fromRect;
fromRect=Spry.Effect.getDimensionsRegardlessOfDisplayState(element);
this.dynamicFromRect=true;}
Spry.Effect.Animator.call(this,options);
this.name='Size';
this.element=Spry.Effect.getElement(element);
if(!this.element)
return;
element=this.element;
if(fromRect.units!=toRect.units){
Spry.Effect.Utils.showError('Spry.Effect.Size: Conflicting units ('+fromRect.units+','+toRect.units+')');
return false;}
this.units=fromRect.units;
var originalRect=Spry.Effect.getDimensionsRegardlessOfDisplayState(element);
this.originalWidth=originalRect.width;this.originalHeight=originalRect.height;this.startWidth=fromRect.width;
this.startHeight=fromRect.height;this.stopWidth=toRect.width;this.stopHeight=toRect.height;this.childImages=new Array();
if(this.options.useCSSBox){
Spry.Effect.makePositioned(this.element);
var intProp=Spry.Effect.intPropStyle;
this.startFromBorder_top=intProp(element,'border-top-width');
this.startFromBorder_bottom=intProp(element,'border-bottom-width');
this.startFromBorder_left=intProp(element,'border-left-width');
this.startFromBorder_right=intProp(element,'border-right-width');
this.startFromPadding_top=intProp(element,'padding-top');
this.startFromPadding_bottom=intProp(element,'padding-bottom');
this.startFromPadding_left=intProp(element,'padding-left');
this.startFromPadding_right=intProp(element,'padding-right');
this.startFromMargin_top=intProp(element,'margin-top');
this.startFromMargin_bottom=intProp(element,'margin-bottom');
this.startFromMargin_right=intProp(element,'margin-right');
this.startFromMargin_left=intProp(element,'margin-left');
this.startLeft=intProp(element,'left');
this.startTop=intProp(element,'top');}
if(this.options.scaleContent)
Spry.Effect.Utils.fetchChildImages(element,this.childImages);
this.fontFactor=1.0;
var fontSize=Spry.Effect.getStyleProp(this.element,'font-size');
if(fontSize&&/em\s*$/.test(fontSize))
this.fontFactor=parseFloat(fontSize);
var isPercent=Spry.Effect.Utils.isPercentValue;
if(isPercent(this.startWidth)){
var startWidthPercent=Spry.Effect.Utils.getPercentValue(this.startWidth);
this.startWidth=originalRect.width*(startWidthPercent/100);}
if(isPercent(this.startHeight)){
var startHeightPercent=Spry.Effect.Utils.getPercentValue(this.startHeight);
this.startHeight=originalRect.height*(startHeightPercent/100);}
if(isPercent(this.stopWidth)){
var stopWidthPercent=Spry.Effect.Utils.getPercentValue(this.stopWidth);
this.stopWidth=originalRect.width*(stopWidthPercent/100);}
if(isPercent(this.stopHeight)){
var stopHeightPercent=Spry.Effect.Utils.getPercentValue(this.stopHeight);
this.stopHeight=originalRect.height*(stopHeightPercent/100);}
this.enforceVisible=Spry.Effect.isInvisible(this.element);};
Spry.Effect.Size.prototype=new Spry.Effect.Animator();
Spry.Effect.Size.prototype.constructor=Spry.Effect.Size;
Spry.Effect.Size.prototype.animate=function(){
var width=0;var height=0;var fontSize=0;var direction=0;
var floor=Math.floor;
var elapsed=this.getElapsedMilliseconds();
if(this.direction==Spry.forwards) {
width=floor(this.options.transition(elapsed,this.startWidth,this.stopWidth-this.startWidth,this.options.duration));
height=floor(this.options.transition(elapsed,this.startHeight,this.stopHeight-this.startHeight,this.options.duration));
direction=1;} else if(this.direction==Spry.backwards) {
width=floor(this.options.transition(elapsed,this.stopWidth,this.startWidth-this.stopWidth,this.options.duration));
height=floor(this.options.transition(elapsed,this.stopHeight,this.startHeight-this.stopHeight,this.options.duration));
direction=-1;}
var propFactor=width/this.originalWidth;
fontSize=this.fontFactor*propFactor;
var elStyle=this.element.style;
if(width<0)
width=0;
if(height<0)
height=0;
elStyle.width=width+this.units;
elStyle.height=height+this.units;
if(typeof this.options.useCSSBox!='undefined'&&this.options.useCSSBox==true){
var intProp=Spry.Effect.intPropStyle;
var origTop=intProp(this.element,'top');
var origLeft=intProp(this.element,'left');
var origMarginTop=intProp(this.element,'margin-top');
var origMarginLeft=intProp(this.element,'margin-left');
var widthFactor=propFactor;
var heightFactor=height/this.originalHeight;
var border_top=floor(this.startFromBorder_top*heightFactor);
var border_bottom=floor(this.startFromBorder_bottom*heightFactor);
var border_left=floor(this.startFromBorder_left*widthFactor);
var border_right=floor(this.startFromBorder_right*widthFactor);
var padding_top=floor(this.startFromPadding_top*heightFactor);
var padding_bottom=floor(this.startFromPadding_bottom*heightFactor);
var padding_left=floor(this.startFromPadding_left*widthFactor);
var padding_right=floor(this.startFromPadding_right*widthFactor);
var margin_top=floor(this.startFromMargin_top*heightFactor);
var margin_bottom=floor(this.startFromMargin_bottom*heightFactor);
var margin_right=floor(this.startFromMargin_right*widthFactor);
var margin_left=floor(this.startFromMargin_left*widthFactor);
elStyle.borderTopWidth=border_top+this.units;
elStyle.borderBottomWidth=border_bottom+this.units;
elStyle.borderLeftWidth=border_left+this.units;
elStyle.borderRightWidth=border_right+this.units;
elStyle.paddingTop=padding_top+this.units;
elStyle.paddingBottom=padding_bottom+this.units;
elStyle.paddingLeft=padding_left+this.units;
elStyle.paddingRight=padding_right+this.units;
elStyle.marginTop =margin_top+this.units;
elStyle.marginBottom=margin_bottom+this.units;
elStyle.marginLeft=margin_left+this.units;
elStyle.marginRight=margin_right+this.units;
elStyle.left=floor(origLeft+origMarginLeft-margin_left)+this.units;
elStyle.top=floor(origTop+origMarginTop-margin_top)+this.units;}
if(this.options.scaleContent){
for(var i=0;i<this.childImages.length;i++){
this.childImages[i][0].style.width=propFactor*this.childImages[i][1]+this.units;
this.childImages[i][0].style.height=propFactor*this.childImages[i][2]+this.units;}
this.element.style.fontSize=fontSize+'em';}
if(this.enforceVisible){
Spry.Effect.enforceVisible(this.element);
this.enforceVisible=false;}};
Spry.Effect.Size.prototype.prepareStart=function(){
if(this.options&&this.options.toggle)
this.doToggle();	
if(this.dynamicFromRect==true){
var fromRect=Spry.Effect.getDimensions(element);
this.startWidth=fromRect.width;
this.startHeight=fromRect.height;
this.widthRange=this.startWidth-this.stopWidth;
this.heightRange=this.startHeight-this.stopHeight;}};
Spry.Effect.Opacity=function(element,startOpacity,stopOpacity,options){
this.dynamicStartOpacity=false;
if(arguments.length==3){
options=stopOpacity;
stopOpacity=startOpacity;
startOpacity=Spry.Effect.getOpacity(element);
this.dynamicStartOpacity=true;}
Spry.Effect.Animator.call(this,options);
this.name='Opacity';
this.element=Spry.Effect.getElement(element);
if(!this.element)
return;
if(/MSIE/.test(navigator.userAgent)&&(!this.element.hasLayout))
Spry.Effect.setStyleProp(this.element,'zoom','1');
this.startOpacity=startOpacity;this.stopOpacity=stopOpacity;this.enforceVisible=Spry.Effect.isInvisible(this.element);};
Spry.Effect.Opacity.prototype=new Spry.Effect.Animator();
Spry.Effect.Opacity.prototype.constructor=Spry.Effect.Opacity;
Spry.Effect.Opacity.prototype.animate=function(){
var opacity=0;
var elapsed=this.getElapsedMilliseconds();
if(this.direction==Spry.forwards) 
opacity=this.options.transition(elapsed,this.startOpacity,this.stopOpacity-this.startOpacity,this.options.duration);
else if(this.direction==Spry.backwards) 
opacity=this.options.transition(elapsed,this.stopOpacity,this.startOpacity-this.stopOpacity,this.options.duration);
if(opacity<0)
opacity=0;
if(/MSIE/.test(navigator.userAgent)){
var tmpval=Spry.Effect.getStyleProp(this.element,'filter');
if(tmpval){
tmpval=tmpval.replace(/alpha\(opacity=[0-9]{1,3}\)/g,'');}
this.element.style.filter=tmpval+"alpha(opacity="+Math.floor(opacity*100)+")";}
else
this.element.style.opacity=opacity;
if(this.enforceVisible){
Spry.Effect.enforceVisible(this.element);
this.enforceVisible=false;}};
Spry.Effect.Opacity.prototype.prepareStart=function(){
if(this.options&&this.options.toggle)
this.doToggle();	
if(this.dynamicStartOpacity==true){this.startOpacity=Spry.Effect.getOpacity(element);this.opacityRange=this.startOpacity-this.stopOpacity;}};
