var SLIDESTATE_LOADING=0;var SLIDESTATE_LOADED=1;var SLIDESTATE_SHOWING=2;var SLIDESTATE_SHOWED=3;var SLIDESTATE_HIDING=4;var SLIDESTATE_HIDDEN=5;var THEME_NONE="none";var THEME_STACK="stack";var THEME_RANDOM_STACK="randomStack";var THEME_RANDOM_SLIDE="randomSlide";var ANIMATION_NONE="none";var ANIMATION_RANDOM="random";var ANIMATION_FADE="fade";var ANIMATION_ZOOM="zoom";var ANIMATION_LEFT_TO_RIGHT="leftToRight";var ANIMATION_RIGHT_TO_LEFT="rightToLeft";var ANIMATION_TOP_TO_BOTTOM="topToBottom";var ANIMATION_BOTTOM_TO_TOP="bottomToTop";var ANIMATION_ZOOM_HORIZONTAL="zoomHorizontal";var ANIMATION_ZOOM_VERTICAL="zoomVertical";var animations=new Array(ANIMATION_FADE,ANIMATION_ZOOM,ANIMATION_LEFT_TO_RIGHT,ANIMATION_RIGHT_TO_LEFT,ANIMATION_TOP_TO_BOTTOM,ANIMATION_BOTTOM_TO_TOP,ANIMATION_ZOOM_HORIZONTAL,ANIMATION_ZOOM_VERTICAL);SlideInfo=function(d,c,b,e,a){if(!d){return}this.imageUrl=b;this.thumbnailUrl=e;this.caption=a;this.slide=null;this.speedRatio=d.speedRatio;this.duration=d.duration;this.endDelay=d.endDelay;this.animationBegin=d.animationBegin;this.animationEnd=d.animationEnd;this.centerX=d.centerX;this.centerY=d.centerY;this.scale=d.scale;this.rotateAngle=d.rotateAngle;this.borderVisible=d.borderVisible;this.borderColor=d.borderColor;this.borderWidth=d.borderWidth;this.borderRadius=d.borderRadius;if(d.theme==THEME_RANDOM_STACK||d.theme==THEME_RANDOM_SLIDE){this.duration="0:0:3";this.endDelay=d.theme==THEME_RANDOM_STACK?"0:0:17":"0:0:0";this.centerX=Math.random()*0.5-0.25;this.centerY=Math.random()*0.5-0.25;this.scale=0.5;this.rotateAngle=Math.random()*20-10;this.borderVisible=true;this.borderColor="White";this.borderWidth=4;this.borderRadius=4}else{if(d.theme==THEME_STACK){this.duration="0:0:4";this.endDelay="0:0:12";this.centerX=Math.random()*0.12-0.06;this.centerY=Math.random()*0.12-0.06;this.scale=0.75;this.rotateAngle=Math.random()*20-10;this.borderVisible=true;this.borderColor="White";this.borderWidth=8;this.borderRadius=4}}};SlideInfo.prototype={getUrl:function(a){if(a){return this.baseUrl?this.baseUrl+a:a}return null},getImageUrl:function(){return this.getUrl(this.imageUrl)},getThumbnailUrl:function(){return this.getUrl(this.thumbnailUrl)},getRandomAnimation:function(){return animations[Math.floor(Math.random()*animations.length)]}};Slide=function(f,e,c,b,d){this.warningImageUrl=d;this.slideInfo=e;var g=this.getXaml(e);this.content=f.content.createFromXaml(g,true);this.slide=this.content.findName("slide");this.slideBorder=this.content.findName("slideBorder");this.slideImage=this.content.findName("slideImage");this.slideImageLoader=this.content.findName("slideImageLoader");this.storyboard=this.content.findName("storyboard");this.storyboardEnd=this.content.findName("storyboardEnd");this.rotate=this.content.findName("rotate");this.scale=this.content.findName("scale");var a=this.storyboardEnd.beginTime.seconds;this.storyboardEnd.beginTime=this.getTimespan(a/this.slideInfo.speedRatio);this.slideImageLoader.addEventListener("DownloadProgressChanged",Silverlight.createDelegate(this,this.slide_downloadProgressChanged));this.slideImageLoader.addEventListener("ImageFailed",Silverlight.createDelegate(this,this.slide_imageFailed));this.storyboard.addEventListener("Completed",Silverlight.createDelegate(this,this.storyboard_Completed));this.storyboardEnd.addEventListener("Completed",Silverlight.createDelegate(this,this.storyboardEnd_Completed));this.stateChanged=null;this.state=SLIDESTATE_LOADING;this.paused=false;this.resize(c,b)};Slide.prototype={slide_downloadProgressChanged:function(b,a){if(b.downloadProgress==1){if(b.width==0||b.height==0){this.timerId=window.setTimeout(Silverlight.createDelegate(this,this.slide_ontimer),50)}else{this.actualWidth=b.width;this.actualHeight=b.height;this.slideImage.source=this.slideImageLoader.source;this.onstateChanged(SLIDESTATE_LOADED);this.resize(this.width,this.height)}}else{this.onstateChanged(SLIDESTATE_LOADING,b.downloadProgress)}},slide_ontimer:function(){window.clearTimeout(this.timerId);if(this.slideImageLoader){this.slide_downloadProgressChanged(this.slideImageLoader,null)}},slide_imageFailed:function(b,a){if(!this.imageFailed){this.imageFailed=true;this.slideImageLoader.Source=this.warningImageUrl}else{this.onstateChanged(SLIDESTATE_LOADED)}},storyboard_Completed:function(b,a){this.onstateChanged(SLIDESTATE_SHOWED)},storyboardEnd_Completed:function(b,a){this.onstateChanged(SLIDESTATE_HIDDEN)},onstateChanged:function(b,a){this.state=b;if(this.stateChanged){this.stateChanged(this,b,a)}},show:function(){if(this.state!=SLIDESTATE_LOADING){this.slide.visibility="Visible";this.storyboardEnd.stop();this.storyboard.begin();this.onstateChanged(SLIDESTATE_SHOWING)}},hide:function(a){this.storyboard.stop();if(a){this.storyboardEnd.stop();this.onstateChanged(SLIDESTATE_HIDDEN)}else{this.storyboardEnd.begin();this.onstateChanged(SLIDESTATE_HIDING)}},pause:function(){if(!this.paused){this.paused=true;this.storyboard.pause();this.storyboardEnd.pause()}},resume:function(){if(this.paused){this.paused=false;this.storyboard.resume();this.storyboardEnd.resume()}},unload:function(){this.content=null;this.slide=null;this.slideBorder=null;this.slideImage=null;this.slideImageLoader=null;this.storyboard=null;this.storyboardEnd=null;this.scale=null;this.rotate=null},resize:function(b,a){this.width=b;this.height=a;if(this.state==SLIDESTATE_LOADING){return}this.slide.setValue("Canvas.Left",this.slideInfo.centerX*b);this.slide.setValue("Canvas.Top",this.slideInfo.centerY*a);this.slide.width=b;this.slide.height=a;var d=1/this.slideInfo.scale;var c;if(this.actualWidth/b<this.actualHeight/a){c=this.height/this.actualHeight;this.slideBorder.setValue("Canvas.Left",(this.width-this.actualWidth*c)/2-this.slideInfo.borderWidth*d);this.slideBorder.setValue("Canvas.Top",-this.slideInfo.borderWidth*d)}else{c=this.width/this.actualWidth;this.slideBorder.setValue("Canvas.Left",-this.slideInfo.borderWidth*d);this.slideBorder.setValue("Canvas.Top",(this.height-this.actualHeight*c)/2-this.slideInfo.borderWidth*d)}this.slideBorder.height=(this.actualHeight*c)+(2*this.slideInfo.borderWidth*d);this.slideBorder.width=(this.actualWidth*c)+(2*this.slideInfo.borderWidth*d);if(this.imageFailed){this.slideImage.width=this.imageFailed?48*1/this.slideInfo.scale:b;this.slideImage.height=this.imageFailed?48*1/this.slideInfo.scale:a;this.slideImage.setValue("Canvas.Left",(this.slide.width-this.slideImage.width)/2);this.slideImage.setValue("Canvas.Top",(this.slide.height-this.slideImage.height)/2)}else{this.slideImage.width=b;this.slideImage.height=a}this.scale.scaleX=this.slideInfo.scale;this.scale.scaleY=this.slideInfo.scale;this.scale.centerX=this.slide.width/2;this.scale.centerY=this.slide.height/2;this.rotate.centerX=this.slide.width/2;this.rotate.centerY=this.slide.height/2;if(this.slideInfo.animationBegin==ANIMATION_LEFT_TO_RIGHT){this.resizeAnimation("beginTranslateX","from",-b)}else{if(this.slideInfo.animationBegin==ANIMATION_RIGHT_TO_LEFT){this.resizeAnimation("beginTranslateX","from",b)}}if(this.slideInfo.animationBegin==ANIMATION_TOP_TO_BOTTOM){this.resizeAnimation("beginTranslateY","from",-a)}else{if(this.slideInfo.animationBegin==ANIMATION_BOTTOM_TO_TOP){this.resizeAnimation("beginTranslateY","from",a)}}if(this.slideInfo.animationEnd==ANIMATION_LEFT_TO_RIGHT){this.resizeAnimation("endTranslateX","to",b)}else{if(this.slideInfo.animationEnd==ANIMATION_RIGHT_TO_LEFT){this.resizeAnimation("endTranslateX","to",-b)}}if(this.slideInfo.animationEnd==ANIMATION_TOP_TO_BOTTOM){this.resizeAnimation("endTranslateY","to",a)}else{if(this.slideInfo.animationEnd==ANIMATION_BOTTOM_TO_TOP){this.resizeAnimation("endTranslateY","to",-a)}}},resizeAnimation:function(a,d,c){var b=this.content.findName(a);if(b){b.setValue(d,c)}},getTimespan:function(e){var f=Math.floor(e/86400);var b=Math.floor(e/3600)%24;var d=Math.floor(e/60)%60;var c=""+(e-Math.floor(e));var a=f+"."+b+":"+d+":"+Math.floor(e%60)+"."+c.substr(2,3);return a},getXaml:function(c){var b='<Storyboard Name="storyboard" Duration="'+c.duration+'" SpeedRatio="'+c.speedRatio+'">';if(c.animationBegin==ANIMATION_FADE){b+='  <DoubleAnimation Storyboard.TargetName="slide" Storyboard.TargetProperty="Opacity" From="0.0" To="1.0" Duration="0:0:1"/>'}else{if(c.animationBegin==ANIMATION_ZOOM){b+='  <DoubleAnimation Storyboard.TargetName="scale" Storyboard.TargetProperty="ScaleX" From="0.0" To="'+c.scale+'" Duration="0:0:1"/>  <DoubleAnimation Storyboard.TargetName="scale" Storyboard.TargetProperty="ScaleY" From="0.0" To="'+c.scale+'" Duration="0:0:1"/>'}else{if(c.animationBegin==ANIMATION_LEFT_TO_RIGHT||c.animationBegin==ANIMATION_RIGHT_TO_LEFT||c.animationBegin==ANIMATION_TOP_TO_BOTTOM||c.animationBegin==ANIMATION_BOTTOM_TO_TOP){b+='  <DoubleAnimation Name="beginTranslateX" Storyboard.TargetName="translate" Storyboard.TargetProperty="X" Duration="0:0:1"/>  <DoubleAnimation Name="beginTranslateY" Storyboard.TargetName="translate" Storyboard.TargetProperty="Y" Duration="0:0:1"/>'}else{if(c.animationBegin==ANIMATION_ZOOM_HORIZONTAL){b+='  <DoubleAnimation Storyboard.TargetName="scale" Storyboard.TargetProperty="ScaleX" From="0.0" To="'+c.scale+'" Duration="0:0:1"/>'}else{if(c.animationBegin==ANIMATION_ZOOM_VERTICAL){b+='  <DoubleAnimation Storyboard.TargetName="scale" Storyboard.TargetProperty="ScaleY" From="0.0" To="'+c.scale+'" Duration="0:0:1"/>'}}}}}b+='</Storyboard><Storyboard Name="storyboardEnd" BeginTime="'+c.endDelay+'" SpeedRatio="'+c.speedRatio+'">';if(c.animationEnd==ANIMATION_FADE){b+='  <DoubleAnimation Storyboard.TargetName="slide" Storyboard.TargetProperty="Opacity" To="0.0" Duration="0:0:1"/>'}else{if(c.animationEnd==ANIMATION_ZOOM){b+='  <DoubleAnimation Storyboard.TargetName="scale" Storyboard.TargetProperty="ScaleX" To="0.0" Duration="0:0:1"/>  <DoubleAnimation Storyboard.TargetName="scale" Storyboard.TargetProperty="ScaleY" To="0.0" Duration="0:0:1"/>'}else{if(c.animationEnd==ANIMATION_LEFT_TO_RIGHT||c.animationEnd==ANIMATION_RIGHT_TO_LEFT||c.animationEnd==ANIMATION_TOP_TO_BOTTOM||c.animationEnd==ANIMATION_BOTTOM_TO_TOP){b+='  <DoubleAnimation Name="endTranslateX" Storyboard.TargetName="translate" Storyboard.TargetProperty="X" Duration="0:0:1"/>  <DoubleAnimation Name="endTranslateY" Storyboard.TargetName="translate" Storyboard.TargetProperty="Y" Duration="0:0:1"/>'}else{if(c.animationEnd==ANIMATION_ZOOM_HORIZONTAL){b+='  <DoubleAnimation Storyboard.TargetName="scale" Storyboard.TargetProperty="ScaleX" From="'+c.scale+'" To="0.0" Duration="0:0:1"/>'}else{if(c.animationEnd==ANIMATION_ZOOM_VERTICAL){b+='  <DoubleAnimation Storyboard.TargetName="scale" Storyboard.TargetProperty="ScaleY" From="'+c.scale+'" To="0.0" Duration="0:0:1"/>'}}}}}b+="</Storyboard>";var a=1/this.slideInfo.scale;var d='<Canvas Name="content">  <Canvas Name="slide" Visibility="Collapsed">    <Canvas.RenderTransform>      <TransformGroup>        <ScaleTransform Name="scale" ScaleX="'+c.scale+'" ScaleY="'+c.scale+'" />        <RotateTransform Name="rotate" Angle="'+c.rotateAngle+'" />        <TranslateTransform Name="translate" />      </TransformGroup>    </Canvas.RenderTransform>    <Canvas.Resources>'+b+'    </Canvas.Resources>    <Rectangle Name="slideBorder" Visibility="'+(c.borderVisible?"Visible":"Collapsed")+'"         Fill="'+c.borderColor+'" Stroke="Black" StrokeThickness="'+a+'"         RadiusX="'+(c.borderRadius*a)+'" RadiusY="'+(c.borderRadius*a)+'">    </Rectangle>    <Image Name="slideImage" Stretch="Uniform" />  </Canvas>  <Image Name="slideImageLoader" Canvas.Top="-10000" Source="'+c.getImageUrl()+'" /></Canvas>';return d}};