(function(a){a.fn.dpg_gallery_thumbnails=function(j,h){var c=[];var g=Math.floor(Math.random()*99999);c[g]=a.extend({container:a(document),offset:90,axis:"horizontal",toggle_visibility:false},j);this.each(function(){c[g].object_container=a(this);c[g].object_to_animate=a("ul",this);c[g].object_container.prepend('<div class="backwards"><a href="#">Back</a></div>');c[g].object_container.prepend('<div class="forwards"><a href="#">Forward</a></div>');a(c[g].object_to_animate).css({position:"absolute"});c[g].animating=false;if(c[g].toggle_visibility===true){a("#gallery #images").append('<div class="toggle_thumbnails"><a href="#">Thumbnails</a></div>');a("#gallery #images .toggle_thumbnails").toggle(function(){c[g].object_container.show("slide",{direction:"right"},500);b();},function(){c[g].object_container.hide("slide",{direction:"right"},500);b();});}a(".backwards").click(function(){if(c[g].animating===false&&f()<0){c[g].animating=true;if((f()*-1)>e()){target="+="+(e()-c[g].offset);}else{target="+="+((f()*-1));}d(target);}});a(".forwards").click(function(){if(c[g].animating===false&&f()<=0){c[g].animating=true;if(a(".image_list.first ul")-f()>e()){target="-="+(e()-c[g].offset);}else{target="-="+(e()-c[g].offset);}d(target);}});a(window).bind("resize",function(){b();});b();});function d(k){if(c[g].axis=="horizontal"){c[g].object_to_animate.animate({left:k},500,function(){if(typeof h=="function"){h();}b();c[g].animating=false;});}else{c[g].object_to_animate.animate({top:k},500,function(){if(typeof h=="function"){h();}b();c[g].animating=false;});}}function f(){if(c[g].axis=="horizontal"){return c[g].object_to_animate.position().left;}else{return c[g].object_to_animate.position().top;}}function i(){if(c[g].axis=="horizontal"){return c[g].object_to_animate.width();}else{return c[g].object_to_animate.height();}}function e(){if(c[g].axis=="horizontal"){return c[g].object_container.width();}else{return c[g].object_container.height();}}function b(){if(f()>=0){a(".backwards").hide();}else{a(".backwards").show();}if(f()<=e()-i()){a(".forwards").hide();}else{a(".forwards").show();}}};})(jQuery);