var photoNum=photoArray.length;var counter=0;var currentheight=photoArray[counter][2];var currentwidth=photoArray[counter][1];var currentcaption=photoArray[counter][3];var speed=500;var transition_busy=0;function prevPhoto(number){if(transition_busy==0){if(number==null){counter--}else{counter=(number-1)};if(counter<0){counter=photoNum-1};loadPhoto(counter);}}
function nextPhoto(number){if(transition_busy==0){if(number==null){counter++}else{counter=(number-1)};if(counter==photoNum){counter=0};loadPhoto(counter);}}
function loadPhoto(){if(document.getElementById('mooshow_navigation')){navigation();}
hide_elements();document.getElementById('mooshow_loading').style.display='inline';imgPreloader=new Image();imgPreloader.onload=function(){document.getElementById('mooshow_loading').style.display='none';new Fx.Style('mooshow_image','opacity').set(0);resize();}
imgPreloader.src=photoArray[counter][0];}
function resize(){currentwidth=document.getElementById('mooshow_image').width;currentheight=document.getElementById('mooshow_image').height;resizeContatinerHeight.start(currentheight,photoArray[counter][2]);resizeContatinerWidth.start(currentwidth,photoArray[counter][1]);}
function hide_elements(){if(document.getElementById('mooshow_caption')){document.getElementById('mooshow_caption').innerHTML='&nbsp;';}
document.getElementById('mooshow_prev').style.display='none';document.getElementById('mooshow_next').style.display='none';}
function switch_photo(){document.getElementById('mooshow_image').src=photoArray[counter][0];document.getElementById('mooshow_image').alt=photoArray[counter][3];document.getElementById('mooshow_image').width=photoArray[counter][1];document.getElementById('mooshow_image').height=photoArray[counter][2];document.getElementById('mooshow_image').name=counter;if(document.getElementById('mooshow_caption')){caption();}
show_elements();}
function show_elements(){fade_in('mooshow_image',speed);if(document.getElementById('mooshow_caption')){fade_in('mooshow_caption',speed);}}
function show_nav_overlay(){document.getElementById('mooshow_prev').style.display='inline';document.getElementById('mooshow_next').style.display='inline';}
function navigation(){document.getElementById('mooshow_navigation').innerHTML='';var i=0
for(i=0;i<photoNum;i++){var content=document.getElementById('mooshow_navigation').innerHTML;if(i==counter){document.getElementById('mooshow_navigation').innerHTML=content+' <span id="mooshow_selected">'+(i+1)+'</span> ';}
else{document.getElementById('mooshow_navigation').innerHTML=content+' <a href=\'#'+(i+1)+'\' onclick=\"nextPhoto('+(i+1)+');\">'+(i+1)+'</a> ';}
if(i<photoNum-1){var content=document.getElementById('mooshow_navigation').innerHTML;document.getElementById('mooshow_navigation').innerHTML=content;}}
if(counter==photoNum-1){document.getElementById('nextphoto').href='#1'}else{document.getElementById('nextphoto').href='#'+(counter+2)};if(counter==0){document.getElementById('prevphoto').href='#'+photoNum}else{document.getElementById('prevphoto').href='#'+(counter)};}
function caption(){var caption;if(photoArray[counter][3]==''){caption='&nbsp;'}else{caption=photoArray[counter][3]}
document.getElementById('mooshow_caption').innerHTML=caption;}
window.onload=function(){transition_busy=1;resizeContatinerHeight=new Fx.Style($('mooshow_image_container'),'height',{'duration':speed,'wait':false,onComplete:function(){switch_photo();transition_busy=0;}});resizeContatinerWidth=new Fx.Style($('mooshow_container'),'width',{'duration':speed,'wait':false});transition_busy=0;nextPhoto(1);}
function fade_in(element,speed){new Fx.Style(element,'opacity',{'duration':speed,'wait':false,onComplete:function(){show_nav_overlay();}}).start(0,1);}