$( function() { // set up the home page carousel, if it exists // I tried jFlow 1.2, Karmic Flow 0.2, and galleryView. // I couldn't get any of them to do what I needed. // So I rolled my own. A bit kludgey, but it works. if ( $("#sidebar-carousel").length ) { $("#sidebar-carousel-slides a").lightBox( { imageLoading: "/js/lib/jquery/lightBox/images/lightbox-ico-loading.gif", imageBtnClose: "/js/lib/jquery/lightBox/images/lightbox-btn-close.gif", imageBtnNext: "/js/lib/jquery/lightBox/images/lightbox-btn-next.gif", imageBtnPrev: "/js/lib/jquery/lightBox/images/lightbox-btn-prev.gif" } ); var scrollWidth = 246; var slideShown = 0; var lastSlide = 7; // TODO: get a real value here var duration = 1000; var easing = "swing"; var $slides = $("#sidebar-carousel-slides"); $("#sidebar-carousel-prev").click( function() { // make sure the carousel isn't already being animated if ( !$slides.is(":animated") ) { if ( slideShown == 0 ) { $slides.animate( { marginLeft: "-" + ( lastSlide * scrollWidth ) + "px" }, duration, easing, function() { slideShown = lastSlide; } ); } else { $slides.animate( { marginLeft: "-" + ( ( slideShown - 1 ) * scrollWidth ) + "px" }, duration, easing, function() { slideShown--; } ); } } } ); $("#sidebar-carousel-next").click( function() { // make sure the carousel isn't already being animated if ( !$slides.is(":animated") ) { if ( slideShown == lastSlide ) { $slides.animate( { marginLeft: "0px" }, duration, easing, function() { slideShown = 0; } ); } else { $slides.animate( { marginLeft: "-" + ( ( slideShown + 1 ) * scrollWidth ) + "px" }, duration, easing, function() { slideShown++; } ); } } } ); } // set up the projects photo gallery, if it exists if ( $("#projects-index").length ) { var $selectedProjectCategory = null; // set up click handlers on the category list $("#projects-index a").click( function( e ) { e.preventDefault(); $("#projects-index a").removeClass("active"); $(this).addClass("active"); if ( $selectedProjectCategory ) { $selectedProjectCategory.css( "display", "none" ); } $selectedProjectCategory = $( $(this).attr("href") ); $selectedProjectCategory.css( "display", "block" ); } ); // autoselect the "All Projects" category $("#projects-index a:first").click(); // set up the lightboxes $(".projects-thumbs").each( function() { $( "a", this ).lightBox( { imageLoading: "/js/lib/jquery/lightBox/images/lightbox-ico-loading.gif", imageBtnClose: "/js/lib/jquery/lightBox/images/lightbox-btn-close.gif", imageBtnNext: "/js/lib/jquery/lightBox/images/lightbox-btn-next.gif", imageBtnPrev: "/js/lib/jquery/lightBox/images/lightbox-btn-prev.gif" } ); } ); } } );