$(function(){function c(e,g){var f=$(b.getItems()[e]).children(".home-gallery-img"),d;if(f.children("img").length>0){if(g){f.children("img").load(function(){b.seekTo(e)})}return}else{d=$("<img />")}if(g){d.load(function(){b.seekTo(e)})}d.attr("src",f.attr("rel"));f.append(d);f.css("min-width","0")}var a=true;var b=$("#home-gallery").scrollable({api:true,circular:true,next:"#home-gallery-next",prev:"#home-gallery-prev",onBeforeSeek:function(g,f){if(!a){return false}f=f<0?b.getItems().length-1:f;var d=$(b.getItems()[f]).find("img");if(d.length<1||d.width()<1){c(f,true);return false}var f=this.getIndex();c(f+2);c(f-2);a=false},onSeek:function(l,g){g=g<0?b.getItems().length-1:g;var f=this,d=$(b.getItems()[g]).find("img"),j=185,k=60,h;if(d.length>0){p_width=d.width()+j;b_width=p_width+k;if(b_width!=$("#main").width()){$(this.getItems()[g]).css({width:p_width});$("#main").animate({width:b_width+"px"},250);$("#home-gallery").animate({width:p_width},250,function(){a=true})}else{a=true}}$("#home-gallery-current-index").html(this.getIndex()+1)}});if(typeof(b)!=="undefined"){b.seekTo(0)}if($(".gallery-pane > a").length>0){$(".gallery-pane > a").lightBox({fixedNavigation:true,containerBorderSize:15});$("#gallery-wrap").scrollable({circular:true,next:"#gallery-next",prev:"#gallery-prev",onSeek:function(){$("#gallery-current-index").html(this.getIndex()+1)}})}});

