//
// Stardock Effects Library
// Trimmed down and slightly enhanced version of jQuery's animation functions.
//
// Copyright (c) 2007-2008 Stardock Systems, Inc.
// Author: Nick Quaranto
// Version 1.0: 10.30.07 --- Initial Revision
// Version 1.1: 01.18.08 --- Adding sliding, various fixes for IE
// Version 1.2: 02.01.08 --- Preparing for compression
// Version 1.3: 02.01.08 --- Added options to NOT show/hide element on fadeIn/fadeOut. AAP 04.04.08
//
// Adapted from jQuery 1.3.1.1/1.2.2 http://jquery.com/
// Copyright (c) 2007 John Resig (jquery.com)
//
// Also adapted from jQuery Cycle plugin
// Version: 1.9 (8/22/2007)
// Copyright (c) 2007 M. Alsup
//
// Uses jQuery Easing v1.1.1 - http://gsgd.co.uk/sandbox/jquery.easing.php
// Copyright (c) 2007 George Smith
//
// Notes:
// These copyright notices must stay in this file according to the MIT License.
// This file requires Stardock.11.js and MicrosoftAjax.debug.js if using SlideShow.
Sd.Effects=Class.create();Sd.Effects=function(B,A,D,C){this.options=A;this.elem=B;this.prop=D;this.extOpts=C;if(!A.orig){A.orig={}}};Sd.Effects.prototype={update:function(){if(this.options.step){this.options.step.apply(this.elem,[this.now,this])}(Sd.Effects.step[this.prop]||Sd.Effects.step._default)(this);if(this.prop=="height"||this.prop=="width"){this.elem.style.display="block"}},cur:function(B){if(this.elem[this.prop]!=null&&this.elem.style[this.prop]==null){return this.elem[this.prop]}var A=parseFloat(Sd.Effects.Style(this.elem,this.prop));return A&&A>-10000?A:parseFloat(Sd.Effects.getCSS(this.elem,this.prop))||0},custom:function(E,D,C){this.startTime=(new Date()).getTime();this.start=E;this.end=D;this.unit=C||this.unit||"px";this.now=this.start;this.pos=this.state=0;this.update();var A=this;function B(F){return A.step(F)}B.elem=this.elem;Sd.Effects.timers.push(B);if(Sd.Effects.timerId==null){Sd.Effects.timerId=setInterval(function(){var G=Sd.Effects.timers;for(var F=0;F<G.length;F++){if(!G[F]()){G.splice(F--,1)}}if(!G.length){clearInterval(Sd.Effects.timerId);Sd.Effects.timerId=null}},13)}},show:function(){this.options.orig[this.prop]=Sd.Effects.getCSS(this.elem,this.prop);this.options.show=((this.elem.show&&(this.elem.show==true||this.elem.show==false))?this.elem.show:true);if(this.extOpts.showElement==false&&this.prop=="opacity"){this.options.orig[this.prop]="1"}this.custom(0,((this.extOpts.showElement==false&&this.prop=="opacity")?1:this.cur()));if(this.prop=="width"||this.prop=="height"){this.elem.style[this.prop]="1px"}if(this.elem.style.display=="none"&&(this.extOpts.showElement==true)){if(this.elem.prevDisplay){this.elem.style.display=this.elem.prevDisplay}else{this.elem.style.display=""}}else{this.elem.style.visibility=""}},hide:function(){this.options.orig[this.prop]=Sd.Effects.getCSS(this.elem,this.prop);this.options.hide=((this.elem.hide&&(this.elem.hide==true||this.elem.hide==false))?this.elem.hide:true);if(Sd.Common.Browser.ie){this.elem.style.filter="alpha(opacity=100)";this.elem.style.zoom=1}this.custom(this.cur(),0)},step:function(D){var C=(new Date()).getTime();if(D||C>this.options.duration+this.startTime){this.now=this.end;this.pos=this.state=1;this.update();this.options.curAnim[this.prop]=true;var A=true;for(var B in this.options.curAnim){if(this.options.curAnim[B]!==true){A=false}}if(A){if(this.options.display!=null){this.elem.style.overflow=this.options.overflow;this.elem.style.display=this.options.display;if(Sd.Effects.getCSS(this.elem,"display")=="none"){this.elem.style.display="block"}}if(this.options.hide&&(this.extOpts.hideElement==true)){this.elem.prevDisplay=this.elem.style.display;this.elem.style.display="none"}else{if(this.options.hide){this.elem.style.visibility="hidden"}}if(this.options.hide||this.options.show){for(var E in this.options.curAnim){Sd.Effects.Style(this.elem,E,this.options.orig[E])}}}if(A&&Sd.Effects.isFunction(this.options.complete)){this.options.complete.apply(this.elem)}return false}else{var F=C-this.startTime;this.state=F/this.options.duration;this.pos=Sd.Effects.easing[this.options.easing||(Sd.Effects.easing.swing?"swing":"linear")](this.state,F,0,1,this.options.duration);this.now=this.start+((this.end-this.start)*this.pos);this.update()}return true}};Sd.Effects.step={scrollLeft:function(A){A.elem.scrollLeft=A.now},scrollTop:function(A){A.elem.scrollTop=A.now},opacity:function(A){Sd.Effects.Style(A.elem,"opacity",A.now)},_default:function(A){A.elem.style[A.prop]=A.now+A.unit}};Sd.Effects.timers=[];Sd.Effects.perform=function(C,A,B,F,G,H){if(!H){H={empty:""}}if(C&&C.constructor==String){C=$id(C)}var J=B&&B.constructor==Object?B:{complete:G,duration:B,easing:F||F&&F.constructor!=Function&&F||"swing"};J.duration=(J.duration&&J.duration.constructor==Number?J.duration:{slow:600,fast:200}[J.duration])||400;J.curAnim=Object.extend({},A);var E=Sd.Effects.Style(C,"display")=="none"||Sd.Effects.Style(C,"visibility")=="hidden"||"hidden"==C.type;for(var D in A){if((A[D]=="hide"&&E)||(A[D]=="show"&&(!E&&H.showElement&&H.showElement==true))){return Sd.Effects.isFunction(J.complete)&&J.complete.apply(this)}if(D=="height"||D=="width"){J.display=Sd.Effects.getCSS(C,"display");J.overflow=C.style.overflow}var I=new Sd.Effects(C,J,D,H);if(A[D].constructor==Number){I.custom(I.cur()||0,A[D])}else{if(A[D]&&A[D]!=""&&I[A[D]]){I[A[D]](A)}}}};Sd.Effects.isFunction=function(A){return !!A&&typeof A!="string"&&!A.nodeName&&A.constructor!=Array&&/function/i.test(A+"")};Sd.Effects.easing={linear:function(C,D,A,B){return A+B*C},swing:function(C,D,A,B){return((-Math.cos(C*Math.PI)/2)+0.5)*B+A},easein:function(B,C,A,E,D){return E*(C/=D)*C+A},easeinout:function(B,C,A,F,E){if(C<E/2){return 2*F*C*C/(E*E)+A}var D=C-E/2;return -2*F*D*D/(E*E)+2*F*D/E+F/2+A},easeout:function(B,C,A,E,D){return -E*C*C/(D*D)+2*E*C/D+A},expoin:function(B,C,A,F,E){var D=1;if(F<0){D*=-1;F*=-1}return D*(Math.exp(Math.log(F)/E*C))+A},expoout:function(B,C,A,F,E){var D=1;if(F<0){D*=-1;F*=-1}return D*(-Math.exp(-Math.log(F)/E*(C-E))+F+1)+A},expoinout:function(B,C,A,F,E){var D=1;if(F<0){D*=-1;F*=-1}if(C<E/2){return D*(Math.exp(Math.log(F/2)/(E/2)*C))+A}return D*(-Math.exp(-2*Math.log(F/2)/E*(C-E))+F+1)+A},bouncein:function(B,C,A,E,D){return E-ref.easing.bounceout(B,D-C,0,E,D)+A},bounceout:function(B,C,A,E,D){if((C/=D)<(1/2.75)){return E*(7.5625*C*C)+A}else{if(C<(2/2.75)){return E*(7.5625*(C-=(1.5/2.75))*C+0.75)+A}else{if(C<(2.5/2.75)){return E*(7.5625*(C-=(2.25/2.75))*C+0.9375)+A}else{return E*(7.5625*(C-=(2.625/2.75))*C+0.984375)+A}}}},bounceinout:function(B,C,A,E,D){if(C<D/2){return ref.easing.bouncein(B,C*2,0,E,D)*0.5+A}return ref.easing.bounceout(B,C*2-D,0,E,D)*0.5+E*0.5+A},elasin:function(B,D,A,H,G){var E=1.70158;var F=0;var C=H;if(D==0){return A}if((D/=G)==1){return A+H}if(!F){F=G*0.3}if(C<Math.abs(H)){C=H;var E=F/4}else{var E=F/(2*Math.PI)*Math.asin(H/C)}return -(C*Math.pow(2,10*(D-=1))*Math.sin((D*G-E)*(2*Math.PI)/F))+A},elasout:function(B,D,A,H,G){var E=1.70158;var F=0;var C=H;if(D==0){return A}if((D/=G)==1){return A+H}if(!F){F=G*0.3}if(C<Math.abs(H)){C=H;var E=F/4}else{var E=F/(2*Math.PI)*Math.asin(H/C)}return C*Math.pow(2,-10*D)*Math.sin((D*G-E)*(2*Math.PI)/F)+H+A},elasinout:function(B,D,A,H,G){var E=1.70158;var F=0;var C=H;if(D==0){return A}if((D/=G/2)==2){return A+H}if(!F){F=G*(0.3*1.5)}if(C<Math.abs(H)){C=H;var E=F/4}else{var E=F/(2*Math.PI)*Math.asin(H/C)}if(D<1){return -0.5*(C*Math.pow(2,10*(D-=1))*Math.sin((D*G-E)*(2*Math.PI)/F))+A}return C*Math.pow(2,-10*(D-=1))*Math.sin((D*G-E)*(2*Math.PI)/F)*0.5+H+A},backin:function(B,C,A,F,E){var D=1.70158;return F*(C/=E)*C*((D+1)*C-D)+A},backout:function(B,C,A,F,E){var D=1.70158;return F*((C=C/E-1)*C*((D+1)*C+D)+1)+A},backinout:function(B,C,A,F,E){var D=1.70158;if((C/=E/2)<1){return F/2*(C*C*(((D*=(1.525))+1)*C-D))+A}return F/2*((C-=2)*C*(((D*=(1.525))+1)*C+D)+2)+A}};Sd.Effects.Style=function(C,B,D){if(D=="selected"&&Sd.Common.Browser.safari){C.parentNode.selectedIndex}if(C&&C.constructor==String){C=$id(C)}if(Sd.Common.Browser.ie||C!=C.style){C=C.style}if(B=="opacity"&&Sd.Common.Browser.ie){if(D!=undefined){C.zoom=1;C.filter=(C.filter||"").replace(/alpha\([^)]*\)/,"")+(parseFloat(D).toString()=="NaN"?"":"alpha(opacity="+D*100+")")}var A=C.filter&&C.filter.indexOf("opacity=")>=0?(parseFloat(C.filter.match(/opacity=([^)]*)/)[1])/100).toString():"";return A==""?"1":A}B=B.replace(/-([a-z])/ig,function(F,E){return E.toUpperCase()});if(D!=undefined){C[B]=D}return C[B]};Sd.Effects.getCSS=function(D,H){var A;if(H=="opacity"&&Sd.Common.Browser.ie){return D.style.filter?(parseFloat(D.style.filter.match(/opacity=([^)]*)/)[1])/100).toString():""}if(H.match(/float/i)){H=Sd.Common.Browser.ie?"styleFloat":"cssFloat"}if(D.style[H]){A=D.style[H]}else{if(document.defaultView&&document.defaultView.getComputedStyle){if(H.match(/float/i)){H="float"}H=H.replace(/([A-Z])/g,"-$1").toLowerCase();var F=document.defaultView.getComputedStyle(D,null);if(F){A=F.getPropertyValue(H)}else{if(H=="display"){A="none"}else{D.style.olddisplay=D.style.display;D.style.display="block";var G=document.defaultView.getComputedStyle(D,"");A=G&&G.getPropertyValue(H)||"";D.style.display=e.style.olddisplay}}}else{if(D.currentStyle){var E=H.replace(/\-(\w)/g,function(I,J){return J.toUpperCase()});A=D.currentStyle[H]||D.currentStyle[E];if(!/^\d+(px)?$/i.test(A)&&/^\d/.test(A)){var C=D.style.left;var B=D.runtimeStyle.left;D.runtimeStyle.left=D.currentStyle.left;D.style.left=A||0;A=D.style.pixelLeft+"px";D.style.left=C;D.runtimeStyle.left=B}}}}return A};Sd.Effects.Hover=Class.create();Sd.Effects.Hover.prototype={activityDelay:100000,delay:250,initialize:function(E,A,D,B){if(E.constructor==String){E=$id(E)}if(E==null){return }this.ele=E;this.funcOver=A;this.funcOut=D;if(B){this.delay=B}var F=Function.createDelegate(this,this.hoverOver);var C=Function.createDelegate(this,this.hoverOut);Sd.Common.addEvent(this.ele,"mouseover",F,this.ele.id+"Hover_MouseOver");Sd.Common.addEvent(this.ele,"mouseout",C,this.ele.id+"Hover_MouseOut")},hoverOver:function(){this.clearTimeout();this.over=true;var A=Function.createDelegate(this,this.fireOver);this.overHandler=window.setTimeout(A,this.delay)},fireOver:function(){if(this.over){this.funcOver.apply(this.ele);var A=Function.createDelegate(this,this.fireOut);this.timeoutFunc=window.setTimeout(A,this.activityDelay)}},hoverOut:function(){this.open=false;if(this.overHandler){window.clearTimeout(this.overHandler)}var A=Function.createDelegate(this,this.fireOut);this.overHandler=window.setTimeout(A,this.delay)},fireOut:function(){if(this.overHandler){window.clearTimeout(this.overHandler)}this.overHandler=0;this.funcOut.apply(this.ele)},clearTimeout:function(){if(this.overHandler){this.overHandler=window.clearTimeout(this.overHandler)}if(this.timeoutFunc){window.clearTimeout(this.timeoutFunc)}},destroy:function(){this.clearTimeout();Sd.Common.removeEvent(this.ele,"mouseover",this.ele.id+"Hover_MouseOver");Sd.Common.removeEvent(this.ele,"mouseout",this.ele.id+"Hover_MouseOut")}};Sd.Effects.fadeOut=function(B,C,D,A){return Sd.Effects.perform(B,{opacity:"hide"},C,"linear",D,{hideElement:A})};Sd.Effects.fadeIn=function(B,C,D,A){return Sd.Effects.perform(B,{opacity:"show"},C,"linear",D,{showElement:A})};Sd.Effects.slideDown=function(A,B,C){return Sd.Effects.perform(A,{height:"show"},B,"linear",C)};Sd.Effects.slideUp=function(A,B,C){return Sd.Effects.perform(A,{height:"hide"},B,"linear",C)};Sd.Effects.slideShow=function(D,B){if(D&&D.constructor==String){D=$id(D)}var F=new Array();var C=B;for(var E in Sd.Effects.slideShow.defaults){if(C[E]==null){C[E]=Sd.Effects.slideShow.defaults[E]}}var A=D.firstChild;for(;A;A=A.nextSibling){if(A.nodeType==1&&(!D||A!=D)){F.push(A)}}if(C.pause){new Sd.Effects.Hover(D,function(){C.paused=1;clearTimeout(D.cycleTimeout);D.cycleTimeout=0},function(){C.paused=0;clearTimeout(D.cycleTimeout);D.cycleTimeout=0;if(C.timeout){D.cycleTimeout=setTimeout(function(){Sd.Effects.slideShow.perform(F,C,0)},C.timeout)}})}D.style.position="relative";if(C.width){D.style.width=C.width}if(C.height&&C.height!="auto"){D.style.height=C.height}for(i=0;i<F.length;i++){Sd.Effects.Style(F[i],"z-index",F.length-i);Sd.Effects.Style(F[i],"position","absolute");Sd.Effects.Style(F[i],"display","none")}Sd.Effects.Style(F[0],"display","block");var G;if(C.fxNext!=null&&C.fxPrev!=null){C.fxDiff=true;G=Sd.Effects.slideShow.transitions[C.fxNext]}else{G=Sd.Effects.slideShow.transitions[C.fx]}if(Sd.Effects.isFunction(G)){G(D,F,C)}C.cssBefore=C.cssBefore||{};C.animIn=C.animIn||{};C.animOut=C.animOut||{};for(prop in C.cssBefore){if(prop!=null){Sd.Effects.Style(F[0],prop,C.cssBefore[prop])}}for(prop in C.cssFirst){if(prop!=null){Sd.Effects.Style(F[0],prop,C.cssFirst[prop])}}if(C.timeout){if(C.speed.constructor==String){C.speed={slow:600,fast:200}[C.speed]||400}if(!C.sync){C.speed=C.speed/2}while((C.timeout-C.speed)<250){C.timeout+=C.speed}}if(C.easing){C.easeIn=C.easeOut=C.easing}if(!C.speedIn){C.speedIn=C.speed}if(!C.speedOut){C.speedOut=C.speed}C.nextSlide=C.random?(Math.floor(Math.random()*(F.length-1)))+1:1;C.currSlide=0;if(C.click&&!C.next){C.next=C.click}if(C.next){Sd.Common.addEvent($id(C.next),"mousedown",function(){return Sd.Effects.slideShow.advance(F,C,1)},D.id+"slideShowNext")}if(C.prev){Sd.Common.addEvent($id(C.prev),"mousedown",function(){return Sd.Effects.slideShow.advance(F,C,-1)},D.id+"slideShowPrev")}if(C.timeout){this.cycleTimeout=setTimeout(function(){Sd.Effects.slideShow.perform(F,C,0)},C.timeout+(C.delay||0))}};Sd.Effects.slideShow.advance=function(A,B,E){if(!B.isAnim&&!B.paused){B.isAnim=true;var D=A[0].parentNode,C=D.cycleTimeout;if(C){clearTimeout(C);D.cycleTimeout=0}B.nextSlide=B.currSlide+E;if(B.nextSlide<0){B.nextSlide=A.length-1}else{if(B.nextSlide>=A.length){B.nextSlide=0}}if(B.fxDiff){if(E==1){init=Sd.Effects.slideShow.transitions[B.fxNext]}else{init=Sd.Effects.slideShow.transitions[B.fxPrev]}if(Sd.Effects.isFunction(init)){init(D,$slides,B)}}Sd.Effects.slideShow.perform(A,B,1,function(){B.isAnim=false});return false}};Sd.Effects.slideShow.perform=function(G,A,C,H){var F=G[0].parentNode;var I=G[A.currSlide];var E=G[A.nextSlide];if(Sd.Effects.isFunction(A.before)){A.before(I,E,A)}if(C||!A.paused){if(A.autostop&&(--A.countdown==0)){return }if(A.nextSlide!=A.currSlide){for(prop in A.cssBefore){if(prop!=null){Sd.Effects.Style(E,prop,A.cssBefore[prop])}}var D=function(){Sd.Effects.perform(E,A.animIn,A.speedIn,A.easeIn,H)};Sd.Effects.perform(I,A.animOut,A.speedOut,A.easeOut,function(){if(!A.sync){D()}});if(A.sync){D()}}if(A.random){A.currSlide=A.nextSlide;while(A.nextSlide==A.currSlide){A.nextSlide=Math.floor(Math.random()*G.length)}}else{var B=(A.nextSlide+1)==G.length;A.nextSlide=B?0:A.nextSlide+1;A.currSlide=B?G.length-1:A.nextSlide-1}}if(A.timeout){clearTimeout(F.cycleTimeout);F.cycleTimeout=setTimeout(function(){Sd.Effects.slideShow.perform(G,A,0)},A.timeout)}};Sd.Effects.slideShow.transitions={scrollRight:function(B,C,A){Sd.Effects.Style(B,"overflow","hidden");A.before=function(F,D,E){E.cssBefore.left=0-F.offsetWidth+"px";E.cssBefore.display="block";E.animOut.left=F.offsetWidth};A.cssFirst={left:"0px"};A.animIn={left:0}},scrollLeft:function(B,C,A){Sd.Effects.Style(B,"overflow","hidden");A.before=function(F,D,E){E.cssBefore.left=F.offsetWidth+"px";E.cssBefore.display="block";E.animOut.left=0-F.offsetWidth};A.cssFirst={left:"0px"};A.animIn={left:0}},fade:function(B,C,A){Sd.Effects.Style(B,"overflow","hidden");A.before=function(F,D,E){if(Sd.Common.Browser.ie){F.style.filter="alpha(opacity=100)";F.style.zoom=1}E.cssBefore.display="block";Sd.Effects.perform(F,{opacity:1},E.speed)};A.animIn={opacity:1};A.animOut={opacity:0};A.cssAfter={display:"none"}}};Sd.Effects.slideShow.defaults={fx:"fade",timeout:4000,speed:1000,speedIn:null,speedOut:null,next:null,prev:null,pager:null,before:null,after:null,easing:"linear",easeIn:null,easeOut:null,animIn:null,animOut:null,cssBefore:null,cssAfter:null,height:"auto",sync:1,fit:0,pause:0,autostop:0,delay:0,isAnim:0,fxNext:null,fxPrev:null,fxDiff:0};