
function SeekCallbackMaker(navDiv) {
    return function scrollSeek() {
        var numPages = this.getPageAmount();
        var curPage = this.getPageIndex();
        
        if( numPages == (curPage+1) ) {
            //$(navDiv + ' .next').hide();
        }
        else {
            //$(navDiv + ' .next').show();
        }
        
        if( curPage == 0 ) {
            //$(navDiv + ' .prev').hide();
            //$(navDiv + ' .prev img').attr('src', '/wp-content/themes/chamber_life/media/images/arrow_prev_disable.png');
    
        }
        else {
           // $(navDiv + ' .prev').show();
        }
    }
}

$(document).ready(function(){ 
    $("div#twitter-carousel").scrollable({
        'clickable':false,
        'loop': false,
        'nextPage': "div#twitter-carousel-nav .next",
        'prevPage': "div#twitter-carousel-nav .prev",
        'speed' : 600,
        'size'  : 5
    });
    var sAPI = $("div#twitter-carousel").scrollable({api:true});
    sAPI.onSeek = SeekCallbackMaker('#twitter-carousel-nav');
    sAPI.begin();
    
    $("div#video-carousel").scrollable({
        'clickable':false,
        'loop': false,
        'nextPage': "div#video-carousel-nav .next",
        'prevPage': "div#video-carousel-nav .prev",
        'speed' : 600,
        'size'  : 4
    });
    sAPI = $("div#video-carousel").scrollable({api:true});
    sAPI.onSeek = SeekCallbackMaker('#video-carousel-nav');
    sAPI.begin();
    
    $("div#photo-carousel").scrollable({
        'clickable':false,
        'loop': false,
        'nextPage': "div#photo-carousel-nav .next",
        'prevPage': "div#photo-carousel-nav .prev",
        'speed' : 600,
        'size'  : 5
    });
    sAPI = $("div#photo-carousel").scrollable({api:true});
    sAPI.onSeek = SeekCallbackMaker('#photo-carousel-nav');
    sAPI.begin();
    
    $("div#blog-carousel").scrollable({
        'clickable':false,
        'loop': false,
        'nextPage': "div#blog-carousel-nav .next",
        'prevPage': "div#blog-carousel-nav .prev",
        'speed' : 350,
        'size'  : 1
    });
    sAPI = $("div#blog-carousel").scrollable({api:true});
    sAPI.onSeek = SeekCallbackMaker('#blog-carousel-nav');
    sAPI.begin();
    
    $('.next img').hover(
        function(){
           var img_path = $(this).attr('src');
           var last_sep_idx = img_path.lastIndexOf('/');
        
           var img_name = img_path.substr(last_sep_idx+1);
           img_path = img_path.substr(0, last_sep_idx);
           
           $(this).data("orig_img", img_path + "/" + img_name);
           
           $(this).attr('src', img_path + '/arrow_next_tan.png');
        },
        function(){
            $(this).attr('src', $(this).data('orig_img'));
    });
    
    $('.prev img').hover(
        function(){
           var img_path = $(this).attr('src');
           var last_sep_idx = img_path.lastIndexOf('/');
        
           var img_name = img_path.substr(last_sep_idx+1);
           img_path = img_path.substr(0, last_sep_idx);
           
          // $(this).img_path = img_path;
           $(this).data("orig_img", img_path + "/" + img_name);
           
           $(this).attr('src', img_path + '/arrow_prev_tan.png');
        },
        function(){
            //alert($(this).img_path);
            $(this).attr('src', $(this).data('orig_img'));
    });
});
        