var currentpos=0;var currentthumbpos=0;var moveamount=570;var thumbnailnum;var maxthumbvisible=15;var moving=false;var finishedsizing=0;var preloadimg="no"
var myloadedimage=new Array();myloadedimage[0]=1;var imggallery=new Array()
var firstimagestart=1;var nextorprev=0;var fadeout=1;var queryString=window.location.href.substr(window.location.href.indexOf("?")+12);if(queryString.length==2){var firstImage='gallery/images/'+queryString.replace(/[A-Za-z$-]/g,"")+'.jpg';var temp_imgid=queryString.replace(/[A-Za-z$-]/g,"");if(temp_imgid<10){var current_imgid=temp_imgid.substr(1)-1;}
else{var current_imgid=temp_imgid;}}else{var firstImage='gallery/images/01.jpg';var current_imgid=0;}
var allPageTags=new Array();function revealSmoothLink(idName,visibility)
{var cssRule;cssRule=document.getElementById(idName);if(cssRule)
{cssRule.style.visibility=visibility;}}
function alterlinks(theClass){var allPageTags=document.getElementsByTagName("*");for(i=0;i<allPageTags.length;i++){if(allPageTags[i].className==theClass){allPageTags[i].style.visibility='hidden';}}}
function loadinfo(){if(fadeout==0){var fademe=new Fx.Style('iptc_info','opacity',{duration:transspeed});fademe.set(0);fadeout=1;}else{var fademe=new Fx.Style('iptc_info','opacity',{duration:transspeed});fademe.set(.75,0);fadeout=0;}}
function areweready(loadarea,imgindex,img_id){if(finishedsizing++){modifyimage(loadarea,imgindex,img_id);finishedsizing=0;}}
function modifyimage(loadarea,imgindex,img_id){loadinfo();function loadimagenow(){if(document.getElementById){if(current_imgid!=img_id){var imgobj=document.getElementById(loadarea);iptch=document.getElementById('iptc_info');var photonum=document.getElementById('photocount')
var smoothlinkstyles=document.getElementById('smoothlinkstyles')
var phototitle=document.getElementById('imgtitle')
imgobj.innerHTML=returnimgcode(imggallery[imgindex]);iptch.innerHTML=returniptc(imggallery[imgindex]);photonum.innerHTML=(Number(imgindex)+1)+" of "+imggallery.length+" Photos";

	alterlinks('imagelinks');
					if (Number(imgindex) < 9)  {
					
					revealSmoothLink("image0" + (Number(imgindex)+1),'visible');
					}
					else {
					
					revealSmoothLink("image" + (Number(imgindex)+1),'visible');
					}


phototitle.innerHTML="<strong>"+tempgallery[img_id][4]+"</strong> "+tempgallery[img_id][7];initImage(loadarea);current_imgid=img_id;myloadedimage[imgindex]=1;}}
return false}
if(myloadedimage[imgindex]==null){new Asset.image(imggallery[imgindex][0],{onload:loadimagenow});}else{loadimagenow();}}
function returnimgcode(theimg){var imghtml=""
if(theimg[1]!="")
imghtml=''
imghtml+='<img src="'+theimg[0]+'" border="0" id="'+theimg[8]+'" />'
if(theimg[1]!="")
imghtml+=''
return imghtml}
function returniptc(theimg){if(theimg[4].length>=1){title='<dt>Title</dt>   <dd>'+' '+theimg[4]+'</dd>';}
else{title='';}
if(theimg[5].length>=1){locat='<dt>Location </dt>   <dd>'+' '+theimg[5]+'</dd>';}
else{locat='';}
if(theimg[6].length>=1){woodType='<dt>Type of wood </dt>   <dd>'+' '+theimg[6]+'</dd>';}
else{woodType='';}
if(theimg[7].length>=1){dimensions='<dt>Dimensions </dt>   <dd>'+' '+theimg[7]+'</dd>';}
else{dimensions='';}
var iptchtml=''+'<div class=\'iptc_left\'><dl>'+
title+
locat+
woodType+
dimensions+'</div>';return iptchtml}
function initImage(imageId){var fader=new Fx.Style(imageId,'opacity',{duration:fadespeed});fader.set(0);fader.start(0,1);var titlefade=new Fx.Style('imgtitle','opacity',{duration:transspeed});titlefade.set(0);titlefade.start(0,1);var fadeiptc=new Fx.Style('iptc_btn','opacity',{duration:transspeed});fadeiptc.set(0);fadeiptc.start(0,1);if(fadeout==0){var fademe=new Fx.Style('iptc_info','opacity',{duration:transspeed});fademe.set(0);fadeout=0;}else{var fademe=new Fx.Style('iptc_info','opacity',{duration:transspeed});fademe.start(0,1);fadeout=1}}
function checkbutton(mynum){var thumbBoxWidth=((tempgallery.length/3)*102);if(mynum==0){mm_shl('back','hidden');mm_shl('more','visible');}else if(mynum<thumbBoxWidth-moveamount){mm_shl('back','visible');mm_shl('more','visible');}else{mm_shl('back','visible');mm_shl('more','hidden');}}
function checknext(mynum){thumbmax=(Number(thumbnailnum)-1);if(mynum<1){mm_shl('prev','hidden');mm_shl('next','visible');}else if(mynum<thumbmax){mm_shl('prev','visible');mm_shl('next','visible');}else{mm_shl('prev','visible');mm_shl('next','hidden');}}
function mm_shl(){var obj,args=arguments;if((obj=MM_findObj(args[0]))!=null){if(obj.style){obj=obj.style;}
obj.visibility=args[1];}}
function MM_findObj(n,d){var p,i,x;if(!d)d=document;if((p=n.indexOf("?"))>0&&parent.frames.length){d=parent.frames[n.substring(p+1)].document;n=n.substring(0,p);}
if(!(x=d[n])&&d.all)x=d.all[n];for(i=0;!x&&i<d.forms.length;i++)x=d.forms[i][n];for(i=0;!x&&d.layers&&i<d.layers.length;i++)x=MM_findObj(n,d.layers[i].document);if(!x&&d.getElementById)x=d.getElementById(n);return x;}
function addposition(addwidth){if(!moving){if(addwidth=="minus"){currentpos-=moveamount;}else if(addwidth=="plus"){currentpos+=moveamount;}}
return currentpos;}
function movethumbs(way){if(way=='plus'){move=(currentthumbpos+moveamount);var movethumbs=new Fx.Styles('thumbgall',{duration:transspeed,transition:Fx.Transitions.quadOut});movethumbs.start({left:[currentthumbpos,move]});currentthumbpos+=moveamount;}else if(way=='minus'){move=(currentthumbpos-moveamount);var movethumbs=new Fx.Styles('thumbgall',{duration:transspeed,transition:Fx.Transitions.quadOut});movethumbs.start({left:[currentthumbpos,move]});currentthumbpos-=moveamount;}}
function MM_openBrWindow(theURL,winName,features){window.open(theURL,winName,features);}
var thumbopen=0
function thumbs(){var resizethumb=new Fx.Styles('thumbhide',{duration:transspeed,transition:Fx.Transitions.quadOut});var movethumbs=new Fx.Styles('thumbbox',{duration:transspeed,transition:Fx.Transitions.quadOut});if(thumbopen==1){resizethumb.start({'height':119});movethumbs.start({'top':[-120,0]});thumbopen=0}else{resizethumb.start({'height':0});movethumbs.start({'top':[0,-120]});thumbopen=1}}
function initGallery(tempgallery,count,first_id,startwidth,startheight){imggallery=tempgallery;if(preloadimg=="yes"){for(x=0;x<imggallery.length;x++){var myimage=new Image()
myimage.src=imggallery[x][0]}}
thumbnailnum=imggallery.length;current_imgid=first_id;currentwidth=startwidth;currentheight=startheight;window.addEvent('load',function(){if(thumbnailnum>maxthumbvisible){lefthtml="<div id='leftmore'><ul><li><a class='fixPNG' href=\"javascript:checkbutton(addposition('minus'));movethumbs('plus');\">prev |</a></li></ul></div>";righthtml="<div id='rightmore'><ul><li><a class='fixPNG' href=\"javascript:checkbutton(addposition('plus'));movethumbs('minus');\">next</a></li></ul></div>";$('back').setHTML(lefthtml);$('more').setHTML(righthtml);}
var setloadersize=new Fx.Styles('main_image_wrapper',{duration:transspeed,onComplete:function(){loadfirstimage(currentwidth,currentheight)}});setloadersize.start({'width':imggallery[0][1],'height':imggallery[0][2]});});}
window.addEvent('domready',function(){initGallery(tempgallery,tempgallery.length,tempgallery[0][8],tempgallery[0][1],tempgallery[0][2],0);});function getstarted(width,height,loadarea,imgindex,img_id,current_imgid){checknext(img_id);if(current_imgid!=img_id){if(firstimagestart==1){currentwidth=firstimagewidth;currentheight=firstimageheight;firstimagestart=0;}
if(nextorprev==1){currentwidth=cwidth;currentheight=cheight;nextorprev=0;}
var resizeDivHeight=new Fx.Styles('main_image_wrapper',{duration:transspeed,onComplete:function(){modifyimage(loadarea,imgindex,img_id);currentheight=height;currentwidth=width;}});var fader=new Fx.Style('imgloader','opacity',{duration:fadespeed,onComplete:function(){resizeDivHeight.start({'height':[currentheight,height],'width':[currentwidth,width]});}});fader.start(1,0);var fadeiptc=new Fx.Style('iptc_btn','opacity',{duration:transspeed});fadeiptc.set(0);var titlefade=new Fx.Style('imgtitle','opacity',{duration:transspeed});titlefade.set(0);fadeout=0
if(fadeout==0){var fademe=new Fx.Style('iptc_info','opacity',{duration:transspeed});fademe.set(0);fadeout=0;}else{var fademe=new Fx.Style('iptc_info','opacity',{duration:transspeed});fademe.start(1,0);fadeout=0}}}
function thumbsfade(){var fade=0,allthumbs=document.getElementById("thumbgall").style,ms=(allthumbs.opacity==0)?0:1,pace=setInterval(Fade,20);function Fade()
{if(fade<100){fade+=5;if(ms)allthumbs.filter="alpha(opacity="+fade+")";else allthumbs.opacity=(fade/100)}else
clearInterval(pace)}};function loadfirstimage(currentwidth,currentheight){thumbsfade();var fadefirst=new Fx.Style('imgloader','opacity',{duration:fadespeed});fadefirst.set(0);var firsttitlefade=new Fx.Style('imgtitle','opacity',{duration:transspeed});firsttitlefade.set(0);function setfirstimage(){var newHTML="<img src='"+firstImage+"' />";$('imgloader').setHTML(newHTML);var firsttitle=document.getElementById('imgtitle');firsttitle.innerHTML="<strong>"+tempgallery[0][4]+"</strong> "+tempgallery[0][7];fadefirst.start(0,1);currentheight=imggallery[0][2];currentwidth=imggallery[0][1];}
new Asset.image(imggallery[0][0],{onload:setfirstimage});}
function nextimage(current_imgid){newimgid=Number(current_imgid)+1;newwidth=imggallery[newimgid][1]
newheight=imggallery[newimgid][2]
newimgindex=imggallery[newimgid][8]
newimgid=imggallery[newimgid][8]
cwidth=imggallery[current_imgid][1]
cheight=imggallery[current_imgid][2]
checknext(newimgid);nextorprev=1;getstarted(Number(newwidth),Number(newheight),'imgloader',Number(newimgindex),Number(newimgid),Number(current_imgid),Number(cwidth),Number(cheight))}
function previmage(current_imgid){newimgid=Number(current_imgid)-1;newwidth=imggallery[newimgid][1]
newheight=imggallery[newimgid][2]
newimgindex=imggallery[newimgid][8]
newimgid=imggallery[newimgid][8]
cwidth=imggallery[current_imgid][1]
cheight=imggallery[current_imgid][2]
checknext(newimgid);nextorprev=1;getstarted(Number(newwidth),Number(newheight),'imgloader',Number(newimgindex),Number(newimgid),Number(current_imgid),Number(cwidth),Number(cheight))}
var Roebox={init:function(options){var j=0;for(var i=0;i<tempgallery.length;i++){var smoothboxdiv=document.createElement("div");smoothboxdiv.setAttribute("className","imagelinks");smoothboxdiv.setAttribute("class","imagelinks");var smoothboxlink=document.createElement("a");smoothboxlink.setAttribute("className","smoothbox");smoothboxlink.setAttribute("class","smoothbox");smoothboxlink.setAttribute("rel","roebox");var magnifyimage=document.createElement("img");magnifyimage.setAttribute("src","gallery/rsrc/magnify.png");magnifyimage.setAttribute("className","fixPNG");magnifyimage.setAttribute("class","fixPNG");smoothboxlink.appendChild(magnifyimage);if(i<9){smoothboxdiv.setAttribute("id","image"+j+(i+1));smoothboxlink.setAttribute('href','gallery\/imagesbig\/'+j+(i+1)+'.jpg');document.getElementById('linkList').appendChild(smoothboxdiv);document.getElementById("image"+j+(i+1)).appendChild(smoothboxlink);}
else{smoothboxdiv.setAttribute("id","image"+(i+1));smoothboxlink.setAttribute('href','gallery\/imagesbig\/'+(i+1)+'.jpg');document.getElementById('linkList').appendChild(smoothboxdiv);document.getElementById("image"+(i+1)).appendChild(smoothboxlink);}}
this.options=Object.extend({resizeDuration:300,resizeTransition:Fx.Transitions.sineInOut,initialWidth:100,initialHeight:100,animateCaption:true},options||{});this.anchors=[];$each(document.links,function(el){if(el.rel&&el.rel.test(/^roebox/i)){el.onclick=this.click.pass(el,this);this.anchors.push(el);}},this);this.eventKeyDown=this.keyboardListener.bindAsEventListener(this);this.eventPosition=this.position.bind(this);this.overlay=new Element('div').setProperty('id','lbOverlay').injectInside(document.body);this.center=new Element('div').setProperty('id','lbCenter').setStyles({width:this.options.initialWidth+'px',height:this.options.initialHeight+'px',marginLeft:'-'+(this.options.initialWidth/2)+'px',display:'none'}).injectInside(document.body);this.image=new Element('div').setProperty('id','lbImage').injectInside(this.center);this.bottomContainer=new Element('div').setProperty('id','lbBottomContainer').setStyle('display','none').injectInside(document.body);this.bottom=new Element('div').setProperty('id','lbBottom').injectInside(this.bottomContainer);new Element('a').setText('CLOSE').setProperties({id:'lbCloseLink',href:'#'}).injectInside(this.bottom).onclick=this.overlay.onclick=this.close.bind(this);this.caption=new Element('div').setProperty('id','lbCaption').injectInside(this.bottom);this.prevLink=new Element('a').setProperties({id:'lbPrevLink',href:'#'}).setStyle('display','none').injectInside(this.bottom);this.number=new Element('div').setProperty('id','lbNumber').injectInside(this.bottom);this.nextLink=this.prevLink.clone().setProperty('id','lbNextLink').injectInside(this.bottom);this.prevLink.onclick=this.previous.bind(this);this.nextLink.onclick=this.next.bind(this);var nextEffect=this.nextEffect.bind(this);this.fx={overlay:this.overlay.effect('opacity',{duration:500}).hide(),resize:this.center.effects({duration:this.options.resizeDuration,transition:this.options.resizeTransition,onComplete:nextEffect}),image:this.image.effect('opacity',{duration:500,onComplete:nextEffect}),bottom:this.bottom.effect('margin-top',{duration:400,onComplete:nextEffect})};this.preloadPrev=new Image();this.preloadNext=new Image();},click:function(link){if(link.rel.length==8)return this.show(link.href,link.title);var j,imageNum,images=[];this.anchors.each(function(el){if(el.rel==link.rel){for(j=0;j<images.length;j++)if(images[j][0]==el.href)break;if(j==images.length){images.push([el.href,el.title]);if(el.href==link.href)imageNum=j;}}},this);return this.open(images,imageNum);},show:function(url,title){return this.open([[url,title]],0);},open:function(images,imageNum){this.images=images;this.position();this.setup(true);this.top=window.getScrollTop()+(window.getHeight()/15);this.center.setStyles({top:this.top+'px',display:''});this.fx.overlay.start(0.8);return this.changeImage(imageNum);},position:function(){this.overlay.setStyles({top:window.getScrollTop()+'px',height:window.getHeight()+'px'});},setup:function(open){var fn=open?'addEvent':'removeEvent';window[fn]('scroll',this.eventPosition)[fn]('resize',this.eventPosition);document[fn]('keydown',this.eventKeyDown);this.step=0;},keyboardListener:function(event){switch(event.keyCode){case 27:case 88:case 67:this.close();break;case 37:case 80:this.previous();break;case 39:case 78:this.next();}},previous:function(){return this.changeImage(this.activeImage-1);},next:function(){return this.changeImage(this.activeImage+1);},changeImage:function(imageNum){if(this.step||(imageNum<0)||(imageNum>=this.images.length))return false;this.step=1;this.activeImage=imageNum;this.bottomContainer.style.display=this.prevLink.style.display=this.nextLink.style.display='none';this.fx.image.hide();this.center.className='lbLoading';this.preload=new Image();this.preload.onload=this.nextEffect.bind(this);this.preload.src=this.images[imageNum][0];return false;},nextEffect:function(){switch(this.step++){case 1:this.center.className='';this.image.style.backgroundImage='url('+this.images[this.activeImage][0]+')';this.image.style.width=this.bottom.style.width=this.preload.width+'px';this.image.style.height=this.preload.height+'px';this.caption.setHTML(this.images[this.activeImage][1]||'');this.number.setHTML((this.images.length==1)?'':'Image '+(this.activeImage+1)+' of '+this.images.length);if(this.activeImage)this.preloadPrev.src=this.images[this.activeImage-1][0];if(this.activeImage!=(this.images.length-1))this.preloadNext.src=this.images[this.activeImage+1][0];if(this.center.clientHeight!=this.image.offsetHeight){this.fx.resize.start({height:this.image.offsetHeight});break;}
this.step++;case 2:if(this.center.clientWidth!=this.image.offsetWidth){this.fx.resize.start({width:this.image.offsetWidth,marginLeft:-this.image.offsetWidth/2});break;}
this.step++;case 3:this.bottomContainer.setStyles({top:(this.top+this.center.clientHeight)+'px',height:'0px',marginLeft:this.center.style.marginLeft,display:''});this.fx.image.start(1);break;case 4:if(this.options.animateCaption){this.fx.bottom.set(-this.bottom.offsetHeight);this.bottomContainer.style.height='';this.fx.bottom.start(0);break;}
this.bottomContainer.style.height='';case 5:if(this.activeImage)this.prevLink.style.display='';if(this.activeImage!=(this.images.length-1))this.nextLink.style.display='';this.step=0;}},close:function(){if(this.step<0)return;this.step=-1;if(this.preload){this.preload.onload=Class.empty;this.preload=null;}
for(var f in this.fx)this.fx[f].stop();this.center.style.display=this.bottomContainer.style.display='none';this.fx.overlay.chain(this.setup.pass(false,this)).start(0);return false;}};window.addEvent('domready',Roebox.init.bind(Roebox));