dojo.require("dojo.html.display");
dojo.require("dojo.lang.common");
dojo.require("dojo.lfx.Animation");
dojo.require("dojo.lfx.html");
var activePhotoIndex=-1;
var activePhotoPage=0;
var photosPerPage=15;
function thumbnailMouseOver(_1){
dojo.html.addClass(_1,"thumbnail_hover");
}
function thumbnailMouseOut(_2){
dojo.html.removeClass(_2,"thumbnail_hover");
}
function getPhotoIndexFromNode(_3){
var _4=Number(_3.id.substring("thumbnail_".length));
return (activePhotoPage*photosPerPage)+_4;
}
function thumbnailOnClick(_5){
stopSlideshow();
var _6=getPhotoIndexFromNode(_5);
showImage(_6);
}
function thumbnailPageControlOnClick(_7){
if(_7==activePhotoPage){
return;
}
stopSlideshow();
showThumbnailPage(_7);
}
function showPreviousImage(){
var _8=(activePhotoIndex==0?photos.length-1:activePhotoIndex-1);
showImage(_8);
}
function showNextImage(){
var _9=(activePhotoIndex==photos.length-1?0:activePhotoIndex+1);
showImage(_9);
}
function showImage(_a){
if(!dojo.lang.isNumber(_a)){
return;
}
_a=Number(_a);
if(_a==activePhotoIndex){
return;
}
if(_a<0||_a>=photos.length){
return;
}
showFullSizeImage(_a,function(){
selectThumbnail(_a);
});
}
function showFullSizeImage(_b,_c){
viewImage(_b,_c);
}
function selectThumbnail(_d){
if(activePhotoPage!=getPageFromPhotoIndex(_d)){
showThumbnailPage(getPageFromPhotoIndex(_d));
}
setThumbnailInactive(activePhotoIndex);
setThumbnailActive(_d);
activePhotoIndex=_d;
}
function getPageFromPhotoIndex(_e){
return Math.floor(_e/photosPerPage);
}
function setThumbnailActive(_f){
var _10=getThumbnailControlIndexFromPhotoIndex(_f);
if(_10!=null){
dojo.html.addClass("thumbnail_"+_10,"thumbnail_active");
}
}
function setThumbnailInactive(_11){
var _12=getThumbnailControlIndexFromPhotoIndex(_11);
if(_12!=null){
dojo.html.removeClass("thumbnail_"+_12,"thumbnail_active");
}
}
function setThumbnailHover(_13){
var _14=getThumbnailControlIndexFromPhotoIndex(_13);
if(_14!=null){
dojo.html.addClass("thumbnail_"+_14,"thumbnail_hover");
}
}
function setThumbnailNoHover(_15){
var _16=getThumbnailControlIndexFromPhotoIndex(_15);
if(_16!=null){
dojo.html.removeClass("thumbnail_"+_16,"thumbnail_hover");
}
}
function getThumbnailControlIndexFromPhotoIndex(_17){
if(_17<(activePhotoPage*photosPerPage)||_17>=photos.length||_17>=((activePhotoPage+1)*photosPerPage)){
return null;
}
return _17-(activePhotoPage*photosPerPage);
}
var slideshowInterval=null;
function toggleSlideshow(){
if(slideshowInterval==null){
startSlideshow();
}else{
stopSlideshow();
}
}
function startSlideshow(){
if(slideshowInterval!=null){
return;
}
showNextImage();
slideshowInterval=setInterval("showNextImage();",3000);
dojo.html.hide("slideshow_play");
dojo.html.show("slideshow_stop");
}
function stopSlideshow(){
if(slideshowInterval==null){
return;
}
clearInterval(slideshowInterval);
slideshowInterval=null;
dojo.html.hide("slideshow_stop");
dojo.html.show("slideshow_play");
}
function showThumbnailPage(_18){
if(isPhotoOnPage(activePhotoIndex,activePhotoPage)){
setThumbnailInactive(activePhotoIndex);
}
for(var _19=0;_19<photosPerPage;_19++){
var _1a=(_18*photosPerPage)+_19;
if(_1a<photos.length&&_1a>=0){
setPhotoForThumbnailControl(_1a,_19);
}else{
hideThumbnailControl(_1a-(_18*photosPerPage));
}
}
dojo.html.removeClass("thumbnail_page_control_"+activePhotoPage,"thumbnail_page_control_active");
activePhotoPage=_18;
dojo.html.addClass("thumbnail_page_control_"+activePhotoPage,"thumbnail_page_control_active");
if(isPhotoOnPage(activePhotoIndex,activePhotoPage)){
setThumbnailActive(activePhotoIndex);
}
}
function isPhotoOnPage(_1b,_1c){
return ((_1b>=_1c*photosPerPage)&&(_1b<(_1c+1)*photosPerPage)&&_1b<photos.length&&_1b>=0);
}
function setPhotoForThumbnailControl(_1d,_1e){
var _1f=dojo.byId("thumbnail_"+_1e);
if(_1f){
_1f.style.background="url("+g_imageServerUrl+"/images/4_0/clear.gif) no-repeat center center";
_1f.style.background="url("+photos[_1d].thumbnail+") no-repeat center center";
}
}
function hideThumbnailControl(_20){
var _21=dojo.byId("thumbnail_"+_20);
if(_21){
_21.style.background="url("+g_imageServerUrl+"/images/4_0/clear.gif) no-repeat center center";
}
}
var activeDiv=1;
var loadingImage=false;
function viewImage(_22,_23){
if(loadingImage&&!imageIsProbablyNotLoading()){
return false;
}
if(_22<0||_22>=photos.length){
return;
}
var _24=photos[_22].full;
loadingImage=true;
var _25=activeDiv;
activeDiv=1-activeDiv;
var _26=document.createElement("img");
_26.onload=function(){
endImageDisplay(this,_25,416,312,250);
if(_23){
_23();
}
};
_26.src=_24;
var _27=document.getElementById("big_photo_"+_25);
while(_27.firstChild){
_27.removeChild(_27.firstChild);
}
_27.appendChild(_26);
return true;
}
function endImageDisplay(_28,_29,_2a,_2b,_2c){
var _2d=_28.width;
var _2e=_28.height;
var _2f=Math.min(_2a/_2d,_2b/_2e);
var _30=Math.floor(Math.min(_2f,1)*_2d);
var _31=Math.floor(Math.min(_2f,1)*_2e);
_28.style.width=_30+"px";
_28.style.height=_31+"px";
_28.style.top=Math.floor((_2b-_31)/2)+"px";
_28.style.left=Math.floor((_2a-_30)/2)+"px";
var _32=dojo.byId("big_photo_"+(1-_29));
var _33=dojo.byId("big_photo_"+_29);
if(_2c>0){
new dojo.lfx.Combine(dojo.lfx.propertyAnimation([_33],[{property:"opacity",end:1}],_2c,dojo.lfx.easeInOut),dojo.lfx.propertyAnimation([_32],[{property:"opacity",end:0}],_2c,dojo.lfx.easeInOut)).play();
}else{
dojo.html.setOpacity(_33,1);
dojo.html.setOpacity(_32,0);
}
lastImageLoad=new Date();
loadingImage=false;
}
var lastImageLoad=new Date();
function imageIsProbablyNotLoading(){
var now=new Date();
if((now.getTime()-lastImageLoad.getTime())>5000){
lastImageLoad=now;
return true;
}
return false;
}

