var gThumbWidth=24;var gThumbHeight=24;var gBehaviorsArray=[];var gSlideShowTimer=null;var gImageLoader=null;dsPhotos.addDataChangedObserver("initPhoto",{onDataChanged:function(dataSet,odcType)
{if(odcType!=Spry.Data.DataSet.ODC_DataChanged)
return;StopSlideShow();setTimeout(function(){ShowCurrentImage();},100);}});function SetMainImage(imgPath,width,height,tnID)
{var img=document.getElementById("mainImage");if(!img)
return;CancelBehavior("mainImage");Spry.Utils.SelectionManager.clearSelection("thumbnailSelection");if(tnID)
{setTimeout(function(){Spry.Utils.SelectionManager.select("thumbnailSelection",document.getElementById(tnID),"selectedThumbnail");},100);}
if(gImageLoader)
{gImageLoader.onload=function(){};gImageLoader=null;}
gBehaviorsArray["mainImage"]=new Spry.Effects.Opacity(img,0,{duration:400,steps:10,onComplete:function(b)
{gBehaviorsArray["mainImage"]=new Spry.Effects.Size(img.parentNode,width,height,{duration:400,steps:10,onComplete:function(b)
{gImageLoader=new Image();gImageLoader.onload=function()
{img.src=gImageLoader.src;gImageLoader=null;gBehaviorsArray["mainImage"]=new Spry.Effects.Opacity(img,1,{duration:400,steps:10,onComplete:function(b){gBehaviorsArray["mainImage"]=null;}});};gImageLoader.src=imgPath;}});}});}
function CancelBehavior(id)
{if(gBehaviorsArray[id])
{gBehaviorsArray[id].stop();gBehaviorsArray[id]=null;}}
function GrowThumbnail(img,width,height)
{Spry.Utils.addClassName(img,"inFocus");img.style.zIndex=150;var id=img.getAttribute("id");var twidth=Math.floor(width*.75);var theight=Math.floor(height*.75);var tx=(gThumbWidth-twidth)/2;var ty=(gThumbHeight-theight)/2;CancelBehavior(id);gBehaviorsArray[id]=new Spry.Effects.SizeAndPosition(img,tx,ty,twidth,theight,{duration:400,steps:10,onComplete:function(b){gBehaviorsArray[id]=null;}});}
function ShrinkThumbnail(img)
{Spry.Utils.addClassName(img,"inFocus");img.style.zIndex=1;var id=img.getAttribute("id");CancelBehavior(id);gBehaviorsArray[id]=new Spry.Effects.SizeAndPosition(img,0,0,gThumbWidth,gThumbHeight,{duration:400,steps:10,onComplete:function(b){gBehaviorsArray[id]=null;Spry.Utils.removeClassName(img,"inFocus");}});}
function ShowCurrentImage()
{var curRow=dsPhotos.getCurrentRow();SetMainImage(dsGalleries.getCurrentRow()["@base"]+"images/"+curRow["@path"],curRow["@width"],curRow["@height"],"tn"+curRow["ds_RowID"]);Spry.Data.updateRegion('imageInfo');Spry.Data.updateRegion('feedback');}
function AdvanceToNextImage(moveBackwards)
{var rows=dsPhotos.getData();var curRow=dsPhotos.getCurrentRow();if(rows.length<1)
return;for(var i=0;i<rows.length;i++)
{if(rows[i]==curRow)
{if(moveBackwards)
--i;else
++i;break;}}
if(!moveBackwards&&i>=rows.length)
i=0;else if(moveBackwards&&i<0)
i=rows.length-1;curRow=rows[i];dsPhotos.setCurrentRow(curRow["ds_RowID"]);ShowCurrentImage();}
function StartSlideShow()
{if(gSlideShowTimer)
clearInterval(gSlideShowTimer);gSlideShowTimer=setInterval(function(){AdvanceToNextImage(false);},6000);var playLabel=document.getElementById("playLabel");if(playLabel)
playLabel.firstChild.data="Pause";}
function StopSlideShow()
{if(gSlideShowTimer)
clearInterval(gSlideShowTimer);gSlideShowTimer=null;var playLabel=document.getElementById("playLabel");if(playLabel)
playLabel.firstChild.data="Play";}
function HandleThumbnailClick(id)
{StopSlideShow();dsPhotos.setCurrentRow(id);ShowCurrentImage();}