jQuery('body').addClass('jQuery-enabled');jQuery(document).ready(function(){var speed=100;jQuery(window).load(function(){jQuery(".scroll-pane img, #gallery-wrap img").hide();timer=setInterval(function(){$notLoaded=jQuery(".scroll-pane img, #gallery-wrap img").not(".loaded");$notLoaded.eq(Math.floor(Math.random()*$notLoaded.length)).fadeIn().addClass("loaded");if($notLoaded.length==0){clearInterval(timer);}},speed);});jQuery('#gallery-wrap img, .scroll-pane li img, .post-thumb a img, .flickr_badge_image a img').hover(function(){jQuery(this).stop().animate({opacity:0.5},200);},function(){jQuery(this).stop().animate({opacity:1},200);});function sortPhotos(cat){if(jQuery('.scroll-pane li, #gallery-wrap li').hasClass(cat)){jQuery('.scroll-pane li, #gallery-wrap li')
.not('.'+cat)
.removeClass('visible')
.find('a')
.fadeOut(500);jQuery('.'+cat)
.addClass('visible')
.find('a')
.fadeIn(800);}}
jQuery('#gallery-terms li a').click(function(){var cat=jQuery(this).attr('data-value')
sortPhotos(cat);jQuery('#gallery-terms li a').removeClass("current");jQuery(this).addClass("current");return false;});jQuery('#gallery-terms li a.all').click(function(e){jQuery('.scroll-pane li, #gallery-wrap li')
.addClass('visible')
.find('a')
.fadeIn(500);return false;});if(jQuery('#gallery-overlay').hasClass('true')){jQuery('.scroll-pane li a, #gallery-wrap li a').click(function(e){var postId=jQuery(this)
.parent()
.attr('id')
.split('photo-')[1];getPhoto(postId,this);e.preventDefault();});}
function galleryInit(){jQuery('#next-post, #prev-post').click(function(){var postId=jQuery(this).attr('data-id');getPhoto(postId,jQuery('li#photo-'+postId+' a'));return false;});jQuery('.gallery-close a').click(function(){jQuery('body').css({overflow:'auto'});jQuery('#gallery-overlay, #body-overlay').fadeOut(500);return false;});}
jQuery('#loader').click(function(){jQuery('#gallery-overlay').fadeOut(1,function(){jQuery('#loader').fadeOut(200);});});function getPhoto(postId,hasSelector){var next=jQuery('.scroll-pane li.visible, #gallery-wrap li.visible')
.first()
.attr('id').split('photo-')[1];var prev=jQuery('.scroll-pane li.visible, #gallery-wrap li.visible')
.last()
.attr('id').split('photo-')[1];var hasNext=jQuery(hasSelector).parent().next();var hasPrev=jQuery(hasSelector).parent().prev();if(hasNext.length!=0){while(hasNext.hasClass('visible')==false&&hasNext.length!=0){hasNext=hasNext.next();}
if(hasNext.length!=0){var next=hasNext
.attr('id').split('photo-')[1];}}
if(hasPrev.length!=0){while(hasPrev.hasClass('visible')==false&&hasPrev.length!=0){hasPrev=hasPrev.prev();}
if(hasPrev.length!=0){var prev=hasPrev
.attr('id').split('photo-')[1];}}
jQuery('#loader').fadeIn(200,function(){jQuery.ajax({url:jQuery('#theme-url').attr('data-id'),data:{id:postId,next:next,prev:prev},success:function(data){var gallery=jQuery('#gallery-overlay');gallery.html(data);jQuery('#next-post').attr('data-id',next);jQuery('body').css({overflow:'hidden'});jQuery('#gallery-overlay, #body-overlay').fadeIn(500,function(){jQuery('#loader').fadeOut(500);});galleryInit();}});});}
var width=0;jQuery('.scroll-pane li').each(function(){width+=jQuery(this).width();});function hideSlider(){if(width<jQuery(window).width()||jQuery(".scroll-pane ul").width()<jQuery(window).width()){jQuery('.scroll-bar').fadeOut(200);}else{jQuery('.scroll-bar').fadeIn(200);return true;}}
var scrollPane=jQuery(".scroll-pane"),scrollContent=jQuery(".scroll-content");var scrollbar=jQuery(".scroll-bar").slider({slide:function(event,ui){if(scrollContent.width()>scrollPane.width()){scrollContent.stop().animate({marginLeft:Math.round(ui.value/100*(scrollPane.width()-scrollContent.width()))+"px",duration:1000,specialEasing:{marginLeft:"easeInOutCirc"}});}else{scrollContent.css("margin-left",0);}}});var handleHelper=scrollbar.find(".ui-slider-handle")
.append("<span class='ui-icon ui-icon-grip-dotted-vertical'></span>")
.wrap("<div class='ui-handle-helper-parent'></div>").parent();scrollPane.css("overflow","hidden");function resetValue(){var remainder=scrollPane.width()-scrollContent.width();var leftVal=scrollContent.css("margin-left")==="auto"?0:parseInt(scrollContent.css("margin-left"));var percentage=Math.round(leftVal/remainder*100);scrollbar.slider("value",percentage);}
function reflowContent(){var showing=scrollContent.width()+parseInt(scrollContent.css("margin-left"),10);var gap=scrollPane.width()-showing;if(gap>0){scrollContent.css("margin-left",parseInt(scrollContent.css("margin-left"),10)+gap);}}
jQuery(window).resize(function(){resetValue();reflowContent();});jQuery(window).resize(function(){hideSlider();});hideSlider();});
