// part specific scripts

// slideshow    
$(function() {
  $('#slideshow1').cycle({
    timeout:       2000,  // milliseconds between slide transitions (0 to disable auto advance) 
    speed:         4000  // speed of the transition (any valid fx speed value) 
  });
  });

  // back to top scroll animation
$(document).ready(function() {
    //$('.flash').click(function(){$('.flash').fadeOut('slow')});
    $('#toplink').click(function(){
        $('html, body').animate({scrollTop:0}, 'slow');
    });
//});  
  
// mouse hover highlighting
    
                               $("#sbento").hover(function(){
                               $("#sbento h4").fadeIn(100); 
                               },function(){
                               $("#sbento h4").fadeOut(); 
                                    });
                               $("#ccastro").hover(function(){
                               $("#ccastro h4").fadeIn(100); 
                               },function(){
                               $("#ccastro h4").fadeOut(); 
                                    });
                                    
                            $("#images_title").click(function () {
                            $("#thumbs").slideToggle("slow");
                                    });
                                    
                            // thumbs
                            $(".latest_img").fadeTo("slow", 0.6);
                            $(".latest_img").hover(function(){
                            $(this).fadeTo("slow", 1.0);
                            },function(){
                            $(this).fadeTo("slow", 0.6);
                            });                             
                                    
                            $("a[rel^='prettyPhoto']").prettyPhoto({
                    animationSpeed: 'normal', /* fast/slow/normal */
                    padding: 40, /* padding for each side of the picture */
                    opacity: 0.35, /* Value betwee 0 and 1 */
                    showTitle: false, /* true/false */
                    allowresize: true, /* true/false */
                    counter_separator_label: ' / ', /* The separator for the gallery counter 1 "of" 2 */
                    theme: 'dark_rounded', /* light_rounded / dark_rounded / light_square / dark_square */
                });
                               
     /*    $('#thumbs').galleryView({
                filmstrip_size: 4,
                frame_width: 100,
                frame_height: 100,
                background_color: 'transparent',
                nav_theme: 'dark',
                border: 'none',
                transition_speed: 600,
                pause_on_hover: true,
                transition_interval: 12000,
                fade_panels: true,
                show_captions:false,
                 easing: 'easeInOutQuad',
                caption_text_color: 'black'
            }); */
        });                        
                               
                             
                               
    // Easing equation, borrowed from jQuery easing plugin
    // http://gsgd.co.uk/sandbox/jquery/easing/
    jQuery.easing.easeOutQuart = function (x, t, b, c, d) {
        return -c * ((t=t/d-1)*t*t*t - 1) + b;
    };                         
                               
    // "go to top" link on window scroll
    var topdistant = false;
    
    function getScrollY() {
        var scrOfY = 0; //, scrOfX = 0;
        if( typeof( window.pageYOffset ) == 'number' ) {
            scrOfY = window.pageYOffset; //scrOfX = window.pageXOffset;
        } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
            scrOfY = document.body.scrollTop; //scrOfX = document.body.scrollLeft;
        } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
            scrOfY = document.documentElement.scrollTop; //scrOfX = document.documentElement.scrollLeft;
        }
        return scrOfY;
    }
    
    function topDistanceCrosses(distance){
        if (getScrollY() > distance && !topdistant) {
            topdistant = true;
            $("#toplink").slideDown('slow');
            return 1 ; // going down
        }
        else if(getScrollY() < distance && topdistant ) {
            topdistant = false;
            $("#toplink").slideUp('fast');
            return 2; // going up
        }
        else {
            return 0; // nothing happens
        }
    }
    
    function showUp(item){
        $(item).hide();
        $(item).slideDown('slow');
    }
