var Gallery={pages:0,imgPerPg:0,count:0,currPg:0,container:"",arrowsCon:"gallery_arrows"+Math.floor(Math.random()*100+Math.random()*11),init:function(id,imagesPerPg){if(typeof(id)!='undefined'){Gallery.container=$("#"+id);Gallery.imgPerPg=(typeof(imagesPerPg)!='undefined')?imagesPerPg:6;Gallery.currImage=Gallery.container.find("img:first");Gallery.count=Gallery.container.find("img").size();Gallery.pages=Math.ceil(Gallery.count/Gallery.imgPerPg);Gallery.container.find("img").each(function(i){$(this).css({'border':'1px solid #000'})});for(var i=0;i<Gallery.pages;i++){var j=i*Gallery.imgPerPg;if(i==(Gallery.pages-1))Gallery.container.find("a").slice(j,Gallery.count).wrapAll("<div class='gallery_page'></div>");else Gallery.container.find("a").slice(j,j+Gallery.imgPerPg).wrapAll("<div class='gallery_page'></div>")}Gallery.container.find(".gallery_page:not(':eq("+Gallery.currPg+")')").hide();Gallery.container.after("<div class='"+Gallery.arrowsCon+"' style='text-align: center;'><a href='#' class='prevBtn'><img alt='Prev' src='/images/bma/works_of_art/previous_arrow.gif' /></a> &nbsp;&nbsp;&nbsp; <a href='#' class='nextBtn'><img alt='Next' src='/images/bma/works_of_art/next_arrow.gif' /></a></div>");Gallery.resetBtn();Gallery.container.find("a").click(function(e){e.preventDefault();Gallery.selected($(this))});$("."+Gallery.arrowsCon+" a").click(function(e){e.preventDefault();Gallery.navigate($(this));Gallery.resetBtn()})}else{alert("You did not specify a container while initializing Gallery!")}},selected:function(id){$(".gallery_main_image").html("<img src='"+id.attr("href")+"' />");if(id.children("span").size()==1)$(".gallery_main_image").append("<div class='gallery_meta'>"+id.children("span").html()+"</div>")},resetBtn:function(){if(Gallery.currPg<Gallery.pages-1)$("."+Gallery.arrowsCon+" > .nextBtn").show();else $("."+Gallery.arrowsCon+" > .nextBtn").hide();if(Gallery.currPg>0)$("."+Gallery.arrowsCon+" > .prevBtn").show();else $("."+Gallery.arrowsCon+" > .prevBtn").hide()},navigate:function(id){Gallery.container.find(".gallery_page:eq("+Gallery.currPg+")").hide();if(id.attr("class")=="nextBtn")Gallery.currPg=Gallery.currPg+1;else Gallery.currPg=Gallery.currPg-1;Gallery.container.find(".gallery_page:eq("+Gallery.currPg+")").show()},};